eac_ruby_utils 0.67.0 → 0.70.0

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: 198a793b8a2d0993f304e80e7463e3350d0944450055e71daaa8494624225264
4
- data.tar.gz: 0e6f0f4edf00f4435ed0c129c9872aaeeeb66a503acbc5875b31c0fee4ad96e8
3
+ metadata.gz: 1d2cf379e2415d60c830cd336cd7e7f10defe243a844de933dfd260aea4c6170
4
+ data.tar.gz: de772d11fa31b9506914471b46a2fcba0c92f1c8c3d4fb5f0bd1f3127273e2af
5
5
  SHA512:
6
- metadata.gz: 67216e383d422fa5961f470823689d76978b2d21b21dc59338c9849198fbc41e198135ad3526f02ae1e4b30e64b5b72292d2b5a17d22b293ff71a48ecc72f405
7
- data.tar.gz: b678963a2c8d920b1c391af8f90a4ab2ccdf60a4fded2008b7d1d4dfb3261dccb164427fb0f1f6e706474a365ed4d7ebff661a64dce6b4364b415376d913ed03
6
+ metadata.gz: 87b220b118861f20ab93b700bbda9e0fef1992021f2ea9a1f33774650522947e925173302a959b612f1f0a4ab877347605c491638dea2f55634ad093f936670b
7
+ data.tar.gz: 49a65d53ee272fe9089c4944b7b115177ceac7a282bdc66fc13ecc689a1925cadc04d6cb62457b13193ed995405640617e9c65ed06f83d2368cd0494b30de4b0
@@ -6,7 +6,7 @@ module EacRubyUtils
6
6
  def parse(value)
7
7
  return parse_string(value) if value.is_a?(::String)
8
8
  return parse_string(value.to_s) if value.is_a?(::Symbol)
9
- return parse_number(value) if value.is_a?(::Number)
9
+ return parse_number(value) if value.is_a?(::Numeric)
10
10
 
11
11
  value ? true : false
12
12
  end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubygems'
4
+ require 'eac_ruby_utils/gems_registry/gem'
5
+
6
+ module EacRubyUtils
7
+ # Search in each gem for a class determined by registry and run the method "register" on each
8
+ # found.
9
+ #
10
+ # Example:
11
+ # * The module suffix is `TheClass`;
12
+ # * A gem with name "my-lib" is being analyzed
13
+ # * If a require for "my/lib/the_class" is succesful the class/module `My::Lib::TheClass` will
14
+ # be collected.
15
+ class GemsRegistry
16
+ attr_reader :module_suffix
17
+
18
+ def initialize(module_suffix)
19
+ @module_suffix = module_suffix
20
+ end
21
+
22
+ # @return [Array<EacRubyUtils::GemsRegistry::Gem>]
23
+ def registered
24
+ @registered ||= all_gems.select(&:found?)
25
+ end
26
+
27
+ private
28
+
29
+ # @return [Array<EacRubyUtils::GemsRegistry::Gem>]
30
+ def all_gems
31
+ ::Gem::Specification.map do |gemspec|
32
+ ::EacRubyUtils::GemsRegistry::Gem.new(self, gemspec)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/string/inflections'
4
+
5
+ module EacRubyUtils
6
+ class GemsRegistry
7
+ class Gem
8
+ attr_reader :registry, :gemspec
9
+
10
+ def initialize(registry, gemspec)
11
+ @registry = registry
12
+ @gemspec = gemspec
13
+ end
14
+
15
+ def found?
16
+ lib_file_found? && registered_module.is_a?(::Module)
17
+ end
18
+
19
+ def lib_file_found?
20
+ gemspec.require_paths.any? do |require_path|
21
+ ::Pathname.new(require_path).expand_path(gemspec.gem_dir).join(path_to_require + '.rb')
22
+ .file?
23
+ end
24
+ end
25
+
26
+ def registered_module
27
+ return nil unless lib_file_found?
28
+
29
+ require path_to_require
30
+ path_to_require.classify.constantize
31
+ end
32
+
33
+ # @return [String]
34
+ def path_to_require
35
+ gemspec.name.gsub('-', '/') + '/' + registry.module_suffix.underscore
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pathname'
4
+
5
+ class Pathname
6
+ # Apply .parent n times.
7
+ # @return [Pathname]
8
+ def parent_n(n) # rubocop:disable Naming/MethodParameterName
9
+ n.times.inject(self) { |a, _e| a.parent }
10
+ end
11
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/rspec/setup'
4
+
5
+ module EacRubyUtils
6
+ module Rspec
7
+ class << self
8
+ def default_setup
9
+ @default_setup ||
10
+ raise("Default instance was not set. Use #{self.class.name}.default_setup_create")
11
+ end
12
+
13
+ def default_setup_create(app_root_path, rspec_config = nil)
14
+ @default_setup = ::EacRubyUtils::Rspec::Setup.create(app_root_path, rspec_config)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/gems_registry'
4
+ require 'eac_ruby_utils/patches/object/if_respond'
5
+ require 'eac_ruby_utils/patches/object/to_pathname'
6
+
7
+ module EacRubyUtils
8
+ module Rspec
9
+ class Setup
10
+ GEMS_REGISTRY_SUFFIX = 'Rspec::SetupInclude'
11
+
12
+ class << self
13
+ def create(app_root_path, rspec_config = nil)
14
+ if rspec_config
15
+ new(app_root_path, rspec_config)
16
+ else
17
+ ::RSpec.configure { |new_rspec_config| new(app_root_path, new_rspec_config) }
18
+ end
19
+ end
20
+ end
21
+
22
+ attr_reader :app_root_path, :rspec_config
23
+
24
+ def initialize(app_root_path, rspec_config)
25
+ @app_root_path = app_root_path.to_pathname
26
+ @rspec_config = rspec_config
27
+ include_registry
28
+ end
29
+
30
+ # @return [EacRubyUtils::GemsRegistry]
31
+ def gems_registry
32
+ @gems_registry ||= ::EacRubyUtils::GemsRegistry.new(GEMS_REGISTRY_SUFFIX)
33
+ end
34
+
35
+ protected
36
+
37
+ def include_registry
38
+ gems_registry.registered.each do |gem|
39
+ singleton_class.include(gem.registered_module)
40
+ gem.registered_module.setup(self) if gem.registered_module.respond_to?(:setup)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -3,11 +3,19 @@
3
3
  module EacRubyUtils
4
4
  module SimpleCache
5
5
  UNCACHED_METHOD_NAME_SUFFIX = '_uncached'
6
- UNCACHED_METHOD_PATTERN = /\A(\s+)_#{::Regexp.quote(UNCACHED_METHOD_NAME_SUFFIX)}\z/.freeze
6
+ UNCACHED_METHOD_PATTERN = /
7
+ \A(\s+)_#{::Regexp.quote(UNCACHED_METHOD_NAME_SUFFIX)}([\!\?]?)\z
8
+ /x.freeze
7
9
 
8
10
  class << self
9
11
  def uncached_method_name(method_name)
10
- "#{method_name}#{UNCACHED_METHOD_NAME_SUFFIX}"
12
+ method_name = method_name.to_s
13
+ end_mark = nil
14
+ if %w[! ?].any? { |mark| method_name.end_with?(mark) }
15
+ end_mark = method_name[-1]
16
+ method_name = method_name[0..-2]
17
+ end
18
+ "#{method_name}#{UNCACHED_METHOD_NAME_SUFFIX}#{end_mark}"
11
19
  end
12
20
  end
13
21
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.67.0'
4
+ VERSION = '0.70.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_ruby_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.67.0
4
+ version: 0.70.0
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: 2021-06-08 00:00:00.000000000 Z
11
+ date: 2021-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.2'
75
+ version: '0.3'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.2'
82
+ version: '0.3'
83
83
  description:
84
84
  email:
85
85
  executables: []
@@ -131,6 +131,8 @@ files:
131
131
  - lib/eac_ruby_utils/fs/traversable.rb
132
132
  - lib/eac_ruby_utils/fs/traverser.rb
133
133
  - lib/eac_ruby_utils/fs_cache.rb
134
+ - lib/eac_ruby_utils/gems_registry.rb
135
+ - lib/eac_ruby_utils/gems_registry/gem.rb
134
136
  - lib/eac_ruby_utils/immutable.rb
135
137
  - lib/eac_ruby_utils/immutable/array_accessor.rb
136
138
  - lib/eac_ruby_utils/immutable/base_accessor.rb
@@ -186,6 +188,7 @@ files:
186
188
  - lib/eac_ruby_utils/patches/object/to_pathname.rb
187
189
  - lib/eac_ruby_utils/patches/pathname.rb
188
190
  - lib/eac_ruby_utils/patches/pathname/basename_sub.rb
191
+ - lib/eac_ruby_utils/patches/pathname/parent_n.rb
189
192
  - lib/eac_ruby_utils/patches/regexp.rb
190
193
  - lib/eac_ruby_utils/patches/regexp/if_match.rb
191
194
  - lib/eac_ruby_utils/patches/regexp/to_parser.rb
@@ -197,6 +200,8 @@ files:
197
200
  - lib/eac_ruby_utils/require_sub.rb
198
201
  - lib/eac_ruby_utils/rspec.rb
199
202
  - lib/eac_ruby_utils/rspec/conditional.rb
203
+ - lib/eac_ruby_utils/rspec/default_setup.rb
204
+ - lib/eac_ruby_utils/rspec/setup.rb
200
205
  - lib/eac_ruby_utils/rspec/stubbed_ssh.rb
201
206
  - lib/eac_ruby_utils/ruby.rb
202
207
  - lib/eac_ruby_utils/ruby/command.rb
@@ -229,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
234
  - !ruby/object:Gem::Version
230
235
  version: '0'
231
236
  requirements: []
232
- rubygems_version: 3.0.9
237
+ rubygems_version: 3.1.6
233
238
  signing_key:
234
239
  specification_version: 4
235
240
  summary: Utilities for E.A.C.'s Ruby projects.