diff
stringlengths
65
26.7k
message
stringlengths
7
9.92k
diff --git a/Treasure.podspec b/Treasure.podspec index abc1234..def5678 100644 --- a/Treasure.podspec +++ b/Treasure.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Treasure' - s.version = '0.1.3' + s.version = '0.1.4' s.summary = 'A small set of tools for deserializing JSON API objects.' s.description = <<-DESC
Increase version number to 0.1.4
diff --git a/core/lib/spree/permission_sets/product_management.rb b/core/lib/spree/permission_sets/product_management.rb index abc1234..def5678 100644 --- a/core/lib/spree/permission_sets/product_management.rb +++ b/core/lib/spree/permission_sets/product_management.rb @@ -9,7 +9,6 @@ can :manage, Spree::ProductProperty can :manage, Spree::OptionType can :manage, Spree::Property - can :manage, Spree::Prototype can :manage, Spree::Taxonomy can :manage, Spree::Taxon can :manage, Spree::Classification
Remove prototype from product management permission set
diff --git a/db/migrate/20111105052819_add_fields_to_privilege.rb b/db/migrate/20111105052819_add_fields_to_privilege.rb index abc1234..def5678 100644 --- a/db/migrate/20111105052819_add_fields_to_privilege.rb +++ b/db/migrate/20111105052819_add_fields_to_privilege.rb @@ -1,9 +1,35 @@ class AddFieldsToPrivilege < ActiveRecord::Migration def self.up add_column :privileges, :description, :text + create_defaults end def self.down remove_column :privileges, :description end + + def self.create_defaults + Privilege.reset_column_information + Privilege.create :name => 'ExaminationControl' , :description => 'Examination Control' + Privilege.create :name => 'EnterResults' , :description => 'Enter Results' + Privilege.create :name => 'ViewResults' , :description => 'View Results' + Privilege.create :name => 'Admission' , :description => 'Admission' + Privilege.create :name => 'StudentsControl' , :description => 'Students Control' + Privilege.create :name => 'ManageNews' , :description => 'Manage News' + Privilege.create :name => 'ManageTimetable' , :description => 'Manage Timetable' + Privilege.create :name => 'StudentAttendanceView' , :description => 'Student Attendance View' + Privilege.create :name => 'HrBasics' , :description => 'Hr Basics' + Privilege.create :name => 'AddNewBatch' , :description => 'Add New Batch' + Privilege.create :name => 'SubjectMaster' , :description => 'Subject Master' + Privilege.create :name => 'EventManagement' , :description => 'Event Management' + Privilege.create :name => 'GeneralSettings' , :description => 'General Settings' + Privilege.create :name => 'FinanceControl' , :description => 'Finance Control' + Privilege.create :name => 'TimetableView' , :description => 'Timetable View' + Privilege.create :name => 'StudentAttendanceRegister' , :description => 'Student Attendance Register' + Privilege.create :name => 'EmployeeAttendance' , :description => 'Employee Attendance' + Privilege.create :name => 'PayslipPowers' , :description => 'Payslip Powers' + Privilege.create :name => 'EmployeeSearch' , :description => 'Employee Search' + Privilege.create :name => 'SMSManagement' , :description => 'Sms Management' + end + end
Move create defaults for privillege into migration git-svn-id: 6fb0b63dee43263dbd2534f09c80ea129ca0b2b4@2354 1b8ff446-76f8-11e0-a33c-ba5893e5f458
diff --git a/db/migrations/012_change_serialize_column_to_json.rb b/db/migrations/012_change_serialize_column_to_json.rb index abc1234..def5678 100644 --- a/db/migrations/012_change_serialize_column_to_json.rb +++ b/db/migrations/012_change_serialize_column_to_json.rb @@ -0,0 +1,13 @@+require 'oj' +require 'common' +::Sequel.migration do + up do + # Change all serialized column initial Marshalled to JSON. + self[:orders].each do |row| + [:state, :parameters].each do |column| + row[column].andtap { |value| row[column] = Oj.dump(Marshal.load(value)) } + end + self[:orders].filter(:id => row.delete(:id)).update(row) + end + end +end
Migration: Change serialized column from Marshal to JSON.
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 @@ -3,3 +3,12 @@ require 'vagrant-list' +puts <<-WARNING +WARNING: Because there is currently no support for mocking or stubbing +out calls to VirtualBox, it is required that there be at least +one running VM called 'Test' loaded into VirtualBox in order +for these tests to pass. + WARNING + + +
Add warning message about requiring having a test vm running
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 +1,7 @@ require 'neo-tmdb' + +api_key = ENV["TMDB_API_KEY"] or raise "You must set the TMDB_API_KEY environment variable to run these tests." + +TMDb.configure do |config| + config.api_key = api_key +end
Add API key loading from environment for rspec Ultimately we'll use something like vcr so that anyone can re-run these tests without having an API key, although why anyone would want to develop this library without an API key is beyond me.
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,4 +1,5 @@ require 'spec' +require 'spec/autorun' $LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
Make it easier to run specs
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 @@ -23,24 +23,3 @@ PuppetlabsSpec::Files.cleanup end end - -require 'pathname' -dir = Pathname.new(__FILE__).parent -Puppet[:modulepath] = File.join(dir, 'fixtures', 'modules') - -# There's no real need to make this version dependent, but it helps find -# regressions in Puppet -# -# 1. Workaround for issue #16277 where default settings aren't initialised from -# a spec and so the libdir is never initialised (3.0.x) -# 2. Workaround for 2.7.20 that now only loads types for the current node -# environment (#13858) so Puppet[:modulepath] seems to get ignored -# 3. Workaround for 3.5 where context hasn't been configured yet, -# ticket https://tickets.puppetlabs.com/browse/MODULES-823 -# -ver = Gem::Version.new(Puppet.version.split('-').first) -if Gem::Requirement.new("~> 2.7.20") =~ ver || Gem::Requirement.new("~> 3.0.0") =~ ver || Gem::Requirement.new("~> 3.5") =~ ver - puts "augeasproviders: setting Puppet[:libdir] to work around broken type autoloading" - # libdir is only a single dir, so it can only workaround loading of one external module - Puppet[:libdir] = "#{Puppet[:modulepath]}/augeasproviders_core/lib" -end
Use modulesync to manage meta files
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,8 @@+ENV['CODECLIMATE_REPO_TOKEN'] = "30676ff831772153d0238cd5ccbab7b8044a17d57c2878b07aa04904e7246328" +require "codeclimate-test-reporter" +CodeClimate::TestReporter.start + require "piu_piu" -require "codeclimate-test-reporter" - -CodeClimate::TestReporter.start RSpec.configure do |config| # Use color in STDOUT
Move Code Climate instance to the very first line.
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 @@ -41,7 +41,7 @@ end def parse(string) - Parser::CurrentRuby.parse(string) + Unparser::Preprocessor.run(Parser::CurrentRuby.parse(string)) end end
Normalize ASTs before mutating spec examples * Reduces smantically unneded empty begin nodes etc. * Allows to sharp specs.
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,3 +1,5 @@+# frozen_string_literal: true + if ENV['COVERAGE'] || ENV['TRAVIS'] require 'simplecov' require 'coveralls' @@ -14,21 +16,14 @@ end require 'bundler/setup' -require 'rspec-benchmark' +require 'rspec/benchmark' RSpec.configure do |config| config.include(RSpec::Benchmark::Matchers) - config.expect_with :rspec do |expectations| - expectations.include_chain_clauses_in_custom_matcher_descriptions = true + config.expect_with :rspec do |c| + c.syntax = :expect end - - config.mock_with :rspec do |mocks| - mocks.verify_partial_doubles = true - end - - config.filter_run :focus - config.run_all_when_everything_filtered = true config.disable_monkey_patching! @@ -39,8 +34,4 @@ end config.profile_examples = 2 - - config.order = :random - - Kernel.srand config.seed end
Change to remove unnecessary options
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,15 @@ # encoding: utf-8 + +require 'devtools/spec_helper' if ENV['COVERAGE'] == 'true' require 'simplecov' + require 'coveralls' + + SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ + SimpleCov::Formatter::HTMLFormatter, + Coveralls::SimpleCov::Formatter + ] SimpleCov.start do command_name 'spec:unit' @@ -12,8 +20,6 @@ end require 'abstract_type' -require 'rspec' -require 'rspec/autorun' if RUBY_VERSION < '1.9' # require spec support files and shared behavior Dir[File.expand_path('../{support,shared}/**/*.rb', __FILE__)].each do |file|
Update specs to report coverage to coveralls
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 @@ -30,4 +30,9 @@ add_filter '/vendor/bundle/' end +# Initialize Guard for running tests. +require 'guard' +Guard.setup(notify: false) + require 'guard/rubocop' +
Fix the test suite to run against latest Guard. The test suite works fine with Guard 2.1, but fails with Guard 2.13. The failure comes from heavy refactoring in recent version of Guard, where static initialization is expected by the runtime. The init just does not happen when running the test suite. guard-compat seems to address the problem, but it was not updated for a year at time of writing, and this commit is pretty simple in the end. The tests remain untouched and all pass.
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,6 @@ ENV["RAILS_ENV"] = "test" require 'i18n-spec' -require 'i18n/core_ext/hash' require 'active_support/core_ext/kernel/reporting' require 'socket' require 'unit/matchers/have_missing_particular_pluralization_keys_matcher'
Stop requiring i18n/core_ext/hash that is not in use i18n removed i18n/core_ext/hash at v1.9.0 (https://github.com/ruby-i18n/i18n/releases/tag/v1.9.0)
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,12 +19,12 @@ config.mock_with :rspec # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" + # config.fixture_path = "#{::Rails.root}/spec/fixtures" # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false # instead of true. - config.use_transactional_fixtures = true + # config.use_transactional_fixtures = true # If true, the base class of anonymous controllers will be inferred # automatically. This will be the default behavior in future versions of
Delete fixture configuration at spec.
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,5 +1,7 @@ require 'simplecov' -SimpleCov.start +SimpleCov.start do + add_filter "/spec/" +end $:.unshift File.expand_path("../..", __FILE__)
Add spec filter for coverage
diff --git a/assets/samples/sample_activity.rb b/assets/samples/sample_activity.rb index abc1234..def5678 100644 --- a/assets/samples/sample_activity.rb +++ b/assets/samples/sample_activity.rb @@ -17,6 +17,5 @@ @text_view.setText "What hath Matz wrought!" toast 'Flipped a bit via butterfly' end - true end end
Revert the last change...onClick does not need to return a value
diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index abc1234..def5678 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -0,0 +1,8 @@+require 'sidekiq/web' + +if ENV["USERNAME"] and ENV["PASSWORD"] + Sidekiq::Web.use(Rack::Auth::Basic) do |user, password| + user = ENV["USERNAME"] + password = ENV["PASSWORD"] + end +end
Add Sidekiq base auth configuration
diff --git a/week-6/nested_data_solution.rb b/week-6/nested_data_solution.rb index abc1234..def5678 100644 --- a/week-6/nested_data_solution.rb +++ b/week-6/nested_data_solution.rb @@ -0,0 +1,98 @@+# RELEASE 2: NESTED STRUCTURE GOLF +# Hole 1 +# Target element: "FORE" + +array = [[1,2], ["inner", ["eagle", "par", ["FORE", "hook"]]]] + +# attempts: +# ============================================================ +p array[1][1][2][0] + + +# ============================================================ + +# Hole 2 +# Target element: "congrats!" + +hash = {outer: {inner: {"almost" => {3 => "congrats!"}}}} + +# # attempts: +# # ============================================================ +p hash[:outer][:inner]["almost"][3] + + +# # ============================================================ + + +# # Hole 3 +# # Target element: "finished" + +nested_data = {array: ["array", {hash: "finished"}]} + +# # attempts: +# # ============================================================ +p nested_data[array:]["array"][hash:] +p nested_data[array:][1][hash:] +p nested_data[:array][1][:hash] + + +# # ============================================================ + +# # RELEASE 3: ITERATE OVER NESTED STRUCTURES + +number_array = [5, [10, 15], [20,25,30], 35] + +number_array.map! do |element| + if element.kind_of?(Array) + element.map! do |element| + element += 5 + end + else + element += 5 + end +end + +# number_array.each {|element| number_array[element] += 5} + +p number_array + +# # Bonus: + +startup_names = ["bit", ["find", "fast", ["optimize", "scope"]]] + +startup_names.map! do |element| + if element.kind_of?(Array) + element.map! do |element| + if element.kind_of?(Array) + element.map! do |element| + element += "ly" + end + else + element += "ly" + end + end + else + element += "ly" + end +end + + +p startup_names + +# # Reflection: + +# What are some general rules you can apply to nested arrays? + +# Nested arrays are still treated as an element of it's 'parent' array. +# You can still iterate over the nested arrays using #each. +# Using 'puts' is a good way to print out each element of a nested array regradless of how many arrays are within the array. + +# What are some ways you can iterate over nested arrays? + +# By using methods like #each or #map, then using #kind_of? to further iterate. +# If you want to print out each element separately, use 'puts'. + +# Did you find any good new methods to implement or did you re-use one you were already familiar with? What was it and why did you decide that was a good option? + +# I wasn't previously familiar with #kind_of?. Otherwise, we used #map! which I was already familiar with. +# We decided #map! was preferable over #each because it was destructive, which was specified in the instructions.
Add 6.5 Nested Data Structures file
diff --git a/config/routes.rb b/config/routes.rb index abc1234..def5678 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,15 +3,18 @@ scope '/:locale' do get '/', to: 'home#index' - end - resource :styleguide, controller: 'styleguide', only: 'show' do - member do - get 'css' - get 'html' - get 'sass' - get 'javascript' - get 'ruby' + resource :styleguide, + controller: 'styleguide', + only: 'show', + constraints: { locale: I18n.default_locale } do + member do + get 'css' + get 'html' + get 'sass' + get 'javascript' + get 'ruby' + end end end end
Enforce localised URL convention for styleguide Scopes the styleguide resource by locale but restricts it to the default locale (en) only. This keeps routing consistent and ensures we have one way to concern ourselves with how to determine the locale.
diff --git a/op_cart.gemspec b/op_cart.gemspec index abc1234..def5678 100644 --- a/op_cart.gemspec +++ b/op_cart.gemspec @@ -11,7 +11,7 @@ s.email = ["ericboehs@gmail.com"] s.homepage = "https://github.com/ericboehs/op_cart" s.summary = "Opinionated cart engine for Ruby on Rails" - s.description = "OpCart makes things simple through inflexibility and lack of features" + s.description = "Opinionated cart engine for Ruby on Rails" s.license = "MIT" s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
Update description on rubygems.org to match Github
diff --git a/Gemfile.d/pulsar.rb b/Gemfile.d/pulsar.rb index abc1234..def5678 100644 --- a/Gemfile.d/pulsar.rb +++ b/Gemfile.d/pulsar.rb @@ -28,8 +28,5 @@ # this gem and you don't think you need pulsar, then you should actually # be running `bundle install --without pulsar` to just skip it. group :pulsar do - # TODO: this dependency is blocking the build because - # the bundle caching process can't seem to find it. - # unblock the build for now. - # gem "pulsar-client", "2.6.1.pre.beta.2" + gem "pulsar-client", "2.6.1.pre.beta.2" end
Revert "Revert "Revert "unblock build for beta release""" This reverts commit 37c3066234d308fa502e30994c7cfe84d0dad8c0.
diff --git a/KeyboardKit.podspec b/KeyboardKit.podspec index abc1234..def5678 100644 --- a/KeyboardKit.podspec +++ b/KeyboardKit.podspec @@ -3,7 +3,7 @@ Pod::Spec.new do |s| s.name = 'KeyboardKit' s.version = '3.1.1' - s.swift_versions = ['5.2'] + s.swift_versions = ['5.3'] s.summary = 'KeyboardKit helps you create iOS keyboard extensions.' s.description = <<-DESC @@ -16,7 +16,7 @@ s.source = { :git => 'https://github.com/danielsaidi/KeyboardKit.git', :tag => s.version.to_s } s.social_media_url = 'https://twitter.com/danielsaidi' - s.swift_version = '5.2' + s.swift_version = '5.3' s.ios.deployment_target = '11.0' s.source_files = 'Sources/KeyboardKit/**/*.swift' end
Update Swift version in Podfile
diff --git a/PusherSwift.podspec b/PusherSwift.podspec index abc1234..def5678 100644 --- a/PusherSwift.podspec +++ b/PusherSwift.podspec @@ -12,7 +12,7 @@ s.source_files = 'Sources/*.swift' s.dependency 'CryptoSwift', '~> 0.8.3' - s.dependency 'Reachability', '~> 4.1.0' + s.dependency 'ReachabilitySwift', '~> 4.1.0' s.dependency 'TaskQueue', '~> 1.1.0' s.dependency 'StarscreamFork', '~> 3.0.5'
Fix Reachability reference in Podspec
diff --git a/boot.rb b/boot.rb index abc1234..def5678 100644 --- a/boot.rb +++ b/boot.rb @@ -21,5 +21,8 @@ Configuration.config do |config| config.logger_filename = "logs/rubycasts.log" config.load_paths = %w(. app/models app/helpers app/views app/lib app/requests) - config.datamapper(:default, "#{database['adapter']}://#{database['host']}/#{database['name']}") + config.datamapper(:default, { + :adapter => database['adapter'], + :host => database['host'], + :database => database['name']}) end
Put Hash options in Datamapper config instead an adress uri
diff --git a/rack-zip.gemspec b/rack-zip.gemspec index abc1234..def5678 100644 --- a/rack-zip.gemspec +++ b/rack-zip.gemspec @@ -5,6 +5,7 @@ spec.description = 'Rack::Zip serves files in zip archives.' spec.authors = ['KITAITI Makoto'] spec.email = 'KitaitiMakoto@gmail.com' + spec.required_ruby_version = '>= 2.0.0' spec.files = ['lib/rack/zip.rb'] spec.add_runtime_dependency 'rack'
Add required Ruby version to gemspec
diff --git a/db/migrate/007_add_missing_indexes.rb b/db/migrate/007_add_missing_indexes.rb index abc1234..def5678 100644 --- a/db/migrate/007_add_missing_indexes.rb +++ b/db/migrate/007_add_missing_indexes.rb @@ -0,0 +1,24 @@+class AddMissingIndexes < ActiveRecord::Migration + + def up + add_index :jenkins_settings, :project_id + + add_index :jenkins_jobs, :project_id + add_index :jenkins_jobs, :repository_id + add_index :jenkins_jobs, [:project_id, :name], unique: true + + add_index :jenkins_builds, :jenkins_job_id + add_index :jenkins_builds, :author_id + + add_index :jenkins_build_changesets, :jenkins_build_id + add_index :jenkins_build_changesets, :repository_id + + add_index :jenkins_test_results, :jenkins_build_id + end + + + def down + + end + +end
Add missing indexes in database
diff --git a/jekyll-remote-plantuml.gemspec b/jekyll-remote-plantuml.gemspec index abc1234..def5678 100644 --- a/jekyll-remote-plantuml.gemspec +++ b/jekyll-remote-plantuml.gemspec @@ -3,17 +3,17 @@ Gem::Specification.new do |s| s.name = 'jekyll-remote-plantuml' - s.version = '0.1.0' + s.version = '0.1.2' s.date = '2015-02-20' + s.homepage = "http://github.com/Patouche/jekyll-remote-plantuml" s.summary = "Jekyll remote plantuml" s.description = "Jekyll to use plantuml with remote provider without any local plantuml.jar installation" s.authors = ["Patouche"] s.email = 'patralla@gmail.com' - s.homepage = 'http://rubygems.org/gems/jekyll-remote-plantuml' - s.files = Dir['lib/*.rb'] + s.files = Dir.glob("{lib}/*.rb") + %w(LICENSE.txt README.md) - s.license = 'MIT' + s.license = 'MIT' s.require_path = "lib" s.add_runtime_dependency('jekyll', '>= 0.11.2')
Add the homepage for plugin and increase version
diff --git a/features/support/page_models/page_asserts/registration_success_page_asserts.rb b/features/support/page_models/page_asserts/registration_success_page_asserts.rb index abc1234..def5678 100644 --- a/features/support/page_models/page_asserts/registration_success_page_asserts.rb +++ b/features/support/page_models/page_asserts/registration_success_page_asserts.rb @@ -7,4 +7,4 @@ end end -World(PageModels::RegistrationSuccess)+World(PageModels::RegistrationSuccessAsserts)
Fix error in world calling.
diff --git a/lib/amorail/entity/persistance.rb b/lib/amorail/entity/persistance.rb index abc1234..def5678 100644 --- a/lib/amorail/entity/persistance.rb +++ b/lib/amorail/entity/persistance.rb @@ -17,11 +17,7 @@ end def save! - if save - true - else - fail InvalidRecord - end + save || fail(InvalidRecord) end def update(attrs = {}) @@ -31,11 +27,7 @@ end def update!(attrs = {}) - if update(attrs) - true - else - fail NotPersisted - end + update(attrs) || fail(NotPersisted) end def reload
Return object while using bang methods
diff --git a/lib/cache_back/rack_middleware.rb b/lib/cache_back/rack_middleware.rb index abc1234..def5678 100644 --- a/lib/cache_back/rack_middleware.rb +++ b/lib/cache_back/rack_middleware.rb @@ -0,0 +1,13 @@+module CacheBack + class RackMiddleware + def initialize(app) + @app = app + end + + def call(env) + result = @app.call(env) + CacheBack.cache.reset! + result + end + end +end
Revert "removing unused rack middleware" This reverts commit 4676a0c0606a3a506b432c3fa8f56787bb972579.
diff --git a/lib/middleman-disqus/extension.rb b/lib/middleman-disqus/extension.rb index abc1234..def5678 100644 --- a/lib/middleman-disqus/extension.rb +++ b/lib/middleman-disqus/extension.rb @@ -14,7 +14,7 @@ options = options.to_h.map do |k,obj| k =~ /^disqus_(.*)$/ ? [$1, obj] : nil end - options = Hash[options] + options = Hash[options.compact] @@options.to_h.merge(options).with_indifferent_access end
Fix MRI Ruby 2.x warnings
diff --git a/lib/simplecov/lines_classifier.rb b/lib/simplecov/lines_classifier.rb index abc1234..def5678 100644 --- a/lib/simplecov/lines_classifier.rb +++ b/lib/simplecov/lines_classifier.rb @@ -17,14 +17,14 @@ end def self.no_cov_line?(line) - line =~ no_cov_line + no_cov_line.match?(line) rescue ArgumentError # E.g., line contains an invalid byte sequence in UTF-8 false end def self.whitespace_line?(line) - line =~ WHITESPACE_OR_COMMENT_LINE + WHITESPACE_OR_COMMENT_LINE.match?(line) rescue ArgumentError # E.g., line contains an invalid byte sequence in UTF-8 false
Improve performance of lines classifier Prefer `Regexp#match?` over `String#=~` which improves the speed by ~50% for these methods.
diff --git a/lib/tasks/fix_unique_legends.rake b/lib/tasks/fix_unique_legends.rake index abc1234..def5678 100644 --- a/lib/tasks/fix_unique_legends.rake +++ b/lib/tasks/fix_unique_legends.rake @@ -4,7 +4,15 @@ query = 'SELECT layer_id, count(*) from legends group by layer_id having count(*) > 1' ActiveRecord::Base.connection.execute(query).each do |row| legends = Carto::Layer.find(row['layer_id']).legends - legends.sort_by(&:updated_at).slice(1..legends.count).each(&:destroy) + legend_types = Carto::Legend::LEGEND_TYPES_PER_ATTRIBUTE.keys + legends_per_type = legend_types.reduce({}) { |m, o| m.merge(o => []) } + legend_per_type = legends.reduce(legends_per_type) do |m, legend| + legend_types.reduce(m) { |m, t| + m[t] << legend if Carto::Legend::LEGEND_TYPES_PER_ATTRIBUTE[t].include?(legend.type) + m + } + end + legend_per_type.each { |_, l| l.sort_by(&:updated_at).slice(1..l.count).each(&:destroy) if l.size > 1 } end end end
Fix rake so it only deletes legends of the same type
diff --git a/spec/event/dispatcher_spec.rb b/spec/event/dispatcher_spec.rb index abc1234..def5678 100644 --- a/spec/event/dispatcher_spec.rb +++ b/spec/event/dispatcher_spec.rb @@ -13,17 +13,22 @@ end describe Dispatcher do + shared_examples "an observer notification" do + it "should send the expected message to the observer" do + observers.each { |o| o.should_receive(expected_message).with(event) } + subject.dispatch event + end + end + context "with a single observer" do - let(:observer) { mock } - subject { Dispatcher.new [observer] } + let(:observers) { [mock] } + subject { Dispatcher.new observers } context "dispatching an example event" do let(:event) { Event.new :example } + let(:expected_message) { :on_example } - it "should call on_example on the observer" do - observer.should_receive(:on_example).with(event) - subject.dispatch event - end + it_behaves_like "an observer notification" end end @@ -33,11 +38,9 @@ context "dispatching an absorb event" do let(:event) { Event.new :absorb } + let(:expected_message) { :on_absorb } - it "should call on_absorb on the observer" do - observers.each { |o| o.should_receive(:on_absorb).with(event) } - subject.dispatch event - end + it_behaves_like "an observer notification" end end
Refactor dispatcher spec with shared example
diff --git a/spec/factories/udl_modules.rb b/spec/factories/udl_modules.rb index abc1234..def5678 100644 --- a/spec/factories/udl_modules.rb +++ b/spec/factories/udl_modules.rb @@ -24,6 +24,14 @@ udl_module.authors << create(:modules_author_user) end end + + factory :udl_module_with_assessment do + after(:create) do |udl_module| + 10.times do + udl_module.assessment_questions << create(:assessment_question_with_answer_choices) + end + end + end end factory :new_udl_module, class: UdlModule do
Add udl_module factory that contains an assessment
diff --git a/spec/models/candidate_spec.rb b/spec/models/candidate_spec.rb index abc1234..def5678 100644 --- a/spec/models/candidate_spec.rb +++ b/spec/models/candidate_spec.rb @@ -4,17 +4,18 @@ describe "scopes" do let!(:candidate) { FactoryGirl.create(:candidate, looking_for_work: true) } let!(:not_looking_candidate) { FactoryGirl.create(:candidate, :not_looking_for_work) } - describe "looking for work" do + describe "looking_for_work" do subject { Candidate.looking_for_work } it { is_expected.to include candidate } it { is_expected.not_to include not_looking_candidate } end - describe "with profession" do + describe "with_profession" do + let!(:carpenter) { FactoryGirl.create(:candidate, profession_name: "Carpenter") } + let!(:welder) { FactoryGirl.create(:candidate, profession_name: "Welder") } + context "when given profession name" do - let!(:carpenter) { FactoryGirl.create(:candidate, profession_name: "Carpenter") } - let!(:welder) { FactoryGirl.create(:candidate, profession_name: "Welder") } subject { Candidate.with_profession "Carpenter" } it { is_expected.to include carpenter } @@ -22,7 +23,11 @@ end context "when given Profession object" do - it "returns candidates with profession" + let(:profession) { Profession.find_or_create_by_name("Carpenter") } + + subject { Candidate.with_profession profession } + + it { is_expected.to include carpenter } end end end
Add specs for Candidate.with_profession with object
diff --git a/StompClient.podspec b/StompClient.podspec index abc1234..def5678 100644 --- a/StompClient.podspec +++ b/StompClient.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "StompClient" - s.version = "0.0.1" + s.version = "0.1.0" s.summary = "Simple STOMP client." s.description = "This project is a simple STOMP client, and we use Starscream as a websocket dependency." s.homepage = "https://github.com/ShengHuaWu/StompClient"
Increase version number to 0.1.0 in podspec.
diff --git a/lib/mocha/integration/mini_test/assertion_counter.rb b/lib/mocha/integration/mini_test/assertion_counter.rb index abc1234..def5678 100644 --- a/lib/mocha/integration/mini_test/assertion_counter.rb +++ b/lib/mocha/integration/mini_test/assertion_counter.rb @@ -11,7 +11,7 @@ end def increment - @test_case._assertions += 1 + @test_case.assert(true) end end
Use public API of MiniTest for registering assertions. As suggested by @tenderlove in [1]. This reduces the dependency on private & potentially more changeable behaviour in MiniTest and gets us closer to the goal of not having to monkey-patch. [1] https://github.com/freerange/mocha/issues/87#issuecomment-6747614
diff --git a/lib/tasks/data_feeds_weather_underground_loader.rake b/lib/tasks/data_feeds_weather_underground_loader.rake index abc1234..def5678 100644 --- a/lib/tasks/data_feeds_weather_underground_loader.rake +++ b/lib/tasks/data_feeds_weather_underground_loader.rake @@ -1,7 +1,7 @@ namespace :data_feeds do desc 'Set up data feeds' task :weather_underground_loader, [:start_date, :end_date] => :environment do |_t, args| - start_date = args[:start_date].present? ? Date.parse(args[:start_date]) : Date.yesterday - 1 + start_date = args[:start_date].present? ? Date.parse(args[:start_date]) : Date.yesterday - 3 end_date = args[:end_date].present? ? Date.parse(args[:end_date]) : Date.yesterday old_readings = DataFeedReading.where(feed_type: [:solar_irradiation, :temperature]).where('at >= ? and at <= ?', start_date.beginning_of_day, end_date.end_of_day)
Change default dates - now yesterday -3 to yesterday
diff --git a/app/controllers/api/users_controller.rb b/app/controllers/api/users_controller.rb index abc1234..def5678 100644 --- a/app/controllers/api/users_controller.rb +++ b/app/controllers/api/users_controller.rb @@ -1,7 +1,8 @@ class Api::UsersController < Api::BaseController def index @users = User.all - @users = @users.where(id: params[:users]) if params[:users] - render json: {users: @users.as_json(only: [:id, :name, :email])} + @users = @users.where(id: params[:ids]) if params[:ids] + @users = @users.where(email: params[:emails]) if params[:emails] + render json: {users: @users.as_json(only: [:id, :name, :email, :image_url])} end -end +end
Add email filter for users api
diff --git a/rr.gemspec b/rr.gemspec index abc1234..def5678 100644 --- a/rr.gemspec +++ b/rr.gemspec @@ -8,21 +8,21 @@ gem.version = RR.version gem.authors = ['Brian Takita', 'Elliot Winkler'] gem.email = ['elliot.winkler@gmail.com'] - gem.description = "RR is a double framework that features a rich selection of double techniques and a terse syntax." - gem.summary = "RR is a double framework that features a rich selection of double techniques and a terse syntax." - gem.homepage = "http://rr.github.com/rr" - gem.license = "MIT" + gem.description = 'RR is a test double framework that features a rich selection of double techniques and a terse syntax.' + gem.summary = 'RR is a test double framework that features a rich selection of double techniques and a terse syntax.' + gem.homepage = 'http://rr.github.com/rr' + gem.license = 'MIT' gem.files = FileList[ 'CHANGES.md', + 'CREDITS.md', 'LICENSE', 'README.md', 'VERSION', + 'doc/*.md', 'lib/**/*.rb', 'rr.gemspec' ].to_a - gem.test_files = FileList['spec/**/*'] - gem.require_paths = ['lib'] end
Update gemspec to actually remove test files and add missing text files
diff --git a/app/controllers/platforms_controller.rb b/app/controllers/platforms_controller.rb index abc1234..def5678 100644 --- a/app/controllers/platforms_controller.rb +++ b/app/controllers/platforms_controller.rb @@ -9,7 +9,7 @@ @updated = Project.platform(@platform_name).limit(5).order('updated_at DESC') @created = Project.platform(@platform_name).limit(5).order('created_at DESC') @contributors = GithubUser.top_for(@platform_name, 24) - @popular = Project.platform(@platform_name).with_repo.limit(30) + @popular = Project.platform(@platform_name).with_repo.limit(50) .order('github_repositories.stargazers_count DESC') .to_a.uniq(&:github_repository_id).first(5) end
Work out most popular from 50 projects
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 @@ -12,7 +12,7 @@ FakeWeb.clean_registry FakeWeb.allow_net_connect = false response = File.open(File.join(File.dirname(__FILE__), 'fixtures', fixture)).read - FakeWeb.register_uri(method, uri.to_s, :string => response) + FakeWeb.register_uri(method, uri.to_s, :body => response) end def teardown
Fix deprecation warnings from FakeWeb
diff --git a/app/serializers/api/state_serializer.rb b/app/serializers/api/state_serializer.rb index abc1234..def5678 100644 --- a/app/serializers/api/state_serializer.rb +++ b/app/serializers/api/state_serializer.rb @@ -1,3 +1,7 @@ class Api::StateSerializer < ActiveModel::Serializer attributes :id, :name, :abbr + + def abbr + object.abbr.upcase + end end
Make state abbreviations upper case
diff --git a/practice.rb b/practice.rb index abc1234..def5678 100644 --- a/practice.rb +++ b/practice.rb @@ -0,0 +1,81 @@+# Given any integer, count the # of occurrences of each digit + +# DESIRED OUTPUT (exact format) + +# 0 1 +# 1 1 +# 2 0 +# 3 0 +# 4 0 +# 5 1 +# 6 0 +# 7 2 +# 8 0 +# 9 0 + + + + +string = gets.chomp.to_s +array = string.split("") +a = 0 +b = 0 +c = 0 +d = 0 +e = 0 +f = 0 +g = 0 +h = 0 +i = 0 +j = 0 +array.each do |x| + integer_x = x.to_i + if integer_x == 0 + a += 1 + elsif integer_x == 1 + b += 1 + elsif integer_x == 2 + c += 1 + elsif integer_x == 3 + d += 1 + elsif integer_x == 4 + e += 1 + elsif integer_x == 5 + f += 1 + elsif integer_x == 6 + g += 1 + elsif integer_x == 7 + h += 1 + elsif integer_x == 8 + i += 1 + elsif integer_x == 9 + j += 1 + end +end + + print 0.to_s + " " + puts a + print 1.to_s + " " + puts b + print 2.to_s + " " + puts c + print 3.to_s + " " + puts d + print 4.to_s + " " + puts e + print 5.to_s + " " + puts f + print 6.to_s + " " + puts g + print 7.to_s + " " + puts h + print 8.to_s + " " + puts i + print 9.to_s + " " + puts j + + + # RESULT: + # time: 0.102268 + # memory: 64 KiB +
Add runner code for implementation problem: given integer, produce occurences of digits in integer
diff --git a/common_lips.gemspec b/common_lips.gemspec index abc1234..def5678 100644 --- a/common_lips.gemspec +++ b/common_lips.gemspec @@ -8,8 +8,8 @@ spec.version = CommonLips::VERSION spec.authors = ["Nicolas McCurdy"] spec.email = ["thenickperson@gmail.com"] - spec.description = %q{TODO: Write a gem description} - spec.summary = %q{TODO: Write a gem summary} + spec.description = "A more confusing version of Common Lisp." + spec.summary = "A more confusing version of Common Lisp." spec.homepage = "" spec.license = "MIT"
Add a description and summary to the gemspec
diff --git a/lib/liquid-renderer/railtie.rb b/lib/liquid-renderer/railtie.rb index abc1234..def5678 100644 --- a/lib/liquid-renderer/railtie.rb +++ b/lib/liquid-renderer/railtie.rb @@ -11,7 +11,7 @@ ActionController::Renderers.add :liquid do |content, options| content_type = options.delete(:content_type) || 'text/html' status = options.delete(:status) || :ok - render text: LiquidRenderer.render(content, options), content_type: content_type, status: status + render plain: LiquidRenderer.render(content, options), content_type: content_type, status: status end end end
Change text: to plain: for rails 5
diff --git a/lib/rrj/process/concurrency.rb b/lib/rrj/process/concurrency.rb index abc1234..def5678 100644 --- a/lib/rrj/process/concurrency.rb +++ b/lib/rrj/process/concurrency.rb @@ -28,7 +28,6 @@ @rabbit.transaction_long { transaction_running } rescue Interrupt ::Log.warn "This process has been interupted #{self.class.name}" - ensure ::Log.warn \ "Close a connection with RabbitMQ instance for #{self.class.name}" @rabbit.close
Remove ensure exec close rabbitmq connection [skip ci]
diff --git a/substring_palindrome.rb b/substring_palindrome.rb index abc1234..def5678 100644 --- a/substring_palindrome.rb +++ b/substring_palindrome.rb @@ -0,0 +1,42 @@+# Find the longest palindrome substring from a given string +# A O(n^2) time and 0(1) space solution + +def longest_substring_palindrome(str) + max_length = 1 + start = 0 + low = 0 + high = 0 + length = str.length + # One by one consider each character as the center point of an even and odd length palindrome + i = 1 + until i == length + # Find the longest even length palindrome with center points i-1 and i + low = i - 1 + high = i + while low >= 0 && high < length && str[low] == str[high] + if high - low + 1 > max_length + start = low + max_length = high - low + 1 + end + low -= 1 + high += 1 + end + + # Find the longest odd length palindrome with center point as i + low = i - 1 + high = i + 1 + while low >= 0 && high < length && str[low] == str[high] + if high - low + 1 > max_length + start = low + max_length = high - low + 1 + end + low -= 1 + high += 1 + end + + i += 1 + end + "The longest substring palindrome is #{str[start...(start + max_length)]} and it's length is #{max_length}" +end + +p longest_substring_palindrome('forgeeksskeegfor')
Add longest substring palindrome function
diff --git a/lib/sweet-alert2-rails/view_helpers.rb b/lib/sweet-alert2-rails/view_helpers.rb index abc1234..def5678 100644 --- a/lib/sweet-alert2-rails/view_helpers.rb +++ b/lib/sweet-alert2-rails/view_helpers.rb @@ -33,7 +33,7 @@ protected def options_has_confirm?(options) - options[:data] && options[:data][:confirm] + options.is_a?(Hash) && options[:data] && options[:data][:confirm] end end end
Verify options is a hash before pulling out confirm
diff --git a/lib/active_record_views/railtie.rb b/lib/active_record_views/railtie.rb index abc1234..def5678 100644 --- a/lib/active_record_views/railtie.rb +++ b/lib/active_record_views/railtie.rb @@ -2,7 +2,7 @@ class Railtie < ::Rails::Railtie initializer 'active_record_views' do |app| ActiveSupport.on_load :active_record do - ActiveRecordViews.sql_load_path << Rails.root + 'app/models' + ActiveRecordViews.sql_load_path += Rails.application.config.paths['app/models'].to_a ActiveRecordViews.init! ActiveRecordViews::Extension.create_enabled = !Rails.env.production? end
Load all configured model paths into the SQL load path
diff --git a/tools/ipmi-vulns.rb b/tools/ipmi-vulns.rb index abc1234..def5678 100644 --- a/tools/ipmi-vulns.rb +++ b/tools/ipmi-vulns.rb @@ -10,13 +10,11 @@ } def search(hash) - vulns = [] SEARCHES.each do | key, vuln | if hash[key] == vuln[:value] - vulns << "VULN-IPMI-#{vuln[:name].upcase}" + hash["VULN-IPMI-#{vuln[:name].upcase}"] = "true" end end - hash['vulnerabilities'] = vulns unless vulns.empty? hash end
Add vulns as indivdual keys
diff --git a/lib/geokit/net_adapter/net_http.rb b/lib/geokit/net_adapter/net_http.rb index abc1234..def5678 100644 --- a/lib/geokit/net_adapter/net_http.rb +++ b/lib/geokit/net_adapter/net_http.rb @@ -15,7 +15,6 @@ http.use_ssl = true http.verify_mode = Geokit::Geocoders.ssl_verify_mode end - http.set_debug_output STDOUT http.start { |http| http.request(req) } end
Remove errant debug line in HTTP adapter
diff --git a/app/exporters/publishing_api_manual_with_sections_withdrawer.rb b/app/exporters/publishing_api_manual_with_sections_withdrawer.rb index abc1234..def5678 100644 --- a/app/exporters/publishing_api_manual_with_sections_withdrawer.rb +++ b/app/exporters/publishing_api_manual_with_sections_withdrawer.rb @@ -4,9 +4,9 @@ entity: manual, ).call - manual.sections.each do |document| + manual.sections.each do |section| PublishingAPIWithdrawer.new( - entity: document, + entity: section, ).call end end
Rename document -> section in PublishingApiManualWithSectionsWithdrawer
diff --git a/lib/pushwoosh/push_notification.rb b/lib/pushwoosh/push_notification.rb index abc1234..def5678 100644 --- a/lib/pushwoosh/push_notification.rb +++ b/lib/pushwoosh/push_notification.rb @@ -41,7 +41,7 @@ def create_message(notification_options = {}) fail Error, 'Message is missing' if notification_options[:content].empty? response = Request.post("/createMessage", - body: build_request(notification_options)) + body: build_request(notification_options).to_json) Response.new(response.parsed_response.with_indifferent_access) end
Fix for "undefined method 'with_indifferent_access' for nil:NilClass" error
diff --git a/lib/serverspec/type/iis_website.rb b/lib/serverspec/type/iis_website.rb index abc1234..def5678 100644 --- a/lib/serverspec/type/iis_website.rb +++ b/lib/serverspec/type/iis_website.rb @@ -17,11 +17,14 @@ backend.check_iis_app_pool(@name, app_pool) end - def path(path) + def has_physical_path?(path) backend.check_iis_website_path(@name, path) end + + def to_s + 'IIS Website' + end - end end end
Verify the physical path of the website
diff --git a/lib/active_merchant/billing/integrations/paydollar/helper.rb b/lib/active_merchant/billing/integrations/paydollar/helper.rb index abc1234..def5678 100644 --- a/lib/active_merchant/billing/integrations/paydollar/helper.rb +++ b/lib/active_merchant/billing/integrations/paydollar/helper.rb @@ -24,9 +24,7 @@ end def currency=(currency_code) - code = CURRENCY_MAP[currency_code] - raise StandardError, "Invalid currency code #{currency_code} specified" if code.nil? - add_field(mappings[:currency], code) + add_field(mappings[:currency], CURRENCY_MAP[currency_code]) end mapping :account, 'merchantId'
Remove extraneous checking of currency code
diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index abc1234..def5678 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -1,16 +1,8 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController skip_before_filter :authenticate_user! def google_oauth2 - auth_info = request.env["omniauth.auth"].info - - unless Rearview::User.valid_email?(auth_info['email'].to_s) - return redirect_to(new_session_path, :flash => { - :error => "Invalid Google domain for email #{auth_info['email'].to_s}. Please use your hungrymachine.com or livingsocial.com account." - }) - end - - user = Rearview::User.find_or_create_by_email(auth_info['email']) + user = Rearview::User.find_or_create_by(:email,auth_info['email']) if user flash[:notice] = I18n.t("devise.omniauth_callbacks.success", :kind => "Google") session[:user_id] = user.id
Remove LivingSocial specific oauth2 code resolves #15
diff --git a/lib/live_editor/cli/validators/config_validator.rb b/lib/live_editor/cli/validators/config_validator.rb index abc1234..def5678 100644 --- a/lib/live_editor/cli/validators/config_validator.rb +++ b/lib/live_editor/cli/validators/config_validator.rb @@ -21,7 +21,7 @@ begin config = JSON.parse(File.read(config_loc)) rescue Exception => e - @errors << { + self.errors << { type: :error, message: 'The file at `/config.json` does not contain valid JSON markup.' } @@ -34,7 +34,7 @@ if config[key].blank? a_an = key.start_with?('a') ? 'an' : 'a' - @errors << { + self.errors << { type: :error, message: "The file at `/config.json` must contain #{a_an} `#{key}` attribute." } @@ -42,13 +42,13 @@ end # No config.json. else - @errors << { - type: :notice, - messag: '`/config.json` has not yet been created.' + self.errors << { + type: :warning, + message: '`/config.json` has not yet been created.' } end - @errors.select { |error| error[:type] == :error }.size == 0 + self.errors.select { |error| error[:type] == :error }.size == 0 end end end
Use mutators instead of instance variables in config validator
diff --git a/breezy_template/breezy_template.gemspec b/breezy_template/breezy_template.gemspec index abc1234..def5678 100644 --- a/breezy_template/breezy_template.gemspec +++ b/breezy_template/breezy_template.gemspec @@ -8,6 +8,7 @@ s.license = 'MIT' s.homepage = 'https://github.com/jho406/breezy/' s.summary = 'Breezy Templates for React props' + s.description = 'Breezy Templates for React props' s.files = Dir['MIT-LICENSE', 'README.md', 'lib/**/*', 'app/**/*'] s.test_files = Dir["test/*"]
Update Breezy gemspec with meta
diff --git a/app/models/event.rb b/app/models/event.rb index abc1234..def5678 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -8,7 +8,7 @@ def self.from_geom(geom_ewkt, params) after_date = params[:after_date] || 7.days.ago - before_date = params[:before_date] || 2.days.from_now + before_date = params[:before_date] || Time.current dataset.with_sql(<<-SQL, params.fetch(:publisher_id), after_date, before_date, geom_ewkt).all SELECT events.geom, events.title FROM events
Use current time as default before_date
diff --git a/event_store-client.gemspec b/event_store-client.gemspec index abc1234..def5678 100644 --- a/event_store-client.gemspec +++ b/event_store-client.gemspec @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = 'event_store-client' - s.version = '0.0.1.4' + s.version = '0.0.1.5' s.summary = 'Common code for the EventStore client' s.description = ' '
Package version is increased from 0.0.1.4 to 0.0.1.5
diff --git a/fulmar_file_sync.gemspec b/fulmar_file_sync.gemspec index abc1234..def5678 100644 --- a/fulmar_file_sync.gemspec +++ b/fulmar_file_sync.gemspec @@ -10,9 +10,8 @@ s.description = 'This gem adds file sync functionality to the fulmar deployment tool. It can be used standalone though.' s.authors = ['Gerrit Visscher'] s.email = 'g.visscher@core4.de' - s.files = `git ls-files -z`.split("\x0") - s.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } - s.test_files = spec.files.grep(%r{^(test|spec|features)/}) + s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } + s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) } s.homepage = 'http://git.core4.lan/core4internal/fulmar_file_sync' s.license = 'proprietary' s.require_paths = ['lib']
[BUGFIX] Fix spec (varname was "s" not "spec")
diff --git a/code/type_null_true_false.rb b/code/type_null_true_false.rb index abc1234..def5678 100644 --- a/code/type_null_true_false.rb +++ b/code/type_null_true_false.rb @@ -1,34 +1,18 @@-def if_value(values) - puts '"if value":' - values.each { |k, v| puts "#{k} - #{v ? 'true' : 'false'}" } +def check(label, fn, values) + puts label + values.each do |value| + begin + result = fn.call(value) ? 'true' : 'false' + rescue => e + result = "error: #{e}" + end + printf(" %-9p - %s\n", value, result) + end puts '' end -def nil_value(values) - puts '"if value.nil?":' - values.each { |k, v| puts "#{k} - #{v.nil? ? 'true' : 'false'}" } - puts '' -end +values = ['string', '', [1, 2, 3], [], 5, 0, true, false, nil] -def empty_value(values) - puts '"if value.empty?":' - values.each do |k, v| - puts "#{k} - #{v.empty? ? 'true' : 'false'}" if v.respond_to? :empty? - end -end - -values = { - "'string'": 'string', - "''": '', - '[1, 2, 3]': [1, 2, 3], - '[]': [], - '5': 5, - '0': 0, - true: true, - false: false, - nil: nil -} - -if_value(values) -nil_value(values) -empty_value(values) +check('if value:', -> (v) { v }, values) +check('if value.nil?:', -> (v) { v.nil? }, values) +check('if value.empty?:', -> (v) { v.empty? }, values)
Refactor null-true-false example in Ruby to make it more readable
diff --git a/config.ru b/config.ru index abc1234..def5678 100644 --- a/config.ru +++ b/config.ru @@ -2,7 +2,6 @@ require 'config/environment' require 'api/v1' -require 'config/logging' require 'rack/contrib' ENV['RACK_ENV'] ||= 'development'
Delete reference to missing file
diff --git a/config.ru b/config.ru index abc1234..def5678 100644 --- a/config.ru +++ b/config.ru @@ -1,7 +1,7 @@ require File.expand_path("../init", __FILE__) if ENV['ADMIN_USERNAME'] && ENV['ADMIN_PASSWORD'] - use Rack::Auth::Basic do |user, pass| - user == ENV['ADMIN_USERNAME'] && pass == ENV['ADMIN_PASSWORD'] + use Rack::Auth::Basic do |username, password| + username == ENV['ADMIN_USERNAME'] && password == ENV['ADMIN_PASSWORD'] end end run Integrity.app
Use username and password in variable names also
diff --git a/lib/active_interaction/pipeline.rb b/lib/active_interaction/pipeline.rb index abc1234..def5678 100644 --- a/lib/active_interaction/pipeline.rb +++ b/lib/active_interaction/pipeline.rb @@ -3,6 +3,10 @@ def initialize(&block) @steps = [] instance_eval(&block) + end + + def pipe(interaction, function = nil) + @steps << [lambdafy(function), interaction] end def run(options = {}) @@ -34,9 +38,5 @@ raise end end - - def pipe(interaction, function = nil) - @steps << [lambdafy(function), interaction] - end end end
Make "pipe" a public method I initially didn't want people creating a pipeline and then tacking things on to it with "pipeline.pipe(..)". I'm no longer convinced that's a bad thing.
diff --git a/lib/dpl/provider/heroku/git_ssh.rb b/lib/dpl/provider/heroku/git_ssh.rb index abc1234..def5678 100644 --- a/lib/dpl/provider/heroku/git_ssh.rb +++ b/lib/dpl/provider/heroku/git_ssh.rb @@ -11,6 +11,10 @@ end def setup_key(file) + warn '' + warn "git-ssh strategy is deprecated, and will be shut down on June 26, 2017." + warn "Please consider moving to the \\`api\\` or \\`git\\` strategy." + warn '' api.post_key File.read(file) end
Add deprecation warning for Heroku `git-ssh` strategy The new Platform API does not support this https://devcenter.heroku.com/articles/platform-api-reference.
diff --git a/lib/jugglite/sse_connection.rb b/lib/jugglite/sse_connection.rb index abc1234..def5678 100644 --- a/lib/jugglite/sse_connection.rb +++ b/lib/jugglite/sse_connection.rb @@ -4,10 +4,16 @@ def initialize(request) @request = request + @longpolling = request.xhr? @body = DeferrableBody.new end + def longpolling? + @longpolling + end + def write(message, options = {}) + reset_timeout if longpolling? buffer = "" options.each { |k, v| buffer << "#{k}: #{v}\n" } message.each_line { |line| buffer << "data: #{line.strip}\n" } @@ -34,5 +40,14 @@ def errback(&block) @body.errback(&block) end + + private + def reset_timeout + # From http://html5doctor.com/server-sent-events/#using-the-polyfill + @timeout.cancel if @timeout + @timeout = EventMachine::Timer.new(0.25) do + self.close + end + end end end
Add support for Remy's EventSource Polyfill through long polling
diff --git a/lib/refinery/tasks/refinery.rb b/lib/refinery/tasks/refinery.rb index abc1234..def5678 100644 --- a/lib/refinery/tasks/refinery.rb +++ b/lib/refinery/tasks/refinery.rb @@ -2,7 +2,7 @@ # So here, we find them (if there are any) and include them into rake. extra_rake_tasks = [] if defined?(Refinery) && Refinery.is_a_gem - extra_rake_tasks << Dir[Refinery.root.join("vendor", "plugins", "*", "**", "tasks", "**", "*", "*.rake")].sort + extra_rake_tasks << Dir[Refinery.root.join("vendor", "plugins", "*", "**", "tasks", "**", "*", "*.rake").to_s].sort end # We also need to load in the rake tasks from gem plugins whether Refinery is a gem or not:
Fix pathname because of different interface in 1.9.x
diff --git a/lib/fixture_dependencies/rspec/sequel.rb b/lib/fixture_dependencies/rspec/sequel.rb index abc1234..def5678 100644 --- a/lib/fixture_dependencies/rspec/sequel.rb +++ b/lib/fixture_dependencies/rspec/sequel.rb @@ -1,3 +1,5 @@+require 'fixture_dependencies/helper_methods' + if defined?(RSpec) example_group = RSpec::Core::ExampleGroup require 'rspec/version' @@ -27,15 +29,5 @@ end example_group.class_eval do - def load(*args) - FixtureDependencies.load(*args) - end - - def load_attributes(*args) - FixtureDependencies.load_attributes(*args) - end - - def build(*args) - FixtureDependencies.build(*args) - end + include FixtureDependencies::HelperMethods end
Use FixtureDependencies::HelperMethods in rspec integration
diff --git a/lib/github_changelog_generator/reader.rb b/lib/github_changelog_generator/reader.rb index abc1234..def5678 100644 --- a/lib/github_changelog_generator/reader.rb +++ b/lib/github_changelog_generator/reader.rb @@ -0,0 +1,74 @@+# +# Author:: Enrico Stahn <mail@enricostahn.com> +# +# Copyright 2014, Zanui, <engineering@zanui.com.au> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +module GitHubChangelogGenerator + # A Reader to read an existing ChangeLog file and return a structured object + # + # Example: + # reader = GitHubChangelogGenerator::Reader.new + # content = reader.read('./CHANGELOG.md') + class Reader + # Parse a single heading and return a Hash + # + # The following heading structures are currently valid: + # - ## [v1.0.2](https://github.com/zanui/chef-thumbor/tree/v1.0.1) (2015-03-24) + # - ## [v1.0.2](https://github.com/zanui/chef-thumbor/tree/v1.0.1) + # - ## v1.0.2 (2015-03-24) + # - ## v1.0.2 + # + # @param [String] heading Heading from the ChangeLog File + # @return [Hash] Returns a structured Hash with version, url and date + def parse_heading(heading) + structures = [ + /^## \[(?<version>v.+?)\]\((?<url>.+?)\)( \((?<date>.+?)\))?$/, + /^## (?<version>v.+?)( \((?<date>.+?)\))?$/, + ] + + captures = {'version' => nil, 'url' => nil, 'date' => nil} + + structures.each do |regexp| + matches = Regexp.new(regexp).match(heading) + captures.merge!(Hash[matches.names.map.zip(matches.captures)]) unless matches.nil? + end + + captures + end + + # Parse the given ChangeLog data into a Hash + # + # @param [String] data File data from the ChangeLog.md + # @return [Hash] Parsed data, e.g. [{ 'version' => ..., 'url' => ..., 'date' => ..., 'content' => ...}, ...] + def parse(data) + sections = data.split(/^## .+?$/) + headings = data.scan(/^## .+?$/) + changelog = [] + + headings.each_with_index do |heading, index| + captures = parse_heading(heading) + captures['content'] = sections.at(index + 1) + changelog.push captures + end + + changelog + end + + def read(file_path) + parse File.read(file_path) + end + end +end
Implement Reader class to parse ChangeLog.md
diff --git a/lib/starting_blocks/minitest_contract.rb b/lib/starting_blocks/minitest_contract.rb index abc1234..def5678 100644 --- a/lib/starting_blocks/minitest_contract.rb +++ b/lib/starting_blocks/minitest_contract.rb @@ -52,9 +52,9 @@ def execute_these_files files requires = files.map { |x| "require '#{x}'" }.join("\n") if options[:use_bundler] - `bundle exec ruby -e "#{requires}"` + Bash.run "bundle exec ruby -e \"#{requires}\"" else - `ruby -e "#{requires}"` + Bash.run "ruby -e \"#{requires}\"" end end
Use the new method for running a command.
diff --git a/lib/tasks/artefact_sections_to_tags.rake b/lib/tasks/artefact_sections_to_tags.rake index abc1234..def5678 100644 --- a/lib/tasks/artefact_sections_to_tags.rake +++ b/lib/tasks/artefact_sections_to_tags.rake @@ -0,0 +1,53 @@+namespace :sections do + + desc "Migrate artefacts to use tags for section information" + task :artefact_sections_to_tags => :environment do + + IMPORTING_LEGACY_DATA = true # Allow resaving artefacts with no need ID + + # Artefacts where section doesn't exist: leave them + # Artefacts where section is nil or empty string: unset section + # Artefacts where section is top-level: + # set top-level section tag; + # set primary section; + # unset section + # Artefacts where section is sub-level: + # set [sub-level, top-level]; + # set primary section to sub-level; + # unset section + + # The current stable version of Mongo doesn't offer criteria updates + Artefact.any_in(:section => [nil, '']).each do |a| + a.unset 'section' + a.save! + end + + Artefact.where(:section.exists => true).each do |a| + section = a['section'] + + # Skip empty values: only useful in development + next if [nil, ''].include? section + + section_parts = section.split(':').map { |s| s.downcase.gsub(' ', '-') } + + case section_parts.length + when 1 + section_tags = section_parts + when 2 + section_tags = [section_parts.join('/'), section_parts[0]] + else + puts 'Wrong number of sections: aargh!' + raise RuntimeError + end + a.sections = section_tags # Will check the tags exist + a.primary_section = section_tags[0] + a.save! + puts "Sections: #{a.sections}; primary: #{a.primary_section}" + + # Word of warning: this *does* persist the artefact, even without save + a.unset 'section' + # a.save! + end + + end +end
Migrate the section field out of existence.
diff --git a/mssql/recipes/configure.rb b/mssql/recipes/configure.rb index abc1234..def5678 100644 --- a/mssql/recipes/configure.rb +++ b/mssql/recipes/configure.rb @@ -2,50 +2,24 @@ log_path = "#{node[:mssql][:root_path]}\\Logs" backup_path = "#{node[:mssql][:root_path]}\\Backups" -%w[ data_path log_path backup_path ].each do |path| +%w[ #{data_path} #{log_path} #{backup_path} ].each do |path| directory path do recursive true action :create end end -powershell_script "Configure MS SQL" do +registry_key "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\#{node[:mssql][:service_name]}\\MSSQLServer" do + values [{:name => "DefaultData", :type => :multi_string, :data => ["#{data_path}"]}, + {:name => "DefaultLog", :type => :multi_string, :data => ["#{log_path}"]}, + {:name => "BackupDirectory", :type => :multi_string, :data => ["#{backup_path}"]} + ] + action :create +end + +powershell_script "Restart MS SQL and dependendant services" do code <<-EOH - $script = @" - USE [master] - GO - - — Change default location for data files - EXEC xp_instance_regwrite - N'HKEY_LOCAL_MACHINE', - N'Software\\Microsoft\\MSSQLServer\\MSSQLServer', - N'DefaultData', - REG_SZ, - N'#{data_path}' - GO - - — Change default location for log files - EXEC xp_instance_regwrite - N'HKEY_LOCAL_MACHINE', - N'Software\\Microsoft\\MSSQLServer\\MSSQLServer', - N'DefaultLog', - REG_SZ, - N'#{log_path}' - GO - - — Change default location for backups - EXEC xp_instance_regwrite - N'HKEY_LOCAL_MACHINE', - N'Software\\Microsoft\\MSSQLServer\\MSSQLServer', - N'BackupDirectory', - REG_SZ, - N'#{backup_path}' - GO - " - Invoke-Sqlcmd -Query $script -ServerInstance "#{node[:mssql][:instance_name]}" - restart-service "#{node[:mssql][:service_name]}" -force -passthru - EOH action :run end
Change mssql registry key creation method
diff --git a/lib/aptrust/solr_helper.rb b/lib/aptrust/solr_helper.rb index abc1234..def5678 100644 --- a/lib/aptrust/solr_helper.rb +++ b/lib/aptrust/solr_helper.rb @@ -3,7 +3,7 @@ def filter_on_institution(solr_parameters, user_parameters) if current_user and !current_user.is? :admin solr_parameters[:fq] ||= [] - solr_parameters[:fq] << '+is_part_of_ssim:' + "\"" + "info:fedora/#{current_user.institution.pid}" + "\"" + solr_parameters[:fq] << "+#{Solrizer.solr_name("is_part_of", :symbol)}:\"info:fedora/#{current_user.institution.pid}\"" end end end
Improve solr fq based on Solrizer.solr_name as demoed by @cam156
diff --git a/lib/bandicoot/processor.rb b/lib/bandicoot/processor.rb index abc1234..def5678 100644 --- a/lib/bandicoot/processor.rb +++ b/lib/bandicoot/processor.rb @@ -26,9 +26,9 @@ end def process_scope(scope) - scoped_contents(scope.css).each_with_object([]) do |scoped_content, data| + scoped_contents(scope.css).each_with_object({}) do |scoped_content, data| scope.attributes.each do |attr| - data << scoped_content.at_css(attr.css_path).text.strip.chomp + data[attr.name] << scoped_content.at_css(attr.css_path).text.strip.chomp end end end
Change returned object from array to hash
diff --git a/lib/execjs/xtrn/routing.rb b/lib/execjs/xtrn/routing.rb index abc1234..def5678 100644 --- a/lib/execjs/xtrn/routing.rb +++ b/lib/execjs/xtrn/routing.rb @@ -1,5 +1,5 @@-module ExecJS::Xtrn - Racks=YAML.load <<-EOY +module ExecJS::Xtrn::Rack + Formats=YAML.load <<-EOY -: mime: text/x-yaml dump: YAML @@ -7,12 +7,18 @@ mime: appication/json dump: JSON EOY - Rack=Proc.new do |req| - f=Racks[req['action_dispatch.request.path_parameters'][:format]]||Racks['-'] + + def self.stats + ExecJS::Xtrn.stats.as_json + end + + def self.call req + f=Formats[req['action_dispatch.request.path_parameters'][:format]] || + Formats['-'] [ 200, {"Content-Type"=> f['mime']}, - [f['dump'].constantize.dump(stats.as_json)], + [f['dump'].constantize.dump(stats)], ] end end
Use Module instead of Proc
diff --git a/lib/email_address/active_record_validator.rb b/lib/email_address/active_record_validator.rb index abc1234..def5678 100644 --- a/lib/email_address/active_record_validator.rb +++ b/lib/email_address/active_record_validator.rb @@ -34,7 +34,7 @@ def validate_email(r,f) return if r[f].nil? e = EmailAddress.new(r[f]) - r.errors[f] << "Email Address Not Valid" unless e.valid? + r.errors[f] << (options[:message] || "Email Address Not Valid") unless e.valid? end end
Add option to customize error message Add option to customize error message when using ActiveRecordValidator.
diff --git a/lib/rack/handler/iodine.rb b/lib/rack/handler/iodine.rb index abc1234..def5678 100644 --- a/lib/rack/handler/iodine.rb +++ b/lib/rack/handler/iodine.rb @@ -7,7 +7,7 @@ # Runs a Rack app, as par the Rack handler requirements. def self.run(app, options = {}) # nested applications... is that a thing? - Iodine.listen(service: :http, handler: app, port: options[:Port], address: options[:Address]) + Iodine.listen(service: :http, handler: app, port: options[:Port], address: options[:Host]) # start Iodine Iodine.start
Fix listen host key name in options Hash Rack::Server passes the listen host as `:Host` and not `:Address`.
diff --git a/lib/stripe_mock/request_handlers/disputes.rb b/lib/stripe_mock/request_handlers/disputes.rb index abc1234..def5678 100644 --- a/lib/stripe_mock/request_handlers/disputes.rb +++ b/lib/stripe_mock/request_handlers/disputes.rb @@ -4,8 +4,8 @@ def Disputes.included(klass) klass.add_handler 'get /v1/disputes/(.*)', :get_dispute + klass.add_handler 'post /v1/disputes/(.*)/close', :close_dispute klass.add_handler 'post /v1/disputes/(.*)', :update_dispute - klass.add_handler 'post /v1/disputes/(.*)/close', :close_dispute klass.add_handler 'get /v1/disputes', :list_disputes end
Fix dispute end point handlers sequence
diff --git a/lib/stripe_mock/request_handlers/disputes.rb b/lib/stripe_mock/request_handlers/disputes.rb index abc1234..def5678 100644 --- a/lib/stripe_mock/request_handlers/disputes.rb +++ b/lib/stripe_mock/request_handlers/disputes.rb @@ -6,26 +6,23 @@ klass.add_handler 'get /v1/disputes/(.*)', :get_dispute klass.add_handler 'post /v1/disputes/(.*)', :update_dispute klass.add_handler 'post /v1/disputes/(.*)/close', :close_dispute - klass.add_handler 'get /v1/disputes', :list_disputes + klass.add_handler 'get /v1/disputes', :list_disputes end def get_dispute(route, method_url, params, headers) route =~ method_url - disputes[$1] = Data.mock_dispute(id: $1) assert_existence :dispute, $1, disputes[$1] end def update_dispute(route, method_url, params, headers) - route =~ method_url - dispute = assert_existence :dispute, $1, disputes[$1] + dispute = get_dispute(route, method_url, params, headers) dispute.merge!(params) dispute end def close_dispute(route, method_url, params, headers) - route =~ method_url - dispute = assert_existence :dispute, $1, disputes[$1] - dispute[:status] = "lost" + dispute = get_dispute(route, method_url, params, headers) + dispute.merge!({:status => 'lost'}) dispute end
Clean up dispute endpoints implementation
diff --git a/lib/tasks/maintenance.rake b/lib/tasks/maintenance.rake index abc1234..def5678 100644 --- a/lib/tasks/maintenance.rake +++ b/lib/tasks/maintenance.rake @@ -0,0 +1,37 @@+namespace :maintenance do + + desc 'Transfer routes from one operator specified as OLD_OPERATOR to another specified as NEW_OPERATOR' + task :transfer_operator_routes_and_stations => :environment do + unless ENV['OLD_OPERATOR'] and ENV['NEW_OPERATOR'] + usage_message "usage: rake maintenance:transfer_routes OLD_OPERATOR=old_operator_name NEW_OPERATOR=new_operator_name" + end + old_operator_name = ENV['OLD_OPERATOR'] + new_operator_name = ENV['NEW_OPERATOR'] + + old_operators = Operator.find(:all, :conditions => ['name = ?', old_operator_name]) + new_operators = Operator.find(:all, :conditions => ['name = ?', new_operator_name]) + operator_data = {old_operator_name => old_operators, new_operator_name => new_operators} + operator_data.each do |operator_name, operator_list| + if operator_list.size != 1 + raise "#{operator_list.size} operators found with name #{operator_name}: Stopping." + end + end + old_operator = old_operators.first + new_operator = new_operators.first + + old_operator.route_operators.each do |route_operator| + route = route_operator.route + RouteOperator.create!(:operator => new_operator, :route => route) + puts "Moving #{route.name} (destroyed route_operator association #{route_operator.id})" + route_operator.destroy + end + old_operator.stop_area_operators.each do |stop_area_operator| + stop_area = stop_area_operator.stop_area + StopAreaOperator.create!(:operator => new_operator, :stop_area => stop_area) + puts "Moving #{stop_area.name} (destroyed stop_area_operator association #{stop_area_operator.id})" + stop_area_operator.destroy + end + + end + +end
Add task for transferring routes from one operator to another.
diff --git a/lib/to_partial_path_fix.rb b/lib/to_partial_path_fix.rb index abc1234..def5678 100644 --- a/lib/to_partial_path_fix.rb +++ b/lib/to_partial_path_fix.rb @@ -8,7 +8,7 @@ def to_partial_path parts = self.class._to_partial_path.split('/') pluralized_parts = parts[0..-3].map { |p| p.pluralize } - "#{pluralized_parts.join('/')}/#{parts.last(2).join('/')}" + "#{pluralized_parts.join('/')}/#{parts.last(2).join('/')}".freeze end end end
Add .freeze on result path
diff --git a/jje/app/controllers/static_pages_controller.rb b/jje/app/controllers/static_pages_controller.rb index abc1234..def5678 100644 --- a/jje/app/controllers/static_pages_controller.rb +++ b/jje/app/controllers/static_pages_controller.rb @@ -18,11 +18,11 @@ def search if params[:q] and params[:q].length > 0 then @results = [] - @name_results = Problem.where("name = ?", :q) + @name_results = Problem.where("name = ?", "%#{:q}%") @name_results.each do |result| @results.push(result) end - @keyword_results = ProblemKeyword.where("keyword = ?", :q) + @keyword_results = ProblemKeyword.where("keyword = ?", "%#{:q}%") @keyword_results.each do |result| @results.push(Problem.where("id = ?", result.problem_id)) end
Fix one part of broken search function
diff --git a/lib/tychus/parsers/base.rb b/lib/tychus/parsers/base.rb index abc1234..def5678 100644 --- a/lib/tychus/parsers/base.rb +++ b/lib/tychus/parsers/base.rb @@ -32,7 +32,7 @@ @uri = uri @recipe = Recipe.new @doc = Nokogiri::HTML(open(uri)) - @recipe_doc = @doc.css(root_doc) + @recipe_doc = root_doc ? @doc.css(root_doc) : @doc end def clean_instructions(obj) @@ -51,6 +51,10 @@ self.class.recipe_attributes end + def root_doc + nil + end + def Value(obj) case obj when NullObject then nil
Fix bug when root_doc doesn't exist on inherited class
diff --git a/core/lib/spree/testing_support/factories/payment_factory.rb b/core/lib/spree/testing_support/factories/payment_factory.rb index abc1234..def5678 100644 --- a/core/lib/spree/testing_support/factories/payment_factory.rb +++ b/core/lib/spree/testing_support/factories/payment_factory.rb @@ -10,7 +10,7 @@ factory :check_payment, class: Spree::Payment do amount 45.75 - payment_method + association(:payment_method, factory: :check_payment_method) order end end
Use check payment method factory in Check payment factory
diff --git a/app/helpers/db_helpers.rb b/app/helpers/db_helpers.rb index abc1234..def5678 100644 --- a/app/helpers/db_helpers.rb +++ b/app/helpers/db_helpers.rb @@ -1,7 +1,7 @@ module DbHelpers def db_concat(*args) env = ENV['RAILS_ENV'] || 'development' - adapter = ActiveRecord::Base.configurations[env]['adapter'].to_sym + adapter = ActiveRecord::Base.configurations.configs_for(env_name:env)[:adapter].to_sym args.map! { |arg| arg.class == Symbol ? arg.to_s : arg } case adapter
CONFIG: Update method to get database name in db helper
diff --git a/lib/dm-types/enum.rb b/lib/dm-types/enum.rb index abc1234..def5678 100644 --- a/lib/dm-types/enum.rb +++ b/lib/dm-types/enum.rb @@ -18,7 +18,7 @@ end if defined?(::DataMapper::Validations) - unless model.skip_auto_validation_for?(self) + unless ::DataMapper::Validations::AutoValidations.skip_auto_validation_for?(self) allowed = flag_map.values_at(*flag_map.keys.sort) model.validates_within name, model.options_with_message({ :set => allowed }, self, :within) end
Update to reflect recent change in dm-validations. Change in dm-validations was to an `@api private` method, but I don't see how to remove the coupling between dm-types and dm-validations without invasive changes.
diff --git a/lib/gitlab/plugin.rb b/lib/gitlab/plugin.rb index abc1234..def5678 100644 --- a/lib/gitlab/plugin.rb +++ b/lib/gitlab/plugin.rb @@ -13,24 +13,11 @@ end def self.execute(file, data) - # Prepare the hook subprocess. Attach a pipe to its stdin, and merge - # both its stdout and stderr into our own stdout. - stdin_reader, stdin_writer = IO.pipe - hook_pid = spawn({}, file, in: stdin_reader, err: :out) - stdin_reader.close - - # Submit changes to the hook via its stdin. - begin - IO.copy_stream(StringIO.new(data.to_json), stdin_writer) - rescue Errno::EPIPE - # It is not an error if the hook does not consume all of its input. + _output, exit_status = Gitlab::Popen.popen([file]) do |stdin| + stdin.write(data.to_json) end - # Close the pipe to let the hook know there is no further input. - stdin_writer.close - - Process.wait(hook_pid) - $?.success? + exit_status.zero? end end end
Use Gitlab::Popen instead of spawn [ci skip] Signed-off-by: Dmitriy Zaporozhets <be23d75b156792e5acab51b196a2deb155d35d6a@gmail.com>
diff --git a/lib/happy/context.rb b/lib/happy/context.rb index abc1234..def5678 100644 --- a/lib/happy/context.rb +++ b/lib/happy/context.rb @@ -22,8 +22,10 @@ old_controller = self.controller self.controller = new_controller - # execute permissions block - controller.class.permissions_blk.try(:call, permissions, self) + # execute permissions block SMELL - better integration + if controller.class.respond_to?(:permissions_blk) + controller.class.permissions_blk.try(:call, permissions, self) + end # execute block yield
Make sure this stuff also works if happy/permissions is not loaded :)
diff --git a/lib/attr_accessible2strong_params/converter.rb b/lib/attr_accessible2strong_params/converter.rb index abc1234..def5678 100644 --- a/lib/attr_accessible2strong_params/converter.rb +++ b/lib/attr_accessible2strong_params/converter.rb @@ -5,9 +5,13 @@ class AttrAccessible2StrongParams::Converter def read_attr_accessible(filename) root_node, comments = parse_file_with_comments(filename) - m = root_node.each_node(:send).select {|n| n.children[1] == :attr_accessible}.first - @model_class_name = m.parent.parent.children[0].children[1] - @aa_list = m.each_node(:sym).collect {|n| n.children[0]} + aa_nodes = root_node.each_node(:send).select {|n| n.children[1] == :attr_accessible} + aa_fields = [] + aa_nodes.each do |m| + @model_class_name = m.parent.parent.children[0].children[1] + aa_fields <<= m.each_node(:sym).collect {|n| n.children[0]} + end + @model_fields = aa_fields.flatten end def write_controller_with_strong_params(filename)
Support attr_accessible appears multi times.
diff --git a/lib/leveldb.rb b/lib/leveldb.rb index abc1234..def5678 100644 --- a/lib/leveldb.rb +++ b/lib/leveldb.rb @@ -8,20 +8,28 @@ ## Loads or creates a LevelDB database as necessary, stored on disk at ## +pathname+. def new pathname - make pathname.to_str, true, false + make path_string(pathname), true, false end ## Creates a new LevelDB database stored on disk at +pathname+. Throws an ## exception if the database already exists. def create pathname - make pathname.to_str, true, true + make path_string(pathname), true, true end ## Loads a LevelDB database stored on disk at +pathname+. Throws an ## exception unless the database already exists. def load pathname - make pathname.to_str, false, false + make path_string(pathname), false, false end + + private + + ## Coerces the argument into a String for use as a filename/-path + def path_string pathname + File.respond_to?(:path) ? File.path(pathname) : pathname.to_str + end + end alias :includes? :exists?
Use File.path to coerce pathname arguments into Strings in 1.9 The previous commit introduced the use of #to_str on the given pathname to coerce it into a String, matching the behavior of File.open and other file handling functions under 1.8. Ruby 1.9 introduces the File.path method for this purpose and deprecates the use of #to_str on classes such as Pathname. This commit introduces a private helper, path_string, that uses File.path when available and falls back to #to_str otherwise. Tested with MRI 1.8.7 and 1.9.2.
diff --git a/lib/specter.rb b/lib/specter.rb index abc1234..def5678 100644 --- a/lib/specter.rb +++ b/lib/specter.rb @@ -50,8 +50,10 @@ yield rescue Exception => exception + flunk nil, Specter::DifferentException unless exception.kind_of? expected + + ensure flunk nil, Specter::MissingException unless exception - flunk nil, Specter::DifferentException unless exception.kind_of? expected end def flunk(message = nil, type = Specter::Flunked)
Fix check for raised exceptions.
diff --git a/docs/_plugins/copy_api_dirs.rb b/docs/_plugins/copy_api_dirs.rb index abc1234..def5678 100644 --- a/docs/_plugins/copy_api_dirs.rb +++ b/docs/_plugins/copy_api_dirs.rb @@ -16,7 +16,7 @@ # Copy over the scaladoc from each project into the docs directory. # This directory will be copied over to _site when `jekyll` command is run. projects.each do |project_name| - source = "../" + project_name + "/target/scala-2.9.1/api" + source = "../" + project_name + "/target/scala-2.9.2/api" dest = "api/" + project_name puts "echo making directory " + dest
Update Jekyll plugin to look at Scala 2.9.2 docs
diff --git a/lib/frecon/database.rb b/lib/frecon/database.rb index abc1234..def5678 100644 --- a/lib/frecon/database.rb +++ b/lib/frecon/database.rb @@ -10,12 +10,23 @@ require "logger" require "mongoid" +require "tempfile" +require "yaml" + require "frecon/models" module FReCon class Database - def self.setup(environment) - Mongoid.load!(File.join(File.dirname(__FILE__), "mongoid.yml"), environment) + def self.setup(environment, mongoid_hash = nil) + if mongoid_hash.is_a?(Hash) + mongoid_tempfile = Tempfile.new("FReCon") + mongoid_tempfile.write(mongoid_hash.to_yaml) + mongoid_tempfile.rewind + + Mongoid.load!(mongoid_tempfile.path, environment) + else + Mongoid.load!(File.join(File.dirname(__FILE__), "mongoid.yml"), environment) + end Mongoid.logger.level = Logger::DEBUG Mongoid.logger = Logger.new($stdout)
FReCon::Database.setup: Enable custom Hash for configuration. If a Hash is given, it is converted to yaml (via to_yaml) and written to a Tempfile. This Tempfile's path is passed to the Mongoid.load! method instead of the path to the "mongoid.yml" file. By default (If no `mongoid_hash' is given), FReCon::Database.setup will give Mongoid.load! the "mongoid.yml" file in the "lib/frecon/" directory's path.
diff --git a/lib/halation/config.rb b/lib/halation/config.rb index abc1234..def5678 100644 --- a/lib/halation/config.rb +++ b/lib/halation/config.rb @@ -5,6 +5,7 @@ module Halation # Application-wide configuraton. class Config + # :nodoc: DEFAULT_CONFIG_PATH = File.expand_path("~/.halation/config.yml").freeze attr_reader :artist
Add nodoc flag to DEFAULT_CONFIG_PATH.
diff --git a/config/application.rb b/config/application.rb index abc1234..def5678 100644 --- a/config/application.rb +++ b/config/application.rb @@ -28,6 +28,9 @@ # config.time_zone = 'Central Time (US & Canada)' config.time_zone = "London" + # Compress JS using a preprocessor. + config.assets.js_compressor = :uglifier + # Using a sass css compressor causes a scss file to be processed twice # (once to build, once to compress) which breaks the usage of "unquote" # to use CSS that has same function names as SCSS such as max.
Enable the js_compressor option for Sprockets Because the default for Rails 6 is to use webpack for JS the Sprockets js_compressor option is not set in the generated production.rb environment file. This leads to bloated file sizes in production so re-enable compression by explicitly setting it.
diff --git a/config/application.rb b/config/application.rb index abc1234..def5678 100644 --- a/config/application.rb +++ b/config/application.rb @@ -18,5 +18,6 @@ config.filter_parameters += [:password] config.assets.enabled = true config.assets.version = '1.0' + config.serve_static_assets = true end end
Add static assets config entry