eac_ruby_utils 0.20.0 → 0.21.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
  SHA256:
3
- metadata.gz: 9ea98d22849b68a6392e5f73d923dd074a9782d9fa72307a0f518d019dbd86f3
4
- data.tar.gz: 148f036930d49255b5008d141f673c12f883a2a7ac40a89b1eff92123c74d9fb
3
+ metadata.gz: 36de192ccd40bc5d05d57d2c466042e0efcc6a57dec7bbd35d7fb0df05e2ff84
4
+ data.tar.gz: db5a334469a76fed656d1f9a02869abb0bc26aedaed6641e621a984cbb1b3745
5
5
  SHA512:
6
- metadata.gz: c1ec87fa319205a03babba70cd39b40ddcb845d2d811f8834544d6d2d30e70b21f7532400e02c82287406f779a20392830d836e591d9bbfc3ca41febb73dc43f
7
- data.tar.gz: 12c1d9821941704db27c1e095e3035322a6e2902317ba02702e3e84808da9f4caf0c77b63b27feda9f4c99e017ff2a6ca4a637bbed0b5f8b69ce3cad033d5ac0
6
+ metadata.gz: 7be9116caa7011ce58bd5096f735c1421caa2c6b42f67626c49a76732e237fe5bb18e7d2e4cc0fb235bdef7f83f176e99d0f6cf81d822315881d6ac42ce5ff04
7
+ data.tar.gz: 0f3898a0b962f1cd103a7d6bb9964c99bd0fbee10051afc0cb015280a62a71395aed18792bcd69d55524a5570430aa622e9a09a8213953a7aed9c7987a3fd49a
@@ -10,11 +10,6 @@ module EacRubyUtils
10
10
  require 'eac_ruby_utils/filesystem_cache'
11
11
  require 'eac_ruby_utils/fs_cache'
12
12
  require 'eac_ruby_utils/listable'
13
- require 'eac_ruby_utils/gem'
14
- require 'eac_ruby_utils/gem/minitest_test'
15
- require 'eac_ruby_utils/gem/rspec_test'
16
- require 'eac_ruby_utils/gem/test'
17
- require 'eac_ruby_utils/gem/test_all'
18
13
  require 'eac_ruby_utils/options_consumer'
19
14
  require 'eac_ruby_utils/settings_provider'
20
15
  require 'eac_ruby_utils/patch'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.20.0'
4
+ VERSION = '0.21.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.20.0
4
+ version: 0.21.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: 2020-02-27 00:00:00.000000000 Z
11
+ date: 2020-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -144,11 +144,6 @@ files:
144
144
  - lib/eac_ruby_utils/envs/ssh_env.rb
145
145
  - lib/eac_ruby_utils/filesystem_cache.rb
146
146
  - lib/eac_ruby_utils/fs_cache.rb
147
- - lib/eac_ruby_utils/gem.rb
148
- - lib/eac_ruby_utils/gem/minitest_test.rb
149
- - lib/eac_ruby_utils/gem/rspec_test.rb
150
- - lib/eac_ruby_utils/gem/test.rb
151
- - lib/eac_ruby_utils/gem/test_all.rb
152
147
  - lib/eac_ruby_utils/listable.rb
153
148
  - lib/eac_ruby_utils/listable/class_methods.rb
154
149
  - lib/eac_ruby_utils/listable/instance_methods.rb
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_ruby_utils/envs'
5
-
6
- module EacRubyUtils
7
- class Gem
8
- enable_simple_cache
9
-
10
- common_constructor :root
11
- set_callback :initialize, :after do
12
- @root = ::Pathname.new(root).expand_path
13
- end
14
-
15
- def to_s
16
- root.basename.to_s
17
- end
18
-
19
- def bundle(*args)
20
- ::EacRubyUtils::Envs.local.command('bundle', *args)
21
- .envvar('BUNDLE_GEMFILE', gemfile_path)
22
- .chdir(root)
23
- end
24
-
25
- def gemfile_lock_gem_version(gem_name)
26
- gemfile_lock_content.specs.find { |gem| gem.name == gem_name }.if_present(&:version)
27
- end
28
-
29
- def gemfile_lock_content
30
- ::Bundler::LockfileParser.new(::Bundler.read_file(gemfile_lock_path))
31
- end
32
-
33
- private
34
-
35
- def gemfile_path_uncached
36
- root.join('Gemfile')
37
- end
38
-
39
- def gemfile_lock_path_uncached
40
- root.join('Gemfile.lock')
41
- end
42
- end
43
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/gem/test'
4
-
5
- module EacRubyUtils
6
- class Gem
7
- class MinitestTest < ::EacRubyUtils::Gem::Test
8
- def bundle_exec_args
9
- %w[rake test]
10
- end
11
-
12
- def dependency_gem
13
- 'minitest'
14
- end
15
-
16
- def test_directory
17
- 'test'
18
- end
19
- end
20
- end
21
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/gem/test'
4
-
5
- module EacRubyUtils
6
- class Gem
7
- class RspecTest < ::EacRubyUtils::Gem::Test
8
- def bundle_exec_args
9
- %w[rspec]
10
- end
11
-
12
- def dependency_gem
13
- 'rspec-core'
14
- end
15
-
16
- def test_directory
17
- 'spec'
18
- end
19
- end
20
- end
21
- end
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_ruby_utils/fs_cache'
5
- require 'eac_ruby_utils/listable'
6
- require 'eac_ruby_utils/on_clean_ruby_environment'
7
-
8
- module EacRubyUtils
9
- class Gem
10
- class Test
11
- include ::EacRubyUtils::Listable
12
-
13
- enable_simple_cache
14
- lists.add_string :result, :failed, :nonexistent, :successful
15
-
16
- common_constructor :gem
17
-
18
- def elegible?
19
- dependency_present? && gem.root.join(test_directory).exist?
20
- end
21
-
22
- def dependency_present?
23
- gem.gemfile_path.exist? && gem.gemfile_lock_gem_version(dependency_gem).present?
24
- end
25
-
26
- def name
27
- self.class.name.demodulize.gsub(/Test\z/, '')
28
- end
29
-
30
- def stdout_cache
31
- root_cache.child('stdout')
32
- end
33
-
34
- def stderr_cache
35
- root_cache.child('stderr')
36
- end
37
-
38
- def to_s
39
- "#{gem}[#{name}]"
40
- end
41
-
42
- private
43
-
44
- def result_uncached
45
- return RESULT_NONEXISTENT unless elegible?
46
- bundle_run ? RESULT_SUCCESSFUL : RESULT_FAILED
47
- end
48
-
49
- def bundle_run
50
- r = ::EacRubyUtils.on_clean_ruby_environment do
51
- gem.bundle('exec', *bundle_exec_args).execute
52
- end
53
- stdout_cache.write(r[:stdout])
54
- stderr_cache.write(r[:stderr])
55
- r[:exit_code].zero?
56
- end
57
-
58
- def root_cache
59
- ::EacRubyUtils.fs_cache.child(gem.root.to_s.parameterize, self.class.name.parameterize)
60
- end
61
- end
62
- end
63
- end
@@ -1,94 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/gem/minitest_test'
4
- require 'eac_ruby_utils/gem/rspec_test'
5
-
6
- module EacRubyUtils
7
- class Gem
8
- class TestAll
9
- enable_console_speaker
10
- enable_simple_cache
11
- common_constructor :gems
12
- set_callback :initialize, :after, :run
13
-
14
- private
15
-
16
- def all_tests_uncached
17
- decorated_gems.flat_map(&:tests)
18
- end
19
-
20
- def bundle_all_gems
21
- infom 'Bundling all gems...'
22
- decorated_gems.each do |gem|
23
- next unless gem.gemfile_path.exist?
24
- infov 'Bundle install', gem
25
- gem.bundle.execute!
26
- end
27
- end
28
-
29
- def decorated_gems_uncached
30
- gems.map { |gem| DecoratedGem.new(gem) }
31
- end
32
-
33
- def failed_tests_uncached
34
- all_tests.select { |r| r.result == ::EacRubyUtils::Gem::Test::RESULT_FAILED }
35
- end
36
-
37
- def final_results_banner
38
- if failed_tests.any?
39
- warn 'Some test did not pass:'
40
- failed_tests.each do |test|
41
- infov ' * Test', test
42
- infov ' * STDOUT', test.stdout_cache.content_path
43
- infov ' * STDERR', test.stderr_cache.content_path
44
- end
45
- else
46
- success 'All tests passed'
47
- end
48
- end
49
-
50
- def run
51
- start_banner
52
- bundle_all_gems
53
- test_all_gems
54
- final_results_banner
55
- end
56
-
57
- def start_banner
58
- infov 'Gems to test', decorated_gems.count
59
- end
60
-
61
- def test_all_gems
62
- infom 'Running tests...'
63
- all_tests.each do |test|
64
- infov test, Result.new(test.result).tag
65
- end
66
- end
67
-
68
- class DecoratedGem < ::SimpleDelegator
69
- def tests
70
- [::EacRubyUtils::Gem::MinitestTest.new(__getobj__),
71
- ::EacRubyUtils::Gem::RspecTest.new(__getobj__)]
72
- end
73
- end
74
-
75
- class Result
76
- common_constructor :result
77
-
78
- COLORS = {
79
- ::EacRubyUtils::Gem::Test::RESULT_FAILED => :red,
80
- ::EacRubyUtils::Gem::Test::RESULT_NONEXISTENT => :white,
81
- ::EacRubyUtils::Gem::Test::RESULT_SUCCESSFUL => :green
82
- }.freeze
83
-
84
- def tag
85
- result.to_s.send(color)
86
- end
87
-
88
- def color
89
- COLORS.fetch(result)
90
- end
91
- end
92
- end
93
- end
94
- end