can_can_dry 0.5.0 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3bf8f9e250599a1c4ab7da0ca8f4bfc8ea294f8ff8d6399ba113e4b93400aa3c
4
- data.tar.gz: 4ea554e0a534db616f0bfc1b544d5624ec7bbe163d2471f7d0217aefd136f211
3
+ metadata.gz: 5235cb0ce7810299e45a52f6942e855d2df2dad7de345675f6342837e1d607f4
4
+ data.tar.gz: 6e5852733b2c139c87041fc2ab8414b225672c197e3638317285c2fac8b6c40f
5
5
  SHA512:
6
- metadata.gz: 39f056216e6f56005d170b8d8fda89bc02bf4dc101527631f7969c178417d8da8f52583d97cffffe6cdd16ceb8e5538e53f16def4223b186c5a1c8e57bf01c39
7
- data.tar.gz: 64f39a8c9c27ca887a0113418d9fcb71757b38fdc13cae2300ec75eefbea57efba4580ab6ee47b362487043407eff22ef7b5cedf6501a09be37bb3392aa28940
6
+ metadata.gz: 0c9150ba70eedd217e2a08f5b43e6ca89c60f84290412a2a2e9b7519b66f749fb688e95043c933cc9758e59c98b17cd6030097141d8aeb43f6fb6f609191d0c6
7
+ data.tar.gz: c337a014e748999fddd9b4987966c8493e7f5051ef2cf89a78fb4063aa3901609a79e732d6622ebbb4e684310dd404a4e07f239f840ab3eeeb13afd784e8620c
@@ -1,55 +1,76 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_ruby_utils/core_ext'
4
+
3
5
  module CanCanDry
4
6
  # Copiado de https://github.com/appirits/awesome_admin_layout
5
7
  # /lib/awesome_admin_layout/recognize_path.rb
6
- module PathRecognizer
8
+ class PathRecognizer
7
9
  class << self
8
10
  def recognize(root_path, path, options = {})
9
- path = remove_root_path(root_path, path)
10
- Rails.application.routes.recognize_path(path, options)
11
- rescue ActionController::RoutingError
12
- Rails::Engine.subclasses.each do |engine|
13
- recognized_path = engine_recognize(engine, path, options)
14
- return recognized_path if recognized_path
15
- end
16
- raise "Path not recognized: \"#{path}\" (Options: #{options})"
11
+ new(root_path, path, options).recognize_or_raise
17
12
  end
18
13
 
19
- private
20
-
21
14
  def remove_root_path(root_path, path)
22
15
  path = path.gsub(/\A#{Regexp.quote(root_path)}/, '')
23
16
  path.gsub(%r{\A/*}, '/')
24
17
  end
18
+ end
19
+
20
+ common_constructor :root_path, :path, :options do
21
+ self.path = self.class.remove_root_path(root_path, path)
22
+ end
23
+
24
+ def recognize_or_raise
25
+ recognize || raise("Path not recognized: \"#{path}\" (Options: #{options})")
26
+ end
27
+
28
+ def recognize
29
+ core_recognize || engines_recognize
30
+ end
31
+
32
+ private
25
33
 
26
- def engine_recognize(engine, path, options)
27
- engine_path = path_for_engine(engine.instance.class, path)
28
- return unless engine_path
34
+ def core_recognize
35
+ Rails.application.routes.recognize_path(path, options)
36
+ rescue ActionController::RoutingError
37
+ nil
38
+ end
29
39
 
30
- begin
31
- return engine.instance.routes.recognize_path(engine_path, options)
32
- rescue ActionController::RoutingError => e
33
- Rails.logger.debug "[#{engine}] ActionController::RoutingError: #{e.message}"
34
- end
35
- nil
40
+ def engines_recognize
41
+ Rails::Engine.subclasses.each do |engine|
42
+ recognized_path = engine_recognize(engine)
43
+ return recognized_path if recognized_path
36
44
  end
45
+ nil
46
+ end
37
47
 
38
- def path_for_engine(engine_class, path)
39
- engine_route = Rails.application.routes.routes.find { |r| app_class_for(r) == engine_class }
40
- return unless engine_route
48
+ def engine_recognize(engine)
49
+ engine_path = path_for_engine(engine.instance.class)
50
+ return unless engine_path
41
51
 
42
- path.gsub(/^#{engine_route.path.spec}/, '')
52
+ begin
53
+ return engine.instance.routes.recognize_path(engine_path, options)
54
+ rescue ActionController::RoutingError => e
55
+ Rails.logger.debug "[#{engine}] ActionController::RoutingError: #{e.message}"
43
56
  end
57
+ nil
58
+ end
59
+
60
+ def path_for_engine(engine_class)
61
+ engine_route = Rails.application.routes.routes.find { |r| app_class_for(r) == engine_class }
62
+ return unless engine_route
63
+
64
+ path.gsub(/^#{engine_route.path.spec}/, '')
65
+ end
44
66
 
45
- def app_class_for(route)
46
- if Rails.version =~ /\A4\.2\./
47
- # for Rails 4.2
48
- route.app.app
49
- else
50
- # for Rails 4.1, 4.0, 3.2
51
- route.app
52
- end
67
+ def app_class_for(route)
68
+ if Rails.version >= '4.2'
69
+ # for Rails 4.2
70
+ route.app.app
71
+ else
72
+ # for Rails 4.1, 4.0, 3.2
73
+ route.app
53
74
  end
54
75
  end
55
76
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CanCanDry
4
- VERSION = '0.5.0'
4
+ VERSION = '0.5.4'
5
5
  end
@@ -1,7 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_gem_support/spec/examples/rubocop_check'
4
-
5
- RSpec.describe ::RuboCop do
6
- include_examples 'rubocop_check', ::File.expand_path('../..', __dir__)
7
- end
3
+ ::EacRubyUtils::Rspec.default_setup.describe_rubocop
data/spec/spec_helper.rb CHANGED
@@ -1,100 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # This file was generated by the `rspec --init` command. Conventionally, all
4
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
- # The generated `.rspec` file contains `--require spec_helper` which will cause
6
- # this file to always be loaded, without a need to explicitly require it in any
7
- # files.
8
- #
9
- # Given that it is always loaded, you are encouraged to keep this file as
10
- # light-weight as possible. Requiring heavyweight dependencies from this file
11
- # will add to the boot time of your test suite on EVERY test run, even for an
12
- # individual file that may not need all of that loaded. Instead, consider making
13
- # a separate helper file that requires the additional dependencies and performs
14
- # the additional setup, and require it from the spec files that actually need
15
- # it.
16
- #
17
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
18
- RSpec.configure do |config|
19
- # rspec-expectations config goes here. You can use an alternate
20
- # assertion/expectation library such as wrong or the stdlib/minitest
21
- # assertions if you prefer.
22
- config.expect_with :rspec do |expectations|
23
- # This option will default to `true` in RSpec 4. It makes the `description`
24
- # and `failure_message` of custom matchers include text for helper methods
25
- # defined using `chain`, e.g.:
26
- # be_bigger_than(2).and_smaller_than(4).description
27
- # # => "be bigger than 2 and smaller than 4"
28
- # ...rather than:
29
- # # => "be bigger than 2"
30
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
31
- end
32
-
33
- # rspec-mocks config goes here. You can use an alternate test double
34
- # library (such as bogus or mocha) by changing the `mock_with` option here.
35
- config.mock_with :rspec do |mocks|
36
- # Prevents you from mocking or stubbing a method that does not exist on
37
- # a real object. This is generally recommended, and will default to
38
- # `true` in RSpec 4.
39
- mocks.verify_partial_doubles = true
40
- end
41
-
42
- # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
43
- # have no way to turn it off -- the option exists only for backwards
44
- # compatibility in RSpec 3). It causes shared context metadata to be
45
- # inherited by the metadata hash of host groups and examples, rather than
46
- # triggering implicit auto-inclusion in groups with matching metadata.
47
- config.shared_context_metadata_behavior = :apply_to_host_groups
48
-
49
- # The settings below are suggested to provide a good initial experience
50
- # with RSpec, but feel free to customize to your heart's content.
51
- # # This allows you to limit a spec run to individual examples or groups
52
- # # you care about by tagging them with `:focus` metadata. When nothing
53
- # # is tagged with `:focus`, all examples get run. RSpec also provides
54
- # # aliases for `it`, `describe`, and `context` that include `:focus`
55
- # # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
56
- # config.filter_run_when_matching :focus
57
- #
58
- # # Allows RSpec to persist some state between runs in order to support
59
- # # the `--only-failures` and `--next-failure` CLI options. We recommend
60
- # # you configure your source control system to ignore this file.
61
- # config.example_status_persistence_file_path = "spec/examples.txt"
62
- #
63
- # # Limits the available syntax to the non-monkey patched syntax that is
64
- # # recommended. For more details, see:
65
- # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
66
- # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
67
- # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
68
- # config.disable_monkey_patching!
69
- #
70
- # # This setting enables warnings. It's recommended, but in some cases may
71
- # # be too noisy due to issues in dependencies.
72
- # config.warnings = true
73
- #
74
- # # Many RSpec users commonly either run the entire suite or an individual
75
- # # file, and it's useful to allow more verbose output when running an
76
- # # individual spec file.
77
- # if config.files_to_run.one?
78
- # # Use the documentation formatter for detailed output,
79
- # # unless a formatter has already been configured
80
- # # (e.g. via a command-line flag).
81
- # config.default_formatter = "doc"
82
- # end
83
- #
84
- # # Print the 10 slowest examples and example groups at the
85
- # # end of the spec run, to help surface which specs are running
86
- # # particularly slow.
87
- # config.profile_examples = 10
88
- #
89
- # # Run specs in random order to surface order dependencies. If you find an
90
- # # order dependency and want to debug it, you can fix the order by providing
91
- # # the seed, which is printed after each run.
92
- # # --seed 1234
93
- # config.order = :random
94
- #
95
- # # Seed global randomization in this process using the `--seed` CLI option.
96
- # # Setting this allows you to use `--seed` to deterministically reproduce
97
- # # test failures related to randomization by passing the same `--seed` value
98
- # # as the one that triggered the failure.
99
- # Kernel.srand config.seed
100
- end
3
+ require 'eac_ruby_utils/rspec/default_setup'
4
+ ::EacRubyUtils::Rspec.default_setup_create(::File.expand_path('..', __dir__))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: can_can_dry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-26 00:00:00.000000000 Z
11
+ date: 2021-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cancancan
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.21'
33
+ version: '0.72'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.21'
40
+ version: '0.72'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rails
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.1'
61
+ version: '0.4'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.1'
68
+ version: '0.4'
69
69
  description:
70
70
  email:
71
71
  executables: []
@@ -109,8 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  requirements: []
112
- rubyforge_project:
113
- rubygems_version: 2.7.7
112
+ rubygems_version: 3.1.6
114
113
  signing_key:
115
114
  specification_version: 4
116
115
  summary: DRY authorization with CanCanCan.