diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -14,8 +14,8 @@ require 'raml-rb' require 'json' -require_relative '../lib/cli' -require_relative '../lib/document_generator' -require_relative '../lib/rspec/spec_file' -require_relative '../lib/rspec/examples' -require_relative '../lib/rspec/example_group' +path = File.expand_path('../../lib', __FILE__) + +Dir.foreach(path) {|f| require f if f.match(/.*\.rb\z/) } + +puts "This file is in #{File.expand_path('../../lib', __FILE__)}"
Use require instead of require relative
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -19,7 +19,7 @@ config.raise_errors_for_deprecations! config.before :all do Mongoid.logger.level = Logger::INFO - Mongo::Logger.logger.level = Logger::INFO if Mongoid::Compatibility::Version.mongoid5? + Mongo::Logger.logger.level = Logger::INFO if Mongoid::Compatibility::Version.mongoid5? || Mongoid::Compatibility::Version.mongoid6? Mongoid.belongs_to_required_by_default = false if Mongoid::Compatibility::Version.mongoid6? end end
Reduce logging level with Mongoid 6.
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -17,8 +17,11 @@ config.before do # Catch stdout - # @stdout, $stdout = $stdout, StringIO.new - # @stderr, $stderr = $stderr, StringIO.new + unless ENV['GIT_COMPOUND_DEBUG'] + @stdout, $stdout = $stdout, StringIO.new + @stderr, $stderr = $stderr, StringIO.new + end + GitCompound::Command::Options.verbose = true GitCompound::Command::Options.disable_colors = true end @@ -33,7 +36,9 @@ config.after do # Reassign stdout - # $stdout, @stdout = @stdout, nil - # $stderr, @stderr = @stderr, nil + unless ENV['GIT_COMPOUND_DEBUG'] + $stdout, @stdout = @stdout, nil + $stderr, @stderr = @stderr, nil + end end end
Enable spec debug information if GIT_COMPOUND_DEBUG env is present
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -11,6 +11,5 @@ I18n.load_path = Dir['spec/i18n/*.yml'] RSpec.configure do |config| - config.filter_run :focus - config.run_all_when_everything_filtered = true + config.filter_run_when_matching :focus end
Update RSpec focus config syntax
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,7 @@ # encoding: utf-8 -gem 'rspec', '~> 2.4' +gem 'rspec', '~> 3.1' require 'rspec' require 'trange_frange' -include TrangeFrange+include TrangeFrange
Fix pessimistic dependency on rdoc and rspec
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,4 @@ # encoding: utf-8 - -require 'devtools/spec_helper' if ENV['COVERAGE'] == 'true' require 'simplecov' @@ -12,21 +10,20 @@ ] SimpleCov.start do - command_name 'spec:unit' - add_filter 'config' - add_filter 'spec' + command_name 'spec:unit' + + add_filter 'config' + add_filter 'spec' + add_filter 'vendor' + minimum_coverage 100 end end +require 'devtools/spec_helper' require 'axiom-types' include Axiom::Types - -# Require spec support files and shared behavior -Dir[File.expand_path('../{support,shared}/**/*.rb', __FILE__)].each do |file| - require file.chomp('.rb') -end RSpec.configure do |config| config.expect_with :rspec do |expect_with|
Update spec helper to be similar to other gems * Remove unnecessary boilerplate
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index abc1234..def5678 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -16,12 +16,10 @@ case backend when :php - puts "booting genghis.php" @genghis_pid = spawn 'php', '-S', "localhost:#{@genghis_port}", 'genghis.php', :out => '/dev/null' sleep 0.1 Faraday.new url: "http://localhost:#{@genghis_port}" when :ruby - puts "\n\nusing genghis.rb" Faraday.new do |conn| conn.adapter :rack, Genghis::Server.new end
Remove debugging output from api spec.
diff --git a/app/models/connection.rb b/app/models/connection.rb index abc1234..def5678 100644 --- a/app/models/connection.rb +++ b/app/models/connection.rb @@ -60,6 +60,6 @@ end def expiring - %w(linkedin youtube) + %w(stackoverflow linkedin youtube) end end
Add stackoverflow to expiring list
diff --git a/search-engine/lib/ban_list/custom_standard.rb b/search-engine/lib/ban_list/custom_standard.rb index abc1234..def5678 100644 --- a/search-engine/lib/ban_list/custom_standard.rb +++ b/search-engine/lib/ban_list/custom_standard.rb @@ -4,4 +4,10 @@ nil, "Dreamheart Mox" => "banned", ) + + change( + "2017-12-15", + nil, + "Reev, Equinox Prophet" => "banned", + ) end
Add Reev, Equinox Prophet to Custom Standard banlist
diff --git a/art/app/models/review.rb b/art/app/models/review.rb index abc1234..def5678 100644 --- a/art/app/models/review.rb +++ b/art/app/models/review.rb @@ -9,7 +9,7 @@ } scope :beloved, -> { where(rating: 5) } - scope :recent, -> { where("created_at > ?", 5.days.ago) } + scope :recent, -> { where("reviews.created_at > ?", 5.days.ago) } scope :for, ->(performance) { where(performance: performance) } scope :by, ->(user) { where(user: user) }
Fix scope recent in Review
diff --git a/UberSignals.podspec b/UberSignals.podspec index abc1234..def5678 100644 --- a/UberSignals.podspec +++ b/UberSignals.podspec @@ -9,7 +9,7 @@ s.source = { :git => 'https://github.com/uber/signals-ios.git', :tag => s.version } s.requires_arc = true - s.ios.deployment_target = '8.0' + s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.7' s.source_files = "#{s.name}/**/*.{h,m}"
Set podspec iOS target back to 7.0
diff --git a/spec/features/badges_cookbook_partner_spec.rb b/spec/features/badges_cookbook_partner_spec.rb index abc1234..def5678 100644 --- a/spec/features/badges_cookbook_partner_spec.rb +++ b/spec/features/badges_cookbook_partner_spec.rb @@ -1,4 +1,4 @@-require 'spec_feature_helper' +require 'spec_helper' describe 'A cookbook that has been granted a Partner badge' do let(:badged_cookbook) { create(:partner_cookbook, name: 'ReallyGreatPartnerCookbook') }
Change to using unified spec_helper from rspec upgrade
diff --git a/lib/twirly.rb b/lib/twirly.rb index abc1234..def5678 100644 --- a/lib/twirly.rb +++ b/lib/twirly.rb @@ -0,0 +1,45 @@+# coding: utf-8 + +require 'delegate' +require 'yaml' +require 'thor' +require 'active_support/hash_with_indifferent_access' +require 'active_support/core_ext' + +require 'twirly/version' + +autoload :Trello, 'trello' +autoload :Liquid, 'liquid' +autoload :FileUtils, 'file_utils' + +I18n.enforce_available_locales = false + +module Twirly + begin + SETTINGS = YAML.load_file('twirly.yml').deep_symbolize_keys + rescue Errno::ENOENT + puts 'twirly.yml was not found, please add one' + end + + def self.board + @board ||= Trello::Board.find(SETTINGS[:publishing_board]) + end + + def self.source_dir(dir = './') + @source ||= (SETTINGS[:source_dir] || File.expand_path(dir)) + end + + autoload :Post, 'twirly/post' + autoload :User, 'twirly/user' + autoload :Compiler, 'twirly/compiler' + autoload :CLI, 'twirly/cli' + autoload :Commands, 'twirly/commands' + autoload :Helpers, 'twirly/helpers' + autoload :Serializers, 'twirly/serializers' +end + +# Load all initializers +Dir[File.join(File.expand_path('../../', __FILE__), + 'config/initializers/*')].sort.each(&method(:require)) + +Liquid::Template.register_tag('youtube', Twirly::Helpers::Youtube)
Initialize Twirly module and dependencies
diff --git a/activerecord-maxdb-adapter/lib/arjdbc/maxdb.rb b/activerecord-maxdb-adapter/lib/arjdbc/maxdb.rb index abc1234..def5678 100644 --- a/activerecord-maxdb-adapter/lib/arjdbc/maxdb.rb +++ b/activerecord-maxdb-adapter/lib/arjdbc/maxdb.rb @@ -1,4 +1,8 @@ require 'arjdbc/jdbc' -jdbc_require_driver 'jdbc/maxdb' + +# This is not needed since AR-JDBC Adapter version 1.2.6, and moreover causes an error. +# Please uncomment it for versions prior to 1.2.6 +# jdbc_require_driver 'jdbc/maxdb' + require 'arjdbc/maxdb/connection_methods' require 'arjdbc/maxdb/adapter'
Comment out a method which is no longer present from AR-JDBC Adapter 1.2.6 Signed-off-by: Krum Bakalsky <085addf56b8a0456baca20d85cde58a9f9d24475@sap.com>
diff --git a/activestorage/test/dummy/config/application.rb b/activestorage/test/dummy/config/application.rb index abc1234..def5678 100644 --- a/activestorage/test/dummy/config/application.rb +++ b/activestorage/test/dummy/config/application.rb @@ -7,13 +7,13 @@ require "action_controller/railtie" require "action_view/railtie" require "sprockets/railtie" +require "active_storage/engine" #require "action_mailer/railtie" #require "rails/test_unit/railtie" #require "action_cable/engine" Bundler.require(*Rails.groups) -require "active_storage" module Dummy class Application < Rails::Application @@ -22,4 +22,3 @@ config.active_storage.service = :local end end -
Fix dummy app for inclusion in Rails
diff --git a/services/build_runner_service.rb b/services/build_runner_service.rb index abc1234..def5678 100644 --- a/services/build_runner_service.rb +++ b/services/build_runner_service.rb @@ -28,10 +28,8 @@ end end - def find_build_runner(project_id: nil, build_number: nil) - raise "You have to provide both a project and a build number" if project_id.nil? || build_number.nil? - - # Fetch all the active runners, and see if there is one WIP + # Fetch all the active runners, and see if there is one WIP + def find_build_runner(project_id:, build_number:) return self.build_runners.find do |build_runner| build_runner.project.id == project_id && build_runner.current_build.number == build_number end
Use of fancy new Ruby syntax cc @taquitos
diff --git a/db/migrate/20141125170450_add_current_host_to_spree_google_shopping_settings.spree_google_trusted_store.rb b/db/migrate/20141125170450_add_current_host_to_spree_google_shopping_settings.spree_google_trusted_store.rb index abc1234..def5678 100644 --- a/db/migrate/20141125170450_add_current_host_to_spree_google_shopping_settings.spree_google_trusted_store.rb +++ b/db/migrate/20141125170450_add_current_host_to_spree_google_shopping_settings.spree_google_trusted_store.rb @@ -0,0 +1,6 @@+class AddCurrentHostToSpreeGoogleShoppingSettings < ActiveRecord::Migration + def change + add_column :spree_google_shopping_settings, :current_host, :string + rename_column :spree_google_shopping_settings, :google_api_appplication_name, :google_api_application_name + end +end
Update migrations for newest trusted store gem
diff --git a/spec/factories/liquid_layouts.rb b/spec/factories/liquid_layouts.rb index abc1234..def5678 100644 --- a/spec/factories/liquid_layouts.rb +++ b/spec/factories/liquid_layouts.rb @@ -18,6 +18,11 @@ title 'thermometer template' content %{ {% include 'thermometer' %} } end + + trait :no_plugins do + title 'layout with no plugins' + content %{ whatever } + end end end
Add factory with 'no-plugin' layout
diff --git a/spec/optparse/subcommand_spec.rb b/spec/optparse/subcommand_spec.rb index abc1234..def5678 100644 --- a/spec/optparse/subcommand_spec.rb +++ b/spec/optparse/subcommand_spec.rb @@ -31,13 +31,13 @@ end end - specify { run("-t").should == [:t] } - specify { run("foo").should == [:foo] } - specify { run("foo -q").should == [:foo, :foo_q] } - specify { run("foo bar").should == [:foo] } - specify { run("-t foo").should == [:t, :foo] } + specify { expect(run("-t")).to eq([:t]) } + specify { expect(run("foo")).to eq([:foo]) } + specify { expect(run("foo -q")).to eq([:foo, :foo_q]) } + specify { expect(run("foo bar")).to eq([:foo]) } + specify { expect(run("-t foo")).to eq([:t, :foo]) } - specify { lambda { run("foo -t") }.should raise_error(OptionParser::InvalidOption )} + specify { expect { run("foo -t") }.to raise_error(OptionParser::InvalidOption )} - specify { options.to_s.should match(/foo/) } + specify { expect(options.to_s).to match(/foo/) } end
Convert specs to RSpec 2.99.2 syntax with Transpec This conversion is done by Transpec 3.3.0 with the following command: transpec * 6 conversions from: obj.should to: expect(obj).to * 5 conversions from: == expected to: eq(expected) * 1 conversion from: lambda { }.should to: expect { }.to For more details: https://github.com/yujinakayama/transpec#supported-conversions
diff --git a/spec/support/test_credentials.rb b/spec/support/test_credentials.rb index abc1234..def5678 100644 --- a/spec/support/test_credentials.rb +++ b/spec/support/test_credentials.rb @@ -6,7 +6,6 @@ credentials_file = File.expand_path("#{__FILE__}/../credentials.rb") unless File.exists?(credentials_file) puts "Please configure your Facebook and Twitter application credentials by copying #{credentials_file}.example to #{credentials_file} and configuring the required values there appropriately." - puts "Then comment out the 'exit' line in #{File.expand_path(__FILE__)} before running rspec." exit end end
Remove unneeded line of output for when configuring gem for testing
diff --git a/app/controllers/api/statistiques_controller.rb b/app/controllers/api/statistiques_controller.rb index abc1234..def5678 100644 --- a/app/controllers/api/statistiques_controller.rb +++ b/app/controllers/api/statistiques_controller.rb @@ -10,10 +10,10 @@ private def total_dossiers - Dossier.all.size + Dossier.where.not(state: :draft).size end def dossiers_mois - Dossier.where(created_at: (1.month.ago)..Time.now).size + Dossier.where.not(state: :draft).where(created_at: (1.month.ago)..Time.now).size end end
Exclude draft dossier on statistiques
diff --git a/subversion/bindings/swig/ruby/test/run-test.rb b/subversion/bindings/swig/ruby/test/run-test.rb index abc1234..def5678 100644 --- a/subversion/bindings/swig/ruby/test/run-test.rb +++ b/subversion/bindings/swig/ruby/test/run-test.rb @@ -15,7 +15,11 @@ begin require "gettext" - Locale.setlocale(Locale::ALL, nil) + if Locale.respond_to?(:set) + Locale.set(nil) + else + Locale.setlocale(Locale::ALL, nil) + end rescue LoadError end
Support the latest version of Ruby-GetText. * subversion/bindings/swig/ruby/test/run-test.rb: Don't use deprecated API Locale.setlocale(Locale::ALL, nil) if Locale.set is available. git-svn-id: f8a4e5e023278da1e04e203c7fe051e3c4285d88@861061 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/api_sampler/middleware.rb b/lib/api_sampler/middleware.rb index abc1234..def5678 100644 --- a/lib/api_sampler/middleware.rb +++ b/lib/api_sampler/middleware.rb @@ -9,7 +9,24 @@ end def call(env) - @app.call(env) + request = Rack::Request.new(env) + status, headers, response = @app.call(env) + collect_sample(request, response) + [status, headers, response] + end + + # Collects a sample of the current request. + # + # @param request [Rack::Request] current request. + # @param response [ActiveDispatch::Response::RackBody] response body. + def collect_sample(request, response) + endpoint = ApiSampler::Endpoint.find_or_create_by!(path: request.path) + endpoint.samples.create!(request_method: request.request_method, + query: request.query_string, + request_body: request.body.read, + response_body: response.body) + rescue ActiveRecord::RecordInvalid => error + Rails.logger.error "api_sampler :: collect_sample :: #{error}" end end end
Implement unconditional collecting of samples
diff --git a/src/generate_data.rb b/src/generate_data.rb index abc1234..def5678 100644 --- a/src/generate_data.rb +++ b/src/generate_data.rb @@ -1,13 +1,25 @@-out_filename = File.expand_path("../res/test.txt", File.dirname(__FILE__)) +xmin = 0 +xmax = 1024 +ymin = 0 +ymax = 1024 +max_width = 10 +max_height = 10 + +out_filename = File.expand_path(ARGV[0] || "../res/test.txt", File.dirname(__FILE__)) +# Default size of 1 Gb +total_size = (ARGV[1] && ARGV[1].to_i) || 1024 * 1024 * 1024 * 1 + +current_size = 0 +i = 0 File.open(out_filename, "w") do |f| - 1024.times do |i| - x1 = rand(1024) - y1 = rand(1024) - x2 = rand(1024) - y2 = rand(1024) - x1, x2 = [x1, x2].sort - y1, y2 = [y1, y2].sort - str = "%011d,%04d,%04d,%04d,%04d" % [i, x1, y1, x2, y2] + while current_size < total_size do + x1 = rand(xmax-xmin)+xmin + y1 = rand(ymax-ymin)+ymin + w = rand(max_width) + h = rand(max_height) + str = [i, x1, y1, x1+w, y1+h].join(",") + i += 1 + current_size += str.length + 1 f.puts str end end
Set destination file and size through command line arguemnts for the generation script
diff --git a/lib/jschema/json_reference.rb b/lib/jschema/json_reference.rb index abc1234..def5678 100644 --- a/lib/jschema/json_reference.rb +++ b/lib/jschema/json_reference.rb @@ -31,7 +31,7 @@ end def download_schema(uri) - request = Net::HTTP::Get.new(uri) + request = Net::HTTP::Get.new(uri.to_s) request['Accept'] = 'application/json+schema' http = Net::HTTP.new(uri.hostname, uri.port)
Fix the gem for older versions of ruby
diff --git a/lib/starting_blocks-blinky.rb b/lib/starting_blocks-blinky.rb index abc1234..def5678 100644 --- a/lib/starting_blocks-blinky.rb +++ b/lib/starting_blocks-blinky.rb @@ -35,6 +35,10 @@ def receive_results results return if @spec_count == 0 + run_the_old_logic_with results + end + + def run_the_old_logic_with results if (results[:tests] || 0) == 0 change_color_to :red elsif (results[:errors] || 0) > 0
Move the existing logic to a single method.
diff --git a/lib/stash_discovery/engine.rb b/lib/stash_discovery/engine.rb index abc1234..def5678 100644 --- a/lib/stash_discovery/engine.rb +++ b/lib/stash_discovery/engine.rb @@ -1,5 +1,8 @@ require 'blacklight' require 'geoblacklight' + +# For undocumented reasons, sass-rails won't load without an explicit require +require 'sass-rails' module StashDiscovery class Engine < ::Rails::Engine
Add explicit require for sass-rails
diff --git a/lib/tasks/update_sitemap.rake b/lib/tasks/update_sitemap.rake index abc1234..def5678 100644 --- a/lib/tasks/update_sitemap.rake +++ b/lib/tasks/update_sitemap.rake @@ -1,14 +1,13 @@ namespace :daimon do desc 'Update sitemap.xml for all sites' task 'update_all_sitemap' => :environment do - Site.pluck(:id).each do |id| + Site.where(opened: true).pluck(:id).each do |id| task = 'daimon:create_sitemap' Rake::Task[task].invoke(id.to_s) Rake::Task[task].reenable - # TODO Enable later - # SitemapGenerator::Sitemap.ping_search_engines + SitemapGenerator::Sitemap.ping_search_engines end end
Enable `ping_search_engines` for opened sites
diff --git a/app/models/user_session.rb b/app/models/user_session.rb index abc1234..def5678 100644 --- a/app/models/user_session.rb +++ b/app/models/user_session.rb @@ -5,6 +5,10 @@ aleph_url Exlibris::Aleph::Config.base_url calling_system "getit" institution_param_key "umlaut.institution" + + def expiration_date + 1.hour.ago + end # (Re-)Set verification and Aleph permissions to user attributes def additional_attributes
Expire development users after an hour :frog:
diff --git a/rails_nlp.gemspec b/rails_nlp.gemspec index abc1234..def5678 100644 --- a/rails_nlp.gemspec +++ b/rails_nlp.gemspec @@ -9,7 +9,7 @@ spec.authors = ["Philip Hale"] spec.email = ["p.hale.09@aberdeen.ac.uk"] spec.summary = "Supercharge your ActiveRecord text fields with NLP analysis." - spec.description = %q{TODO: Write a longer description. Optional.} + spec.description = "Add Rails NLP to your Rails project to allow deeper full-text search across your ActiveRecord models." spec.homepage = "" spec.license = "TBC" @@ -20,4 +20,5 @@ spec.add_development_dependency "bundler", "~> 1.6" spec.add_development_dependency "rake" + spec.add_development_dependency "rspec" end
Add a description to gemspec.
diff --git a/invisible_captcha.gemspec b/invisible_captcha.gemspec index abc1234..def5678 100644 --- a/invisible_captcha.gemspec +++ b/invisible_captcha.gemspec @@ -19,5 +19,6 @@ spec.add_dependency 'rails' spec.add_development_dependency 'rspec-rails', '~> 3.1' + spec.add_development_dependency 'mime-types-data', '< 3' end
Fix mime-types-data dependency for TravisCI in ruby 1.9.3
diff --git a/blinkbox-common_messaging.gemspec b/blinkbox-common_messaging.gemspec index abc1234..def5678 100644 --- a/blinkbox-common_messaging.gemspec +++ b/blinkbox-common_messaging.gemspec @@ -1,5 +1,5 @@ # -*- encoding: utf-8 -*- -$LOAD_PATH.unshift(File.join(__dir__, "lib")) +$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "lib")) require "blinkbox/common_messaging/version" Gem::Specification.new do |gem|
Fix Travis using 1.9.3 to build gems
diff --git a/lib/awestruct/pipeline.rb b/lib/awestruct/pipeline.rb index abc1234..def5678 100644 --- a/lib/awestruct/pipeline.rb +++ b/lib/awestruct/pipeline.rb @@ -17,6 +17,7 @@ def extension(e) @extensions << e + e.transform(@transformers) if e.respond_to?('transform') end def helper(h)
Allow extensions to add to the transformers list.
diff --git a/lib/correios_slack_bot.rb b/lib/correios_slack_bot.rb index abc1234..def5678 100644 --- a/lib/correios_slack_bot.rb +++ b/lib/correios_slack_bot.rb @@ -20,6 +20,28 @@ end match /^rastreia o pacote (?<package_code>\w*)$/ do |client, data, match| + package_log = CorreiosSlackBot::Correios.new(match[:package_code]).package_log + known_package_log = package_log + client.say(text: 'Blz, vou começar a rastrar, qualquer coisa te falo', + channel: data.channel) + loop do + new_package_log = CorreiosSlackBot::Correios.new(match[:package_code]).package_log + if (new_package_log - known_package_log).size > 0 + log = new_package_log[0] + client.web_client.chat_postMessage( + channel: data.channel, + as_user: true, + attachments: [ + { + title: "#{log[:date]} - #{log[:origin]}", + text: "#{log[:description]} (#{log[:status]})" + } + ] + ) + known_package_log = new_package_log + end + sleep 30 + end end end end
Implement a basic package monitor feature, need refactoring e improvments
diff --git a/.delivery/build_cookbook/recipes/setup_build.rb b/.delivery/build_cookbook/recipes/setup_build.rb index abc1234..def5678 100644 --- a/.delivery/build_cookbook/recipes/setup_build.rb +++ b/.delivery/build_cookbook/recipes/setup_build.rb @@ -11,7 +11,7 @@ ## for the build user or the build nodes must have all the packages required for a build installed already. ## Either choice must be done outside of the actual build cookbook. ## It is, of course, recommended you use chef to manage any pre-reqs for your build nodes via a cookbook. -execute "sudo yum install -y #{build_config['required_build_packages']}" +execute "sudo yum install -y #{build_config['required_build_packages']} >/dev/null" src_dir = "#{workflow_workspace_repo}/httpd" # Root directory for the source to go into on the build node @@ -32,4 +32,5 @@ bash 'Building autoconf script' do code "#{src_dir}/buildconf" + cwd src_dir end
Make sure buildconf runs in correct working dir
diff --git a/BHCDatabase/app/controllers/areas_controller.rb b/BHCDatabase/app/controllers/areas_controller.rb index abc1234..def5678 100644 --- a/BHCDatabase/app/controllers/areas_controller.rb +++ b/BHCDatabase/app/controllers/areas_controller.rb @@ -24,8 +24,16 @@ Area end - column(:id, :mandatory => true) - column(:name, :mandatory => true) + column(:id, :mandatory => true) do |model| + format(model.id) do |value| + link_to value, model + end + end + column(:name, :mandatory => true) do |model| + format(model.name) do |value| + link_to value, model + end + end column(:description, :mandatory => true) end
Add link to specfic area from id and name in area table.
diff --git a/config/initializers/log_tagger.rb b/config/initializers/log_tagger.rb index abc1234..def5678 100644 --- a/config/initializers/log_tagger.rb +++ b/config/initializers/log_tagger.rb @@ -0,0 +1,8 @@+# This puts the request id and session id as prefix values for each log entry. +# This helps aggregate papertrail logs. These will be prepended to your Rails +# logging messages +# Thanks to https://gist.github.com/soultech67/67cf623b3fbc732291a2 +Rails.application.config.log_tags = [ + lambda { |request| "#{request.uuid}"[0..15] }, + lambda { |request| "#{request.cookie_jar["_web_session"]}"[0..15] }, +]
Add tagging on rails logs
diff --git a/lib/juicer/command/cat.rb b/lib/juicer/command/cat.rb index abc1234..def5678 100644 --- a/lib/juicer/command/cat.rb +++ b/lib/juicer/command/cat.rb @@ -14,12 +14,13 @@ class Cat include Juicer::Loggable attr_reader :output, :type + DESC = "Resolve dependencies and concatenate files" def initialize(args = nil) args = args.split(" ") if args.is_a?(String) opts = Trollop::options(args || []) do - banner "Resolve dependencies and concatenate files" + banner DESC opt :output, "File to write concatenated contents to", :default => nil, :type => :string opt :type, "css or javascript. Not necessary to specify when using files", :default => nil, :type => :string end
Put command description in DESC constant for use in command list
diff --git a/lib/ktl/migration_plan.rb b/lib/ktl/migration_plan.rb index abc1234..def5678 100644 --- a/lib/ktl/migration_plan.rb +++ b/lib/ktl/migration_plan.rb @@ -2,10 +2,13 @@ module Ktl class MigrationPlan - def initialize(zk_client, old_leader, new_leader) + def initialize(zk_client, old_leader, new_leader, options = {}) @zk_client = zk_client @old_leader = old_leader.to_java @new_leader = new_leader.to_java + @options = options + @logger = options[:logger] || NullLogger.new + @log_plan = !!options[:log_plan] end def generate @@ -18,6 +21,7 @@ if replicas.contains?(@old_leader) index = replicas.index_of(@old_leader) new_replicas = replicas.updated(index, @new_leader, CanBuildFrom) + @logger.info "Moving #{topic_partition.topic},#{topic_partition.partition} from #{replicas} to #{new_replicas}" if @log_plan plan += Scala::Tuple.new(topic_partition, new_replicas) end end
Add verbose and dryrun to migrate-broker
diff --git a/lib/meta/rails/railtie.rb b/lib/meta/rails/railtie.rb index abc1234..def5678 100644 --- a/lib/meta/rails/railtie.rb +++ b/lib/meta/rails/railtie.rb @@ -3,6 +3,12 @@ initializer 'meta_description.helper' do ActiveSupport.on_load :action_view do include MetaRailsHelpers::MetaDescriptionHelper + end + end + + initializer 'robots.helper' do + ActiveSupport.on_load :action_view do + include MetaRailsHelpers::RobotsHelper end end
Add initializer for robots helper
diff --git a/lib/one_secret/railtie.rb b/lib/one_secret/railtie.rb index abc1234..def5678 100644 --- a/lib/one_secret/railtie.rb +++ b/lib/one_secret/railtie.rb @@ -15,7 +15,7 @@ # concern 4 - security message for people keeping production secret_key_base in secrets.yml # concern 5 - copy all Rails.application.secrets to ENV Rails.application.secrets.each_pair do |key, value| - ENV[key.to_s] = value + ENV[key.to_s] = Secret.load(value) end end
Use Secret to load values into ENV
diff --git a/lib/uncomtrade/options.rb b/lib/uncomtrade/options.rb index abc1234..def5678 100644 --- a/lib/uncomtrade/options.rb +++ b/lib/uncomtrade/options.rb @@ -12,7 +12,11 @@ def update(opts={}) opts.each do |key, value| - self.options[key] = value if key != :fmt # don't let user update :fmt + if [:p,:r].include?(key) + self.options[key] = iso_code(value) + else + self.options[key] = value if key != :fmt # don't let user update :fmt + end end end
Fix bug where update wasn't using country helper.
diff --git a/test/functional/logic_test.rb b/test/functional/logic_test.rb index abc1234..def5678 100644 --- a/test/functional/logic_test.rb +++ b/test/functional/logic_test.rb @@ -0,0 +1,30 @@+require 'test_helper' + +class LogicTest < ActionController::TestCase + setup do + @user = FactoryGirl.create :user + end + + context 'saving a transient logic' do + context 'whose iri has http scheme' do + logic = FactoryGirl.create :logic, :user => @user + logic.name = 'FOL' + logic.iri = 'http://logic.org/FOL' + logic.save! + end + + context 'whose iri has urn scheme' do + logic = FactoryGirl.create :logic, :user => @user + logic.name = 'CommonLogic' + logic.iri = 'urn:logic:CommonLogic' + logic.save! + end + + context 'whose iri has ftp scheme' do + logic = FactoryGirl.create :logic, :user => @user + logic.name = 'DescriptiveLogic' + logic.iri = 'ftp://logic.org/DL' + logic.save! + end + end +end
Add skeleton for logic test
diff --git a/test/link_checker_api_test.rb b/test/link_checker_api_test.rb index abc1234..def5678 100644 --- a/test/link_checker_api_test.rb +++ b/test/link_checker_api_test.rb @@ -5,40 +5,40 @@ describe GdsApi::LinkCheckerApi do include GdsApi::TestHelpers::LinkCheckerApi - before do - @base_api_url = Plek.find("link-checker-api") - @api = GdsApi::LinkCheckerApi.new(@base_api_url) - end + describe "test helpers" do + let(:base_url) { Plek.find("link-checker-api") } + let(:api_client) { GdsApi::LinkCheckerApi.new(base_url) } - describe "#check" do - it "returns a useful response" do - stub_link_checker_api_check(uri: "http://example.com", status: :broken) + describe "#check" do + it "returns a useful response" do + stub_link_checker_api_check(uri: "http://example.com", status: :broken) - link_report = @api.check("http://example.com") + link_report = api_client.check("http://example.com") - assert_equal :broken, link_report.status + assert_equal :broken, link_report.status + end end - end - describe "#create_batch" do - it "returns a useful response" do - stub_link_checker_api_create_batch(uris: ["http://example.com"]) + describe "#create_batch" do + it "returns a useful response" do + stub_link_checker_api_create_batch(uris: ["http://example.com"]) - batch_report = @api.create_batch(["http://example.com"]) + batch_report = api_client.create_batch(["http://example.com"]) - assert_equal :in_progress, batch_report.status - assert_equal "http://example.com", batch_report.links[0].uri + assert_equal :in_progress, batch_report.status + assert_equal "http://example.com", batch_report.links[0].uri + end end - end - describe "#get_batch" do - it "returns a useful response" do - stub_link_checker_api_get_batch(id: 10, links: [{ uri: "http://example.com" }]) + describe "#get_batch" do + it "returns a useful response" do + stub_link_checker_api_get_batch(id: 10, links: [{ uri: "http://example.com" }]) - batch_report = @api.get_batch(10) + batch_report = api_client.get_batch(10) - assert_equal :completed, batch_report.status - assert_equal "http://example.com", batch_report.links[0].uri + assert_equal :completed, batch_report.status + assert_equal "http://example.com", batch_report.links[0].uri + end end end end
Refactor Link Checker API tests Move the existing tests into a block about testing the test helpers so we can add some more tests which use Pact for contract testing.
diff --git a/lib/bond/readlines/jruby.rb b/lib/bond/readlines/jruby.rb index abc1234..def5678 100644 --- a/lib/bond/readlines/jruby.rb +++ b/lib/bond/readlines/jruby.rb @@ -4,7 +4,7 @@ require 'readline' require 'jruby' class << Readline - ReadlineExt ||= org.jruby.ext.Readline + ReadlineExt = org.jruby.ext.Readline def line_buffer ReadlineExt.s_get_line_buffer(JRuby.runtime.current_context, JRuby.reference(self)) end
Revert "Enable plural Readline invocations sans warnings." Said to be fixed by pry team on their end This reverts commit 24c7bbbba55804d36eec2a6abc1a420b1622d148.
diff --git a/lib/cocoapods/executable.rb b/lib/cocoapods/executable.rb index abc1234..def5678 100644 --- a/lib/cocoapods/executable.rb +++ b/lib/cocoapods/executable.rb @@ -7,13 +7,13 @@ raise Informative, "Unable to locate the executable `#{name}'" end if Config.instance.verbose? - print " $ #{name} #{command.length > 20 ? command[0..20] + '...' : command}\r" + print " $ #{name}...\r" $stdout.flush output = `#{bin} #{command} 2>&1` puts " #{$?.exitstatus.zero? ? '-' : '!'.red} #{name} #{command}" - output = output.gsub(/^ */,' ') + output = output.gsub(/ */,' ').gsub(/^ */,' ') puts output unless output.strip.empty? else `#{bin} #{command} 2> /dev/null`
[Executable] Remove original white space formatting from the output.
diff --git a/lib/mountain_view/engine.rb b/lib/mountain_view/engine.rb index abc1234..def5678 100644 --- a/lib/mountain_view/engine.rb +++ b/lib/mountain_view/engine.rb @@ -31,8 +31,8 @@ initializer "mountain_view.add_helpers" do ActiveSupport.on_load :action_controller do - helper MountainView::ApplicationHelper - helper MountainView::ComponentHelper + ::ActionController::Base.helper MountainView::ApplicationHelper + ::ActionController::Base.helper MountainView::ComponentHelper end end end
Fix nomethoderror when including helpers Explicitly calls helper inclusion via ActionController::Base, preventing errors in Rails 5.1 (Issue#52).
diff --git a/lib/olaf/tasks/test_task.rb b/lib/olaf/tasks/test_task.rb index abc1234..def5678 100644 --- a/lib/olaf/tasks/test_task.rb +++ b/lib/olaf/tasks/test_task.rb @@ -1,3 +1,5 @@+# Copyright (C) 2013 OL2, inc. All Rights Reserved. + require 'ci/reporter/rake/minitest' require 'rake/testtask' @@ -5,7 +7,13 @@ Rake::TestTask.new do |t| t.libs << "test" t.ruby_opts.concat ["-r", OL_TEST_HELPER] # Helper FIRST - t.test_files = FileList['test/**/*_test.rb'] + t.test_files = FileList['test/**/*_test.rb'] - FileList['test/integration/*_test.rb'] t.verbose = true end +Rake::TestTask.new("test:integration") do |t| + t.libs << "test" + t.ruby_opts.concat ["-r", OL_TEST_HELPER] # Helper FIRST + t.test_files = FileList['test/integration/*_test.rb'] + t.verbose = true +end
Add test:integration to all Olaf Rakefiles, currently unused. VAL-232
diff --git a/lib/rails/cache/tags/set.rb b/lib/rails/cache/tags/set.rb index abc1234..def5678 100644 --- a/lib/rails/cache/tags/set.rb +++ b/lib/rails/cache/tags/set.rb @@ -14,7 +14,7 @@ end def current(tag) - @cache.fetch(tag.to_key) { 1 }.to_i + @cache.fetch_without_tags(tag.to_key) { 1 }.to_i end def expire(tag)
Reduce cache hits during tags fetching
diff --git a/lib/sass/tree/while_node.rb b/lib/sass/tree/while_node.rb index abc1234..def5678 100644 --- a/lib/sass/tree/while_node.rb +++ b/lib/sass/tree/while_node.rb @@ -12,7 +12,7 @@ def _perform(environment) children = [] while @expr.perform(environment).to_bool - children += perform_children + children += perform_children(environment) end children end
Fix a bug in @while.
diff --git a/lib/sidekiq/logging/json.rb b/lib/sidekiq/logging/json.rb index abc1234..def5678 100644 --- a/lib/sidekiq/logging/json.rb +++ b/lib/sidekiq/logging/json.rb @@ -20,7 +20,7 @@ '@status' => nil, '@severity' => severity, '@run_time' => nil - }.merge(process_message(message)).to_json + "\r\n" + }.merge(process_message(message)).to_json + "\n" end def process_message(message)
Remove carriage returns from log output.
diff --git a/lib/tasks/data_hygiene.rake b/lib/tasks/data_hygiene.rake index abc1234..def5678 100644 --- a/lib/tasks/data_hygiene.rake +++ b/lib/tasks/data_hygiene.rake @@ -23,4 +23,23 @@ call_change_note_remover(args[:content_id], args[:locale], args[:query], dry_run: false) end end + + desc "Check the status of a document whether it's in Content Store or Router." + task :document_status_check, %i[content_id locale] => :environment do |_, args| + document = Document.find_by!(args) + status = DataHygiene::DocumentStatusChecker.new(document) + + content_store = status.content_store? + router = status.router? + + puts "Has the document made it to:" + puts "Content Store? #{content_store ? 'Yes' : 'No'}" + puts "Router? #{router ? 'Yes' : 'No'}" + + unless content_store && router + puts "" + puts "You could try running:" + puts "rake 'represent_downstream:content_id[#{args[:content_id]}]'" + end + end end
Add a document status check Rake task
diff --git a/models/walkmydog/profile.rb b/models/walkmydog/profile.rb index abc1234..def5678 100644 --- a/models/walkmydog/profile.rb +++ b/models/walkmydog/profile.rb @@ -4,7 +4,7 @@ property :id, Serial property :firstname, Text, required: true property :lastname, Text, required: true - property :email, Text, required: true, key: true + property :email, String, required: true, length: 255, key: true property :password_hash, Text, required: true property :cell_phone_number, Text, required: true property :street_address, Text, required: true
Change email to be a String
diff --git a/Library/Contributions/cmd/brew-tap-readme.rb b/Library/Contributions/cmd/brew-tap-readme.rb index abc1234..def5678 100644 --- a/Library/Contributions/cmd/brew-tap-readme.rb +++ b/Library/Contributions/cmd/brew-tap-readme.rb @@ -0,0 +1,32 @@+name = ARGV.first + +raise "A name is required" if name.nil? + +template = <<-EOS +Homebrew-#{name} +=========#{'=' * name.size} + +How do I install these formulae? +-------------------------------- +Just `brew tap homebrew/#{name}` and then `brew install <formula>`. + +If the formula conflicts with one from mxcl/master or another tap, you can `brew install homebrew/#{name}/<formula>`. + +You can also install via URL: + +``` +brew install https://raw.github.com/Homebrew/homebrew-#{name}/master/<formula>.rb +``` + +Docs +---- +`brew help`, `man brew`, or the Homebrew [wiki][]. + +[wiki]:http://wiki.github.com/mxcl/homebrew +EOS + +# puts ERB.new(template, nil, '>').result(binding) +puts template if ARGV.verbose? +path = Pathname.new('./README.md') +raise "#{path} already exists" if path.exist? +path.write template
Add `brew tap-readme <name>` external command. Closes #17935.
diff --git a/app.rb b/app.rb index abc1234..def5678 100644 --- a/app.rb +++ b/app.rb @@ -25,6 +25,11 @@ send_file File.join('app/views/flood-locations-map.html') end +# For old links +get '/flood_locations' do + send_file File.join('app/views/flood-locations-map.html') +end + get '/campaigns' do send_file File.join('app/views/campaigns.html') end
Add flood_locations route for old shared links
diff --git a/cramp.gemspec b/cramp.gemspec index abc1234..def5678 100644 --- a/cramp.gemspec +++ b/cramp.gemspec @@ -11,9 +11,9 @@ s.email = "pratiknaik@gmail.com" s.homepage = "http://m.onkey.org" - s.add_dependency('activesupport', '= 3.0.pre') - s.add_dependency('activemodel', '= 3.0.pre') - s.add_dependency('arel', '= 0.2.pre') + s.add_dependency('activesupport', '= 3.0.beta') + s.add_dependency('activemodel', '= 3.0.beta') + s.add_dependency('arel', '= 0.2.1') s.add_dependency('rack', '~> 1.1.0') s.add_dependency('mysqlplus', '~> 0.1.1') s.add_dependency('eventmachine', '~> 0.12.10')
Change to beta versions of activesupport, activemodel & arel dependenices.
diff --git a/actiontext/app/helpers/action_text/content_helper.rb b/actiontext/app/helpers/action_text/content_helper.rb index abc1234..def5678 100644 --- a/actiontext/app/helpers/action_text/content_helper.rb +++ b/actiontext/app/helpers/action_text/content_helper.rb @@ -4,20 +4,27 @@ module ActionText module ContentHelper - SANITIZER = Rails::Html::Sanitizer.white_list_sanitizer - ALLOWED_TAGS = SANITIZER.allowed_tags + [ ActionText::Attachment::TAG_NAME, "figure", "figcaption" ] - ALLOWED_ATTRIBUTES = SANITIZER.allowed_attributes + ActionText::Attachment::ATTRIBUTES + mattr_accessor(:sanitizer) { Rails::Html::Sanitizer.white_list_sanitizer.new } + mattr_accessor(:allowed_tags) { sanitizer.class.allowed_tags + [ ActionText::Attachment::TAG_NAME, "figure", "figcaption" ] } + mattr_accessor(:allowed_attributes) { sanitizer.class.allowed_attributes + ActionText::Attachment::ATTRIBUTES } + mattr_accessor(:scrubber) def render_action_text_content(content) - content = content.render_attachments do |attachment| + sanitize_action_text_content(render_action_text_attachments(content)) + end + + def sanitize_action_text_content(content) + sanitizer.sanitize(content.to_html, tags: allowed_tags, attributes: allowed_attributes, scrubber: scrubber).html_safe + end + + def render_action_text_attachments(content) + content.render_attachments do |attachment| unless attachment.in?(content.gallery_attachments) attachment.node.tap do |node| node.inner_html = render(attachment, in_gallery: false).chomp end end - end - - content = content.render_attachment_galleries do |attachment_gallery| + end.render_attachment_galleries do |attachment_gallery| render(layout: attachment_gallery, object: attachment_gallery) do attachment_gallery.attachments.map do |attachment| attachment.node.inner_html = render(attachment, in_gallery: true).chomp @@ -25,8 +32,6 @@ end.join("").html_safe end.chomp end - - sanitize content.to_html, tags: ALLOWED_TAGS, attributes: ALLOWED_ATTRIBUTES end end end
Make Action Text's rendering helpers more configurable - Allow configuring the sanitizer and its options - Split attachment rendering and sanitizing helpers so each can be overridden by applications
diff --git a/wright.gemspec b/wright.gemspec index abc1234..def5678 100644 --- a/wright.gemspec +++ b/wright.gemspec @@ -20,5 +20,6 @@ gem.add_development_dependency 'rake', '~> 10.2.2' gem.add_development_dependency 'rdoc', '~> 4.1.1' gem.add_development_dependency 'simplecov', '~> 0.7.1' + gem.add_development_dependency 'pry' gem.add_development_dependency 'rubocop' end
Add pry as a development dependency
diff --git a/spec/support/authentication_helper.rb b/spec/support/authentication_helper.rb index abc1234..def5678 100644 --- a/spec/support/authentication_helper.rb +++ b/spec/support/authentication_helper.rb @@ -6,26 +6,33 @@ ActionController::Parameters.new(user: args) end - def get_as(user, action, params = nil, flash = nil) - session_vars = { 'uid' => user.id, 'timeout' => 3.days.from_now } - xhr :get, action, params, session_vars, flash + def sign_in(user) + real_controller = @controller + @controller = MainController.new + post :login, params: { user_login: user.user_name, user_password: 'x' } + @controller = real_controller + end + + def get_as(user, action, params = nil) + sign_in user + get action, xhr: true, params: params end # Performs POST request as the supplied user for authentication - def post_as(user, action, params = nil, flash = nil) - session_vars = { 'uid' => user.id, 'timeout' => 3.days.from_now } - xhr :post, action, params, session_vars, flash + def post_as(user, action, params = nil) + sign_in user + post action, xhr: true, params: params end # Performs PUT request as the supplied user for authentication - def put_as(user, action, params = nil, flash = nil) - session_vars = { 'uid' => user.id, 'timeout' => 3.days.from_now } - xhr :put, action, params, session_vars, flash + def put_as(user, action, params = nil) + sign_in user + put action, xhr: true, params: params end # Performs DELETE request as the supplied user for authentication - def delete_as(user, action, params = nil, flash = nil) - session_vars = { 'uid' => user.id, 'timeout' => 3.days.from_now } - xhr :delete, action, params, session_vars, flash + def delete_as(user, action, params = nil) + sign_in user + delete action, xhr: true, params: params end end
rails5: Migrate xhr helper functions in rspec tests
diff --git a/app/controllers/api/discovery_entities_controller.rb b/app/controllers/api/discovery_entities_controller.rb index abc1234..def5678 100644 --- a/app/controllers/api/discovery_entities_controller.rb +++ b/app/controllers/api/discovery_entities_controller.rb @@ -10,18 +10,38 @@ private + SP_EAGER_FETCH = { + entity_id: {}, + sp_sso_descriptors: { + ui_info: %i(logos descriptions display_names information_urls + privacy_statement_urls), + discovery_response_services: [], + tags: [] + } + } + + IDP_EAGER_FETCH = { + entity_id: {}, + idp_sso_descriptors: { + ui_info: %i(logos descriptions display_names), + disco_hints: %i(geolocation_hints domain_hints), + tags: [] + } + } + def service_providers entities_with_role_descriptor(:sp_sso_descriptors) + .eager(SP_EAGER_FETCH).all end def identity_providers entities_with_role_descriptor(:idp_sso_descriptors) + .eager(IDP_EAGER_FETCH).all end def entities_with_role_descriptor(table) - EntityDescriptor.dataset.qualify.distinct(:id) + EntityDescriptor.qualify.distinct(:id) .join(table, entity_descriptor_id: :id) - .to_a end end end
Optimize queries to resolve SELECT N+1 problem
diff --git a/app/controllers/heartbeat_rails/health_controller.rb b/app/controllers/heartbeat_rails/health_controller.rb index abc1234..def5678 100644 --- a/app/controllers/heartbeat_rails/health_controller.rb +++ b/app/controllers/heartbeat_rails/health_controller.rb @@ -20,7 +20,7 @@ def send_response(status_msg, meta_info = {}) write_headers(meta_info) - render :text => status_msg.to_s, :status => status_msg, :content_type => Mime::TEXT + render plain: status_msg.to_s, status: status_msg end def write_headers(values = {})
Make engine working with rails 5.1
diff --git a/akane.gemspec b/akane.gemspec index abc1234..def5678 100644 --- a/akane.gemspec +++ b/akane.gemspec @@ -20,6 +20,8 @@ spec.add_dependency "tweetstream", "~> 2.6.0" spec.add_dependency "elasticsearch", "~> 0.4.1" + spec.add_dependency "twitter", "~> 5.5.1" + spec.add_dependency "oauth", ">= 0.4.7" spec.add_development_dependency "bundler" spec.add_development_dependency "rake"
Add oauth and twitter gem
diff --git a/rails.gemspec b/rails.gemspec index abc1234..def5678 100644 --- a/rails.gemspec +++ b/rails.gemspec @@ -25,5 +25,5 @@ s.add_dependency('activeresource', version) s.add_dependency('actionmailer', version) s.add_dependency('railties', version) - s.add_dependency('bundler', '~> 1.0.3') + s.add_dependency('bundler', '~> 1.0') end
Allow bundler 1.1 (and 1.2, etc.) in Rails 1.0.2 and above
diff --git a/oembed.gemspec b/oembed.gemspec index abc1234..def5678 100644 --- a/oembed.gemspec +++ b/oembed.gemspec @@ -7,6 +7,7 @@ gem.description = %q{A slim library to work with oEmbed format.} gem.summary = %q{A slim library to work with oEmbed format.} gem.homepage = "http://soulim.github.com/oembed" + gem.license = 'MIT' gem.files = `git ls-files`.split($\) gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
Add license description to gemspec
diff --git a/flipper-ui.gemspec b/flipper-ui.gemspec index abc1234..def5678 100644 --- a/flipper-ui.gemspec +++ b/flipper-ui.gemspec @@ -21,7 +21,7 @@ gem.metadata = Flipper::METADATA gem.add_dependency 'rack', '>= 1.4', '< 3' - gem.add_dependency 'rack-protection', '>= 1.5.3', '<= 2.3.0' + gem.add_dependency 'rack-protection', '>= 1.5.3', '<= 4.0.0' gem.add_dependency 'flipper', "~> #{Flipper::VERSION}" gem.add_dependency 'erubi', '>= 1.0.0', '< 2.0.0' gem.add_dependency 'sanitize', '< 7'
Update rack protection to < 4 3 is out and it works fine.
diff --git a/spec/lib/resume_spec.rb b/spec/lib/resume_spec.rb index abc1234..def5678 100644 --- a/spec/lib/resume_spec.rb +++ b/spec/lib/resume_spec.rb @@ -12,14 +12,6 @@ expect(constant_defined).to be true end end - - context 'for DATA_LOCATION' do - let(:const) { :DATA_LOCATION } - - it 'is present' do - expect(constant_defined).to be true - end - end end describe '.generate' do
Remove spec for DATA_LOCATION const
diff --git a/decent_exposure.gemspec b/decent_exposure.gemspec index abc1234..def5678 100644 --- a/decent_exposure.gemspec +++ b/decent_exposure.gemspec @@ -3,7 +3,7 @@ Gem::Specification.new do |spec| spec.name = "decent_exposure" spec.version = DecentExposure::VERSION - spec.authors = ["Pavel Pravosud"] + spec.authors = ["Pavel Pravosud", "Stephen Caudill"] spec.email = ["info@hashrocket.com"] spec.summary = "A helper for creating declarative interfaces in controllers" spec.description = %q{
Add Stephen Caudill back to authors list
diff --git a/generative.gemspec b/generative.gemspec index abc1234..def5678 100644 --- a/generative.gemspec +++ b/generative.gemspec @@ -20,7 +20,6 @@ gem.files = `git ls-files`.split($/) gem.executables = gem.files.grep(%r{^bin/}).map { |file| File.basename file } - gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) gem.require_paths = ["lib"] gem.add_dependency 'rspec', '>= 3.0'
Drop unused test_files directive from gemspec The test_files directive is not used for anything in RubyGems.org any longer.
diff --git a/app/controllers/robots_controller.rb b/app/controllers/robots_controller.rb index abc1234..def5678 100644 --- a/app/controllers/robots_controller.rb +++ b/app/controllers/robots_controller.rb @@ -1,10 +1,13 @@ class RobotsController < ApplicationController + + DEFAULT_FILENAME = 'config/robots.txt'.freeze + def robots filename = if subdomain && subdomain != 'www' "config/robots.#{ subdomain }.txt" end - file_to_render = File.exists?(filename.to_s) ? filename : 'config/robots.txt' + file_to_render = File.exists?(filename.to_s) ? filename : DEFAULT_FILENAME render file: file_to_render, layout: false, content_type: 'text/plain' end
Use a constant for the default robots.txt filename
diff --git a/app/controllers/skills_controller.rb b/app/controllers/skills_controller.rb index abc1234..def5678 100644 --- a/app/controllers/skills_controller.rb +++ b/app/controllers/skills_controller.rb @@ -7,7 +7,7 @@ end def create - skill = User.first.skills.build(skills_params) + skill = current_user.skills.build(skills_params) if skill.save respond_to do |format| format.html {redirect_to skill_path(skill)}
Replace temporary user solution with current_user helper
diff --git a/app/controllers/orders_controller_decorator.rb b/app/controllers/orders_controller_decorator.rb index abc1234..def5678 100644 --- a/app/controllers/orders_controller_decorator.rb +++ b/app/controllers/orders_controller_decorator.rb @@ -2,5 +2,7 @@ def thank_you @order = Order.find_by_number(params[:id]) @current_order=nil + session[:order_id] = nil + end end
Clear the order id in the session when thank you shown
diff --git a/app/controllers/target_dashboard_controller.rb b/app/controllers/target_dashboard_controller.rb index abc1234..def5678 100644 --- a/app/controllers/target_dashboard_controller.rb +++ b/app/controllers/target_dashboard_controller.rb @@ -4,7 +4,7 @@ countries = Country.paginate(per_page: CountrySerializer::PER_PAGE, page: 1) @countries = CountrySerializer.new({}, countries).serialize @targets = Aichi11TargetSerializer.new.serialize - @global_stats = Aichi11Target.get_global_stats.to_json + @global_stats = Aichi11Target.get_global_stats end def load
Remove the to_json where it is not needed
diff --git a/app/classes/query/name_description_by_editor.rb b/app/classes/query/name_description_by_editor.rb index abc1234..def5678 100644 --- a/app/classes/query/name_description_by_editor.rb +++ b/app/classes/query/name_description_by_editor.rb @@ -0,0 +1,21 @@+class Query::NameDescriptionByEditor < Query::NameDescription + def parameter_declarations + super.merge( + user: User + ) + end + + def initialize_flavor + user = find_cached_parameter_instance(User, :user) + title_args[:user] = user.legal_name + + glue_table = "name_decriptions_editors".to_sym + add_join(glue_table) + self.where << "#{glue_table}.user_id = '#{params[:user]}'" + super + end + + def default_order + "name" + end +end
Fix accidentally overwritten file & add some NameDescription subqueries I overwrote: name_description_by_edittor with name_with_descriptions_by_editor
diff --git a/app/models/data_model/interaction_claim_type.rb b/app/models/data_model/interaction_claim_type.rb index abc1234..def5678 100644 --- a/app/models/data_model/interaction_claim_type.rb +++ b/app/models/data_model/interaction_claim_type.rb @@ -5,6 +5,8 @@ include Genome::Extensions::HasCacheableQuery has_and_belongs_to_many :interaction_claims, :join_table => 'interaction_claim_types_interaction_claims' + has_and_belongs_to_many :interactions, + :join_table => "interaction_types_interactions" cache_query :all_type_names, :all_interaction_type_names
Add has_and_belongs_to_many relationship to interactions from interaction claims
diff --git a/test/test_helper.rb b/test/test_helper.rb index abc1234..def5678 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -2,6 +2,7 @@ require File.expand_path('../dummy/config/environment.rb', __FILE__) require 'rails/test_help' +require 'minitest/pride' Minitest.backtrace_filter = Minitest::BacktraceFilter.new ActiveSupport::TestCase.fixture_path = File.expand_path('../fixtures', __FILE__)
Add MiniTest Pride coloured output
diff --git a/test/test_helper.rb b/test/test_helper.rb index abc1234..def5678 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -8,10 +8,7 @@ require 'serialize_with_options' require File.dirname(__FILE__) + "/../init" -ActiveRecord::Base.establish_connection( - :adapter => 'sqlite3', - :database => 'test.db' -) +ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:') [:users, :posts, :comments, :check_ins, :reviews].each do |table| ActiveRecord::Base.connection.drop_table table rescue nil
Use in-memory SQLite DB for tests * Big ups to Rob Ares (http://github.com/rares)
diff --git a/app/services/url_domain_formatter.rb b/app/services/url_domain_formatter.rb index abc1234..def5678 100644 --- a/app/services/url_domain_formatter.rb +++ b/app/services/url_domain_formatter.rb @@ -3,8 +3,6 @@ if !URI.parse(domain).host domain.prepend("http://") end - # remove file path - domain = URI.join(domain, "/").to_s domain end
Remove urldomainformatter code that removed file path.
diff --git a/lib/brillo/adapter/postgres.rb b/lib/brillo/adapter/postgres.rb index abc1234..def5678 100644 --- a/lib/brillo/adapter/postgres.rb +++ b/lib/brillo/adapter/postgres.rb @@ -4,7 +4,9 @@ def load_command host = config["host"] ? "--host #{config["host"]}" : "" password = config["password"] ? "PGPASSWORD=#{config["password"]} " : "" - "#{password}psql #{host} -U #{config.fetch("username")} #{config.fetch("database")}" + search_path = config["schema_search_path"] ? "PGOPTIONS=--search_path=#{config["schema_search_path"]} " : "" + inline_options = password + search_path + "#{inline_options}psql #{host} -U #{config.fetch("username")} #{config.fetch("database")}" end # pgdump without schema does not set sequences, so we have to do it ourselves, or the first insert
Make sure to set schema search path that is present on database.yml
diff --git a/lib/fluent/plugin/out_split.rb b/lib/fluent/plugin/out_split.rb index abc1234..def5678 100644 --- a/lib/fluent/plugin/out_split.rb +++ b/lib/fluent/plugin/out_split.rb @@ -6,6 +6,10 @@ # Define `router` method of v0.12 to support v0.10 or earlier unless method_defined?(:router) define_method("router") { Fluent::Engine } + end + + unless method_defined?(:log) + define_method(:log) { $log } end def initialize @@ -45,8 +49,8 @@ end chain.next rescue => e - $log.warn e.message - $log.warn e.backtrace.join(', ') + log.warn e.message + log.warn e.backtrace.join(', ') end end end
Support plugin specific log level
diff --git a/lib/generators/seed_scatter.rb b/lib/generators/seed_scatter.rb index abc1234..def5678 100644 --- a/lib/generators/seed_scatter.rb +++ b/lib/generators/seed_scatter.rb @@ -0,0 +1,11 @@+require 'rails/generators/named_base' + +module SeedScatter + module Generators + class Base < Rails::Generators::NamedBase + def self.source_root + File.expand_path(File.join(File.dirname(__FILE__), generator_name, 'templates')) + end + end + end +end
Extend NamedBase generator and change source_root
diff --git a/lib/middleman-title/helpers.rb b/lib/middleman-title/helpers.rb index abc1234..def5678 100644 --- a/lib/middleman-title/helpers.rb +++ b/lib/middleman-title/helpers.rb @@ -13,53 +13,54 @@ end private - def title_options - ::Middleman::TitleExtension.options + + def title_options + ::Middleman::TitleExtension.options + end + + def website_name + current_page.data.title_site || title_options.site + end + + def title_separator + title_options.separator + end + + def title_reverse + if current_page.data.title_reverse.nil? == false + current_page.data.title_reverse + else + title_options.reverse + end + end + + def page_name + page_name = current_page.data.title + + if page_name.is_a? Array + page_name = page_name.join(title_separator) end - def website_name - current_page.data.title_site || title_options.site + page_name + end + + def add_website_name_to_title(title) + if current_page.data.title_site == false || website_name == false + title + elsif website_name_first? + title.unshift(website_name) + else + title << website_name end + end - def title_separator - title_options.separator - end + def add_page_name_to_title(title) + title << page_name + end - def title_reverse - if current_page.data.title_reverse.nil? == false - current_page.data.title_reverse - else - title_options.reverse - end - end - - def page_name - page_name = current_page.data.title - - if page_name.is_a? Array - page_name = page_name.join(title_separator) - end - - page_name - end - - def add_website_name_to_title(title) - if current_page.data.title_site == false || website_name == false - title - elsif website_name_first? - title.unshift(website_name) - else - title << website_name - end - end - - def add_page_name_to_title(title) - title << page_name - end - - def website_name_first? - title_reverse - end + def website_name_first? + title_reverse + end end end
Fix indention of private methods
diff --git a/lib/letter_opener/delivery_method.rb b/lib/letter_opener/delivery_method.rb index abc1234..def5678 100644 --- a/lib/letter_opener/delivery_method.rb +++ b/lib/letter_opener/delivery_method.rb @@ -9,7 +9,7 @@ messages = mail.parts.map { |part| Message.new(location, mail, part) } messages << Message.new(location, mail) if messages.empty? messages.each { |message| message.render } - Launchy.open("file://#{messages.first.filepath}") + Launchy::Browser.run("file://#{messages.first.filepath}") end end end
Change from Launchy.open to Launchy::Browser.run
diff --git a/lib/libis/workflow/tasks/analyzer.rb b/lib/libis/workflow/tasks/analyzer.rb index abc1234..def5678 100644 --- a/lib/libis/workflow/tasks/analyzer.rb +++ b/lib/libis/workflow/tasks/analyzer.rb @@ -8,8 +8,11 @@ class Analyzer < Task - parameter quiet: true - parameter always_run: true + parameter quiet: true, frozen: true + parameter abort_on_error: false, frozen: true + parameter always_run: true, frozen: true + parameter subitems: false, frozen: true + parameter recursive: false, frozen: true def run(item) @@ -30,7 +33,7 @@ end end - rescue Exception => ex + rescue RuntimeError => ex puts 'Failed to analyze item: %s - %s' % [item.class, item.name] puts 'Exception: %s' % ex.message
Use new parameter property: frozen
diff --git a/lib/refinery/elasticsearch/result.rb b/lib/refinery/elasticsearch/result.rb index abc1234..def5678 100644 --- a/lib/refinery/elasticsearch/result.rb +++ b/lib/refinery/elasticsearch/result.rb @@ -16,7 +16,7 @@ end def record - @record ||= klass.find(@result['_id']) rescue nil + @record ||= klass.find(@result['_id'].to_i) rescue nil end # Delegate methods to `@result` or `@result._source`
Use integer id for finding records, because strings will trigger the slug search of friendly_id
diff --git a/lib/travis/hub/support/logs.rb b/lib/travis/hub/support/logs.rb index abc1234..def5678 100644 --- a/lib/travis/hub/support/logs.rb +++ b/lib/travis/hub/support/logs.rb @@ -31,7 +31,7 @@ private def client - @client ||= Faraday.new(url: url) do |c| + @client ||= Faraday.new(http_options.merge(url: url)) do |c| c.request :authorization, :token, token c.request :retry, max: 5, interval: 0.1, backoff_factor: 2 c.response :raise_error @@ -46,6 +46,10 @@ def token config[:token] || raise('Logs token not set.') end + + def http_options + { ssl: Travis.config.ssl.compact.to_h } + end end end end
Include ssl options in Faraday call for self signed certs in Enterprise
diff --git a/lib/web_console/interceptor.rb b/lib/web_console/interceptor.rb index abc1234..def5678 100644 --- a/lib/web_console/interceptor.rb +++ b/lib/web_console/interceptor.rb @@ -1,8 +1,7 @@ module WebConsole module Interceptor - def self.call(request, exception) + def self.call(request, error) backtrace_cleaner = request.get_header("action_dispatch.backtrace_cleaner") - error = ActionDispatch::ExceptionWrapper.new(backtrace_cleaner, exception).exception # Get the original exception if ExceptionWrapper decides to follow it. Thread.current[:__web_console_exception] = error
Remove extra exception wrapper allocation ```ruby ActionDispatch::ExceptionWrapper.new(backtrace_cleaner, exception).exception ``` The above code just returns the original exception object. You can see [in Rails](https://github.com/rails/rails/blob/08ef43ed5e01b42b2aec847a0424515f537ed427/actionpack/lib/action_dispatch/middleware/exception_wrapper.rb#L44-L48) the exception is simply stored in an ivar and then returned with an attr_reader. There shouldn't be any reason to construct this object
diff --git a/app/controllers/api/v1/exports_controller.rb b/app/controllers/api/v1/exports_controller.rb index abc1234..def5678 100644 --- a/app/controllers/api/v1/exports_controller.rb +++ b/app/controllers/api/v1/exports_controller.rb @@ -2,7 +2,7 @@ format 'json' def show - datasets = Dataset.where(id: params[:id].split(',')) + datasets = Dataset.where(geo_id: params[:id].split(',')) json = datasets.map do |dataset| dataset.editable_attributes.as_json.merge(
Change dataset export to geo_id instead of id
diff --git a/recipes/ppa.rb b/recipes/ppa.rb index abc1234..def5678 100644 --- a/recipes/ppa.rb +++ b/recipes/ppa.rb @@ -4,6 +4,7 @@ components ['main'] keyserver 'keyserver.ubuntu.com' key 'E1DF1F24' + notifies :run, 'execute[apt-get update]', :immediately end package "git"
Make sure apt-get updates after new apt repository
diff --git a/lib/generators/active_record/templates/migration.rb b/lib/generators/active_record/templates/migration.rb index abc1234..def5678 100644 --- a/lib/generators/active_record/templates/migration.rb +++ b/lib/generators/active_record/templates/migration.rb @@ -3,6 +3,7 @@ change_table :<%= table_name %> do |t| t.string :authy_id t.datetime :last_sign_in_with_authy + t.boolean :authy_enabled, :default => false end add_index :<%= table_name %>, :authy_id @@ -10,7 +11,8 @@ def self.down change_table :<%= table_name %> do |t| - t.remove :authy_id, :last_sign_in_with_authy + t.remove :authy_id, :last_sign_in_with_authy, :authy_enabled end end end +
Add an attribute to track whether authy is enabled or not.
diff --git a/lib/rspec_api_documentation/writers/slate_writer.rb b/lib/rspec_api_documentation/writers/slate_writer.rb index abc1234..def5678 100644 --- a/lib/rspec_api_documentation/writers/slate_writer.rb +++ b/lib/rspec_api_documentation/writers/slate_writer.rb @@ -25,6 +25,7 @@ file.write %Q{title: "#{configuration.api_name}"\n} file.write %Q{language_tabs:\n} file.write %Q{ - json: JSON\n} + file.write %Q{ - shell: cURL\n} file.write %Q{---\n\n} IndexHelper.sections(index.examples, @configuration).each do |section|
Make SlateWriter output cURL cmd in separate tab
diff --git a/license_finder_upgrade.gemspec b/license_finder_upgrade.gemspec index abc1234..def5678 100644 --- a/license_finder_upgrade.gemspec +++ b/license_finder_upgrade.gemspec @@ -12,7 +12,7 @@ spec.authors = ["Jacob Maine"] spec.email = [""] - spec.homepage = "" + spec.homepage = "https://github.com/mainej/license_finder_upgrade" spec.summary = %q{Upgrade helper for license_finder} spec.description = %q{This tool helps upgrade license_finder projects from version 1.2 to 2.0.}
Use github as project homepage
diff --git a/Library/Contributions/cmd/brew-which.rb b/Library/Contributions/cmd/brew-which.rb index abc1234..def5678 100644 --- a/Library/Contributions/cmd/brew-which.rb +++ b/Library/Contributions/cmd/brew-which.rb @@ -8,13 +8,9 @@ real_cellar = HOMEBREW_CELLAR.realpath - paths=%w[bin sbin lib].collect {|d| HOMEBREW_PREFIX+d} - - paths.each do |path| - path.find do |path| - next unless path.symlink? && path.resolved_path_exists? - brew_links << Pathname.new(path.realpath) - end + (HOMEBREW_PREFIX/'opt').subdirs.each do |path| + next unless path.symlink? && path.resolved_path_exists? + brew_links << Pathname.new(path.realpath) end brew_links = brew_links.collect{|p|p.relative_path_from(real_cellar).to_s}.reject{|p|p.start_with?("../")}
Use HOMEBREW_PREFIX/opt to find installs instead of symlinks in bin, lib, sbin. Closes #25868. Signed-off-by: Adam Vandenberg <34c2b6407fd5a10249a15d699d40f9ed1782e98c@gmail.com>
diff --git a/cookbooks/geoserver/recipes/_setup_glassfish.rb b/cookbooks/geoserver/recipes/_setup_glassfish.rb index abc1234..def5678 100644 --- a/cookbooks/geoserver/recipes/_setup_glassfish.rb +++ b/cookbooks/geoserver/recipes/_setup_glassfish.rb @@ -14,6 +14,6 @@ domain = node['geoserver']['glassfish']['domain'] -node.override['glassfish']['domains'][domain]['config']['jvm_options'] = %w(-DGEOSERVER_DATA_DIR=#{node['geoserver']['data_dir']}) +node.override['glassfish']['domains'][domain]['config']['jvm_options'] = %W(-DGEOSERVER_DATA_DIR=#{node['geoserver']['data_dir']}) node.override['glassfish']['domains'][domain]['deployables']['geoserver']['url'] = "file://#{node['geoserver']['base_dir']}/geoserver.war" node.override['glassfish']['domains'][domain]['deployables']['geoserver']['context_root'] = node['geoserver']['glassfish']['root']
Use %W rather than %w literal as required interpolation
diff --git a/db/migrate/20151112160945_create_friendships.rb b/db/migrate/20151112160945_create_friendships.rb index abc1234..def5678 100644 --- a/db/migrate/20151112160945_create_friendships.rb +++ b/db/migrate/20151112160945_create_friendships.rb @@ -2,7 +2,7 @@ def change create_table :friendships do |t| t.references :user, index: true, foreign_key: true - t.references :friend, class: 'User', index: true, foreign_key: true + t.integer :friend_id, class: 'User', index: true, foreign_key: true t.timestamps null: false end
Change friendships migration for Heroku pg.
diff --git a/lib/dropcaster/contributors.rb b/lib/dropcaster/contributors.rb index abc1234..def5678 100644 --- a/lib/dropcaster/contributors.rb +++ b/lib/dropcaster/contributors.rb @@ -23,10 +23,11 @@ # rubocop:disable Lint/RescueWithoutErrorClass def contributor_link(contributor) - "[#{@octokit.user(contributor.login).name}](#{contributor.html_url})" - rescue => e - warn "Error: Could not link to contributor. #{e}" - contributor.tr('[]', '()') + if contributor.type == 'Anonymous' + contributor.name.tr('[]', '()') + else + "[#{@octokit.user(contributor.login).name}](#{contributor.html_url})" + end end end end
Replace exception handler with check for anonymous contributor
diff --git a/lib/fakeredis/expiring_hash.rb b/lib/fakeredis/expiring_hash.rb index abc1234..def5678 100644 --- a/lib/fakeredis/expiring_hash.rb +++ b/lib/fakeredis/expiring_hash.rb @@ -34,7 +34,7 @@ def expired?(key) key = normalize key - expires.include?(key) && expires[key] < Time.now + expires.include?(key) && expires[key] <= Time.now end def key?(key)
Update expiry conditional to be inclusive
diff --git a/lib/nationbuilder/paginator.rb b/lib/nationbuilder/paginator.rb index abc1234..def5678 100644 --- a/lib/nationbuilder/paginator.rb +++ b/lib/nationbuilder/paginator.rb @@ -14,7 +14,7 @@ define_method(:"#{page_type}") do |call_body = {}| return nil unless send(:"#{page_type}?") path = send(:"#{page_type}?").split('/api/v1').last - call_body[:limit] ||= CGI.parse(path)['limit'] + call_body[:limit] ||= CGI.parse(path)['limit'][0] results = @client.raw_call(path, :get, call_body) return self.class.new(@client, results) end
Fix pagination bug where the limit parsed to an array value When that's given, the (new) QueryParser that is used for `get` requests would pass this through as `limit[] => n` instead of `limit => n`. Introduced in https://github.com/nationbuilder/nationbuilder-rb/pull/45/commits/25f80a0f15edf0e86cda2abce55bd0e4fd97f0dd
diff --git a/lib/omniauth/strategies/pam.rb b/lib/omniauth/strategies/pam.rb index abc1234..def5678 100644 --- a/lib/omniauth/strategies/pam.rb +++ b/lib/omniauth/strategies/pam.rb @@ -17,7 +17,10 @@ end def callback_phase - unless Rpam.auth(request['username'], request['password']) + rpam_opts = Hash.new + rpam_opts['service'] = options['service'] unless options['service'].nil? + + unless Rpam.auth(request['username'], request['password'], rpam_opts) return fail!(:invalid_credentials) end @@ -27,6 +30,15 @@ uid do request['username'] end + + info do + { + :nickname => uid, + :name => uid + } + end end end end + +OmniAuth.config.add_camelization 'pam', 'PAM'
Add missing omniauth interface requirements
diff --git a/lib/rdl/types/annotated_arg.rb b/lib/rdl/types/annotated_arg.rb index abc1234..def5678 100644 --- a/lib/rdl/types/annotated_arg.rb +++ b/lib/rdl/types/annotated_arg.rb @@ -15,7 +15,7 @@ end def to_s - "#{@type.to_s} \"#{@name}\"" + "#{@type.to_s} #{@name}" end def eql?(other)
Fix printing of annotated args
diff --git a/lib/tasks/holdings_update.rake b/lib/tasks/holdings_update.rake index abc1234..def5678 100644 --- a/lib/tasks/holdings_update.rake +++ b/lib/tasks/holdings_update.rake @@ -0,0 +1,29 @@+require 'csv' + +namespace :holdings do + desc '[Temporary Task] Update prices of all holdings' + task :update => :environment do + stocks = [] + Holding.select(:asset, :asset_name).group(:asset, :asset_name).each do |h| + if h.asset == Transaction::ASSET['stock'] + stocks << h.asset_name.upcase.strip + '.SA' + end + end + + args = { + 's' => stocks.join(' '), + 'f' => 'sl1' + } + url = "?s=HYPE3.SA+BVMF3.SA&f=sl1" + agent = Mechanize.new + agent.get('http://finance.yahoo.com/d/quotes.csv', args) + CSV.parse(agent.page.body).each do |row| + symbol, price = row + symbol = symbol.gsub(/\.SA\Z/, '') + Holding.where(asset: Transaction::ASSET['stock']) + .where(asset_name: symbol) + .update_all(current_price: BigDecimal.new(price)) + end + agent.shutdown + end +end
Add rake task to update stock prices