eac_ruby_utils 0.71.0 → 0.74.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eac_ruby_utils/gems_registry.rb +2 -3
- data/lib/eac_ruby_utils/gems_registry/gem.rb +36 -0
- data/lib/eac_ruby_utils/recursive_builder.rb +51 -0
- data/lib/eac_ruby_utils/rspec/default_setup.rb +4 -2
- data/lib/eac_ruby_utils/rspec/setup.rb +4 -37
- data/lib/eac_ruby_utils/rspec/setup/conditionals.rb +17 -0
- data/lib/eac_ruby_utils/rspec/setup_manager.rb +49 -0
- data/lib/eac_ruby_utils/version.rb +1 -1
- metadata +11 -4
- 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: c880b9a4d8c7f5bdeaeb79714b93d4cb06a27b60284351ce0efebc6604314a7f
|
4
|
+
data.tar.gz: 8f6673a2c76689929d05c263130013c5ac3194da3dd79308e5547f26106ff4f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b18f437b042599390df09581bbd8458598d9e1ed9db610393f5dae710c91414acf4363eab6d60f04fcb4612b9b20ffe340c3d24b050f4ea93512037196cebe18
|
7
|
+
data.tar.gz: 78c592a8a35f720d2cf4a6a7e97c920fb21ab98d1d6e5b6496cdc3ee1c8d97585d2e63125ff81d58a84a582b6e99f5f4adc96d565749c8a40bded6ba046fd7a5
|
@@ -28,9 +28,8 @@ module EacRubyUtils
|
|
28
28
|
|
29
29
|
# @return [Array<EacRubyUtils::GemsRegistry::Gem>]
|
30
30
|
def all_gems
|
31
|
-
::Gem::Specification.map
|
32
|
-
|
33
|
-
end
|
31
|
+
::Gem::Specification.map { |gemspec| ::EacRubyUtils::GemsRegistry::Gem.new(self, gemspec) }
|
32
|
+
.sort
|
34
33
|
end
|
35
34
|
end
|
36
35
|
end
|
@@ -1,10 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'active_support/core_ext/string/inflections'
|
4
|
+
require 'eac_ruby_utils/recursive_builder'
|
5
|
+
require 'eac_ruby_utils/simple_cache'
|
4
6
|
|
5
7
|
module EacRubyUtils
|
6
8
|
class GemsRegistry
|
7
9
|
class Gem
|
10
|
+
include ::Comparable
|
11
|
+
include ::EacRubyUtils::SimpleCache
|
12
|
+
|
8
13
|
attr_reader :registry, :gemspec
|
9
14
|
|
10
15
|
def initialize(registry, gemspec)
|
@@ -12,6 +17,23 @@ module EacRubyUtils
|
|
12
17
|
@gemspec = gemspec
|
13
18
|
end
|
14
19
|
|
20
|
+
def depend_on(gem)
|
21
|
+
dependencies.lazy.map(&:name).include?(gem.gemspec.name)
|
22
|
+
end
|
23
|
+
|
24
|
+
def dependencies
|
25
|
+
@dependencies ||= dependencies_uncached # dependencies_uncached
|
26
|
+
end
|
27
|
+
|
28
|
+
def <=>(other)
|
29
|
+
sd = depend_on(other)
|
30
|
+
od = other.depend_on(self)
|
31
|
+
return 1 if sd && !od
|
32
|
+
return -1 if od && !sd
|
33
|
+
|
34
|
+
gemspec.name <=> other.gemspec.name
|
35
|
+
end
|
36
|
+
|
15
37
|
def found?
|
16
38
|
lib_file_found? && registered_module.is_a?(::Module)
|
17
39
|
end
|
@@ -34,6 +56,20 @@ module EacRubyUtils
|
|
34
56
|
def path_to_require
|
35
57
|
gemspec.name.gsub('-', '/') + '/' + registry.module_suffix.underscore
|
36
58
|
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def dependencies_uncached
|
63
|
+
::EacRubyUtils::RecursiveBuilder
|
64
|
+
.new(gemspec) { |item| gem_item_dependencies(item) }
|
65
|
+
.result
|
66
|
+
end
|
67
|
+
|
68
|
+
def gem_item_dependencies(item)
|
69
|
+
::Gem::Specification.find_by_name(item.name).dependencies
|
70
|
+
rescue ::Gem::MissingSpecError
|
71
|
+
[]
|
72
|
+
end
|
37
73
|
end
|
38
74
|
end
|
39
75
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/simple_cache'
|
4
|
+
|
5
|
+
module EacRubyUtils
|
6
|
+
class RecursiveBuilder
|
7
|
+
include ::EacRubyUtils::SimpleCache
|
8
|
+
|
9
|
+
attr_reader :root, :neighbors_block
|
10
|
+
|
11
|
+
def initialize(root, &neighbors_block)
|
12
|
+
@root = root
|
13
|
+
@neighbors_block = neighbors_block
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_reader :added, :to_check
|
19
|
+
|
20
|
+
def result_uncached
|
21
|
+
@added = []
|
22
|
+
@to_check = []
|
23
|
+
item_try_add_to_check(root)
|
24
|
+
while check_next_item
|
25
|
+
# Do nothing
|
26
|
+
end
|
27
|
+
added
|
28
|
+
end
|
29
|
+
|
30
|
+
def item_try_add_to_check(item)
|
31
|
+
to_check << item unless item_added?(item)
|
32
|
+
end
|
33
|
+
|
34
|
+
def item_added?(item)
|
35
|
+
added.include?(item) || to_check.include?(item)
|
36
|
+
end
|
37
|
+
|
38
|
+
def check_next_item
|
39
|
+
return false unless to_check.any?
|
40
|
+
|
41
|
+
item = to_check.shift
|
42
|
+
added << item
|
43
|
+
item_neighborhs(item).each { |sub_item| item_try_add_to_check(sub_item) }
|
44
|
+
true
|
45
|
+
end
|
46
|
+
|
47
|
+
def item_neighborhs(item)
|
48
|
+
neighbors_block.call(item)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -1,17 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'eac_ruby_utils/rspec/
|
3
|
+
require 'eac_ruby_utils/rspec/setup_manager'
|
4
4
|
|
5
5
|
module EacRubyUtils
|
6
6
|
module Rspec
|
7
7
|
class << self
|
8
|
+
# @return [EacRubyUtils::Rspec::SetupManager]
|
8
9
|
def default_setup
|
9
10
|
@default_setup ||
|
10
11
|
raise("Default instance was not set. Use #{self.class.name}.default_setup_create")
|
11
12
|
end
|
12
13
|
|
14
|
+
# @return [EacRubyUtils::Rspec::SetupManager]
|
13
15
|
def default_setup_create(app_root_path, rspec_config = nil)
|
14
|
-
@default_setup = ::EacRubyUtils::Rspec::
|
16
|
+
@default_setup = ::EacRubyUtils::Rspec::SetupManager.create(app_root_path, rspec_config)
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
@@ -1,45 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'eac_ruby_utils/
|
4
|
-
require 'eac_ruby_utils/patches/object/if_respond'
|
5
|
-
require 'eac_ruby_utils/patches/object/to_pathname'
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
6
4
|
|
7
5
|
module EacRubyUtils
|
8
6
|
module Rspec
|
9
|
-
|
10
|
-
|
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
|
7
|
+
module Setup
|
8
|
+
extend ::ActiveSupport::Concern
|
9
|
+
require_sub __FILE__, include_modules: true
|
43
10
|
end
|
44
11
|
end
|
45
12
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacRubyUtils
|
4
|
+
module Rspec
|
5
|
+
module 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,49 @@
|
|
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
|
+
include_gem_registered(gem.registered_module)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# @param gem [EacRubyUtils::GemsRegistry::Gem]
|
44
|
+
def include_gem_registered(registered_module)
|
45
|
+
extend(registered_module)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
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.74.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-
|
11
|
+
date: 2021-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -73,6 +73,9 @@ dependencies:
|
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0.3'
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 0.3.2
|
76
79
|
type: :development
|
77
80
|
prerelease: false
|
78
81
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -80,6 +83,9 @@ dependencies:
|
|
80
83
|
- - "~>"
|
81
84
|
- !ruby/object:Gem::Version
|
82
85
|
version: '0.3'
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 0.3.2
|
83
89
|
description:
|
84
90
|
email:
|
85
91
|
executables: []
|
@@ -196,13 +202,14 @@ files:
|
|
196
202
|
- lib/eac_ruby_utils/patches/string/inflector.rb
|
197
203
|
- lib/eac_ruby_utils/patches/time.rb
|
198
204
|
- lib/eac_ruby_utils/patches/time/required_zone.rb
|
205
|
+
- lib/eac_ruby_utils/recursive_builder.rb
|
199
206
|
- lib/eac_ruby_utils/regexp_parser.rb
|
200
207
|
- lib/eac_ruby_utils/require_sub.rb
|
201
208
|
- lib/eac_ruby_utils/rspec.rb
|
202
|
-
- lib/eac_ruby_utils/rspec/conditional.rb
|
203
209
|
- lib/eac_ruby_utils/rspec/default_setup.rb
|
204
210
|
- lib/eac_ruby_utils/rspec/setup.rb
|
205
|
-
- lib/eac_ruby_utils/rspec/
|
211
|
+
- lib/eac_ruby_utils/rspec/setup/conditionals.rb
|
212
|
+
- lib/eac_ruby_utils/rspec/setup_manager.rb
|
206
213
|
- lib/eac_ruby_utils/ruby.rb
|
207
214
|
- lib/eac_ruby_utils/ruby/command.rb
|
208
215
|
- lib/eac_ruby_utils/ruby/on_clean_environment.rb
|
@@ -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
|