diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/rack-attack-recaptcha.gemspec b/rack-attack-recaptcha.gemspec index abc1234..def5678 100644 --- a/rack-attack-recaptcha.gemspec +++ b/rack-attack-recaptcha.gemspec @@ -6,11 +6,11 @@ Gem::Specification.new do |spec| spec.name = "rack-attack-recaptcha" spec.version = Rack::Attack::Recaptcha::VERSION - spec.authors = ["Omer Rauchwerger"] + spec.authors = ["Omer Lachish-Rauchwerger"] spec.email = ["omer@rauchy.net"] - spec.description = %q{TODO: Write a gem description} - spec.summary = %q{TODO: Write a gem summary} - spec.homepage = "" + spec.description = %q{An extension for Rack::Attack that supports responding to throttled requests with Recaptcha tags} + spec.summary = %q{Block & throttle abusive requests with Recaptcha} + spec.homepage = "http://github.com/rauchy/rack-attack-recaptcha" spec.license = "MIT" spec.files = `git ls-files`.split($/) @@ -20,4 +20,6 @@ spec.add_development_dependency "bundler", "~> 1.3" spec.add_development_dependency "rake" + spec.add_development_dependency "rack-attack" + spec.add_development_dependency "recaptcha" end
Add gem info and dependencies
diff --git a/db/migrate/20120919171223_add_question_comments.rb b/db/migrate/20120919171223_add_question_comments.rb index abc1234..def5678 100644 --- a/db/migrate/20120919171223_add_question_comments.rb +++ b/db/migrate/20120919171223_add_question_comments.rb @@ -4,7 +4,7 @@ t.integer :id t.integer :question_id t.integer :creator_id - t.string :body + t.text :body t.timestamps end end
Comment bodies should be text, not varchar
diff --git a/core/app/models/spree/promotion_item_handlers.rb b/core/app/models/spree/promotion_item_handlers.rb index abc1234..def5678 100644 --- a/core/app/models/spree/promotion_item_handlers.rb +++ b/core/app/models/spree/promotion_item_handlers.rb @@ -1,4 +1,16 @@ module Spree + # Decides which promotion should be activated given the current order context + # + # By activated it doesn't necessarily mean that the order will have an + # discount for every activated promotion. It means that the discount will be + # created and might eventually become eligible. The intention here is to + # reduce overhead. e.g. a promotion that requires item A to be eligible + # shouldn't be eligible unless item A is added to the order. + # + # It can be used as a wrapper for custom handlers as well. Different + # applications might have completely different requirements to make + # the promotions system accurate and performant. Here they can plug custom + # handler to activate promos as they wish once an item is added to cart class PromotionItemHandlers attr_reader :line_item, :order @@ -8,20 +20,51 @@ def activate promotions.each do |promotion| - if promotion.rules.empty? || eligible_item?(promotion) + if promotion.rules.empty? promotion.activate(line_item: line_item, order: order) + next + end + + rule_handlers.each do |handler| + if handler.new(promotion: promotion, line_item: line_item).appliable? + promotion.activate(line_item: line_item, order: order) + next + end end end end private + # TODO Once we're sure this is worth it we should call: + # + # Rails.application.config.spree.promotion_rule_handlers + # + # so that it's pluggable + def rule_handlers + [PromotionRuleHandler::Product] + end + # TODO Coupon code promotions should be removed here + # we need a way to define promo activated when item is added to cart + # (maybe still use the event_name attr in Promotion for that) def promotions Promotion.active.includes(:promotion_rules) end + end - def eligible_item?(promotion) + # Tell if a given promotion is a valid candidate for the current order state + module PromotionRuleHandler + class Product + attr_reader :promotion, :line_item + + def initialize(payload = {}) + @promotion = payload[:promotion] + @line_item = payload[:line_item] + end + + def appliable? promotion.product_ids.empty? || promotion.product_ids.include?(line_item.product.id) end + end end end
Make PromotionItemHandler have pluggable behaviour
diff --git a/config/initializers/fast_get_text.rb b/config/initializers/fast_get_text.rb index abc1234..def5678 100644 --- a/config/initializers/fast_get_text.rb +++ b/config/initializers/fast_get_text.rb @@ -5,6 +5,8 @@ FastGettext::TranslationRepository::Db.require_models #load and include default models FastGettext.available_locales = ['en'] FastGettext.add_text_domain('app', :type => :db, :model => TranslationKey) + +include FastGettext::Translation module FastGettext::Translation def strip_(key, &block)
Use include to make the functions available in rails apps by default
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index abc1234..def5678 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,3 +1,4 @@ # Be sure to restart your server when you modify this file. -Rails.application.config.session_store :cookie_store, key: '_openpprn-backend_session' +Rails.application.config.session_store :cookie_store, key: '_myapnea_session', + secure: Rails.env.production?
Make use of secure session cookies
diff --git a/spec/matest_specs/aliases_spec.rb b/spec/matest_specs/aliases_spec.rb index abc1234..def5678 100644 --- a/spec/matest_specs/aliases_spec.rb +++ b/spec/matest_specs/aliases_spec.rb @@ -1,65 +1,65 @@ scope do spec { true } - xspec { true } + xspec { false } example { true } - xexample { true } + xexample { false } it { true } - xit { true } + xit { false } end describe do spec { true } - xspec { true } + xspec { false } example { true } - xexample { true } + xexample { false } it { true } - xit { true } + xit { false } end context do spec { true } - xspec { true } + xspec { false } example { true } - xexample { true } + xexample { false } it { true } - xit { true } + xit { false } end xscope do spec { true } - xspec { true } + xspec { false } example { true } - xexample { true } + xexample { false } it { true } - xit { true } + xit { false } end xdescribe do spec { true } - xspec { true } + xspec { false } example { true } - xexample { true } + xexample { false } it { true } - xit { true } + xit { false } end xcontext do spec { true } - xspec { true } + xspec { false } example { true } - xexample { true } + xexample { false } it { true } - xit { true } + xit { false } end
Make skipped specs fail if aliases are broken Previously, skip aliases would error if they were not defined. This change ensures that skipped specs will fail if, for some reason, skip aliases are overwritten but not undefined.
diff --git a/spec/metacrunch/db/reader_spec.rb b/spec/metacrunch/db/reader_spec.rb index abc1234..def5678 100644 --- a/spec/metacrunch/db/reader_spec.rb +++ b/spec/metacrunch/db/reader_spec.rb @@ -1,6 +1,7 @@ describe Metacrunch::Db::Reader do - DB_URL = "sqlite://#{File.join(asset_dir, "dummy.sqlite")}" + DB_PROTOCOL = defined?(JRUBY_VERSION) ? "jdbc:sqlite" : "sqlite" + DB_URL = "#{DB_PROTOCOL}://#{File.join(asset_dir, "dummy.sqlite")}" describe "#each" do subject { Metacrunch::Db::Reader.new(DB_URL, "select * from users") }
Make sure to use the right connection string in case of JRuby.
diff --git a/foodr-backend/app/models/user.rb b/foodr-backend/app/models/user.rb index abc1234..def5678 100644 --- a/foodr-backend/app/models/user.rb +++ b/foodr-backend/app/models/user.rb @@ -5,9 +5,13 @@ has_many :products, through: :searches has_many :ingredients, through: :products + validates :email, :password, presence: true validates :email, uniqueness: true def grade - + numerator = self.products.pluck(:score).reduce { |sum, score| sum + score } + denominator = self.products.length + average = numerator / denominator + '%.1f' % average # returns 1 decimal place even for round numbers end end
Add validation to require password and email. Add method to return average grade as 2 decimal places
diff --git a/app/models/developer.rb b/app/models/developer.rb index abc1234..def5678 100644 --- a/app/models/developer.rb +++ b/app/models/developer.rb @@ -2,12 +2,32 @@ devise :database_authenticatable, :trackable, :validatable, :omniauthable store_accessor :data, :html_url, :avatar_url, :company, :blog, :followers, :public_gists, :public_repos + after_commit :cache_login!, :delete_cache!, :delete_languages_cache! + after_commit :set_premium!, on: :update, if: :completed? - after_commit :cache_login! + def completed? + premium_fields.all?{|field| send(field).present? } + end private def cache_login! REDIS.sadd('hireables:developers_logins', login) end + + def set_premium! + update!(premium: true) + end + + def delete_cache! + Rails.cache.delete(login) + end + + def delete_languages_cache! + Rails.cache.delete([login, 'languages']) + end + + def premium_fields + %w(bio email platforms location) + end end
Add callbacks to invalidate cache and set premium
diff --git a/features/support/env.rb b/features/support/env.rb index abc1234..def5678 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -8,8 +8,8 @@ class CustomWorld - def initialize screenFactory - @screen_factory = screenFactory + def initialize screen_factory + @screen_factory = screen_factory end def launch_to_screen screen
Use ruby conventions on param name
diff --git a/db/migrate/012_sandboxes.rb b/db/migrate/012_sandboxes.rb index abc1234..def5678 100644 --- a/db/migrate/012_sandboxes.rb +++ b/db/migrate/012_sandboxes.rb @@ -0,0 +1,25 @@+require File.expand_path('../settings', __FILE__) + +Sequel.migration do + up do + create_table(:checksums) do + String(:org_id, :null => false, :fixed => true, :size => 32) + String(:checksum, :null => false, :fixed => true, :size => 32) + primary_key [:org_id, :checksum] + end + + create_table(:sandbox_checksum) do + String(:org_id, :fixed => true, :size => 32) + String(:sandbox_id, :fixed => true, :size => 32) + String(:checksum, :fixed => true, :size => 32) + DateTime(:created_at, :null => false) + primary_key [:sandbox_id, :org_id, :checksum] + end + end + + down do + [:sandbox_checksum, :checksums].each do |table| + drop_table(table) + end + end +end
Add checksums and sandbox_checksums tables
diff --git a/packages/yaml_cpp.rb b/packages/yaml_cpp.rb index abc1234..def5678 100644 --- a/packages/yaml_cpp.rb +++ b/packages/yaml_cpp.rb @@ -9,7 +9,7 @@ opts.all do mkdir "Build" cd "Build" do - sh "cmake -DBUILD_SHARED_LIBS=FALSE -DCMAKE_INSTALL_PREFIX=#{opts.prefix} ../" + sh "cmake -DBUILD_SHARED_LIBS=FALSE -DAPPLE_UNIVERSAL_BIN=TRUE -DCMAKE_INSTALL_PREFIX=#{opts.prefix} ../" sh "make -j 3" sh "make install" end
Fix compilation to have a universal lib
diff --git a/github_lda.gemspec b/github_lda.gemspec index abc1234..def5678 100644 --- a/github_lda.gemspec +++ b/github_lda.gemspec @@ -17,6 +17,8 @@ gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"] + gem.add_development_dependency "rake", ">= 0.9.2.2" + gem.add_runtime_dependency "grit", ">= 2.5.0" gem.add_runtime_dependency "github-linguist", ">= 2.3.4" gem.add_runtime_dependency "nokogiri", ">= 1.5.5"
Add dev dependency to gemspec
diff --git a/init.rb b/init.rb index abc1234..def5678 100644 --- a/init.rb +++ b/init.rb @@ -1,9 +1,11 @@-require 'factory_girl' +config.gem 'thoughtbot-factory_girl', :lib => 'factory_girl', :source => 'http://gems.github.com' -%w(test spec).each do |dir| - factories = File.join(RAILS_ROOT, dir, 'factories.rb') - require factories if File.exists?(factories) - Dir[File.join(RAILS_ROOT, dir, 'factories', '*.rb')].each do |file| - require file - end +config.after_initialize do + %w(test spec).each do |dir| + factories = File.join(RAILS_ROOT, dir, 'factories.rb') + require factories if File.exists?(factories) + Dir[File.join(RAILS_ROOT, dir, 'factories', '*.rb')].each do |file| + require file + end + end end
Use config.gem to depend on factory_girl.
diff --git a/Casks/handbrakecli-nightly.rb b/Casks/handbrakecli-nightly.rb index abc1234..def5678 100644 --- a/Casks/handbrakecli-nightly.rb +++ b/Casks/handbrakecli-nightly.rb @@ -1,10 +1,10 @@ class HandbrakecliNightly < Cask - version '6419svn' - sha256 '3fcd67ddda23ba406789f0f00c9d501fd85a6c6348385ba6da8550db0fcfefb2' + version '6430svn' + sha256 'e62a9c051a00a00bdb09a76e624014a9c79c3cd387c9982f030282e11b1e1f1d' - url 'http://download.handbrake.fr/nightly/HandBrake-6419svn-MacOSX.6_CLI_x86_64.dmg' + url "http://download.handbrake.fr/nightly/HandBrake-#{version}-MacOSX.6_CLI_x86_64.dmg" homepage 'http://handbrake.fr' - license :unknown + license :gpl binary 'HandBrakeCLI' end
Update HandBrakeCLI Nightly to v6430svn HandBrakeCLI Nightly Build 6430svn released 2014-10-02.
diff --git a/Casks/handbrakecli-nightly.rb b/Casks/handbrakecli-nightly.rb index abc1234..def5678 100644 --- a/Casks/handbrakecli-nightly.rb +++ b/Casks/handbrakecli-nightly.rb @@ -1,6 +1,6 @@ cask :v1 => 'handbrakecli-nightly' do - version '6859svn' - sha256 '656a716c4c75d325cdfda874db4215ba280355b672c6f19ae5dd01325955d5af' + version '6897svn' + sha256 '3cfd28e62a517fc5fdecd82b7fe2cb14c3ca3061694b5b0c2b0a1938f1f8b638' url "http://download.handbrake.fr/nightly/HandBrake-#{version}-MacOSX.6_CLI_x86_64.dmg" homepage 'http://handbrake.fr'
Update HandbrakeCLI Nightly to v6897svn HandBrakeCLI Nightly v6897svn built 2015-02-13.
diff --git a/lib/collective/collectors/rabbitmq.rb b/lib/collective/collectors/rabbitmq.rb index abc1234..def5678 100644 --- a/lib/collective/collectors/rabbitmq.rb +++ b/lib/collective/collectors/rabbitmq.rb @@ -28,7 +28,7 @@ queues.each do |queue| group 'rabbitmq.queue' do |group| - instrument_hash(group, queue, source: "rabbitmq.queue.#{queue['name']}") + instrument_hash(group, queue, source: queue['name']) end end end
Set source as queue name.
diff --git a/lib/modules/wdpa/carto_db_importer.rb b/lib/modules/wdpa/carto_db_importer.rb index abc1234..def5678 100644 --- a/lib/modules/wdpa/carto_db_importer.rb +++ b/lib/modules/wdpa/carto_db_importer.rb @@ -28,10 +28,10 @@ end def upload + cartodb_uploader = CartoDb::Uploader.new @cartodb_username, @cartodb_api_key + @shapefiles.each do |table_name, shapefiles| shapefiles.each do |shapefile| - cartodb_uploader = CartoDb::Uploader.new @cartodb_username, @cartodb_api_key - upload_successful = cartodb_uploader.upload shapefile.compress return false unless upload_successful end
Reduce carto db uploader instance number
diff --git a/spec/classes/homebrew_spec.rb b/spec/classes/homebrew_spec.rb index abc1234..def5678 100644 --- a/spec/classes/homebrew_spec.rb +++ b/spec/classes/homebrew_spec.rb @@ -20,11 +20,6 @@ should contain_boxen__env_script("homebrew") - ["latest", "install"].each do |cmd| - should contain_file("#{cmddir}/brew-boxen-#{cmd}.rb"). - with_source("puppet:///modules/homebrew/brew-boxen-#{cmd}.rb") - end - should contain_file("#{dir}/lib").with_ensure("directory") should contain_file(cmddir).with_ensure("directory") should contain_file("#{dir}/Library/Taps").with_ensure("directory")
Remove boxen-latest and boxen-install in favour of Homebrew
diff --git a/spec/deployment/nginx_spec.rb b/spec/deployment/nginx_spec.rb index abc1234..def5678 100644 --- a/spec/deployment/nginx_spec.rb +++ b/spec/deployment/nginx_spec.rb @@ -2,6 +2,15 @@ describe 'nginx' do describe 'configuration' do + CONFIG_PATH = "/var/vcap/jobs/cf-redis-broker/config/nginx.conf" + + def service + Prof::MarketplaceService.new( + name: bosh_manifest.property('redis.broker.service_name'), + plan: 'shared-vm' + ) + end + let(:bucket_size) do if bosh_manifest.property('redis.broker').dig('nginx', 'bucket_size').nil? 128 @@ -10,19 +19,9 @@ end end - let(:dedicated_node_ip) { @binding.credentials[:host] } - let(:config_path) { "/var/vcap/jobs/cf-redis-broker/config/nginx.conf" } - - def service - Prof::MarketplaceService.new( - name: bosh_manifest.property('redis.broker.service_name'), - plan: 'shared-vm' - ) - end - before(:all) do @service_instance = service_broker.provision_instance(service.name, service.plan) - @binding = service_broker.bind_instance(@service_instance) + @binding = service_broker.bind_instance(@service_instance) end after(:all) do @@ -32,9 +31,9 @@ it 'has the correct server_names_hash_bucket_size' do expect(bucket_size).to be > 0 - command = "grep 'server_names_hash_bucket_size #{bucket_size}' #{config_path}" - result = ssh_gateway.execute_on(dedicated_node_ip, command) - expect(result.to_s).not_to be_empty + command = %Q{sudo grep "server_names_hash_bucket_size #{bucket_size}" #{CONFIG_PATH}} + result = dedicated_node_ssh.execute(command) + expect(result.strip).not_to be_empty end end end
Use bosh ssh wrapper in nginx deployment test - This spec file is not included in any rake task, is it an orphan? [#145917557]
diff --git a/db/migrate/20180930205254_add_variables_to_users.rb b/db/migrate/20180930205254_add_variables_to_users.rb index abc1234..def5678 100644 --- a/db/migrate/20180930205254_add_variables_to_users.rb +++ b/db/migrate/20180930205254_add_variables_to_users.rb @@ -9,7 +9,7 @@ def up add_column :users, :variables, :jsonb, default: {}, null: false - + User.reset_column_information User.update_all(variables: VARIABLES) end
Refresh user's model in variables migration [SCI-2864]
diff --git a/app/models/question.rb b/app/models/question.rb index abc1234..def5678 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -4,4 +4,12 @@ validates_presence_of :body validates_presence_of :title + + def self.search(words) + matches = [] + words.split(' ').each do |word| + matches << Question.all.map { |q| q.title.include?(word) || q.body.include?(word) } + end + matches + end end
Add search class method for Question.
diff --git a/spec/direction_matrix_spec.rb b/spec/direction_matrix_spec.rb index abc1234..def5678 100644 --- a/spec/direction_matrix_spec.rb +++ b/spec/direction_matrix_spec.rb @@ -3,9 +3,9 @@ describe DirectionMatrix do it 'provides a method for each direction' do - expect(described_class.north).to eq [0,1] - expect(described_class.east).to eq [1,0] - expect(described_class.south).to eq [0,-1] - expect(described_class.west).to eq [-1,0] + expect(described_class.north).to eq [0, 1] + expect(described_class.east).to eq [1, 0] + expect(described_class.south).to eq [0, -1] + expect(described_class.west).to eq [-1, 0] end end
Add extra spaces in DirectionMatrix spec
diff --git a/spec/rrj/rrj_requests_spec.rb b/spec/rrj/rrj_requests_spec.rb index abc1234..def5678 100644 --- a/spec/rrj/rrj_requests_spec.rb +++ b/spec/rrj/rrj_requests_spec.rb @@ -6,24 +6,26 @@ describe '.message_template_ask' do let(:transaction) { RRJ::RRJ.new } - let(:request_info) { transaction.message_template_ask } + let(:request_info) { transaction.ask } it 'send a request info' do expect(request_info.class).to eq Hash end - let(:response_info) { transaction.message_template_response(request_info) } + let(:response_info) { transaction.response(request_info) } it 'ask a response to info request' do expect(response_info.class).to eq Hash end - let(:create) { transaction.message_template_ask('create') } + let(:create) { transaction.ask('create') } it 'send a request create' do expect(create.class).to eq Hash end + let(:create) { transaction.ask('create') } + let(:create_response) { transaction.response(create) } + let(:destroy) { transaction.ask('destroy', create_response) } it 'send a request destroy' do - expect(transaction.message_template_ask('destroy').class).to eq Hash - expect(transaction.message_template_response(create).class).to eq Hash + expect(transaction.response(destroy).class).to eq Hash end end end
Fix test destroy and replace methods with aliases
diff --git a/app/models/tip.rb b/app/models/tip.rb index abc1234..def5678 100644 --- a/app/models/tip.rb +++ b/app/models/tip.rb @@ -27,7 +27,7 @@ def should_generate_new_friendly_id? if persisted? - created_at < 1.day.ago + created_at > 1.day.ago else super end
Fix another small bug in friendly_id for Tips Apparently the condition for generating new slugs was reversed.
diff --git a/scripts/generate_toc.rb b/scripts/generate_toc.rb index abc1234..def5678 100644 --- a/scripts/generate_toc.rb +++ b/scripts/generate_toc.rb @@ -0,0 +1,15 @@+#!/usr/bin/env ruby + +# Source: https://gist.github.com/albertodebortoli/9310424 +# Via: http://stackoverflow.com/a/22131019/873282 + +File.open("Code-Howtos.md", 'r') do |f| + f.each_line do |line| + forbidden_words = ['Table of contents', 'define', 'pragma'] + next if !line.start_with?("#") || forbidden_words.any? { |w| line =~ /#{w}/ } + + title = line.gsub("#", "").strip + href = title.gsub(" ", "-").downcase + puts " " * (line.count("#")-1) + "* [#{title}](\##{href})" + end +end
Add script to generate a TOC based for markdown files
diff --git a/gemfiles/travis.rb b/gemfiles/travis.rb index abc1234..def5678 100644 --- a/gemfiles/travis.rb +++ b/gemfiles/travis.rb @@ -2,6 +2,6 @@ gem "codeclimate-test-reporter".freeze gem "json".freeze, "~> 1.8.3".freeze -gem "rake".freeze +gem "rake".freeze, "~> 10.5.0".freeze gem "rspec".freeze gem "simplecov".freeze
Use older `rake` version for Travis tests.
diff --git a/gemologist.gemspec b/gemologist.gemspec index abc1234..def5678 100644 --- a/gemologist.gemspec +++ b/gemologist.gemspec @@ -8,10 +8,6 @@ spec.version = Gemologist::VERSION spec.authors = ["Yuji Nakayama"] spec.email = ["nkymyj@gmail.com"] - - if spec.respond_to?(:metadata) - spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server." - end spec.summary = %q{TODO: Write a short summary, because Rubygems requires one.} spec.description = %q{TODO: Write a longer description or delete this line.}
Remove allowed_push_host definition in gemspec
diff --git a/core/db/migrate/20130802022321_migrate_tax_categories_to_line_items.rb b/core/db/migrate/20130802022321_migrate_tax_categories_to_line_items.rb index abc1234..def5678 100644 --- a/core/db/migrate/20130802022321_migrate_tax_categories_to_line_items.rb +++ b/core/db/migrate/20130802022321_migrate_tax_categories_to_line_items.rb @@ -2,7 +2,7 @@ def change Spree::LineItem.includes(:variant => { :product => :tax_category }).find_in_batches do |line_items| line_items.each do |line_item| - line_item.update_column(:tax_category_id, line_item.product.tax_category.id) + line_item.update_column(:tax_category_id, line_item.product.tax_category_id) end end end
Fix migration to run when no tax category set on product.
diff --git a/instrumental_tools.gemspec b/instrumental_tools.gemspec index abc1234..def5678 100644 --- a/instrumental_tools.gemspec +++ b/instrumental_tools.gemspec @@ -15,7 +15,7 @@ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] s.add_runtime_dependency(%q<json>, [">=0"]) - s.add_runtime_dependency(%q<instrumental_agent>, [">=0.8.3"]) + s.add_runtime_dependency(%q<instrumental_agent>, [">=0.12.1"]) s.add_runtime_dependency(%q<pidly>, [">=0.1.3"]) s.add_development_dependency(%q<rake>, [">=0"]) end
Upgrade to latest version of instrumental_agent.
diff --git a/db/data_migration/20210225103359_update_pa_ur_translations_to_pa_pk.rb b/db/data_migration/20210225103359_update_pa_ur_translations_to_pa_pk.rb index abc1234..def5678 100644 --- a/db/data_migration/20210225103359_update_pa_ur_translations_to_pa_pk.rb +++ b/db/data_migration/20210225103359_update_pa_ur_translations_to_pa_pk.rb @@ -0,0 +1,9 @@+translations = Edition::Translation.where(locale: "pa-ur") + +document_ids = Edition.distinct.where(id: translations.select(:edition_id)).pluck(:document_id) + +translations.update_all(locale: "pa-pk") + +document_ids.each do |id| + PublishingApiDocumentRepublishingWorker.perform_async_in_queue("bulk_republishing", id) +end
Update all pa-ur locales to pa-pk, and republish
diff --git a/lib/finite_machine/threadable.rb b/lib/finite_machine/threadable.rb index abc1234..def5678 100644 --- a/lib/finite_machine/threadable.rb +++ b/lib/finite_machine/threadable.rb @@ -7,15 +7,30 @@ module InstanceMethods @@sync = Sync.new + # Exclusive lock + # + # @return [nil] + # + # @api public def sync_exclusive(&block) @@sync.synchronize(:EX, &block) end + # Shared lock + # + # @return [nil] + # + # @api public def sync_shared(&block) @@sync.synchronize(:SH, &block) end end + # Module hook + # + # @return [nil] + # + # @api private def self.included(base) base.extend ClassMethods base.module_eval do @@ -23,17 +38,35 @@ end end + private_class_method :included + module ClassMethods include InstanceMethods + # Defines threadsafe attributes for a class + # + # @example + # attr_threadable :errors, :events + # + # @example + # attr_threadable :errors, default: [] + # + # @return [nil] + # + # @api public def attr_threadsafe(*attrs) + opts = attrs.last.is_a?(::Hash) ? attrs.pop : {} + default = opts.fetch(:default, nil) attrs.flatten.each do |attr| class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 def #{attr}(*args) - if args.empty? + value = args.shift + if value + self.#{attr} = value + elsif instance_variables.include?(:@#{attr}) sync_shared { @#{attr} } - else - self.#{attr} = args.shift + elsif #{!default.nil?} + sync_shared { instance_variable_set(:@#{attr}, #{default}) } end end alias_method '#{attr}?', '#{attr}'
Change to allow for default value, add docs.
diff --git a/lib/formalist/output_compiler.rb b/lib/formalist/output_compiler.rb index abc1234..def5678 100644 --- a/lib/formalist/output_compiler.rb +++ b/lib/formalist/output_compiler.rb @@ -23,33 +23,33 @@ end def visit_attr(data) - name, elements, _errors = data + name, predicates, errors, children = data - {name => elements.map { |node| visit(node) }.inject(:merge) } + {name => children.map { |node| visit(node) }.inject(:merge) } end def visit_field(data) - name, type, display_variant, value, _errors = data + name, type, display_variant, value, predicates, errors = data {name => coerce(value, type: type)} end def visit_group(data) - elements, _config = data + config, children = data - elements.map { |node| visit(node) }.inject(:merge) + children.map { |node| visit(node) }.inject(:merge) end def visit_many(data) - name, elements, _errors, _config = data + name, predicates, errors, config, template, children = data - {name => elements.map { |item| item.map { |node| visit(node) }.inject(:merge) }} + {name => children.map { |item| item.map { |node| visit(node) }.inject(:merge) }} end def visit_section(data) - _name, elements, _config = data + name, config, children = data - elements.map { |node| visit(node) }.inject(:merge) + children.map { |node| visit(node) }.inject(:merge) end private
Update output compiler to match AST output
diff --git a/lib/nested_db/models/instance.rb b/lib/nested_db/models/instance.rb index abc1234..def5678 100644 --- a/lib/nested_db/models/instance.rb +++ b/lib/nested_db/models/instance.rb @@ -27,6 +27,7 @@ module ClassMethods def image_variation(input, variation = nil) + input = input.url if input.kind_of?(CarrierWave::Uploader::Base) input.gsub!(/^(.*)\/(.*?)(\?\d+)?$/, "\\1/#{variation.to_s}_\\2") if variation input end
Convert input to a string if the input was an uploader
diff --git a/spec/filtration_spec.rb b/spec/filtration_spec.rb index abc1234..def5678 100644 --- a/spec/filtration_spec.rb +++ b/spec/filtration_spec.rb @@ -27,16 +27,15 @@ end it 'raises an error if the method has no arguments' do - pending class Foo3 def foo 2 end end class Test3 < Foo3 - prefilter(:foo){|x| x * 2} + extend RSpec::Matchers + lambda { prefilter(:foo){|x| x * 2} }.should raise_error end - lambda { Test3.new.foo }.should raise_error end end
Fix no argument error test
diff --git a/spec/lib/column_spec.rb b/spec/lib/column_spec.rb index abc1234..def5678 100644 --- a/spec/lib/column_spec.rb +++ b/spec/lib/column_spec.rb @@ -20,22 +20,17 @@ it 'returns the email from a proc correctly' do email_column.value(dummy_model, view_context).should == 'robert at example.com' end + end - context '.available?' do - it 'returns true on successful constraint' do - table = Class.new(DummyTable).new([dummy_model], view_context) - column = TableCloth::Column.new(:name, if: :admin?) - column.available?(table).should be_true - end + context "human name" do + it "returns the label when set" do + column = FactoryGirl.build(:column, options: { label: "Whatever" }) + expect(column.human_name).to eq("Whatever") + end - it 'returns false on failed constraints' do - table = Class.new(DummyTable).new([dummy_model], view_context) - table.stub admin?: false - - - column = TableCloth::Column.new(:name, if: :admin?) - column.available?(table).should be_false - end + it "humanizes the symbol if no label is set" do + column = FactoryGirl.build(:column, name: :email) + expect(column.human_name).to eq("Email") end end end
Remove available spec in columns. Add specs for human name.
diff --git a/lib/printer/jobs/prepare_page.rb b/lib/printer/jobs/prepare_page.rb index abc1234..def5678 100644 --- a/lib/printer/jobs/prepare_page.rb +++ b/lib/printer/jobs/prepare_page.rb @@ -3,6 +3,7 @@ require "printer/id_generator" require "printer/preview" require "timeout" +require "shellwords" class Printer::Jobs::PreparePage def self.queue @@ -36,7 +37,7 @@ end def self.save_url_to_path(url, width, path) - cmd = "phantomjs rasterise.js #{url} #{width} #{path}" + cmd = "phantomjs rasterise.js #{url.shellescape} #{width} #{path}" run(cmd) end
Patch shell injection vulnerability in prepare page By escaping the URL argument, we prevent arbitrary commands from being able to be injected there. Fixes #56
diff --git a/lib/rodzilla/resource/product.rb b/lib/rodzilla/resource/product.rb index abc1234..def5678 100644 --- a/lib/rodzilla/resource/product.rb +++ b/lib/rodzilla/resource/product.rb @@ -11,7 +11,7 @@ end def get_accessible_products - prepare_request + self.class.prepare_request @response = self.class.get(@request_url, @params) puts @response.inspect end
Make prepare request a class method call
diff --git a/lib/sequel_mapper/root_mapper.rb b/lib/sequel_mapper/root_mapper.rb index abc1234..def5678 100644 --- a/lib/sequel_mapper/root_mapper.rb +++ b/lib/sequel_mapper/root_mapper.rb @@ -3,6 +3,7 @@ module SequelMapper class RootMapper include MapperMethods + include Enumerable def initialize(relation:, mapping:, dirty_map:) @relation = relation @@ -13,14 +14,30 @@ attr_reader :relation, :mapping private :relation, :mapping + def each(&block) + relation + .map(&row_loader_func) + .each(&block) + end + def where(criteria) - relation - .where(criteria) - .map(&row_loader_func) + new_with_dataset( + relation.where(criteria) + ) end def save(graph_root) upsert_if_dirty(mapping.dump(graph_root)) end + + private + + def new_with_dataset(dataset) + self.class.new( + relation: dataset, + mapping: mapping, + dirty_map: dirty_map, + ) + end end end
Refactor RootMapper to fluid interface
diff --git a/lib/picolena/templates/spec/controllers/application_controller_spec.rb b/lib/picolena/templates/spec/controllers/application_controller_spec.rb index abc1234..def5678 100644 --- a/lib/picolena/templates/spec/controllers/application_controller_spec.rb +++ b/lib/picolena/templates/spec/controllers/application_controller_spec.rb @@ -1,12 +1,17 @@ require File.dirname(__FILE__) + '/../spec_helper' describe ApplicationController do - it "should give 403 when denying access" do + it "should give 403 status when denying access" do get 'access_denied' response.headers["Status"].should == "403 Forbidden" end - it "should flash with a wrong request" do + it "should render 'Access denied' text when denying access" do + get 'access_denied' + response.body.should == 'Access denied' + end + + it "should flash a warning if given a wrong request" do get 'unknown_request' response.should be_redirect response.should redirect_to(documents_url)
Access denied specs. Preparing views specs. git-svn-id: 52e2e43ce7a15623d54ec01c4d971b259c993eed@215 354c73f7-f838-4446-8ec5-bf0d774acd2b
diff --git a/lib/specinfra/command/freebsd.rb b/lib/specinfra/command/freebsd.rb index abc1234..def5678 100644 --- a/lib/specinfra/command/freebsd.rb +++ b/lib/specinfra/command/freebsd.rb @@ -30,6 +30,10 @@ def install(package) "pkg_add -r install #{package}" end + + def get_package_version(package, opts=nil) + "pkg_info -Ix #{escape(package)} | cut -f 1 -w | sed -n 's/^#{escape(package)}-//p'" + end end end end
Support return package version for installed packages on FreeBSD
diff --git a/lib/toy_robot_simulator/robot.rb b/lib/toy_robot_simulator/robot.rb index abc1234..def5678 100644 --- a/lib/toy_robot_simulator/robot.rb +++ b/lib/toy_robot_simulator/robot.rb @@ -3,6 +3,8 @@ module ToyRobotSimulator class Robot attr_accessor :x, :y, :facing + + DEFAULT_MOVEMENT = "FORWARD" def initialize @x = nil; @y = nil; @facing = nil @@ -18,6 +20,7 @@ end def move move + move ||= DEFAULT_MOVEMENT raise Exceptions::RobotNotPlaced unless placed? raise Exceptions::MoveCommandNotAllowed unless Movement.allowed_movement?(move)
Add default movement to be FORWARD
diff --git a/init.rb b/init.rb index abc1234..def5678 100644 --- a/init.rb +++ b/init.rb @@ -1,4 +1,8 @@ require "taobao_fu" + +#Fix "couldn't parse YAML" error ruby 1.9.2/rails 3.1 +require 'yaml' +YAML::ENGINE.yamler= 'syck' config_file = File.join(Rails.root, "config", "taobao.yml") TaobaoFu.load(config_file) if FileTest::exists?(config_file)
Fix "couldn't parse YAML" error ruby 1.9.2/rails 3.1
diff --git a/lib/fake_xml_server/api.rb b/lib/fake_xml_server/api.rb index abc1234..def5678 100644 --- a/lib/fake_xml_server/api.rb +++ b/lib/fake_xml_server/api.rb @@ -24,7 +24,9 @@ sent = params[:s] respond_to do |f| - f.xml { post_file(doc, sent, request.body.read)} + f.xml do + post_file(doc, sent, request.body.read) && respond_with(200) + end end end @@ -45,5 +47,7 @@ File.open(current_file(doc, sent), 'w') do |f| f.puts(xml) end + # Should do some error handling here + true end end
Add positive response to post
diff --git a/lib/feature_definitions.rb b/lib/feature_definitions.rb index abc1234..def5678 100644 --- a/lib/feature_definitions.rb +++ b/lib/feature_definitions.rb @@ -11,6 +11,8 @@ def initialize(proc) @test_proc = proc end + + @@context = nil def self.context=(context) @@context = context
Initialize @@context in super class
diff --git a/lib/graphql/scalar_type.rb b/lib/graphql/scalar_type.rb index abc1234..def5678 100644 --- a/lib/graphql/scalar_type.rb +++ b/lib/graphql/scalar_type.rb @@ -1,5 +1,14 @@ module GraphQL # The parent type for scalars, eg {GraphQL::STRING_TYPE}, {GraphQL::INT_TYPE} + # + # @example defining a type for Time + # TimeType = GraphQL::ObjectType.define do + # name "Time" + # description "Time since epoch in seconds" + # + # coerce_input ->(value) { Time.at(Float(value)) } + # coerce_result ->(value) { value.to_f } + # end # class ScalarType < GraphQL::BaseType defined_by_config :name, :coerce, :coerce_input, :coerce_result, :description
Add an example for a custom scalar.
diff --git a/lib/fulcrum/resource.rb b/lib/fulcrum/resource.rb index abc1234..def5678 100644 --- a/lib/fulcrum/resource.rb +++ b/lib/fulcrum/resource.rb @@ -47,7 +47,7 @@ end def all(params = default_index_params) - result = call(:get, collection, params) + result = call(:get, collection, default_index_params.merge(params)) Page.new(result, resources_name) end
Make sure default params are always used.
diff --git a/lib/like/interaction.rb b/lib/like/interaction.rb index abc1234..def5678 100644 --- a/lib/like/interaction.rb +++ b/lib/like/interaction.rb @@ -13,7 +13,7 @@ def post_action if ActionPack::VERSION::STRING.to_i > 4 - controller.redirect_back fallback_location: "/"#, status: 303 + controller.redirect_back fallback_location: "/", status: 303 else controller.redirect_to :back, status: 303 end
Remove accidental comment in redirect_back change.
diff --git a/lib/micro_migrations.rb b/lib/micro_migrations.rb index abc1234..def5678 100644 --- a/lib/micro_migrations.rb +++ b/lib/micro_migrations.rb @@ -1,7 +1,5 @@ require 'rails' require 'active_record/railtie' - -Bundler.require app = Class.new(Rails::Application) app.config.active_support.deprecation = :log
Remove Bundler.require call. Makes no sense inside a gem.
diff --git a/lib/nanite/exchanges.rb b/lib/nanite/exchanges.rb index abc1234..def5678 100644 --- a/lib/nanite/exchanges.rb +++ b/lib/nanite/exchanges.rb @@ -1,4 +1,11 @@ module Nanite + # Using these methods actors can participate in distributed processing + # with other nodes using topic exchange publishing (classic pub/sub with + # matching) + # + # This lets you handle a work to do to a single agent from a mapper in your + # Merb/Rails app, and let agents to self-organize who does what, as long as the + # properly collect the result to return to requesting peer. class Agent def push_to_exchange(type, domain, payload="") req = Request.new(type, payload, identity)
Document how Nanite agents can participate in distrubuted processing using topic queues and push_to_exchange/subscribe_to_exchange. Signed-off-by: ezmobius <4aca359fa1b78e51bc8226c4f161d16fdc1e21c8@engineyard.com>
diff --git a/lib/rack/methodoverride.rb b/lib/rack/methodoverride.rb index abc1234..def5678 100644 --- a/lib/rack/methodoverride.rb +++ b/lib/rack/methodoverride.rb @@ -4,6 +4,7 @@ METHOD_OVERRIDE_PARAM_KEY = "_method".freeze HTTP_METHOD_OVERRIDE_HEADER = "HTTP_X_HTTP_METHOD_OVERRIDE".freeze + ALLOWED_METHODS = ["POST"] def initialize(app) @app = app @@ -31,7 +32,7 @@ private def allowed_methods - ["POST"] + ALLOWED_METHODS end def method_override_param(req)
Move ["POST"] to a constant
diff --git a/lib/r_fast_r_furious.rb b/lib/r_fast_r_furious.rb index abc1234..def5678 100644 --- a/lib/r_fast_r_furious.rb +++ b/lib/r_fast_r_furious.rb @@ -7,7 +7,12 @@ SOURCE = "https://raw.github.com/alunny/r_fast_r_furious/master/fast.js" def check(string, url = SOURCE) uri = URI.parse(SOURCE) - content = Net::HTTP.get(uri) + http = Net::HTTP.new(uri.host, uri.port) + http.use_ssl = true + http.verify_mode = OpenSSL::SSL::VERIFY_NONE + request = Net::HTTP::Get.new(uri.request_uri) + response = http.request(request) + content = response.body cxt = V8::Context.new cxt.eval(content, "fast.js") cxt["r_fast_r_furious"].call(string)
Make specs pass on Ruby 1.9
diff --git a/lib/urban_dictionary.rb b/lib/urban_dictionary.rb index abc1234..def5678 100644 --- a/lib/urban_dictionary.rb +++ b/lib/urban_dictionary.rb @@ -16,9 +16,9 @@ def self.random_word url = URI.parse(RANDOM_URL) req = Net::HTTP::Get.new(url.path) - rsp = Net::HTTP.start(url.host, url.port) {|http| + rsp = Net::HTTP.start(url.host, url.port) do |http| http.request(req) - } + end Word.from_url(rsp['location']) end
Use do ... end for multiline blocks
diff --git a/flamegraph.gemspec b/flamegraph.gemspec index abc1234..def5678 100644 --- a/flamegraph.gemspec +++ b/flamegraph.gemspec @@ -10,7 +10,7 @@ spec.email = ["sam.saffron@gmail.com"] spec.description = %q{Flamegraph support for arbitrary ruby apps} spec.summary = %q{Flamegraph support for arbitrary ruby apps} - spec.homepage = "" + spec.homepage = "https://github.com/SamSaffron/flamegraph" spec.license = "MIT" spec.files = `git ls-files`.split($/)
Add homepage link to gemspec
diff --git a/lib/capybara-screenshot/rspec/html_link_reporter.rb b/lib/capybara-screenshot/rspec/html_link_reporter.rb index abc1234..def5678 100644 --- a/lib/capybara-screenshot/rspec/html_link_reporter.rb +++ b/lib/capybara-screenshot/rspec/html_link_reporter.rb @@ -22,7 +22,7 @@ end def link_to_screenshot(title, path) - url = URI.escape("file://#{path}") + url = URI::DEFAULT_PARSER.escape("file://#{path}") title = CGI.escape_html(title) attributes = attributes_for_screenshot_link(url).map { |name, val| %{#{name}="#{CGI.escape_html(val)}"} }.join(" ") "<a #{attributes}>#{title}</a>"
Fix undefined 'URI.escape' method in Ruby3.0.2 https://github.com/mattheworiordan/capybara-screenshot/issues/283
diff --git a/lib/fog/brightbox/models/compute/firewall_policy.rb b/lib/fog/brightbox/models/compute/firewall_policy.rb index abc1234..def5678 100644 --- a/lib/fog/brightbox/models/compute/firewall_policy.rb +++ b/lib/fog/brightbox/models/compute/firewall_policy.rb @@ -41,6 +41,16 @@ true end + def remove(server_group_id) + requires :identity + options = { + :server_group => server_group_id + } + data = connection.remove_firewall_policy(identity, options) + merge_attributes(data) + true + end + def destroy requires :identity data = connection.destroy_firewall_policy(identity) @@ -51,4 +61,4 @@ end end -end+end
[Brightbox] Add model method for remove
diff --git a/lib/fixer_upper/engine/erb.rb b/lib/fixer_upper/engine/erb.rb index abc1234..def5678 100644 --- a/lib/fixer_upper/engine/erb.rb +++ b/lib/fixer_upper/engine/erb.rb @@ -1,10 +1,12 @@ class FixerUpper module Engine class Erb - def call(text, scope:, &block) + def call(text, scope:, _filepath_:, &block) scope_binding = scope.instance_eval { binding } - ::ERB.new(text).result(scope_binding) + erb = ::ERB.new(text) + erb.filename = _filepath_ + erb.result(scope_binding) end end end
Set filepath on ERB engine
diff --git a/lib/tasks/taxonomy/remove_non_education_taxons.rake b/lib/tasks/taxonomy/remove_non_education_taxons.rake index abc1234..def5678 100644 --- a/lib/tasks/taxonomy/remove_non_education_taxons.rake +++ b/lib/tasks/taxonomy/remove_non_education_taxons.rake @@ -0,0 +1,48 @@+namespace :taxonomy do + desc "remove non-education taxons" + task remove_non_education_taxons: :environment do + all_taxon_ids = fetch_all_taxon_ids + education_taxon_ids = fetch_education_taxon_ids + + puts "Find non-education taxon IDs" + non_education_taxon_ids = all_taxon_ids - education_taxon_ids + + errors = [] + + non_education_taxon_ids.each do |taxon_id| + taxon = Taxonomy::BuildTaxon.call(content_id: taxon_id) + puts "Removing: #{taxon.content_id} #{taxon.title}" + begin + Services.publishing_api.unpublish(taxon_id, type: "gone").code + rescue GdsApi::HTTPUnprocessableEntity => e + puts e.message + errors << { taxon_id: taxon.content_id, taxon_title: taxon.title } + end + end + + puts "Finished with #{errors.length} errors." + + puts "The following taxons could not be unpublished:" unless errors.empty? + + errors.each do |error| + puts "#{error[:taxon_id]} #{error[:taxon_title]}" + end + end + + def fetch_all_taxon_ids + puts "Fetch all taxon IDs" + total = RemoteTaxons.new.search.search_response["total"] + RemoteTaxons.new.search(per_page: total).taxons.map(&:content_id) + end + + def fetch_education_taxon_ids + puts "Fetch education taxon IDs" + taxon_id = 'c58fdadd-7743-46d6-9629-90bb3ccc4ef0' + + chosen_taxon = OpenStruct.new Services.publishing_api.get_content(taxon_id).to_h + taxonomy = Taxonomy::ExpandedTaxonomy.new(chosen_taxon.content_id) + taxonomy.build_child_expansion + + taxonomy.child_expansion.map(&:content_id) + end +end
Add rake task to remove non-education taxon
diff --git a/lib/scorebutt/host_watcher.rb b/lib/scorebutt/host_watcher.rb index abc1234..def5678 100644 --- a/lib/scorebutt/host_watcher.rb +++ b/lib/scorebutt/host_watcher.rb @@ -28,13 +28,13 @@ begin result = client.get(target) if ok_status_codes.include? result.header.status_code - puts "#{self.ip}: OK".green + "#{self.ip}: OK".green else - puts "#{self.ip}: UNKNOWN, Status Code: ".yellow + result.header.status_code.to_s + "#{self.ip}: UNKNOWN, Status Code: ".yellow + result.header.status_code.to_s end rescue Exception => detail # An actual error occurred. Report it, don't die on me! - puts "#{self.ip}: ERROR ".red + detail.to_s + "#{self.ip}: ERROR ".red + detail.to_s end end end
Remove puts in service method, Scorer can print it
diff --git a/lib/tasks/connectors_api.rake b/lib/tasks/connectors_api.rake index abc1234..def5678 100644 --- a/lib/tasks/connectors_api.rake +++ b/lib/tasks/connectors_api.rake @@ -0,0 +1,30 @@+namespace :cartodb do + namespace :connectors do + desc 'Adapt connector synchronizations to the new API' + task adapt_api: :environment do + + def get_ignoring_case(hash, key) + _k, v = hash.find { |k, _v| k.to_s.casecmp(key.to_s) == 0 } + v + end + + # This is meant to be run before deploying the new API (#9674). + # Some syncs may fail before deployment is done (because they expect the newer API), + # but deployment will be hopefully done before they're retried, so they should succeed then. + # No attempt is done to avoid changing 'dead' syncs (left 'created' or retried too many times). + # This is idempotent and will do no harm to connectors that use the new API. + Carto::Synchronization.where(service_name: 'connector').find_each do |sync| + parameters = JSON.load(sync.service_item_id) rescue nil + if parameters + provider = get_ignoring_case(parameters, 'provider') + if !provider + puts "Adapting #{sync.id}" + parameters['provider'] = 'odbc' + sync.service_item_id = parameters.to_json + sync.save! + end + end + end + end + end +end
Add rake task to adapt syncs to API changes The rake taks will adapt existing connector synchronizations to work with the new API defined by #9674
diff --git a/lib/tasks/webhookr_tasks.rake b/lib/tasks/webhookr_tasks.rake index abc1234..def5678 100644 --- a/lib/tasks/webhookr_tasks.rake +++ b/lib/tasks/webhookr_tasks.rake @@ -1,4 +1,16 @@-# desc "Explaining what the task does" -# task :webhookr do -# # Task goes here -# end +namespace :webhookr do + desc "List the configured services and paths" + task :services => :environment do + + puts "No webhookr services configured - add and configure webhookr plugins." and next if Webhookr.adapters.empty? + + include Webhookr::Engine.routes.url_helpers + + Webhookr.adapters.each do |key, adapter| + puts "\n\n#{key}:" + %w{ GET POST}.each do |x| + puts " #{x}\t#{events_path(key, :security_token => Webhookr.config[key].try(:security_token))}\n" + end + end + end +end
Add a rake task to show the configured services paths
diff --git a/lib/travis-deploy-logs/app.rb b/lib/travis-deploy-logs/app.rb index abc1234..def5678 100644 --- a/lib/travis-deploy-logs/app.rb +++ b/lib/travis-deploy-logs/app.rb @@ -42,7 +42,7 @@ halt 404, "Unknown app" end - redirect "https://dashboard-next.heroku.com/orgs/#{heroku_org}/apps/#{heroku_app}/activity/builds/#{params[:id]}" + redirect "https://dashboard.heroku.com/orgs/#{heroku_org}/apps/#{heroku_app}/activity/builds/#{params[:id]}" end end end
Change Heroku redirect URL to their new dashboard domain
diff --git a/lib/windcharger/attributes.rb b/lib/windcharger/attributes.rb index abc1234..def5678 100644 --- a/lib/windcharger/attributes.rb +++ b/lib/windcharger/attributes.rb @@ -3,13 +3,13 @@ module Windcharger module Attributes def attributes - (@__attributes || []).dup.freeze + (@__windcharger_attributes || []).dup.freeze end private def __windcharger_add_attribute name - (@__attributes ||= []) << name.to_sym + (@__windcharger_attributes ||= []) << name.to_sym end def attribute *attributes
Reduce collision probability with ivars Since these are in the user’s class.
diff --git a/lib/be_gateway/checkout.rb b/lib/be_gateway/checkout.rb index abc1234..def5678 100644 --- a/lib/be_gateway/checkout.rb +++ b/lib/be_gateway/checkout.rb @@ -3,7 +3,8 @@ include Connection def get_token(params) - send_request('post', '/ctp/api/checkouts', checkout: params.merge('version' => '2.1')) + params['version'] ||= '2.1' + send_request('post', '/ctp/api/checkouts', checkout: params) end def query(token)
Add version acceptance with 2.1 by default
diff --git a/lib/bcu/options.rb b/lib/bcu/options.rb index abc1234..def5678 100644 --- a/lib/bcu/options.rb +++ b/lib/bcu/options.rb @@ -35,6 +35,11 @@ parser.parse!(args) + if args[0] == "help" + puts parser + exit + end + options.cask = args[0] self.options = options
Add `brew cu help` command Closes #50
diff --git a/lib/lita/builder.rb b/lib/lita/builder.rb index abc1234..def5678 100644 --- a/lib/lita/builder.rb +++ b/lib/lita/builder.rb @@ -17,7 +17,7 @@ # Constructs a {Lita::Handler} from the provided block. def build_handler handler = create_plugin(Handler) - handler.instance_exec(&@block) + handler.class_exec(&@block) handler end
Use class_exec when building a handler for better semantics.
diff --git a/lib/mjml/railtie.rb b/lib/mjml/railtie.rb index abc1234..def5678 100644 --- a/lib/mjml/railtie.rb +++ b/lib/mjml/railtie.rb @@ -7,8 +7,12 @@ class Railtie < ::Rails::Railtie # Template handler for Rails class Handler + def initialize(base_handler = :erb) + @base_handler = base_handler + end + def call(template) - compiled = erb_handler.call(template) + compiled = send("#{@base_handler}_handler").call(template) "::MJML::Parser.new.call(begin;#{compiled};end).html_safe" end @@ -16,6 +20,14 @@ def erb_handler @erb_handler ||= ActionView::Template.registered_template_handler(:erb) + end + + def slim_handler + @slim_handler ||= ActionView::Template.registered_template_handler(:slim) + end + + def haml_handler + @haml_handler ||= ActionView::Template.registered_template_handler(:haml) end end @@ -30,6 +42,8 @@ ActiveSupport.on_load(:action_view) do ActionView::Template.register_template_handler(:mjml, Handler.new) + ActionView::Template.register_template_handler(:mjmlslim, Handler.new(:slim)) + ActionView::Template.register_template_handler(:mjmlhaml, Handler.new(:haml)) end end end
Handle slim and haml templates
diff --git a/app/controllers/podcasts_controller.rb b/app/controllers/podcasts_controller.rb index abc1234..def5678 100644 --- a/app/controllers/podcasts_controller.rb +++ b/app/controllers/podcasts_controller.rb @@ -1,6 +1,7 @@ class PodcastsController < ApplicationController def show @podcast = Podcast.find(podcast_params) + @feed = @podcast.default_feed if @podcast.locked? && !params[:unlock] redirect_to @podcast.published_url
Set the default feed for the podcast
diff --git a/app/models/feeder/feedable_observer.rb b/app/models/feeder/feedable_observer.rb index abc1234..def5678 100644 --- a/app/models/feeder/feedable_observer.rb +++ b/app/models/feeder/feedable_observer.rb @@ -15,6 +15,8 @@ end def after_save(feedable) + feedable.reload + item = feedable.feeder_item item.sticky = feedable.sticky
Fix a bug that caused a NoMethodError on nil
diff --git a/app/presenters/option_set_presenter.rb b/app/presenters/option_set_presenter.rb index abc1234..def5678 100644 --- a/app/presenters/option_set_presenter.rb +++ b/app/presenters/option_set_presenter.rb @@ -14,9 +14,7 @@ TypeCoersion::HashCoercer.new(config: option_types).coerce(options) end - # rubocop:disable Metrics/MethodLength def option_types OptionConfig.option_types end - # rubocop:enable Metrics/MethodLength end
Remove unnecessary rubocop disable comments This method used to be long but now it has been extracted
diff --git a/lib/rudy/aws.rb b/lib/rudy/aws.rb index abc1234..def5678 100644 --- a/lib/rudy/aws.rb +++ b/lib/rudy/aws.rb @@ -21,7 +21,7 @@ str.to_s.tr!("[\0\n\r\032\\\\]", '').gsub!(/([\'\"])/, '\\1\\1') end - require 'rudy/aws/sdb' + #require 'rudy/aws/sdb' require 'rudy/aws/ec2' require 'rudy/aws/s3'
ADDED: Debug mode global option -D
diff --git a/lib/salt/clt.rb b/lib/salt/clt.rb index abc1234..def5678 100644 --- a/lib/salt/clt.rb +++ b/lib/salt/clt.rb @@ -2,9 +2,9 @@ require 'salt/clt/version' require 'salt/clt/config' -require 'salt/clt/cli' require 'salt/clt/errors' require 'salt/clt/api' +require 'salt/clt/cli' module Salt module CLT
Load CLI a bit later
diff --git a/lib/zebra/zpl/printable.rb b/lib/zebra/zpl/printable.rb index abc1234..def5678 100644 --- a/lib/zebra/zpl/printable.rb +++ b/lib/zebra/zpl/printable.rb @@ -16,6 +16,9 @@ def position=(coords) @position, @x, @y = coords, coords[0], coords[1] + if @justification + @x = 0 + end end def justification=(just)
Set x position to zero if justification is given
diff --git a/lib/plotly/axis.rb b/lib/plotly/axis.rb index abc1234..def5678 100644 --- a/lib/plotly/axis.rb +++ b/lib/plotly/axis.rb @@ -4,9 +4,12 @@ class Axis include Castable - ATTRS = %i(title range).freeze + ATTRS = %i(title range zeroline).freeze attr_accessor(*ATTRS) + # @option opts [String] title + # @option opts [Array] range + # @option opts [Boolean] zeroline def initialize(opts) return unless opts.is_a?(Hash) opts.each { |k, v| instance_variable_set("@#{k}", v) }
Add an attribute to Axis
diff --git a/lib/poke/window.rb b/lib/poke/window.rb index abc1234..def5678 100644 --- a/lib/poke/window.rb +++ b/lib/poke/window.rb @@ -12,14 +12,14 @@ @paused = false - @user = User.new(self, 416, 288) + @player = User.new(self, 416, 288) @controls = Controls.new(window: self) @pause_screen = PauseScreen.new(window: self, width: @width, height: @height) @grid_one = Grid.new(window: self, - user: @user, + user: @player, map_file: "media/grid_one/map.txt", tileset: "media/grid_one/tileset.png") @current_grid = @grid_one @@ -31,7 +31,7 @@ def update unless @paused @current_grid.update - @user.update + @player.update @camera.update end end @@ -39,7 +39,7 @@ def draw translate(-@camera_x, -@camera_y) do @current_grid.draw - @user.draw + @player.draw end if @paused
Change Window's user ivar to player
diff --git a/microsoft-live-simple.gemspec b/microsoft-live-simple.gemspec index abc1234..def5678 100644 --- a/microsoft-live-simple.gemspec +++ b/microsoft-live-simple.gemspec @@ -1,9 +1,9 @@ Gem::Specification.new do |spec| - spec.name = 'microsoft-live-rest-client' + spec.name = 'microsoft-live-simple' spec.version = '0.1.0' spec.authors = ['John Drago'] spec.email = 'jdrago.999@gmail.com' - spec.homepage = 'https://github.com/jdrago999/microsoft-live-rest-client' + spec.homepage = 'https://github.com/jdrago999/microsoft-live-simple' spec.summary = 'Client for the Microsoft Live REST API' spec.description = 'Client for the Microsoft Live REST API' spec.required_rubygems_version = '>= 1.3.6'
Update gemspec with correct gem name.
diff --git a/libexec/um-list.rb b/libexec/um-list.rb index abc1234..def5678 100644 --- a/libexec/um-list.rb +++ b/libexec/um-list.rb @@ -25,7 +25,7 @@ end if $stdout.isatty - exec(%{ls "#{topic_directory}" | sed 's/.txt//' | column}) + exec(%{ls "#{topic_directory}" | sed 's/\.[[:alnum:]]*$//' | column}) else - exec(%{ls "#{topic_directory}" | sed 's/.txt//' }) + exec(%{ls "#{topic_directory}" | sed 's/\.[[:alnum:]]*$//' }) end
Update um list extension filter regex to accomodate .md
diff --git a/lib/cxml/status.rb b/lib/cxml/status.rb index abc1234..def5678 100644 --- a/lib/cxml/status.rb +++ b/lib/cxml/status.rb @@ -2,6 +2,7 @@ class Status attr_accessor :code attr_accessor :text + attr_accessor :content attr_accessor :xml_lang # Initialize a new Status instance @@ -12,6 +13,7 @@ if data.kind_of?(Hash) && !data.empty? @code = data['code'].to_i @text = data['text'] + @content = data['content'] @xml_lang = data['xml:lang'] end end @@ -29,7 +31,9 @@ end def render(node) - node.Status(:code => @code, :text => @text) + node.Status(:code => @code, :text => @text) do |p| + p.text @content + end end end -end+end
Add support for Status content
diff --git a/lib/lifeguard/infinite_threadpool.rb b/lib/lifeguard/infinite_threadpool.rb index abc1234..def5678 100644 --- a/lib/lifeguard/infinite_threadpool.rb +++ b/lib/lifeguard/infinite_threadpool.rb @@ -9,6 +9,7 @@ @queued_jobs = ::Queue.new @shutdown = false @super_async_mutex = ::Mutex.new + @scheduler = create_scheduler end # Handle to original async method @@ -18,20 +19,19 @@ def async(*args, &block) return false if @shutdown @queued_jobs << { :args => args, :block => block } - check_queued_jobs return true end - def check_queued_jobs - loop do - break if busy? - break if @queued_jobs.size <= 0 - - @super_async_mutex.synchronize do - break if busy? - queued_job = @queued_jobs.pop - super_async(*queued_job[:args], &queued_job[:block]) + def create_scheduler + Thread.new do + while !@shutdown || @queud_jobs.size > 0 + if busy? + sleep 0.1 + else + queued_job = @queued_jobs.pop + super_async(*queued_job[:args], &queued_job[:block]) + end end end end
Use a scheduler for infinite threadpool
diff --git a/spec/dummy/app/relations/users.rb b/spec/dummy/app/relations/users.rb index abc1234..def5678 100644 --- a/spec/dummy/app/relations/users.rb +++ b/spec/dummy/app/relations/users.rb @@ -1,6 +1,4 @@ class Users < ROM::Relation[:sql] - base_name :users - def by_id(id) where(id: id) end
Update dummy app to pass on latest ROM from master
diff --git a/spec/services/next_bidder_spec.rb b/spec/services/next_bidder_spec.rb index abc1234..def5678 100644 --- a/spec/services/next_bidder_spec.rb +++ b/spec/services/next_bidder_spec.rb @@ -0,0 +1,29 @@+require 'rails_helper' + +RSpec.describe NextBidder do + describe "#call" do + subject(:service) { NextBidder.new(game_state) } + + let(:game_state) { GameState.new } + + it "returns East when the previous bidder was North" do + game_state.bidder = :north + expect(service.call).to eq :east + end + + it "returns South when the previous bidder was East" do + game_state.bidder = :east + expect(service.call).to eq :south + end + + it "returns West when the previous bidder was South" do + game_state.bidder = :south + expect(service.call).to eq :west + end + + it "returns North when the previous bidder was West" do + game_state.bidder = :west + expect(service.call).to eq :north + end + end +end
Add RSpec test for NextBidder
diff --git a/lib/mako/writer.rb b/lib/mako/writer.rb index abc1234..def5678 100644 --- a/lib/mako/writer.rb +++ b/lib/mako/writer.rb @@ -0,0 +1,16 @@+module Mako + class Writer + attr_reader :renderer, :destination + + def initialize(args) + @renderer = args.fetch(:renderer) + @destination = args.fetch(:destination) + end + + def write + File.open(destination, 'w+', encoding: 'utf-8') do |f| + f.write(renderer.render) + end + end + end +end
Add Writer class to write output of renderers
diff --git a/lib/pcap/packet.rb b/lib/pcap/packet.rb index abc1234..def5678 100644 --- a/lib/pcap/packet.rb +++ b/lib/pcap/packet.rb @@ -22,7 +22,7 @@ # Returns the data payload of the packet. # def payload - self + self.size + self.to_ptr + self.size end #
Make sure to call to_ptr.
diff --git a/NSObject-SafeExpectations.podspec b/NSObject-SafeExpectations.podspec index abc1234..def5678 100644 --- a/NSObject-SafeExpectations.podspec +++ b/NSObject-SafeExpectations.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "NSObject-SafeExpectations" - s.version = "0.0.4-beta.1" + s.version = "0.0.4" s.summary = "No more crashes getting unexpected values from a NSDictionary." s.homepage = "https://github.com/wordpress-mobile/NSObject-SafeExpectations" s.license = { :type => 'MIT', :file => 'LICENSE' }
Update podspec, change version to 0.0.4
diff --git a/lib/rackstash/filters/clear_color.rb b/lib/rackstash/filters/clear_color.rb index abc1234..def5678 100644 --- a/lib/rackstash/filters/clear_color.rb +++ b/lib/rackstash/filters/clear_color.rb @@ -9,6 +9,12 @@ module Filters # Remove all ANSI color codes from the `"message"` field of the given event # `Hash`. + # + # @example + # Rackstash::Flow.new(STDOUT) do + # # Removes all ANSI color codes from the message field + # filter :clear_color + # end class ClearColor # a regular expression matching ANSI color codes COLOR_REGEX = /\e\[[0-9;]*m/.freeze
Add code example how to instantiate the ClearColor filter
diff --git a/lib/devise/models/suspendable.rb b/lib/devise/models/suspendable.rb index abc1234..def5678 100644 --- a/lib/devise/models/suspendable.rb +++ b/lib/devise/models/suspendable.rb @@ -12,14 +12,14 @@ def active_for_authentication? if super - return true if !suspended? + return true unless suspended? EventLog.record_event(self, EventLog::SUSPENDED_ACCOUNT_AUTHENTICATED_LOGIN) end false end def inactive_message - !suspended? ? super : :suspended + suspended? ? :suspended : super end # Suspends the user in the database.
Remove unnecessary negation from suspension logic. Use `unless` and flip ternary operators to avoid having to think through too much negation in conditionals; hopefully this makes the logic a bit clearer.
diff --git a/lib/ruxero/base_model/finders.rb b/lib/ruxero/base_model/finders.rb index abc1234..def5678 100644 --- a/lib/ruxero/base_model/finders.rb +++ b/lib/ruxero/base_model/finders.rb @@ -1,8 +1,8 @@ class Ruxero::BaseModel - def self.all(params = {}) + def self.all(params = {}, headers = {}) parts = ["/api.xro/2.0/#{pluralized_name}", build_conditions(params)] - result = Ruxero.application.get(parts.join('?')) + result = Ruxero.application.get(parts.join('?'), headers) parse_collection(result) || Array.new end
Allow passing headers to Ruxero model 'all' method
diff --git a/lib/sidekiq/expected_failures.rb b/lib/sidekiq/expected_failures.rb index abc1234..def5678 100644 --- a/lib/sidekiq/expected_failures.rb +++ b/lib/sidekiq/expected_failures.rb @@ -48,3 +48,9 @@ Sidekiq::Web.register Sidekiq::ExpectedFailures::Web Sidekiq::Web.tabs["Expected Failures"] = "expected_failures" + +Sidekiq.configure_server do |config| + config.server_middleware do |chain| + chain.add Sidekiq::ExpectedFailures::Middleware + end +end
Insert server middleware by default
diff --git a/lib/sinatra/assetpack/helpers.rb b/lib/sinatra/assetpack/helpers.rb index abc1234..def5678 100644 --- a/lib/sinatra/assetpack/helpers.rb +++ b/lib/sinatra/assetpack/helpers.rb @@ -11,7 +11,7 @@ def img(src, options={}) attrs = { :src => HtmlHelpers.get_file_uri(src, settings.assets) } - .merge!(options) + attrs = attrs.merge(options) "<img#{HtmlHelpers.kv attrs} />" end
Fix for ruby 1.8 compatiblity
diff --git a/octokit.gemspec b/octokit.gemspec index abc1234..def5678 100644 --- a/octokit.gemspec +++ b/octokit.gemspec @@ -4,7 +4,7 @@ require 'octokit/version' Gem::Specification.new do |spec| - spec.add_development_dependency 'bundler', '~> 1.0' + spec.add_development_dependency 'bundler', '>= 1', '< 3' spec.add_dependency 'sawyer', '>= 0.5.3', '~> 0.8.0' spec.authors = ["Wynn Netherland", "Erik Michaels-Ober", "Clint Shryock"] spec.description = %q{Simple wrapper for the GitHub API}
Expand Bundler dependency version requirements
diff --git a/sample/db/samples/adjustments.rb b/sample/db/samples/adjustments.rb index abc1234..def5678 100644 --- a/sample/db/samples/adjustments.rb +++ b/sample/db/samples/adjustments.rb @@ -8,7 +8,7 @@ :source => first_order, :originator => Spree::TaxRate.find_by_name!("North America"), :label => "Tax", - :locked => false, + :state => "open", :mandatory => true }, :without_protection => true) @@ -17,7 +17,7 @@ :source => last_order, :originator => Spree::TaxRate.find_by_name!("North America"), :label => "Tax", - :locked => false, + :state => "open", :mandatory => true }, :without_protection => true) @@ -26,7 +26,7 @@ :source => first_order, :originator => Spree::ShippingMethod.find_by_name!("UPS Ground (USD)"), :label => "Shipping", - :locked => true, + :state => "finalized", :mandatory => true }, :without_protection => true) @@ -35,6 +35,6 @@ :source => last_order, :originator => Spree::ShippingMethod.find_by_name!("UPS Ground (USD)"), :label => "Shipping", - :locked => true, + :state => "finalized", :mandatory => true }, :without_protection => true)
Convert db seed + sample files to Ruby This removes some confusion about what countries are in what zone members, and will prevent us from running into issues like #2547
diff --git a/tests/spec/requests/cors_spec.rb b/tests/spec/requests/cors_spec.rb index abc1234..def5678 100644 --- a/tests/spec/requests/cors_spec.rb +++ b/tests/spec/requests/cors_spec.rb @@ -0,0 +1,23 @@+require 'net/http' +require 'spec_helper' + +RSpec.feature "Cross-origin requests", type: :request do + let(:evaluate_json_uri) { URI.join(Capybara.app_host, '/evaluate.json') } + + it "allows preflight requests for POSTing to evaluate.json" do + Net::HTTP.start(evaluate_json_uri.host, evaluate_json_uri.port) do |http| + request = Net::HTTP::Options.new(evaluate_json_uri) + request['origin'] = 'https://rust-lang.org' + request['access-control-request-headers'] = 'content-type' + request['access-control-request-method'] = 'POST' + + response = http.request(request) + + expect(response['access-control-allow-headers']).to match(/content-type/i) + expect(response['access-control-allow-methods'].split(',').map(&:strip)).to match_array([/GET/i, /POST/i]) + expect(response['access-control-allow-origin']).to eq('*') + expect(response['access-control-max-age']).to eq('3600') + expect(response['vary'].split(',').map(&:strip)).to match_array([/origin/i, /access-control-request-method/i, /access-control-request-headers/i]) + end + end +end
Test that CORS requests are allowed
diff --git a/build_tools/publisher/ejs_publisher.rb b/build_tools/publisher/ejs_publisher.rb index abc1234..def5678 100644 --- a/build_tools/publisher/ejs_publisher.rb +++ b/build_tools/publisher/ejs_publisher.rb @@ -5,6 +5,7 @@ module Publisher class EJSPublisher + include Helpers GIT_REPO = "github.com/alphagov/govuk_template_ejs.git" GIT_URL = "https://#{ENV['GITHUB_TOKEN']}@#{GIT_REPO}"
Add missing include statement to EJS publisher
diff --git a/jsoneur/service.rb b/jsoneur/service.rb index abc1234..def5678 100644 --- a/jsoneur/service.rb +++ b/jsoneur/service.rb @@ -1,3 +1,5 @@+require 'open-uri' + module Jsoneur class Service @@ -6,11 +8,14 @@ def initialize(name, base_url, &block) @name = name @base_url = base_url - @faraday = Faraday.new(@base_url) - @faraday_configured = false + block.call(self) - set_faraday_defaults unless @faraday_configured + if @faraday.nil? + @faraday = Faraday.new(@base_url) do |f| + set_faraday_defaults(f) + end + end end def default_params @@ -18,22 +23,31 @@ end def connection(&block) - block.call(@faraday) - @faraday_configured = true + @faraday = Faraday.new(@base_url, &block) end - def set_faraday_defaults - @faraday.adapter Faraday.default_adapter - @faraday.request :json - @faraday.response :mashify - @faraday.response :json, :content_type => /\bjson$/ + def set_faraday_defaults(faraday) + faraday.adapter Faraday.default_adapter + faraday.request :json + faraday.response :mashify + faraday.response :json, :content_type => /\bjson$/ end def get(params = {}) - result = @faraday.get(path, default_params.merge(params)) + final_path = path % urlencoded_params(params) + result = @faraday.get(final_path, default_params.merge(params)) # TODO how to do error handling? result.body end + + private + def urlencoded_params(params) + safe_params = params.dup + safe_params.each do |key, value| + safe_params[key] = URI::encode(value) + end + end + end end
Fix problem with Faraday config
diff --git a/combo_build_api/lib/api_constraints.rb b/combo_build_api/lib/api_constraints.rb index abc1234..def5678 100644 --- a/combo_build_api/lib/api_constraints.rb +++ b/combo_build_api/lib/api_constraints.rb @@ -0,0 +1,10 @@+class ApiConstraints + def initialize(options) + @version = options[:version] + @default = options[:default] + end + + def matches?(req) + @default || req.headers['Accept'].include?("application/vnd.combobuild.v#{@version}") + end +end
Add api constraints file under lib folder
diff --git a/mixlib-log.gemspec b/mixlib-log.gemspec index abc1234..def5678 100644 --- a/mixlib-log.gemspec +++ b/mixlib-log.gemspec @@ -11,7 +11,7 @@ gem.authors = ["Opscode, Inc."] gem.has_rdoc = true gem.extra_rdoc_files = ["README.rdoc", "LICENSE", 'NOTICE'] - gem.files = Dir['lib/**/*'] + gem.files = Dir['lib/**/*'] + Dir['spec/**/*'] gem.add_development_dependency 'rake', '~> 0.9.2.2' gem.add_development_dependency 'rspec', '~> 2.10.0' gem.add_development_dependency 'cucumber', '~> 1.2.0'
CHEF-3169: Include tests in gem package for distros, test.rubygems.org, etc
diff --git a/spec/integration/adapter_spec.rb b/spec/integration/adapter_spec.rb index abc1234..def5678 100644 --- a/spec/integration/adapter_spec.rb +++ b/spec/integration/adapter_spec.rb @@ -12,7 +12,11 @@ setup.relation(:users, adapter: :yesql) end - it 'works yay!' do - expect(users.by_name(name: 'Jane')).to match_array([{ id: 1, name: 'Jane' }]) + describe 'query method' do + it 'uses hash-based interpolation by default' do + expect(users.by_name(name: 'Jane')).to match_array([ + { id: 1, name: 'Jane' } + ]) + end end end
Update example descriptions in spec
diff --git a/lib/gitnesse.rb b/lib/gitnesse.rb index abc1234..def5678 100644 --- a/lib/gitnesse.rb +++ b/lib/gitnesse.rb @@ -1,11 +1,9 @@ require 'gitnesse/version' -require 'gitnesse/commit_info_generator' require 'gitnesse/config' require 'gitnesse/config_loader' require 'gitnesse/dependency_checker' require 'gitnesse/feature_extractor' require 'gitnesse/feature_transform' -require 'gitnesse/git_config_reader' require 'gitnesse/dir_manager' require 'gitnesse/wiki'
Remove requires for no-longer-used classes
diff --git a/spec/features/remote/github/miscellaneous/gitignore_spec.rb b/spec/features/remote/github/miscellaneous/gitignore_spec.rb index abc1234..def5678 100644 --- a/spec/features/remote/github/miscellaneous/gitignore_spec.rb +++ b/spec/features/remote/github/miscellaneous/gitignore_spec.rb @@ -0,0 +1,19 @@+require 'github_helper' + +# http://developer.github.com/v3/gitignore/ +resource :gitignore do + extend Authorize + authorize_with token: ENV['RSPEC_API_GITHUB_TOKEN'] + + has_attribute :name, type: :string + has_attribute :source, type: :string + + # This is the only case where returns a collection of strings, not of objects + # get '/gitignore/templates', collection: true do + # respond_with :ok + # end + + get '/gitignore/templates/:name' do + respond_with :ok, name: existing(:gitignore_template) + end +end
Add spec for GitHub gitignore
diff --git a/lib/parsable.rb b/lib/parsable.rb index abc1234..def5678 100644 --- a/lib/parsable.rb +++ b/lib/parsable.rb @@ -15,7 +15,14 @@ crunched = original.dup parsed_parts.each do |item| - crunched.gsub!("{{#{item.original}}}", context.read(item.object, item.attribute).to_s) + # Using the block form of this method here due to how backslashes are handled by gsub. + # See https://stackoverflow.com/questions/1542214/weird-backslash-substitution-in-ruby + # particularly the answer that reads: + ################################################################################################################## + # The problem is that when using sub (and gsub), without a block, ruby interprets special character sequences + # in the replacement parameter. + ################################################################################################################## + crunched.gsub!("{{#{item.original}}}") { context.read(item.object, item.attribute).to_s } end crunched
Use block form of gsub