From bd07a65eae8c1c6886c468102fd2f9cf66013cff Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Mon, 23 May 2016 17:44:58 -0700 Subject: [PATCH 1/9] update predicate for Rails 5 compatibility --- app/helpers/recurring_select_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/recurring_select_helper.rb b/app/helpers/recurring_select_helper.rb index b4fc7e70..33ee216c 100644 --- a/app/helpers/recurring_select_helper.rb +++ b/app/helpers/recurring_select_helper.rb @@ -2,7 +2,7 @@ module RecurringSelectHelper module FormHelper - if Rails::VERSION::MAJOR == 4 + if Rails::VERSION::MAJOR == 4 || Rails::VERSION::MAJOR == 5 def select_recurring(object, method, default_schedules = nil, options = {}, html_options = {}) RecurringSelectTag.new(object, method, self, default_schedules, options, html_options).render end From 59d8d2bb3f4a80fe2179674863bcfb4a4fd65292 Mon Sep 17 00:00:00 2001 From: Florian Wininger Date: Mon, 23 Apr 2018 13:48:16 +0200 Subject: [PATCH 2/9] Drop Rails 3 support Signed-off-by: Florian Wininger --- app/helpers/recurring_select_helper.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/app/helpers/recurring_select_helper.rb b/app/helpers/recurring_select_helper.rb index 33ee216c..c25a3f5b 100644 --- a/app/helpers/recurring_select_helper.rb +++ b/app/helpers/recurring_select_helper.rb @@ -2,14 +2,8 @@ module RecurringSelectHelper module FormHelper - if Rails::VERSION::MAJOR == 4 || Rails::VERSION::MAJOR == 5 - def select_recurring(object, method, default_schedules = nil, options = {}, html_options = {}) - RecurringSelectTag.new(object, method, self, default_schedules, options, html_options).render - end - elsif Rails::VERSION::MAJOR == 3 - def select_recurring(object, method, default_schedules = nil, options = {}, html_options = {}) - InstanceTag.new(object, method, self, options.delete(:object)).to_recurring_select_tag(default_schedules, options, html_options) - end + def select_recurring(object, method, default_schedules = nil, options = {}, html_options = {}) + RecurringSelectTag.new(object, method, self, default_schedules, options, html_options).render end end From a28d2b286b4f1ba78a268f07b1d2d8e51f1552e8 Mon Sep 17 00:00:00 2001 From: Florian Wininger Date: Mon, 23 Apr 2018 13:52:32 +0200 Subject: [PATCH 3/9] Update dependencies Signed-off-by: Florian Wininger --- Gemfile | 7 +- Gemfile.lock | 255 +++++++++++++++++++------------ recurring-select.sublime-project | 8 - recurring_select.gemspec | 8 +- 4 files changed, 163 insertions(+), 115 deletions(-) delete mode 100644 recurring-select.sublime-project diff --git a/Gemfile b/Gemfile index f9e1be74..29c2da29 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,9 @@ source 'https://rubygems.org' gemspec -gem 'pg', platform: :ruby -gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby +gem 'mysql2' gem 'jquery-rails' -gem 'rails', '~> 4.0.12' -gem 'sass-rails', '~> 4.0.5' +gem 'rails', '~> 5.2' +gem 'sass-rails', '~> 5.0' diff --git a/Gemfile.lock b/Gemfile.lock index 70357775..3ac4bb66 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,129 +4,186 @@ PATH recurring_select (2.0.0) coffee-rails (>= 3.1) ice_cube (>= 0.11) - jquery-rails (>= 3.0) - rails (>= 3.2) - sass-rails (>= 4.0) + jquery-rails (>= 4.0) + rails (>= 5.0) + sass-rails (>= 5.0) GEM remote: https://rubygems.org/ specs: - actionmailer (4.0.13) - actionpack (= 4.0.13) + actioncable (5.2.0) + actionpack (= 5.2.0) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.0) + actionpack (= 5.2.0) + actionview (= 5.2.0) + activejob (= 5.2.0) mail (~> 2.5, >= 2.5.4) - actionpack (4.0.13) - activesupport (= 4.0.13) - builder (~> 3.1.0) - erubis (~> 2.7.0) - rack (~> 1.5.2) - rack-test (~> 0.6.2) - activemodel (4.0.13) - activesupport (= 4.0.13) - builder (~> 3.1.0) - activerecord (4.0.13) - activemodel (= 4.0.13) - activerecord-deprecated_finders (~> 1.0.2) - activesupport (= 4.0.13) - arel (~> 4.0.0) - activerecord-deprecated_finders (1.0.4) - activesupport (4.0.13) - i18n (~> 0.6, >= 0.6.9) - minitest (~> 4.2) - multi_json (~> 1.3) - thread_safe (~> 0.1) - tzinfo (~> 0.3.37) - arel (4.0.2) - builder (3.1.4) - coffee-rails (4.1.0) + rails-dom-testing (~> 2.0) + actionpack (5.2.0) + actionview (= 5.2.0) + activesupport (= 5.2.0) + rack (~> 2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.0) + activesupport (= 5.2.0) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.0) + activesupport (= 5.2.0) + globalid (>= 0.3.6) + activemodel (5.2.0) + activesupport (= 5.2.0) + activerecord (5.2.0) + activemodel (= 5.2.0) + activesupport (= 5.2.0) + arel (>= 9.0) + activestorage (5.2.0) + actionpack (= 5.2.0) + activerecord (= 5.2.0) + marcel (~> 0.3.1) + activesupport (5.2.0) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + arel (9.0.0) + builder (3.2.3) + coffee-rails (4.2.2) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.0) + railties (>= 4.0.0) coffee-script (2.4.1) coffee-script-source execjs - coffee-script-source (1.9.1.1) - diff-lcs (1.2.5) - erubis (2.7.0) - execjs (2.6.0) - hike (1.2.3) - i18n (0.7.0) - ice_cube (0.13.0) - jquery-rails (3.1.2) - railties (>= 3.0, < 5.0) + coffee-script-source (1.12.2) + concurrent-ruby (1.0.5) + crass (1.0.4) + diff-lcs (1.3) + erubi (1.7.1) + execjs (2.7.0) + ffi (1.9.23) + globalid (0.4.1) + activesupport (>= 4.2.0) + i18n (1.0.1) + concurrent-ruby (~> 1.0) + ice_cube (0.16.2) + jquery-rails (4.3.3) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) thor (>= 0.14, < 2.0) - mail (2.6.3) - mime-types (>= 1.16, < 3) - mime-types (2.6.2) - minitest (4.7.5) - multi_json (1.11.2) - pg (0.17.1) - rack (1.5.5) - rack-test (0.6.3) - rack (>= 1.0) - rails (4.0.13) - actionmailer (= 4.0.13) - actionpack (= 4.0.13) - activerecord (= 4.0.13) - activesupport (= 4.0.13) - bundler (>= 1.3.0, < 2.0) - railties (= 4.0.13) - sprockets-rails (~> 2.0) - railties (4.0.13) - actionpack (= 4.0.13) - activesupport (= 4.0.13) + loofah (2.2.2) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.0) + mini_mime (>= 0.1.1) + marcel (0.3.2) + mimemagic (~> 0.3.2) + method_source (0.9.0) + mimemagic (0.3.2) + mini_mime (1.0.0) + mini_portile2 (2.3.0) + minitest (5.11.3) + mysql2 (0.5.1) + nio4r (2.3.0) + nokogiri (1.8.2) + mini_portile2 (~> 2.3.0) + rack (2.0.4) + rack-test (1.0.0) + rack (>= 1.0, < 3) + rails (5.2.0) + actioncable (= 5.2.0) + actionmailer (= 5.2.0) + actionpack (= 5.2.0) + actionview (= 5.2.0) + activejob (= 5.2.0) + activemodel (= 5.2.0) + activerecord (= 5.2.0) + activestorage (= 5.2.0) + activesupport (= 5.2.0) + bundler (>= 1.3.0) + railties (= 5.2.0) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.0.4) + loofah (~> 2.2, >= 2.2.2) + railties (5.2.0) + actionpack (= 5.2.0) + activesupport (= 5.2.0) + method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (10.4.2) - rspec (3.1.0) - rspec-core (~> 3.1.0) - rspec-expectations (~> 3.1.0) - rspec-mocks (~> 3.1.0) - rspec-core (3.1.7) - rspec-support (~> 3.1.0) - rspec-expectations (3.1.2) + rake (12.3.1) + rb-fsevent (0.10.3) + rb-inotify (0.9.10) + ffi (>= 0.5.0, < 2) + rspec (3.7.0) + rspec-core (~> 3.7.0) + rspec-expectations (~> 3.7.0) + rspec-mocks (~> 3.7.0) + rspec-core (3.7.1) + rspec-support (~> 3.7.0) + rspec-expectations (3.7.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.7.0) + rspec-mocks (3.7.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.1.0) - rspec-mocks (3.1.3) - rspec-support (~> 3.1.0) - rspec-rails (3.1.0) + rspec-support (~> 3.7.0) + rspec-rails (3.7.2) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec-core (~> 3.1.0) - rspec-expectations (~> 3.1.0) - rspec-mocks (~> 3.1.0) - rspec-support (~> 3.1.0) - rspec-support (3.1.2) - sass (3.2.19) - sass-rails (4.0.5) - railties (>= 4.0.0, < 5.0) - sass (~> 3.2.2) - sprockets (~> 2.8, < 3.0) - sprockets-rails (~> 2.0) - sprockets (2.12.4) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.3.3) - actionpack (>= 3.0) - activesupport (>= 3.0) + rspec-core (~> 3.7.0) + rspec-expectations (~> 3.7.0) + rspec-mocks (~> 3.7.0) + rspec-support (~> 3.7.0) + rspec-support (3.7.1) + sass (3.5.6) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sass-rails (5.0.7) + railties (>= 4.0.0, < 6) + sass (~> 3.1) sprockets (>= 2.8, < 4.0) - thor (0.19.1) - thread_safe (0.3.5) - tilt (1.4.1) - tzinfo (0.3.44) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + sprockets (3.7.1) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + thor (0.20.0) + thread_safe (0.3.6) + tilt (2.0.8) + tzinfo (1.2.5) + thread_safe (~> 0.1) + websocket-driver (0.7.0) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.3) PLATFORMS ruby DEPENDENCIES - activerecord-jdbcpostgresql-adapter - bundler (>= 1.3.5) + bundler (>= 1.16.1) jquery-rails - pg - rails (~> 4.0.12) + mysql2 + rails (~> 5.2) rake (>= 0.9.6) recurring_select! rspec (>= 2.14) rspec-rails (>= 2.14) - sass-rails (~> 4.0.5) + sass-rails (~> 5.0) + +BUNDLED WITH + 1.16.1 diff --git a/recurring-select.sublime-project b/recurring-select.sublime-project deleted file mode 100644 index 24db3031..00000000 --- a/recurring-select.sublime-project +++ /dev/null @@ -1,8 +0,0 @@ -{ - "folders": - [ - { - "path": "." - } - ] -} diff --git a/recurring_select.gemspec b/recurring_select.gemspec index d881ddcd..fed6f1b1 100644 --- a/recurring_select.gemspec +++ b/recurring_select.gemspec @@ -16,13 +16,13 @@ Gem::Specification.new do |s| s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"] s.test_files = Dir["test/**/*"] - s.add_dependency "rails", ">= 3.2" - s.add_dependency "jquery-rails", ">= 3.0" + s.add_dependency "rails", ">= 5.0" + s.add_dependency "jquery-rails", ">= 4.0" s.add_dependency "ice_cube", ">= 0.11" - s.add_dependency "sass-rails", ">= 4.0" + s.add_dependency "sass-rails", ">= 5.0" s.add_dependency "coffee-rails", ">= 3.1" - s.add_development_dependency "bundler", ">= 1.3.5" + s.add_development_dependency "bundler", ">= 1.16.1" s.add_development_dependency "rspec-rails", ">= 2.14" s.add_development_dependency "rspec", ">= 2.14" s.add_development_dependency "rake", ">= 0.9.6" From f4b7b3f3bf61d981ce848b67e3b08d0717d885d2 Mon Sep 17 00:00:00 2001 From: Florian Wininger Date: Mon, 23 Apr 2018 14:03:55 +0200 Subject: [PATCH 4/9] Do some rubocop enhancement Signed-off-by: Florian Wininger --- .rubocop.yml | 1 + .rubocop_todo.yml | 214 ++++++++++++++++++ Guardfile | 12 +- Rakefile | 5 +- app/helpers/recurring_select_helper.rb | 33 ++- app/middleware/recurring_select_middleware.rb | 12 +- lib/recurring_select.rb | 13 +- lib/recurring_select/engine.rb | 12 +- lib/recurring_select/version.rb | 2 +- recurring_select.gemspec | 38 ++-- script/rails | 6 +- .../helpers/recurring_select_helper_spec.rb | 31 ++- spec/dummy/Rakefile | 3 +- .../app/controllers/sample_controller.rb | 2 - spec/dummy/app/models/fake_model.rb | 1 + spec/dummy/config.ru | 2 +- spec/dummy/config/application.rb | 9 +- spec/dummy/config/boot.rb | 4 +- spec/dummy/config/environment.rb | 2 +- spec/dummy/config/environments/test.rb | 4 +- spec/dummy/script/rails | 4 +- spec/lib/recurring_select_spec.rb | 53 +++-- spec/spec_helper.rb | 6 +- 23 files changed, 335 insertions(+), 134 deletions(-) create mode 100644 .rubocop.yml create mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000..cc32da4b --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1 @@ +inherit_from: .rubocop_todo.yml diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 00000000..09b1bfab --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,214 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2018-04-23 14:03:34 +0200 using RuboCop version 0.55.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 1 +Lint/IneffectiveAccessModifier: + Exclude: + - 'lib/recurring_select.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Lint/ScriptPermission: + Exclude: + - 'Rakefile' + - 'spec/dummy/Rakefile' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. +Lint/UnusedBlockArgument: + Exclude: + - 'lib/recurring_select.rb' + - 'lib/recurring_select/engine.rb' + +# Offense count: 1 +# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods. +Lint/UselessAccessModifier: + Exclude: + - 'lib/recurring_select.rb' + +# Offense count: 1 +# Configuration parameters: CheckForMethodsWithNoSideEffects. +Lint/Void: + Exclude: + - 'spec/lib/recurring_select_spec.rb' + +# Offense count: 2 +Metrics/AbcSize: + Max: 63 + +# Offense count: 3 +# Configuration parameters: CountComments, ExcludedMethods. +Metrics/BlockLength: + Max: 51 + +# Offense count: 2 +Metrics/CyclomaticComplexity: + Max: 10 + +# Offense count: 5 +# Configuration parameters: CountComments. +Metrics/MethodLength: + Max: 30 + +# Offense count: 1 +# Configuration parameters: CountKeywordArgs. +Metrics/ParameterLists: + Max: 6 + +# Offense count: 2 +Metrics/PerceivedComplexity: + Max: 11 + +# Offense count: 1 +# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros. +# NamePrefix: is_, has_, have_ +# NamePrefixBlacklist: is_, has_, have_ +# NameWhitelist: is_a? +# MethodDefinitionMacros: define_method, define_singleton_method +Naming/PredicateName: + Exclude: + - 'spec/**/*' + - 'lib/recurring_select.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, conditionals +Style/AndOr: + Exclude: + - 'app/helpers/recurring_select_helper.rb' + - 'app/middleware/recurring_select_middleware.rb' + - 'lib/recurring_select.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods. +# SupportedStyles: line_count_based, semantic, braces_for_chaining +# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object +# FunctionalMethods: let, let!, subject, watch +# IgnoredMethods: lambda, proc, it +Style/BlockDelimiters: + Exclude: + - 'app/helpers/recurring_select_helper.rb' + - 'lib/recurring_select.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: braces, no_braces, context_dependent +Style/BracesAroundHashParameters: + Exclude: + - 'spec/lib/recurring_select_spec.rb' + +# Offense count: 8 +Style/Documentation: + Exclude: + - 'spec/**/*' + - 'test/**/*' + - 'app/helpers/recurring_select_helper.rb' + - 'app/middleware/recurring_select_middleware.rb' + - 'lib/recurring_select.rb' + - 'lib/recurring_select/engine.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: compact, expanded +Style/EmptyMethod: + Exclude: + - 'spec/dummy/app/controllers/sample_controller.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Style/IfUnlessModifier: + Exclude: + - 'app/helpers/recurring_select_helper.rb' + - 'lib/recurring_select.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: InverseMethods, InverseBlocks. +Style/InverseMethods: + Exclude: + - 'lib/recurring_select.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/MutableConstant: + Exclude: + - 'lib/recurring_select/version.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: both, prefix, postfix +Style/NegatedIf: + Exclude: + - 'app/helpers/recurring_select_helper.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/Not: + Exclude: + - 'lib/recurring_select.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: PreferredDelimiters. +Style/PercentLiteralDelimiters: + Exclude: + - 'spec/dummy/config/application.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/RedundantParentheses: + Exclude: + - 'Guardfile' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, AllowInnerSlashes. +# SupportedStyles: slashes, percent_r, mixed +Style/RegexpLiteral: + Exclude: + - 'app/middleware/recurring_select_middleware.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AllowIfMethodIsEmpty. +Style/SingleLineMethods: + Exclude: + - 'spec/dummy/app/models/fake_model.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: . +# SupportedStyles: use_perl_names, use_english_names +Style/SpecialGlobalVars: + EnforcedStyle: use_perl_names + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + EnforcedStyle: percent + MinSize: 3 + +# Offense count: 1 +# Cop supports --auto-correct. +Style/ZeroLengthPredicate: + Exclude: + - 'lib/recurring_select.rb' + +# Offense count: 55 +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Metrics/LineLength: + Max: 171 diff --git a/Guardfile b/Guardfile index fff12133..b59fb25a 100644 --- a/Guardfile +++ b/Guardfile @@ -1,7 +1,7 @@ # A sample Guardfile # More info at https://github.com/guard/guard#readme -guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do +guard 'spork', cucumber_env: { 'RAILS_ENV' => 'test' }, rspec_env: { 'RAILS_ENV' => 'test' } do watch('config/application.rb') watch('config/environment.rb') watch('config/environments/test.rb') @@ -14,13 +14,13 @@ guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAIL end guard 'rspec', ({ - :cli => "--drb --color --format documentation", - :run_all => { :cli => "--drb --color" }, + cli: '--drb --color --format documentation', + run_all: { cli: '--drb --color' } }) do watch(%r{^spec/.+_spec\.rb$}) - watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } - watch(%r{^app/helpers/(.+)\.rb$}) { |m| "spec/app/helpers/#{m[1]}_spec.rb" } - watch('spec/spec_helper.rb') { "spec" } + watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } + watch(%r{^app/helpers/(.+)\.rb$}) { |m| "spec/app/helpers/#{m[1]}_spec.rb" } + watch('spec/spec_helper.rb') { 'spec' } end # guard :jasmine do diff --git a/Rakefile b/Rakefile index 5c22f32e..e31e96b0 100644 --- a/Rakefile +++ b/Rakefile @@ -4,7 +4,7 @@ require 'bundler/setup' require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) -task :default => :spec +task default: :spec require 'rubygems/package_task' Bundler::GemHelper.install_tasks @@ -18,6 +18,5 @@ RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_files.include('lib/**/*.rb') end -APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__) +APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__) load 'rails/tasks/engine.rake' - diff --git a/app/helpers/recurring_select_helper.rb b/app/helpers/recurring_select_helper.rb index c25a3f5b..51fd643d 100644 --- a/app/helpers/recurring_select_helper.rb +++ b/app/helpers/recurring_select_helper.rb @@ -1,4 +1,4 @@ -require "ice_cube" +require 'ice_cube' module RecurringSelectHelper module FormHelper @@ -13,40 +13,39 @@ def select_recurring(method, default_schedules = nil, options = {}, html_options @template.class.send(:include, RecurringSelectHelper::FormHelper) end - @template.select_recurring(@object_name, method, default_schedules, options.merge(:object => @object), html_options) + @template.select_recurring(@object_name, method, default_schedules, options.merge(object: @object), html_options) end end module FormOptionsHelper def recurring_options_for_select(currently_selected_rule = nil, default_schedules = nil, options = {}) - options_array = [] - blank_option_label = options[:blank_label] || I18n.t("recurring_select.not_recurring") - blank_option = [blank_option_label, "null"] - separator = [I18n.t("recurring_select.or"), {:disabled => true}] + blank_option_label = options[:blank_label] || I18n.t('recurring_select.not_recurring') + blank_option = [blank_option_label, 'null'] + separator = [I18n.t('recurring_select.or'), { disabled: true }] if default_schedules.blank? if currently_selected_rule.present? options_array << ice_cube_rule_to_option(currently_selected_rule) options_array << separator - options_array << [I18n.t("recurring_select.change_schedule"), "custom"] + options_array << [I18n.t('recurring_select.change_schedule'), 'custom'] options_array << blank_option if options[:allow_blank] else options_array << blank_option - options_array << [I18n.t("recurring_select.set_schedule"), "custom"] + options_array << [I18n.t('recurring_select.set_schedule'), 'custom'] end else options_array << blank_option if options[:allow_blank] - options_array += default_schedules.collect{|dc| + options_array += default_schedules.collect { |dc| ice_cube_rule_to_option(dc) } if currently_selected_rule.present? and !current_rule_in_defaults?(currently_selected_rule, default_schedules) options_array << ice_cube_rule_to_option(currently_selected_rule, true) - custom_label = [I18n.t("recurring_select.new_custom_schedule"), "custom"] + custom_label = [I18n.t('recurring_select.new_custom_schedule'), 'custom'] else - custom_label = [I18n.t("recurring_select.custom_schedule"), "custom"] + custom_label = [I18n.t('recurring_select.custom_schedule'), 'custom'] end options_array << separator @@ -65,15 +64,15 @@ def ice_cube_rule_to_option(supplied_rule, custom = false) ar = [rule.to_s, rule.to_hash.to_json] if custom - ar[0] << "*" - ar << {"data-custom" => true} + ar[0] << '*' + ar << { 'data-custom' => true } end ar end def current_rule_in_defaults?(currently_selected_rule, default_schedules) - default_schedules.any?{|option| + default_schedules.any? { |option| option == currently_selected_rule or (option.is_a?(Array) and option[1] == currently_selected_rule) } @@ -85,7 +84,7 @@ module SelectHTMLOptions def recurring_select_html_options(html_options) html_options = html_options.stringify_keys - html_options["class"] = (html_options["class"].to_s.split + ["recurring_select"]).join(" ") + html_options['class'] = (html_options['class'].to_s.split + ['recurring_select']).join(' ') html_options end end @@ -127,10 +126,8 @@ def to_recurring_select_tag(default_schedules, options, html_options) recurring_options_for_select(value, default_schedules, options), options, value ) - content_tag("select", options, html_options) + content_tag('select', options, html_options) end end end - - end diff --git a/app/middleware/recurring_select_middleware.rb b/app/middleware/recurring_select_middleware.rb index 5ddc450e..9299840b 100644 --- a/app/middleware/recurring_select_middleware.rb +++ b/app/middleware/recurring_select_middleware.rb @@ -1,28 +1,26 @@ -require "ice_cube" +require 'ice_cube' class RecurringSelectMiddleware - def initialize(app) @app = app end def call(env) regexp = /^\/recurring_select\/translate\/(.*)/ - if env["PATH_INFO"] =~ regexp - I18n.locale = env["PATH_INFO"].scan(regexp).first.first + if env['PATH_INFO'] =~ regexp + I18n.locale = env['PATH_INFO'].scan(regexp).first.first request = Rack::Request.new(env) params = request.params params.symbolize_keys! if params and params[:rule_type] rule = RecurringSelect.dirty_hash_to_rule(params) - [200, {"Content-Type" => "text/html"}, [rule.to_s]] + [200, { 'Content-Type' => 'text/html' }, [rule.to_s]] else - [200, {"Content-Type" => "text/html"}, [""]] + [200, { 'Content-Type' => 'text/html' }, ['']] end else @app.call(env) end end - end diff --git a/lib/recurring_select.rb b/lib/recurring_select.rb index 5f727ed4..674cd8f7 100644 --- a/lib/recurring_select.rb +++ b/lib/recurring_select.rb @@ -1,8 +1,7 @@ -require "recurring_select/engine" -require "ice_cube" +require 'recurring_select/engine' +require 'ice_cube' module RecurringSelect - def self.dirty_hash_to_rule(params) if params.is_a? IceCube::Rule params @@ -35,13 +34,13 @@ def self.is_valid_rule?(possible_rule) # TODO: this should really have an extra step where it tries to perform the final parsing return true if possible_rule.is_a?(Hash) - false #only a hash or a string of a hash can be valid + false # only a hash or a string of a hash can be valid end private def self.filter_params(params) - params.reject!{|key, value| value.blank? || value=="null" } + params.reject! { |key, value| value.blank? || value == 'null' } params[:interval] = params[:interval].to_i if params[:interval] params[:week_start] = params[:week_start].to_i if params[:week_start] @@ -65,11 +64,11 @@ def self.filter_params(params) else originals = params[:validations][:day_of_week].dup params[:validations][:day_of_week] = {} - originals.each{|key, value| + originals.each { |key, value| params[:validations][:day_of_week][key.to_i] = value } end - params[:validations][:day_of_week].each{|key, value| + params[:validations][:day_of_week].each { |key, value| params[:validations][:day_of_week][key] = value.collect(&:to_i) } end diff --git a/lib/recurring_select/engine.rb b/lib/recurring_select/engine.rb index e53ad34a..01cff55b 100644 --- a/lib/recurring_select/engine.rb +++ b/lib/recurring_select/engine.rb @@ -1,16 +1,14 @@ module RecurringSelect class Engine < Rails::Engine - - initializer "recurring_select.extending_form_builder" do |app| - # config.to_prepare do + initializer 'recurring_select.extending_form_builder' do |app| + # config.to_prepare do ActionView::Helpers::FormHelper.send(:include, RecurringSelectHelper::FormHelper) ActionView::Helpers::FormOptionsHelper.send(:include, RecurringSelectHelper::FormOptionsHelper) ActionView::Helpers::FormBuilder.send(:include, RecurringSelectHelper::FormBuilder) end - - initializer "recurring_select.connecting_middleware" do |app| - app.middleware.use RecurringSelectMiddleware # insert_after ActionDispatch::ParamsParser, + + initializer 'recurring_select.connecting_middleware' do |app| + app.middleware.use RecurringSelectMiddleware # insert_after ActionDispatch::ParamsParser, end - end end diff --git a/lib/recurring_select/version.rb b/lib/recurring_select/version.rb index 86e59cce..6d9238a0 100644 --- a/lib/recurring_select/version.rb +++ b/lib/recurring_select/version.rb @@ -1,3 +1,3 @@ module RecurringSelect - VERSION = "2.0.0" + VERSION = '2.0.0' end diff --git a/recurring_select.gemspec b/recurring_select.gemspec index fed6f1b1..11086f23 100644 --- a/recurring_select.gemspec +++ b/recurring_select.gemspec @@ -1,31 +1,31 @@ -$:.push File.expand_path("../lib", __FILE__) +$:.push File.expand_path('lib', __dir__) # Maintain your gem's version: -require "recurring_select/version" +require 'recurring_select/version' # Describe your gem and declare its dependencies: Gem::Specification.new do |s| - s.name = "recurring_select" + s.name = 'recurring_select' s.version = RecurringSelect::VERSION - s.authors = ["Jobber", "Forrest Zeisler", "Nathan Youngman"] - s.email = ["forrest@getjobber.com"] - s.homepage = "http://github.com/getjobber/recurring_select" - s.summary = "A select helper which gives you magical powers to generate ice_cube rules." - s.description = "This gem provides a useful interface for creating recurring rules for the ice_cube gem." + s.authors = ['Jobber', 'Forrest Zeisler', 'Nathan Youngman'] + s.email = ['forrest@getjobber.com'] + s.homepage = 'http://github.com/getjobber/recurring_select' + s.summary = 'A select helper which gives you magical powers to generate ice_cube rules.' + s.description = 'This gem provides a useful interface for creating recurring rules for the ice_cube gem.' - s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"] - s.test_files = Dir["test/**/*"] + s.files = Dir['{app,config,db,lib}/**/*'] + ['MIT-LICENSE', 'Rakefile', 'README.md'] + s.test_files = Dir['test/**/*'] - s.add_dependency "rails", ">= 5.0" - s.add_dependency "jquery-rails", ">= 4.0" - s.add_dependency "ice_cube", ">= 0.11" - s.add_dependency "sass-rails", ">= 5.0" - s.add_dependency "coffee-rails", ">= 3.1" + s.add_dependency 'coffee-rails', '>= 3.1' + s.add_dependency 'ice_cube', '>= 0.11' + s.add_dependency 'jquery-rails', '>= 4.0' + s.add_dependency 'rails', '>= 5.0' + s.add_dependency 'sass-rails', '>= 5.0' - s.add_development_dependency "bundler", ">= 1.16.1" - s.add_development_dependency "rspec-rails", ">= 2.14" - s.add_development_dependency "rspec", ">= 2.14" - s.add_development_dependency "rake", ">= 0.9.6" + s.add_development_dependency 'bundler', '>= 1.16.1' + s.add_development_dependency 'rake', '>= 0.9.6' + s.add_development_dependency 'rspec', '>= 2.14' + s.add_development_dependency 'rspec-rails', '>= 2.14' s.license = 'MIT' end diff --git a/script/rails b/script/rails index 43098569..4d07ff54 100755 --- a/script/rails +++ b/script/rails @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -#!/usr/bin/env ruby +# !/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. -ENGINE_PATH = File.expand_path('../..', __FILE__) -load File.expand_path('../../spec/dummy/script/rails', __FILE__) +ENGINE_PATH = File.expand_path('..', __dir__) +load File.expand_path('../spec/dummy/script/rails', __dir__) diff --git a/spec/app/helpers/recurring_select_helper_spec.rb b/spec/app/helpers/recurring_select_helper_spec.rb index c43ce34a..17aa7cd7 100644 --- a/spec/app/helpers/recurring_select_helper_spec.rb +++ b/spec/app/helpers/recurring_select_helper_spec.rb @@ -1,13 +1,12 @@ require 'spec_helper' describe RecurringSelectHelper do - class FromTester include RecurringSelectHelper::FormOptionsHelper end - describe "#recurring_options_for_select" do - it "should use the correct options (basic)" do + describe '#recurring_options_for_select' do + it 'should use the correct options (basic)' do subject = FromTester.new subject.should_receive(:options_for_select).with( [ @@ -18,43 +17,43 @@ class FromTester subject.recurring_options_for_select end - it "should use the correct options (no defaults but custom rule)" do + it 'should use the correct options (no defaults but custom rule)' do subject = FromTester.new subject.should_receive(:options_for_select).with( [ - ["Weekly", IceCube::Rule.weekly.to_hash.to_json], - ['or', {:disabled => true}], + ['Weekly', IceCube::Rule.weekly.to_hash.to_json], + ['or', { disabled: true }], ['Change schedule...', 'custom'] ], IceCube::Rule.weekly.to_hash.to_json ) subject.recurring_options_for_select(IceCube::Rule.weekly, []) end - it "should use the correct options (defaults with no rule)" do + it 'should use the correct options (defaults with no rule)' do subject = FromTester.new subject.should_receive(:options_for_select).with( [ - ["Weekly", IceCube::Rule.weekly.to_hash.to_json], - ["Monthly", IceCube::Rule.monthly.to_hash.to_json], - ['or', {:disabled => true}], + ['Weekly', IceCube::Rule.weekly.to_hash.to_json], + ['Monthly', IceCube::Rule.monthly.to_hash.to_json], + ['or', { disabled: true }], ['Custom schedule...', 'custom'] ], 'null' ) subject.recurring_options_for_select(nil, [IceCube::Rule.weekly, IceCube::Rule.monthly]) end - it "should use the correct options (non-recurring rule with defaults)" do + it 'should use the correct options (non-recurring rule with defaults)' do subject = FromTester.new subject.should_receive(:options_for_select).with( [ - ["- not recurring -", 'null'], - ["different", 1], - ["Weekly", IceCube::Rule.weekly.to_hash.to_json], - ['or', {:disabled => true}], + ['- not recurring -', 'null'], + ['different', 1], + ['Weekly', IceCube::Rule.weekly.to_hash.to_json], + ['or', { disabled: true }], ['Custom schedule...', 'custom'] ], '1' ) - subject.recurring_options_for_select(1, [["different", 1], IceCube::Rule.weekly], :allow_blank => true) + subject.recurring_options_for_select(1, [['different', 1], IceCube::Rule.weekly], allow_blank: true) end end end diff --git a/spec/dummy/Rakefile b/spec/dummy/Rakefile index c0734f50..0b210da1 100644 --- a/spec/dummy/Rakefile +++ b/spec/dummy/Rakefile @@ -2,7 +2,6 @@ # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require File.expand_path('../config/application', __FILE__) +require File.expand_path('config/application', __dir__) Dummy::Application.load_tasks - diff --git a/spec/dummy/app/controllers/sample_controller.rb b/spec/dummy/app/controllers/sample_controller.rb index b0d3a678..1b6e218b 100644 --- a/spec/dummy/app/controllers/sample_controller.rb +++ b/spec/dummy/app/controllers/sample_controller.rb @@ -1,6 +1,4 @@ class SampleController < ApplicationController - def index end - end diff --git a/spec/dummy/app/models/fake_model.rb b/spec/dummy/app/models/fake_model.rb index 73ec77d4..24bc383c 100644 --- a/spec/dummy/app/models/fake_model.rb +++ b/spec/dummy/app/models/fake_model.rb @@ -15,5 +15,6 @@ def current_custom_rule end def non_recurring_rule; 1; end + def persisted?; false; end end diff --git a/spec/dummy/config.ru b/spec/dummy/config.ru index 1989ed8d..cbd74159 100644 --- a/spec/dummy/config.ru +++ b/spec/dummy/config.ru @@ -1,4 +1,4 @@ # This file is used by Rack-based servers to start the application. -require ::File.expand_path('../config/environment', __FILE__) +require ::File.expand_path('../config/environment', __FILE__) run Dummy::Application diff --git a/spec/dummy/config/application.rb b/spec/dummy/config/application.rb index e6e55311..c1844948 100644 --- a/spec/dummy/config/application.rb +++ b/spec/dummy/config/application.rb @@ -1,9 +1,9 @@ -require File.expand_path('../boot', __FILE__) +require File.expand_path('boot', __dir__) require 'rails/all' -Bundler.require(*Rails.groups(:assets => %w(development test))) -require "recurring_select" +Bundler.require(*Rails.groups(assets: %w(development test))) +require 'recurring_select' module Dummy class Application < Rails::Application @@ -30,7 +30,7 @@ class Application < Rails::Application # config.i18n.default_locale = :de # Configure the default encoding used in templates for Ruby 1.9. - config.encoding = "utf-8" + config.encoding = 'utf-8' # Configure sensitive parameters which will be filtered from the log file. config.filter_parameters += [:password] @@ -42,4 +42,3 @@ class Application < Rails::Application config.assets.version = '1.0' end end - diff --git a/spec/dummy/config/boot.rb b/spec/dummy/config/boot.rb index eba06813..97ac260c 100644 --- a/spec/dummy/config/boot.rb +++ b/spec/dummy/config/boot.rb @@ -1,5 +1,5 @@ require 'rubygems' -gemfile = File.expand_path('../../../../Gemfile', __FILE__) +gemfile = File.expand_path('../../../Gemfile', __dir__) if File.exist?(gemfile) ENV['BUNDLE_GEMFILE'] = gemfile @@ -7,4 +7,4 @@ Bundler.setup end -$:.unshift File.expand_path('../../../../lib', __FILE__) \ No newline at end of file +$:.unshift File.expand_path('../../../lib', __dir__) diff --git a/spec/dummy/config/environment.rb b/spec/dummy/config/environment.rb index 3da5eb91..4b7e8894 100644 --- a/spec/dummy/config/environment.rb +++ b/spec/dummy/config/environment.rb @@ -1,5 +1,5 @@ # Load the rails application -require File.expand_path('../application', __FILE__) +require File.expand_path('application', __dir__) # Initialize the rails application Dummy::Application.initialize! diff --git a/spec/dummy/config/environments/test.rb b/spec/dummy/config/environments/test.rb index d8c47738..4996a0e8 100644 --- a/spec/dummy/config/environments/test.rb +++ b/spec/dummy/config/environments/test.rb @@ -9,7 +9,7 @@ # Configure static asset server for tests with Cache-Control for performance config.serve_static_assets = true - config.static_cache_control = "public, max-age=3600" + config.static_cache_control = 'public, max-age=3600' # Show full error reports and disable caching config.consider_all_requests_local = true @@ -19,7 +19,7 @@ config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment - config.action_controller.allow_forgery_protection = false + config.action_controller.allow_forgery_protection = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the diff --git a/spec/dummy/script/rails b/spec/dummy/script/rails index f8da2cff..3c234a25 100755 --- a/spec/dummy/script/rails +++ b/spec/dummy/script/rails @@ -1,6 +1,6 @@ #!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. -APP_PATH = File.expand_path('../../config/application', __FILE__) -require File.expand_path('../../config/boot', __FILE__) +APP_PATH = File.expand_path('../config/application', __dir__) +require File.expand_path('../config/boot', __dir__) require 'rails/commands' diff --git a/spec/lib/recurring_select_spec.rb b/spec/lib/recurring_select_spec.rb index 3b00fa5f..7a156f80 100644 --- a/spec/lib/recurring_select_spec.rb +++ b/spec/lib/recurring_select_spec.rb @@ -1,50 +1,49 @@ require 'spec_helper' describe RecurringSelect do - it "should be a module" do + it 'should be a module' do RecurringSelect.should be_kind_of Module end - describe "#is_valid_rule?" do - it "should identify invalid rules" do + describe '#is_valid_rule?' do + it 'should identify invalid rules' do RecurringSelect.should_not be_is_valid_rule(nil) - RecurringSelect.should_not be_is_valid_rule("") + RecurringSelect.should_not be_is_valid_rule('') RecurringSelect.should_not be_is_valid_rule(false) - RecurringSelect.should_not be_is_valid_rule("null") - RecurringSelect.should_not be_is_valid_rule("0") - RecurringSelect.should_not be_is_valid_rule("custom") + RecurringSelect.should_not be_is_valid_rule('null') + RecurringSelect.should_not be_is_valid_rule('0') + RecurringSelect.should_not be_is_valid_rule('custom') RecurringSelect.should_not be_is_valid_rule([1, 2]) end - it "should identify valid rules" do + it 'should identify valid rules' do RecurringSelect.should be_is_valid_rule(IceCube::Rule.weekly) RecurringSelect.should be_is_valid_rule(IceCube::Rule.weekly.to_hash) RecurringSelect.should be_is_valid_rule(IceCube::Rule.weekly.to_hash.to_json) end end - describe "#filter_params" do - it "Monthly with day_of_week" do + describe '#filter_params' do + it 'Monthly with day_of_week' do RecurringSelect.filter_params({ - :validations=>{"day_of_week"=>{"wednesday"=>["1", "3"]}}, - :rule_type=>"IceCube::MonthlyRule", - :interval=>1 - }).should == { - :validations=>{:day_of_week =>{:wednesday =>[1, 3]}}, - :rule_type=>"IceCube::MonthlyRule", - :interval=>1 - } + validations: { 'day_of_week' => { 'wednesday' => ['1', '3'] } }, + rule_type: 'IceCube::MonthlyRule', + interval: 1 + }).should == { + validations: { day_of_week: { wednesday: [1, 3] } }, + rule_type: 'IceCube::MonthlyRule', + interval: 1 + } RecurringSelect.filter_params({ - :validations=>{"day_of_week"=>{"2"=>["1", "3"]}}, - :rule_type=>"IceCube::MonthlyRule", - :interval=>1 - }).should == { - :validations=>{:day_of_week =>{2 =>[1, 3]}}, - :rule_type=>"IceCube::MonthlyRule", - :interval=>1 - } + validations: { 'day_of_week' => { '2' => ['1', '3'] } }, + rule_type: 'IceCube::MonthlyRule', + interval: 1 + }).should == { + validations: { day_of_week: { 2 => [1, 3] } }, + rule_type: 'IceCube::MonthlyRule', + interval: 1 + } end end - end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c4a4466c..6c618503 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,7 @@ -require "rspec" +require 'rspec' -ENV["RAILS_ENV"] = "test" -require File.expand_path("../dummy/config/environment.rb", __FILE__) +ENV['RAILS_ENV'] = 'test' +require File.expand_path('dummy/config/environment.rb', __dir__) Rails.backtrace_cleaner.remove_silencers! From 384fe33820ab811031ecd6da571d8aed95047fb7 Mon Sep 17 00:00:00 2001 From: Florian Wininger Date: Mon, 23 Apr 2018 14:05:05 +0200 Subject: [PATCH 5/9] Remove old ruby support Signed-off-by: Florian Wininger --- .ruby-version | 2 +- .travis.yml | 18 +----------------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/.ruby-version b/.ruby-version index ac2cdeba..73462a5a 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.1.3 +2.5.1 diff --git a/.travis.yml b/.travis.yml index 829f3efd..3f480141 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,25 +2,9 @@ sudo: false language: ruby script: bundle exec rspec spec rvm: - - 1.9.3 - - 2.0.0 - - 2.1.5 - 2.2.0 - - jruby-19mode + - 2.5.1 gemfile: - - spec/gemfiles/Gemfile.rails-4.0.x - - spec/gemfiles/Gemfile.rails-4.1.x - spec/gemfiles/Gemfile.rails-4.2.x -matrix: - exclude: - - rvm: 1.9.3 - gemfile: spec/gemfiles/rails-4.0.x.gemfile - - rvm: 1.9.3 - gemfile: spec/gemfiles/rails-4.1.x.gemfile - - rvm: 1.9.3 - gemfile: spec/gemfiles/rails-4.2.x.gemfile - - rvm: jruby-19mode - gemfile: spec/gemfiles/Gemfile.rails-3.2.x - fast_finish: true notifications: email: false From 46ec5f11069392a40ed1b4b2aeb31292beb2825e Mon Sep 17 00:00:00 2001 From: Florian Wininger Date: Mon, 23 Apr 2018 14:05:49 +0200 Subject: [PATCH 6/9] Remove unnecessary file Signed-off-by: Florian Wininger --- app/assets/images/recurring_select/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 app/assets/images/recurring_select/.gitkeep diff --git a/app/assets/images/recurring_select/.gitkeep b/app/assets/images/recurring_select/.gitkeep deleted file mode 100644 index e69de29b..00000000 From 2a608a499d8eb598837002985a179b51faf7619b Mon Sep 17 00:00:00 2001 From: Florian Wininger Date: Mon, 23 Apr 2018 14:09:52 +0200 Subject: [PATCH 7/9] Update rubocop_todo Signed-off-by: Florian Wininger --- .rubocop_todo.yml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 09b1bfab..bd491764 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2018-04-23 14:03:34 +0200 using RuboCop version 0.55.0. +# on 2018-04-23 14:09:14 +0200 using RuboCop version 0.55.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -76,6 +76,12 @@ Naming/PredicateName: - 'spec/**/*' - 'lib/recurring_select.rb' +# Offense count: 1 +# Cop supports --auto-correct. +Performance/RegexpMatch: + Exclude: + - 'app/middleware/recurring_select_middleware.rb' + # Offense count: 5 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. @@ -124,6 +130,13 @@ Style/EmptyMethod: Exclude: - 'spec/dummy/app/controllers/sample_controller.rb' +# Offense count: 36 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: when_needed, always, never +Style/FrozenStringLiteralComment: + Enabled: false + # Offense count: 4 # Cop supports --auto-correct. Style/IfUnlessModifier: @@ -158,6 +171,15 @@ Style/Not: Exclude: - 'lib/recurring_select.rb' +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, EnforcedStyle. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Exclude: + - 'spec/**/*' + - 'lib/recurring_select.rb' + # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: PreferredDelimiters. From 8ac05fe928cd8683dad0b1d1c713bb8693f5f51c Mon Sep 17 00:00:00 2001 From: Florian Wininger Date: Mon, 23 Apr 2018 14:10:10 +0200 Subject: [PATCH 8/9] Drop Rails 3 support Signed-off-by: Florian Wininger --- app/helpers/recurring_select_helper.rb | 53 ++++++++------------------ 1 file changed, 16 insertions(+), 37 deletions(-) diff --git a/app/helpers/recurring_select_helper.rb b/app/helpers/recurring_select_helper.rb index 51fd643d..a65375b5 100644 --- a/app/helpers/recurring_select_helper.rb +++ b/app/helpers/recurring_select_helper.rb @@ -89,45 +89,24 @@ def recurring_select_html_options(html_options) end end - if Rails::VERSION::STRING.to_f >= 4.0 - # === Rails 4 - class RecurringSelectTag < ActionView::Helpers::Tags::Base - include RecurringSelectHelper::FormOptionsHelper - include SelectHTMLOptions - - def initialize(object, method, template_object, default_schedules = nil, options = {}, html_options = {}) - @default_schedules = default_schedules - @choices = @choices.to_a if @choices.is_a?(Range) - @method_name = method.to_s - @object_name = object.to_s - @html_options = recurring_select_html_options(html_options) - add_default_name_and_id(@html_options) - - super(object, method, template_object, options) - end - - def render - option_tags = add_options(recurring_options_for_select(value(object), @default_schedules, @options), @options, value(object)) - select_content_tag(option_tags, @options, @html_options) - end + class RecurringSelectTag < ActionView::Helpers::Tags::Base + include RecurringSelectHelper::FormOptionsHelper + include SelectHTMLOptions + + def initialize(object, method, template_object, default_schedules = nil, options = {}, html_options = {}) + @default_schedules = default_schedules + @choices = @choices.to_a if @choices.is_a?(Range) + @method_name = method.to_s + @object_name = object.to_s + @html_options = recurring_select_html_options(html_options) + add_default_name_and_id(@html_options) + + super(object, method, template_object, options) end - else - # === Rails 3 - class InstanceTag < ActionView::Helpers::InstanceTag - include RecurringSelectHelper::FormOptionsHelper - include SelectHTMLOptions - - def to_recurring_select_tag(default_schedules, options, html_options) - html_options = recurring_select_html_options(html_options) - add_default_name_and_id(html_options) - value = value(object) - options = add_options( - recurring_options_for_select(value, default_schedules, options), - options, value - ) - content_tag('select', options, html_options) - end + def render + option_tags = add_options(recurring_options_for_select(value(object), @default_schedules, @options), @options, value(object)) + select_content_tag(option_tags, @options, @html_options) end end end From 6e8b2d6e6c3d84f2a0377487cba1bdd94aa05a80 Mon Sep 17 00:00:00 2001 From: Florian Wininger Date: Tue, 24 Apr 2018 13:17:57 +0200 Subject: [PATCH 9/9] Fix rails 5.2 Signed-off-by: Florian Wininger --- app/helpers/recurring_select_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/recurring_select_helper.rb b/app/helpers/recurring_select_helper.rb index a65375b5..1fb7f9ad 100644 --- a/app/helpers/recurring_select_helper.rb +++ b/app/helpers/recurring_select_helper.rb @@ -105,7 +105,7 @@ def initialize(object, method, template_object, default_schedules = nil, options end def render - option_tags = add_options(recurring_options_for_select(value(object), @default_schedules, @options), @options, value(object)) + option_tags = add_options(recurring_options_for_select(value, @default_schedules, @options), @options, value) select_content_tag(option_tags, @options, @html_options) end end