eac_ruby_gems_utils 0.6.1 → 0.7.3

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: 7f75298747a013afc0a9885aa971bf93245ca3b94b6967b21c80a2644a19ec68
4
- data.tar.gz: 5b8c611448808035da09b60baf19e97cd1e86f631fb889c18dc53c638a096ce9
3
+ metadata.gz: c26b2235fcb990e88ce893a82c90d84300c6a11e2d236a3259cba110f56e8c45
4
+ data.tar.gz: 250ecc8711c9419c044344257e059a1045b26d73a5f4fa17e43254e424e760a1
5
5
  SHA512:
6
- metadata.gz: c075d0b148870a9981c6457cccdfc3a7a41b8f79b8a9d4fa6aecbf8adb11bc483049d3359d8d034d30225d5a27b5f667a8cc4dbc58b8e91f70c19272149192aa
7
- data.tar.gz: 50a6af80b9f47c4673669c1c6da5a041700700de23d15ecc05150b608b85d16019f894d437efb2c5b3fafe04519055fcd4229528d89dceff0e863f36b1117ec2
6
+ metadata.gz: 04523c761475b7acdb4558f80e17312fad58929918c3ff610e9cf690a065837a7c27403cdadca9af732907f30a3323c145016f977cf0f88eeb09e5ce0b101e58
7
+ data.tar.gz: 690a80843b3a9afbd736c153d9e38037dcf5d14f96ada89e6eb2114bbd51d3b8578d6750a4415406c9d7653c80c4037bcbde28ecc7bd4b13df6ae350036d7c06
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'eac_ruby_utils/core_ext'
4
4
  require 'eac_ruby_utils/envs'
5
+ require 'rubygems'
5
6
 
6
7
  module EacRubyGemsUtils
7
8
  class Gem
@@ -22,6 +23,11 @@ module EacRubyGemsUtils
22
23
  ::EacRubyGemsUtils::Gem::Command.new(self, %w[bundle] + args).envvar_gemfile
23
24
  end
24
25
 
26
+ # @return A [Pathname] array with relative paths from root listed in gemspec's .file directive.
27
+ def files
28
+ gemspec.files.map(&:to_pathname)
29
+ end
30
+
25
31
  def gemfile_lock_gem_version(gem_name)
26
32
  gemfile_lock_content.specs.find { |gem| gem.name == gem_name }.if_present(&:version)
27
33
  end
@@ -54,7 +60,7 @@ module EacRubyGemsUtils
54
60
  end
55
61
 
56
62
  def version
57
- /VERSION\s*=\s*[\'\"]([^\'\"]+)[\'\"]/.if_match(version_file.read) { |m| m[1] }
63
+ version_file.value
58
64
  end
59
65
 
60
66
  private
@@ -64,7 +70,11 @@ module EacRubyGemsUtils
64
70
  end
65
71
 
66
72
  def gemfile_lock_path_uncached
67
- root.join('Gemfile.lock')
73
+ gemfile_path.basename_sub { |b| "#{b}.lock" }
74
+ end
75
+
76
+ def gemspec_uncached
77
+ ::Gem::Specification.load(gemspec_path.to_path)
68
78
  end
69
79
 
70
80
  def gemspec_path_uncached
@@ -76,6 +86,10 @@ module EacRubyGemsUtils
76
86
  end
77
87
 
78
88
  def version_file_uncached
89
+ ::EacRubyGemsUtils::Gem::VersionFile.new(version_file_path)
90
+ end
91
+
92
+ def version_file_path_uncached
79
93
  root.join('lib', *namespace_parts, 'version.rb')
80
94
  end
81
95
  end
@@ -0,0 +1,41 @@
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
@@ -7,6 +7,7 @@ require 'eac_ruby_utils/core_ext'
7
7
  module EacRubyGemsUtils
8
8
  module Tests
9
9
  class Multiple
10
+ require_sub __FILE__
10
11
  enable_console_speaker
11
12
  enable_simple_cache
12
13
  common_constructor :gems, :options, default: [{}]
@@ -26,14 +27,9 @@ module EacRubyGemsUtils
26
27
  decorated_gems.flat_map(&:tests)
27
28
  end
28
29
 
29
- def bundle_all_gems
30
- infom 'Bundling all gems...'
31
- decorated_gems.each do |gem|
32
- next unless gem.gemfile_path.exist?
33
-
34
- infov 'Bundle install', gem
35
- gem.bundle.execute!
36
- end
30
+ def prepare_all_gems
31
+ infom 'Preparing all gems...'
32
+ decorated_gems.each(&:prepare)
37
33
  end
38
34
 
39
35
  def decorated_gems_uncached
@@ -61,7 +57,7 @@ module EacRubyGemsUtils
61
57
 
62
58
  def run
63
59
  start_banner
64
- bundle_all_gems
60
+ prepare_all_gems
65
61
  test_all_gems
66
62
  final_results_banner
67
63
  end
@@ -76,31 +72,6 @@ module EacRubyGemsUtils
76
72
  infov test, Result.new(test.result).tag
77
73
  end
78
74
  end
79
-
80
- class DecoratedGem < ::SimpleDelegator
81
- def tests
82
- [::EacRubyGemsUtils::Tests::Minitest.new(__getobj__),
83
- ::EacRubyGemsUtils::Tests::Rspec.new(__getobj__)]
84
- end
85
- end
86
-
87
- class Result
88
- common_constructor :result
89
-
90
- COLORS = {
91
- ::EacRubyGemsUtils::Tests::Base::RESULT_FAILED => :red,
92
- ::EacRubyGemsUtils::Tests::Base::RESULT_NONEXISTENT => :white,
93
- ::EacRubyGemsUtils::Tests::Base::RESULT_SUCCESSFUL => :green
94
- }.freeze
95
-
96
- def tag
97
- result.to_s.send(color)
98
- end
99
-
100
- def color
101
- COLORS.fetch(result)
102
- end
103
- end
104
75
  end
105
76
  end
106
77
  end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyGemsUtils
4
+ module Tests
5
+ class Multiple
6
+ class DecoratedGem < ::SimpleDelegator
7
+ enable_console_speaker
8
+
9
+ def prepare
10
+ return unless gemfile_path.exist?
11
+
12
+ log('running "bundle install"...')
13
+ return if bundle('install').execute.fetch(:exit_code).zero?
14
+
15
+ unless can_remove_gemfile_lock?
16
+ raise '"bundle install" failed and the Gemfile.lock is part of gem' \
17
+ '(Should be changed by developer)'
18
+ end
19
+
20
+ prepare_with_removable_gemfile_lock
21
+ end
22
+
23
+ def tests
24
+ [::EacRubyGemsUtils::Tests::Minitest.new(__getobj__),
25
+ ::EacRubyGemsUtils::Tests::Rspec.new(__getobj__)]
26
+ end
27
+
28
+ private
29
+
30
+ def log(message)
31
+ infov self, message
32
+ end
33
+
34
+ def prepare_with_removable_gemfile_lock
35
+ log('"bundle install" failed, removing Gemfile.lock and trying again...')
36
+ gemfile_lock_path.unlink if gemfile_lock_path.exist?
37
+ bundle('install').execute!
38
+ end
39
+
40
+ def can_remove_gemfile_lock?
41
+ !files.include?(gemfile_lock_path.relative_path_from(root))
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,25 @@
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,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyGemsUtils
4
- VERSION = '0.6.1'
4
+ VERSION = '0.7.3'
5
5
  end
@@ -0,0 +1,14 @@
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
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Tools
5
+ VERSION = '0.69.1'
6
+ end
7
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_ruby_gems_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.3
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-07-24 00:00:00.000000000 Z
11
+ date: 2020-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_ruby_utils
@@ -55,14 +55,19 @@ files:
55
55
  - lib/eac_ruby_gems_utils.rb
56
56
  - lib/eac_ruby_gems_utils/gem.rb
57
57
  - lib/eac_ruby_gems_utils/gem/command.rb
58
+ - lib/eac_ruby_gems_utils/gem/version_file.rb
58
59
  - lib/eac_ruby_gems_utils/tests.rb
59
60
  - lib/eac_ruby_gems_utils/tests/base.rb
60
61
  - lib/eac_ruby_gems_utils/tests/minitest.rb
61
62
  - lib/eac_ruby_gems_utils/tests/multiple.rb
63
+ - lib/eac_ruby_gems_utils/tests/multiple/decorated_gem.rb
64
+ - lib/eac_ruby_gems_utils/tests/multiple/result.rb
62
65
  - lib/eac_ruby_gems_utils/tests/rspec.rb
63
66
  - lib/eac_ruby_gems_utils/version.rb
67
+ - spec/code/rubocop_check_spec.rb
68
+ - spec/lib/eac_ruby_gems_utils/gem/version_file_spec.rb
69
+ - spec/lib/eac_ruby_gems_utils/gem/version_file_spec_files/a_version_file.rb
64
70
  - spec/lib/eac_ruby_gems_utils/gem_spec.rb
65
- - spec/rubocop_check_spec.rb
66
71
  - spec/spec_helper.rb
67
72
  - spec/support/mygem/Gemfile
68
73
  - spec/support/mygem/Gemfile.lock
@@ -92,13 +97,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
97
  - !ruby/object:Gem::Version
93
98
  version: '0'
94
99
  requirements: []
95
- rubygems_version: 3.0.6
100
+ rubygems_version: 3.0.8
96
101
  signing_key:
97
102
  specification_version: 4
98
103
  summary: Utilities for Ruby gems development.
99
104
  test_files:
105
+ - spec/code/rubocop_check_spec.rb
106
+ - spec/lib/eac_ruby_gems_utils/gem/version_file_spec.rb
107
+ - spec/lib/eac_ruby_gems_utils/gem/version_file_spec_files/a_version_file.rb
100
108
  - spec/lib/eac_ruby_gems_utils/gem_spec.rb
101
- - spec/rubocop_check_spec.rb
102
109
  - spec/spec_helper.rb
103
110
  - spec/support/mygem/Gemfile
104
111
  - spec/support/mygem/Gemfile.lock