eac_ruby_gems_utils 0.9.10 → 0.10.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: '0493496dc3a737bae887d400c587474ed81b7c00d497b0a21b50dbd7522495ef'
4
- data.tar.gz: 847f87433d77c5f1ad191f9856e059132a66947c31e05b80d9e9501e4c4ca847
3
+ metadata.gz: 97186383fb111da8af2e3c38989b41db1ef8c75c1d90872d9793308bfe8ba514
4
+ data.tar.gz: e8ca7537e7a2407f43eb7a7a574c1be74d9aa6cdbc34bc0decee9b16b2cca8f7
5
5
  SHA512:
6
- metadata.gz: 45f11ad6f1e965f725ad14b46f4d9c897570571c14e916d6bfa514e93b7ba6a0fbec8ee80f6736ade60716f464fc559efe1b22eece21a784474824c66ead110a
7
- data.tar.gz: 0bec84f384784c2c88d03889e4057ddc0b608b1b85958b046eaefea00370fcebaca62d6416586f487540a26b14c7f8ae0664d031865fbdb0a97a854842171405
6
+ metadata.gz: 1bfac8001f74cd7798b24e4d640daa12281cc8be06a8a95fde3557f3fdb45dc5970cd2e2b5fde7bd6bcf0cc7f69a8cec181df78a525adf2bba2e3d4571d60708
7
+ data.tar.gz: 329cbee10a5d8370c74c862eaf9a7fffa186e9aa56cd7bb8fab098646a3f0969f3f4a4011cbc16d6cb78ef76e3fae54f471270d68f3db4be3137d82bed24c982
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyGemsUtils
4
- VERSION = '0.9.10'
4
+ VERSION = '0.10.0'
5
5
  end
metadata CHANGED
@@ -1,43 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_ruby_gems_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.10
4
+ version: 0.10.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: 2022-06-04 00:00:00.000000000 Z
11
+ date: 2022-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: eac_fs
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '0.8'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '0.8'
41
13
  - !ruby/object:Gem::Dependency
42
14
  name: eac_ruby_utils
43
15
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +38,7 @@ dependencies:
66
38
  - - "~>"
67
39
  - !ruby/object:Gem::Version
68
40
  version: 0.5.1
69
- description:
41
+ description: 'Deprecated: use gem "avm-eac_ruby_base1" instead.'
70
42
  email:
71
43
  executables: []
72
44
  extensions: []
@@ -77,29 +49,9 @@ files:
77
49
  - Gemfile
78
50
  - README.rdoc
79
51
  - lib/eac_ruby_gems_utils.rb
80
- - lib/eac_ruby_gems_utils/gem.rb
81
- - lib/eac_ruby_gems_utils/gem/command.rb
82
- - lib/eac_ruby_gems_utils/gem/version_file.rb
83
- - lib/eac_ruby_gems_utils/tests.rb
84
- - lib/eac_ruby_gems_utils/tests/base.rb
85
- - lib/eac_ruby_gems_utils/tests/minitest.rb
86
- - lib/eac_ruby_gems_utils/tests/multiple.rb
87
- - lib/eac_ruby_gems_utils/tests/multiple/decorated_gem.rb
88
- - lib/eac_ruby_gems_utils/tests/multiple/result.rb
89
- - lib/eac_ruby_gems_utils/tests/rspec.rb
90
52
  - lib/eac_ruby_gems_utils/version.rb
91
53
  - spec/code/rubocop_check_spec.rb
92
- - spec/lib/eac_ruby_gems_utils/gem/version_file_spec.rb
93
- - spec/lib/eac_ruby_gems_utils/gem/version_file_spec_files/a_version_file.rb
94
- - spec/lib/eac_ruby_gems_utils/gem_spec.rb
95
54
  - spec/spec_helper.rb
96
- - spec/support/mygem/Gemfile
97
- - spec/support/mygem/Gemfile.lock
98
- - spec/support/mygem/Rakefile
99
- - spec/support/mygem/exe/myrunner
100
- - spec/support/mygem/lib/mygem.rb
101
- - spec/support/mygem/lib/mygem/version.rb
102
- - spec/support/mygem/mygem.gemspec
103
55
  homepage: https://github.com/esquilo-azul/eac_ruby_gems_utils
104
56
  licenses:
105
57
  - MIT
@@ -124,18 +76,8 @@ requirements: []
124
76
  rubygems_version: 3.1.6
125
77
  signing_key:
126
78
  specification_version: 4
127
- summary: Utilities for Ruby gems development.
79
+ summary: Utilities for Ruby gems development (Deprecated).
128
80
  test_files:
129
- - spec/lib/eac_ruby_gems_utils/gem/version_file_spec_files/a_version_file.rb
130
- - spec/lib/eac_ruby_gems_utils/gem/version_file_spec.rb
131
- - spec/lib/eac_ruby_gems_utils/gem_spec.rb
132
81
  - spec/spec_helper.rb
133
82
  - spec/code/rubocop_check_spec.rb
134
- - spec/support/mygem/Rakefile
135
- - spec/support/mygem/Gemfile
136
- - spec/support/mygem/lib/mygem/version.rb
137
- - spec/support/mygem/lib/mygem.rb
138
- - spec/support/mygem/exe/myrunner
139
- - spec/support/mygem/mygem.gemspec
140
- - spec/support/mygem/Gemfile.lock
141
83
  - ".rspec"
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_ruby_utils/ruby/command'
5
- require 'delegate'
6
-
7
- module EacRubyGemsUtils
8
- class Gem
9
- class Command < ::EacRubyUtils::Ruby::Command
10
- attr_reader :gem
11
-
12
- def initialize(gem, command_args, extra_options = {})
13
- @gem = gem
14
- super(command_args, extra_options.merge(host_env: gem.host_env))
15
- end
16
-
17
- # Changes current directory to the gem's directory.
18
- def chdir_root
19
- chdir(gem.root.to_path)
20
- end
21
-
22
- def envvar_gemfile
23
- envvar('BUNDLE_GEMFILE', gem.gemfile_path.to_path)
24
- end
25
-
26
- protected
27
-
28
- def duplicate(command, extra_options)
29
- self.class.new(gem, command, extra_options)
30
- end
31
- end
32
- end
33
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module EacRubyGemsUtils
6
- class Gem
7
- class VersionFile
8
- common_constructor :path
9
-
10
- VERSION_LINE_PATTERN = /\A(\s*)VERSION\s*=\s*[\'\"]([^\'\"]+)[\'\"](\s*)\z/.freeze
11
-
12
- def value
13
- path.read.each_line.lazy.map { |line| line_value(line) }.find { |v| v }
14
- end
15
-
16
- def value=(new_value)
17
- path.write(new_value_content(new_value))
18
- end
19
-
20
- private
21
-
22
- # @return Version found in line, nil otherwise.
23
- def line_value(line)
24
- VERSION_LINE_PATTERN.if_match(line.rstrip, false) { |m| ::Gem::Version.new(m[2]) }
25
- end
26
-
27
- def new_value_content(new_value)
28
- path.read.each_line
29
- .map { |line| new_value_line(line, new_value) }
30
- .join
31
- end
32
-
33
- def new_value_line(line, new_value)
34
- m = VERSION_LINE_PATTERN.match(line)
35
- return line unless m
36
-
37
- "#{m[1]}VERSION = '#{new_value}'#{m[3]}"
38
- end
39
- end
40
- end
41
- end
@@ -1,97 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_ruby_utils/envs'
5
- require 'rubygems'
6
-
7
- module EacRubyGemsUtils
8
- class Gem
9
- require_sub __FILE__
10
- enable_simple_cache
11
-
12
- GEMSPEC_EXTNAME = '.gemspec'
13
-
14
- common_constructor :root, :host_env, default: [nil] do
15
- @root = ::Pathname.new(root).expand_path
16
- self.host_env ||= ::EacRubyUtils::Envs.local
17
- end
18
-
19
- def to_s
20
- name
21
- end
22
-
23
- def bundle(*args)
24
- ::EacRubyGemsUtils::Gem::Command.new(self, %w[bundle] + args).envvar_gemfile
25
- end
26
-
27
- # @return A [Pathname] array with relative paths from root listed in gemspec's .file directive.
28
- def files
29
- gemspec.files.map(&:to_pathname)
30
- end
31
-
32
- def gemfile_lock_gem_version(gem_name)
33
- gemfile_lock_content.specs.find { |gem| gem.name == gem_name }.if_present(&:version)
34
- end
35
-
36
- def gemfile_lock_content
37
- ::Bundler::LockfileParser.new(::Bundler.read_file(gemfile_lock_path))
38
- end
39
-
40
- def name
41
- name_by_gemspec || name_by_path
42
- end
43
-
44
- def name_by_gemspec
45
- gemspec_path.if_present { |v| v.basename(GEMSPEC_EXTNAME).to_path }
46
- end
47
-
48
- def name_by_path
49
- fullname = root.basename.to_s
50
- /\A(.+)(?:-\d+(?:\.\d+)*)\z/.if_match(fullname, false) { |m| m[1] }.if_present(fullname)
51
- end
52
-
53
- def namespace_parts
54
- name.split('-')
55
- end
56
-
57
- def rake(*args)
58
- raise "File \"#{rakefile_path}\" does not exist" unless rakefile_path.exist?
59
-
60
- bundle('exec', 'rake', '--rakefile', rakefile_path, *args)
61
- end
62
-
63
- def version
64
- version_file.value
65
- end
66
-
67
- private
68
-
69
- def gemfile_path_uncached
70
- root.join('Gemfile')
71
- end
72
-
73
- def gemfile_lock_path_uncached
74
- gemfile_path.basename_sub { |b| "#{b}.lock" }
75
- end
76
-
77
- def gemspec_uncached
78
- ::Gem::Specification.load(gemspec_path.to_path)
79
- end
80
-
81
- def gemspec_path_uncached
82
- ::Pathname.glob("#{root.to_path}/*#{GEMSPEC_EXTNAME}").first
83
- end
84
-
85
- def rakefile_path_uncached
86
- root.join('Rakefile')
87
- end
88
-
89
- def version_file_uncached
90
- ::EacRubyGemsUtils::Gem::VersionFile.new(version_file_path)
91
- end
92
-
93
- def version_file_path_uncached
94
- root.join('lib', *namespace_parts, 'version.rb')
95
- end
96
- end
97
- end
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'eac_fs/logs'
5
- require 'eac_ruby_utils/listable'
6
-
7
- module EacRubyGemsUtils
8
- module Tests
9
- class Base
10
- include ::EacRubyUtils::Listable
11
-
12
- enable_simple_cache
13
- lists.add_string :result, :failed, :nonexistent, :successful
14
-
15
- common_constructor :gem
16
-
17
- def elegible?
18
- dependency_present? && gem.root.join(test_directory).exist?
19
- end
20
-
21
- def dependency_present?
22
- gem.gemfile_path.exist? && gem.gemfile_lock_gem_version(dependency_gem).present?
23
- end
24
-
25
- def name
26
- self.class.name.demodulize.gsub(/Test\z/, '')
27
- end
28
-
29
- def to_s
30
- "#{gem}[#{name}]"
31
- end
32
-
33
- private
34
-
35
- def logs_uncached
36
- ::EacFs::Logs.new.add(:stdout).add(:stderr)
37
- end
38
-
39
- def result_uncached
40
- return RESULT_NONEXISTENT unless elegible?
41
-
42
- exec_run_with_log ? RESULT_SUCCESSFUL : RESULT_FAILED
43
- end
44
-
45
- def exec_run
46
- gem.bundle('exec', *bundle_exec_args).chdir_root.execute
47
- end
48
-
49
- def exec_run_with_log
50
- r = exec_run
51
- logs[:stdout].write(r[:stdout])
52
- logs[:stderr].write(r[:stderr])
53
- r[:exit_code].zero?
54
- end
55
- end
56
- end
57
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_gems_utils/tests/base'
4
-
5
- module EacRubyGemsUtils
6
- module Tests
7
- class Minitest < ::EacRubyGemsUtils::Tests::Base
8
- def bundle_exec_args
9
- %w[rake test]
10
- end
11
-
12
- def dependency_gem
13
- 'minitest'
14
- end
15
-
16
- def elegible?
17
- super && gem.rakefile_path.exist?
18
- end
19
-
20
- def test_directory
21
- 'test'
22
- end
23
- end
24
- end
25
- end
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module EacRubyGemsUtils
6
- module Tests
7
- class Multiple
8
- class DecoratedGem < ::SimpleDelegator
9
- enable_speaker
10
-
11
- def prepare
12
- return unless gemfile_path.exist?
13
-
14
- log('running "bundle install"...')
15
- return if bundle('install').execute.fetch(:exit_code).zero?
16
-
17
- unless can_remove_gemfile_lock?
18
- raise '"bundle install" failed and the Gemfile.lock is part of gem' \
19
- '(Should be changed by developer)'
20
- end
21
-
22
- prepare_with_removable_gemfile_lock
23
- end
24
-
25
- def tests
26
- [::EacRubyGemsUtils::Tests::Minitest.new(__getobj__),
27
- ::EacRubyGemsUtils::Tests::Rspec.new(__getobj__)]
28
- end
29
-
30
- private
31
-
32
- def log(message)
33
- infov self, message
34
- end
35
-
36
- def prepare_with_removable_gemfile_lock
37
- log('"bundle install" failed, removing Gemfile.lock and trying again...')
38
- gemfile_lock_path.unlink if gemfile_lock_path.exist?
39
- bundle('install').execute!
40
- end
41
-
42
- def can_remove_gemfile_lock?
43
- !files.include?(gemfile_lock_path.relative_path_from(root))
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module EacRubyGemsUtils
4
- module Tests
5
- class Multiple
6
- class Result
7
- common_constructor :result
8
-
9
- COLORS = {
10
- ::EacRubyGemsUtils::Tests::Base::RESULT_FAILED => :red,
11
- ::EacRubyGemsUtils::Tests::Base::RESULT_NONEXISTENT => :white,
12
- ::EacRubyGemsUtils::Tests::Base::RESULT_SUCCESSFUL => :green
13
- }.freeze
14
-
15
- def tag
16
- result.to_s.send(color)
17
- end
18
-
19
- def color
20
- COLORS.fetch(result)
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,84 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_gems_utils/tests/minitest'
4
- require 'eac_ruby_gems_utils/tests/rspec'
5
- require 'eac_ruby_utils/core_ext'
6
-
7
- module EacRubyGemsUtils
8
- module Tests
9
- class Multiple
10
- require_sub __FILE__
11
- enable_speaker
12
- enable_simple_cache
13
- common_constructor :gems, :options, default: [{}]
14
- set_callback :initialize, :after, :run
15
-
16
- def ok?
17
- failed_tests.none?
18
- end
19
-
20
- def only
21
- options[:only]
22
- end
23
-
24
- private
25
-
26
- def all_tests_uncached
27
- decorated_gems.flat_map(&:tests)
28
- end
29
-
30
- def clear_logs
31
- all_tests.each do |test|
32
- test.logs.remove_all
33
- end
34
- end
35
-
36
- def prepare_all_gems
37
- infom 'Preparing all gems...'
38
- decorated_gems.each(&:prepare)
39
- end
40
-
41
- def decorated_gems_uncached
42
- r = gems
43
- r = r.select { |gem| only.include?(gem.name) } if only.present?
44
- r.map { |gem| DecoratedGem.new(gem) }
45
- end
46
-
47
- def failed_tests_uncached
48
- all_tests.select { |r| r.result == ::EacRubyGemsUtils::Tests::Base::RESULT_FAILED }
49
- end
50
-
51
- def final_results_banner
52
- if failed_tests.any?
53
- warn 'Some test did not pass:'
54
- failed_tests.each do |test|
55
- infov ' * Test', test
56
- info test.logs.truncate_all
57
- end
58
- else
59
- success 'All tests passed'
60
- end
61
- end
62
-
63
- def run
64
- start_banner
65
- prepare_all_gems
66
- test_all_gems
67
- final_results_banner
68
- ensure
69
- clear_logs
70
- end
71
-
72
- def start_banner
73
- infov 'Gems to test', decorated_gems.count
74
- end
75
-
76
- def test_all_gems
77
- infom 'Running tests...'
78
- all_tests.each do |test|
79
- infov test, Result.new(test.result).tag
80
- end
81
- end
82
- end
83
- end
84
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_gems_utils/tests/base'
4
-
5
- module EacRubyGemsUtils
6
- module Tests
7
- class Rspec < ::EacRubyGemsUtils::Tests::Base
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,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module EacRubyGemsUtils
6
- module Tests
7
- require_sub(__FILE__)
8
- end
9
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_gems_utils/gem'
4
-
5
- ::RSpec.describe ::EacRubyGemsUtils::Gem::VersionFile do
6
- let(:stubs_dir) { ::Pathname.new(__dir__).join('version_file_spec_files') }
7
- let(:stub_file) { stubs_dir.join('a_version_file.rb') }
8
- let(:instance) { described_class.new(stub_file) }
9
- let(:target_version) { ::Gem::Version.new('0.69.1') }
10
-
11
- describe '#value' do
12
- it { expect(instance.value).to eq(target_version) }
13
- end
14
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Avm
4
- module Tools
5
- VERSION = '0.69.1'
6
- end
7
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_gems_utils/gem'
4
-
5
- ::RSpec.describe ::EacRubyGemsUtils::Gem do
6
- let(:mygem_path) { ::Pathname.new(__dir__).expand_path.parent.parent.join('support', 'mygem') }
7
- let(:mygem) { described_class.new(mygem_path) }
8
-
9
- describe '#bundle' do
10
- specify do
11
- expect(mygem.bundle('exec', 'myrunner').execute!).to include('My Runner')
12
- end
13
- end
14
-
15
- describe '#rake' do
16
- specify do
17
- expect(mygem.rake('mygem:stub').execute!).to include('Stub!')
18
- end
19
- end
20
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- gemspec
@@ -1,19 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- mygem (1.0.0)
5
- rake
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- rake (13.0.1)
11
-
12
- PLATFORMS
13
- ruby
14
-
15
- DEPENDENCIES
16
- mygem!
17
-
18
- BUNDLED WITH
19
- 2.2.25
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- begin
4
- require 'bundler/setup'
5
- rescue LoadError
6
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
- end
8
-
9
- namespace :mygem do
10
- desc 'A stub task.'
11
- task :stub do
12
- puts 'Stub!'
13
- end
14
- end
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- $LOAD_PATH.unshift("#{__dir__}/../lib")
5
- puts 'My Runner'
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mygem
4
- VERSION = '1.0.0'
5
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mygem
4
- require 'mygem/version'
5
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $LOAD_PATH.push File.expand_path('lib', __dir__)
4
-
5
- Gem::Specification.new do |s|
6
- s.name = 'mygem'
7
- s.version = '1.0.0'
8
- s.authors = ['Esquilo Azul Company']
9
- s.summary = 'Stub gem.'
10
-
11
- s.files = Dir['{exe,lib}/**/*', 'Gemfile', 'Rakefile']
12
- s.bindir = 'exe'
13
- s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
14
-
15
- s.add_dependency 'rake'
16
- end