eac_ruby_utils 0.69.0 → 0.72.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 +4 -4
- data/lib/eac_ruby_utils/boolean.rb +1 -1
- data/lib/eac_ruby_utils/envs/executable.rb +15 -3
- data/lib/eac_ruby_utils/gems_registry.rb +36 -0
- data/lib/eac_ruby_utils/gems_registry/gem.rb +39 -0
- data/lib/eac_ruby_utils/rspec/default_setup.rb +20 -0
- data/lib/eac_ruby_utils/rspec/setup.rb +16 -0
- data/lib/eac_ruby_utils/rspec/setup/conditionals.rb +17 -0
- data/lib/eac_ruby_utils/rspec/setup_manager.rb +44 -0
- data/lib/eac_ruby_utils/version.rb +1 -1
- metadata +17 -7
- data/lib/eac_ruby_utils/rspec/conditional.rb +0 -35
- data/lib/eac_ruby_utils/rspec/stubbed_ssh.rb +0 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b24691000bd2898cc25e42008b85e0fd995ccb59469c90ed3605e188b6647b7
|
4
|
+
data.tar.gz: 8f574e39585fad8cf17ebaedebad4effce286ee97d2e3b94365168f6b337b055
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80d55c6dfe85ba433b85ab5564140fd392799a8a03e5608798c0ee6b74302cae8b4c181726d8c267546d98a512a35658ffefae984c5f96b1c3c0d916f3ca4aa2
|
7
|
+
data.tar.gz: d30fac4198006b23d93bc2aa7f34913be7ff833260ec4eaf59efe10f4ed35f30686f34509f730349539bc53288a5149a7d2431ec47bed958259fad8c6b63b11a
|
@@ -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?(::
|
9
|
+
return parse_number(value) if value.is_a?(::Numeric)
|
10
10
|
|
11
11
|
value ? true : false
|
12
12
|
end
|
@@ -22,7 +22,7 @@ module EacRubyUtils
|
|
22
22
|
def validate
|
23
23
|
return nil if exist?
|
24
24
|
|
25
|
-
"Program \"#{
|
25
|
+
"Program \"#{::Shellwords.join(executable_args)}\" not found in environment #{env}"
|
26
26
|
end
|
27
27
|
|
28
28
|
def validate!
|
@@ -33,13 +33,25 @@ module EacRubyUtils
|
|
33
33
|
|
34
34
|
def command(*command_args)
|
35
35
|
validate!
|
36
|
-
env.command(
|
36
|
+
env.command(*executable_args, *command_args)
|
37
|
+
end
|
38
|
+
|
39
|
+
def executable_args
|
40
|
+
executable_args_from_envvar || [name]
|
41
|
+
end
|
42
|
+
|
43
|
+
def executable_args_envvar
|
44
|
+
"#{name}_command".variableize.upcase
|
45
|
+
end
|
46
|
+
|
47
|
+
def executable_args_from_envvar
|
48
|
+
ENV[executable_args_envvar].if_present { |v| ::Shellwords.split(v) }
|
37
49
|
end
|
38
50
|
|
39
51
|
private
|
40
52
|
|
41
53
|
def exist_uncached
|
42
|
-
env.command(
|
54
|
+
env.command(*executable_args, *check_args).execute!
|
43
55
|
true
|
44
56
|
rescue Errno::ENOENT
|
45
57
|
false
|
@@ -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,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/rspec/setup_manager'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
module Rspec
|
7
|
+
class << self
|
8
|
+
# @return [EacRubyUtils::Rspec::SetupManager]
|
9
|
+
def default_setup
|
10
|
+
@default_setup ||
|
11
|
+
raise("Default instance was not set. Use #{self.class.name}.default_setup_create")
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [EacRubyUtils::Rspec::SetupManager]
|
15
|
+
def default_setup_create(app_root_path, rspec_config = nil)
|
16
|
+
@default_setup = ::EacRubyUtils::Rspec::SetupManager.create(app_root_path, rspec_config)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
module Rspec
|
7
|
+
class Setup
|
8
|
+
require_sub __FILE__
|
9
|
+
common_constructor :setup_obj
|
10
|
+
|
11
|
+
def perform
|
12
|
+
setup_obj.singleton_class.include(::EacRubyUtils::Rspec::Setup::Conditionals)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacRubyUtils
|
4
|
+
module Rspec
|
5
|
+
class Setup
|
6
|
+
module Conditionals
|
7
|
+
def conditional(tag, &condition)
|
8
|
+
message = condition.call
|
9
|
+
return if message.blank?
|
10
|
+
|
11
|
+
puts("[WARN] Excluded tag: #{tag}: #{message}")
|
12
|
+
rspec_config.filter_run_excluding tag
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,44 @@
|
|
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 SetupManager
|
10
|
+
GEMS_REGISTRY_SUFFIX = 'Rspec::Setup'
|
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
|
+
gem.registered_module.new(self).perform
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
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.
|
4
|
+
version: 0.72.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-07-
|
11
|
+
date: 2021-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -72,14 +72,20 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0.
|
75
|
+
version: '0.3'
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 0.3.1
|
76
79
|
type: :development
|
77
80
|
prerelease: false
|
78
81
|
version_requirements: !ruby/object:Gem::Requirement
|
79
82
|
requirements:
|
80
83
|
- - "~>"
|
81
84
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0.
|
85
|
+
version: '0.3'
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 0.3.1
|
83
89
|
description:
|
84
90
|
email:
|
85
91
|
executables: []
|
@@ -131,6 +137,8 @@ files:
|
|
131
137
|
- lib/eac_ruby_utils/fs/traversable.rb
|
132
138
|
- lib/eac_ruby_utils/fs/traverser.rb
|
133
139
|
- lib/eac_ruby_utils/fs_cache.rb
|
140
|
+
- lib/eac_ruby_utils/gems_registry.rb
|
141
|
+
- lib/eac_ruby_utils/gems_registry/gem.rb
|
134
142
|
- lib/eac_ruby_utils/immutable.rb
|
135
143
|
- lib/eac_ruby_utils/immutable/array_accessor.rb
|
136
144
|
- lib/eac_ruby_utils/immutable/base_accessor.rb
|
@@ -197,8 +205,10 @@ files:
|
|
197
205
|
- lib/eac_ruby_utils/regexp_parser.rb
|
198
206
|
- lib/eac_ruby_utils/require_sub.rb
|
199
207
|
- lib/eac_ruby_utils/rspec.rb
|
200
|
-
- lib/eac_ruby_utils/rspec/
|
201
|
-
- lib/eac_ruby_utils/rspec/
|
208
|
+
- lib/eac_ruby_utils/rspec/default_setup.rb
|
209
|
+
- lib/eac_ruby_utils/rspec/setup.rb
|
210
|
+
- lib/eac_ruby_utils/rspec/setup/conditionals.rb
|
211
|
+
- lib/eac_ruby_utils/rspec/setup_manager.rb
|
202
212
|
- lib/eac_ruby_utils/ruby.rb
|
203
213
|
- lib/eac_ruby_utils/ruby/command.rb
|
204
214
|
- lib/eac_ruby_utils/ruby/on_clean_environment.rb
|
@@ -230,7 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
230
240
|
- !ruby/object:Gem::Version
|
231
241
|
version: '0'
|
232
242
|
requirements: []
|
233
|
-
rubygems_version: 3.
|
243
|
+
rubygems_version: 3.1.6
|
234
244
|
signing_key:
|
235
245
|
specification_version: 4
|
236
246
|
summary: Utilities for E.A.C.'s Ruby projects.
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'active_support/core_ext/object/blank'
|
4
|
-
|
5
|
-
module EacRubyUtils
|
6
|
-
module Rspec
|
7
|
-
class Conditional
|
8
|
-
def self.default
|
9
|
-
@default ||= new
|
10
|
-
end
|
11
|
-
|
12
|
-
def initialize
|
13
|
-
@tags = {}
|
14
|
-
end
|
15
|
-
|
16
|
-
def add(tag, &condition)
|
17
|
-
tags[tag] = condition
|
18
|
-
end
|
19
|
-
|
20
|
-
def configure(rspec_config)
|
21
|
-
tags.each do |tag, condition|
|
22
|
-
message = condition.call
|
23
|
-
if message.present?
|
24
|
-
puts("[WARN] Excluded tag: #{tag}: #{message}")
|
25
|
-
rspec_config.filter_run_excluding tag
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
attr_reader :tags
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'active_support/core_ext/object/blank'
|
4
|
-
require 'eac_ruby_utils/envs/ssh_env'
|
5
|
-
require 'eac_ruby_utils/patches/object/if_present'
|
6
|
-
|
7
|
-
module EacRubyUtils
|
8
|
-
module Rspec
|
9
|
-
class StubbedSsh
|
10
|
-
DEFAULT_ENVVAR_NAME = 'STUBBED_SSH_URL'
|
11
|
-
|
12
|
-
class << self
|
13
|
-
def default
|
14
|
-
@default ||= new(DEFAULT_ENVVAR_NAME)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
attr_reader :envvar_name
|
19
|
-
|
20
|
-
def initialize(envvar_name)
|
21
|
-
@envvar_name = envvar_name
|
22
|
-
end
|
23
|
-
|
24
|
-
def validate
|
25
|
-
return nil if provided_url.present?
|
26
|
-
|
27
|
-
"Environment variable \"#{envvar_name}\" unprovided or blank"
|
28
|
-
end
|
29
|
-
|
30
|
-
def validate!
|
31
|
-
validate.if_present { |v| raise v }
|
32
|
-
end
|
33
|
-
|
34
|
-
def provided_url
|
35
|
-
ENV[envvar_name]
|
36
|
-
end
|
37
|
-
|
38
|
-
def build_env
|
39
|
-
validate!
|
40
|
-
::EacRubyUtils::Envs::SshEnv.new(provided_url)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|