action_args 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e8f99c507ba7d9a77264851459c344095c6b3368
4
- data.tar.gz: 8ae5a3690c88d10ff55270705ad37558b66a1efc
3
+ metadata.gz: f9cb11e1b130b2399db5822b438360194f84367e
4
+ data.tar.gz: 9206b615c8d47577a55fc1e30e5ee4958842546f
5
5
  SHA512:
6
- metadata.gz: b7b0b63137e252a121d71d202891841548bb43b40daae9289112811b42b4cc1afe4477c3fe73ca81d572e8bd7f4bdfd41d95fcb1aa78219af3feabc407918437
7
- data.tar.gz: 16ad6ad19f3530e1773bc9f567d80a8c0c5b6366a9ba8e1c69bf6e3611d4817eaa58ba888d50c05766079fd1ca46fd131914007ae0c4838af0654c4ba2c43bcf
6
+ metadata.gz: 1c0e862e70f26c6fd50866fc95021c418f749e03b6b4ff9ae01a20d537e1744f29f73c7f8a79913cb99beeffdeaf9123ea9cb0148149ad9b9f7ccb606abcec83
7
+ data.tar.gz: e47c8285b8a7aae7e568cc91745607c03a6c43ff456955b7d8d608c374e41f9c999ba62e11861973a80864009b157d2a2b5d6d324c51f18ebd98027632382464
data/.travis.yml CHANGED
@@ -5,30 +5,40 @@ sudo: false
5
5
  rvm:
6
6
  - 2.0.0
7
7
  - 2.1.10
8
- - 2.2.5
9
- - 2.3.1
8
+ - 2.2.6
9
+ - 2.3.3
10
+ - 2.4.0
10
11
  - ruby-head
11
- - jruby-9.1.0.0
12
- - rbx-3
12
+ - jruby-9.1.8.0
13
+ - rubinius-3
13
14
  matrix:
14
15
  exclude:
15
- - rvm: ruby-head
16
- gemfile: gemfiles/rails_41.gemfile
17
- - rvm: ruby-head
18
- gemfile: gemfiles/rails_42.gemfile
19
16
  - rvm: 2.0.0
20
17
  gemfile: gemfiles/rails_50.gemfile
21
18
  - rvm: 2.1.10
22
19
  gemfile: gemfiles/rails_50.gemfile
20
+ - rvm: 2.0.0
21
+ gemfile: gemfiles/rails_51.gemfile
22
+ - rvm: 2.1.10
23
+ gemfile: gemfiles/rails_51.gemfile
23
24
  - rvm: 2.0.0
24
25
  gemfile: gemfiles/rails_edge.gemfile
25
26
  - rvm: 2.1.10
26
27
  gemfile: gemfiles/rails_edge.gemfile
28
+ - rvm: 2.4.0
29
+ gemfile: gemfiles/rails_41.gemfile
30
+ - rvm: 2.4.0
31
+ gemfile: gemfiles/rails_42.gemfile
32
+ - rvm: ruby-head
33
+ gemfile: gemfiles/rails_41.gemfile
34
+ - rvm: ruby-head
35
+ gemfile: gemfiles/rails_42.gemfile
27
36
  allow_failures:
28
- - rvm: jruby-9.1.0.0
29
- - rvm: rbx-3
37
+ - rvm: jruby-9.1.8.0
38
+ - rvm: rubinius-3
30
39
  gemfile:
31
40
  - gemfiles/rails_41.gemfile
32
41
  - gemfiles/rails_42.gemfile
33
42
  - gemfiles/rails_50.gemfile
43
+ - gemfiles/rails_51.gemfile
34
44
  - gemfiles/rails_edge.gemfile
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  source 'https://rubygems.org'
2
3
 
3
4
  # Specify your gem's dependencies in action_args.gemspec
data/README.md CHANGED
@@ -213,14 +213,14 @@ end
213
213
  ```
214
214
 
215
215
  You may notice that
216
- * There are no globalish `params` referrence
216
+ * There are no globalish `params` reference
217
217
  * It's quite easy to comprehend what's the actual input value for each action
218
218
  * You may write the unit test code as if the actions are just normal Ruby methods
219
219
 
220
220
 
221
221
  ## Supported versions
222
222
 
223
- * Ruby 2.0.0, 2.1.x, 2.2.x, 2.3.x, 2.4.0 (trunk), JRuby, & Rubinius with 2.0+ mode
223
+ * Ruby 2.0.0, 2.1.x, 2.2.x, 2.3.x, 2.4.x, 2.5.0 (trunk), JRuby, & Rubinius with 2.0+ mode
224
224
 
225
225
  * Rails 4.1.x, 4.2.x, 5.0, 5.1 (edge)
226
226
 
data/action_args.gemspec CHANGED
@@ -1,4 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ # frozen_string_literal: true
2
3
  $:.push File.expand_path("../lib", __FILE__)
3
4
  require 'action_args/version'
4
5
 
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
1
2
  source 'https://rubygems.org'
2
3
 
3
4
  gem 'rails', '~> 4.1.0'
5
+ gem 'nokogiri', RUBY_VERSION < '2.1' ? '~> 1.6.0' : '>= 1.7'
4
6
 
5
7
  gemspec :path => '../'
6
8
 
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
1
2
  source 'https://rubygems.org'
2
3
 
3
4
  gem 'rails', '~> 4.2.0'
5
+ gem 'nokogiri', RUBY_VERSION < '2.1' ? '~> 1.6.0' : '>= 1.7'
4
6
 
5
7
  gemspec :path => '../'
6
8
 
@@ -1,8 +1,14 @@
1
+ # frozen_string_literal: true
1
2
  source 'https://rubygems.org'
3
+ git_source(:github) do |repo_name|
4
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
5
+ "https://github.com/#{repo_name}.git"
6
+ end
2
7
 
3
- gem 'rails', '~> 5.0.0'
8
+ gem 'rails', '~> 5.0.1'
4
9
 
5
- gem 'rails-controller-testing'
10
+ # FIXME: bundle from GH master until > 1.0.1 release
11
+ gem 'rails-controller-testing', github: 'rails/rails-controller-testing'
6
12
 
7
13
  gemspec :path => '../'
8
14
 
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+ source 'https://rubygems.org'
3
+ git_source(:github) do |repo_name|
4
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
5
+ "https://github.com/#{repo_name}.git"
6
+ end
7
+
8
+ gem 'rails', '~> 5.1.0.beta1'
9
+
10
+ # FIXME: bundle from GH master until > 1.0.1 release
11
+ gem 'rails-controller-testing', github: 'rails/rails-controller-testing'
12
+
13
+ gemspec :path => '../'
14
+
15
+ platforms :ruby do
16
+ gem 'sqlite3'
17
+ end
18
+
19
+ platforms :jruby do
20
+ gem 'activerecord-jdbcsqlite3-adapter'
21
+ end
@@ -1,4 +1,9 @@
1
+ # frozen_string_literal: true
1
2
  source 'https://rubygems.org'
3
+ git_source(:github) do |repo_name|
4
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
5
+ "https://github.com/#{repo_name}.git"
6
+ end
2
7
 
3
8
  gem 'rails', github: 'rails/rails'
4
9
  gem 'rack', github: 'rack/rack'
@@ -6,7 +11,8 @@ gem 'arel', github: 'rails/arel'
6
11
  gem 'sprockets', github: 'rails/sprockets'
7
12
  gem 'sprockets-rails', github: 'rails/sprockets-rails'
8
13
  gem 'sass-rails', github: 'rails/sass-rails'
9
- gem 'rails-controller-testing'
14
+ # FIXME: bundle from GH master until > 1.0.1 release
15
+ gem 'rails-controller-testing', github: 'rails/rails-controller-testing'
10
16
 
11
17
  gemspec :path => '../'
12
18
 
data/lib/action_args.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'action_args/params_handler'
2
3
  require 'action_args/abstract_controller'
3
4
  require 'action_args/callbacks'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require_relative 'params_handler'
2
3
  using ActionArgs::ParamsHandler
3
4
 
@@ -26,12 +27,8 @@ module ActionArgs
26
27
  # end
27
28
  # end
28
29
  #
29
- def permits(*attributes)
30
- if attributes.last.is_a?(Hash) && attributes.last.extractable_options? && attributes.last.key?(:model_name)
31
- options = attributes.pop
32
- @permitting_model_name = options[:model_name]
33
- end
34
- @permitted_attributes = attributes
30
+ def permits(*attributes, model_name: nil)
31
+ @permitted_attributes, @permitting_model_name = attributes, model_name
35
32
  end
36
33
  end
37
34
  end
@@ -1,36 +1,67 @@
1
+ # frozen_string_literal: true
1
2
  using ActionArgs::ParamsHandler
2
3
 
3
4
  module ActionArgs
4
5
  module ActiveSupport
6
+ # For Rails >= 5.1
5
7
  module CallbackParameterizer
6
- # Extending AS::Callbacks::Callback's `make_lambda` not just to call specified
7
- # method but to call the method with method parameters taken from `params`.
8
- # This would happen only when
9
- # * the filter was defined in Symbol form
10
- # * the target object is_a ActionController object
11
- def make_lambda(filter)
12
- if Symbol === filter
13
- lambda do |target, _, &blk|
14
- if ActionController::Base === target
15
- target.strengthen_params! filter
16
- values = target.extract_method_arguments_from_params filter
17
- target.send filter, *values, &blk
18
- else
19
- target.send filter, &blk
20
- end
8
+ # Extending AS::Callbacks::Callback's `expand` not just to call specified
9
+ # method but to call the method with method parameters taken from `params`.
10
+ # This would happen only when
11
+ # * the target object is_a ActionController object
12
+ # * the filter was not defined via lambda
13
+ def expand(*)
14
+ target, block, method, *arguments = super
15
+
16
+ if (ActionController::Base === target) && (method != :instance_exec) && arguments.empty?
17
+ target.strengthen_params! method
18
+ arguments = target.extract_method_arguments_from_params method
19
+ end
20
+
21
+ [target, block, method, *arguments]
22
+ end
23
+ end
24
+
25
+ # For Rails 4 & 5.0
26
+ module CallbackParameterizerLegacy
27
+ # Extending AS::Callbacks::Callback's `make_lambda` not just to call specified
28
+ # method but to call the method with method parameters taken from `params`.
29
+ # This would happen only when
30
+ # * the filter was defined in Symbol form
31
+ # * the target object is_a ActionController object
32
+ def make_lambda(filter)
33
+ if Symbol === filter
34
+ lambda do |target, _, &blk|
35
+ if ActionController::Base === target
36
+ target.strengthen_params! filter
37
+ values = target.extract_method_arguments_from_params filter
38
+ target.send filter, *values, &blk
39
+ else
40
+ target.send filter, &blk
21
41
  end
22
- else
23
- super
24
42
  end
43
+ else
44
+ super
25
45
  end
46
+ end
26
47
  end
27
48
  end
28
49
  end
29
50
 
30
- module ActiveSupport
31
- module Callbacks
32
- class Callback
33
- prepend ActionArgs::ActiveSupport::CallbackParameterizer
51
+ if Rails.version >= '5.1'
52
+ module ActiveSupport
53
+ module Callbacks
54
+ class CallTemplate
55
+ prepend ActionArgs::ActiveSupport::CallbackParameterizer
56
+ end
57
+ end
58
+ end
59
+ else
60
+ module ActiveSupport
61
+ module Callbacks
62
+ class Callback
63
+ prepend ActionArgs::ActiveSupport::CallbackParameterizerLegacy
64
+ end
34
65
  end
35
66
  end
36
67
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ActionArgs
2
3
  module ParamsHandler
3
4
  refine AbstractController::Base do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ActionArgs
2
- VERSION = '2.1.0'
3
+ VERSION = '2.2.0'
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # load original rails scaffold_controller generator
2
3
  require 'rails/generators/rails/scaffold_controller/scaffold_controller_generator'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class BooksControllerTest < ActionController::TestCase
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class BooksControllerTest < ActionController::TestCase
@@ -12,8 +13,10 @@ class BooksControllerTest < ActionController::TestCase
12
13
  assert_equal @book, assigns(:book)
13
14
  end
14
15
 
15
- test 'via String' do
16
- assert assigns(:string_filter_executed)
16
+ if Rails.version < '5.1'
17
+ test 'via String' do
18
+ assert assigns(:string_filter_executed)
19
+ end
17
20
  end
18
21
 
19
22
  test 'via Proc' do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class KwBooksControllerTest < ActionController::TestCase
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class KwKeyreqBooksControllerTest < ActionController::TestCase
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class AuthorsControllerTest < ActionController::TestCase
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class StoresControllerTest < ActionController::TestCase
data/test/fake_app.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
4
  # config
4
5
  ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
@@ -68,7 +69,9 @@ end
68
69
  class BooksController < ApplicationController
69
70
  before_action :set_book, only: :show
70
71
  before_action -> { @proc_filter_executed = true }, only: :show
71
- before_action '@string_filter_executed = true', only: :show
72
+ if Rails.version < '5.1'
73
+ before_action '@string_filter_executed = true', only: :show
74
+ end
72
75
  around_action :benchmark_action
73
76
  before_action :omg
74
77
  skip_before_action :omg
@@ -147,7 +150,7 @@ require_relative 'kwargs_controllers'
147
150
  require_relative 'kwargs_keyreq_controllers' if RUBY_VERSION >= '2.1'
148
151
 
149
152
  # migrations
150
- class CreateAllTables < ActiveRecord::Migration
153
+ class CreateAllTables < ActiveRecord::VERSION::MAJOR >= 5 ? ActiveRecord::Migration[5.0] : ActiveRecord::Migration
151
154
  def self.up
152
155
  create_table(:authors) {|t| t.string :name}
153
156
  create_table(:books) {|t| t.string :title; t.integer :price}
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # this file should not be loaded from Ruby <2.0
2
3
 
3
4
  class KwBooksController < ApplicationController
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # this file should not be loaded from Ruby <2.1
2
3
 
3
4
  class KwKeyreqBooksController < ApplicationController
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
 
3
4
  class UserMailerTest < ActionMailer::TestCase
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'test_helper'
2
3
  using ActionArgs::ParamsHandler
3
4
 
data/test/test_helper.rb CHANGED
@@ -1,9 +1,14 @@
1
+ # frozen_string_literal: true
1
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
3
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
4
  # load Rails first
4
5
  require 'rails'
5
6
  require 'active_record'
6
7
  require 'action_controller/railtie'
8
+ begin
9
+ require 'rails-controller-testing'
10
+ rescue LoadError
11
+ end
7
12
  require 'action_args'
8
13
  require 'fake_app'
9
14
  require 'test/unit/rails/test_help'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_args
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akira Matsuda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-12 00:00:00.000000000 Z
11
+ date: 2017-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,6 +70,7 @@ files:
70
70
  - gemfiles/rails_41.gemfile
71
71
  - gemfiles/rails_42.gemfile
72
72
  - gemfiles/rails_50.gemfile
73
+ - gemfiles/rails_51.gemfile
73
74
  - gemfiles/rails_edge.gemfile
74
75
  - lib/action_args.rb
75
76
  - lib/action_args/abstract_controller.rb
@@ -109,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
110
  version: '0'
110
111
  requirements: []
111
112
  rubyforge_project:
112
- rubygems_version: 2.6.4
113
+ rubygems_version: 2.6.10
113
114
  signing_key:
114
115
  specification_version: 4
115
116
  summary: Controller action arguments parameterizer for Rails 4+ & Ruby 2.0+