eac_ruby_gems_utils 0.6.2 → 0.7.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: b640e8bf4f8118ad8bc047b79bb4929331324a132b79edf6f62a1f14bf524181
4
- data.tar.gz: dcbae45900e3e2ab4f6060c1a7e9df16326069cc4a0fc7f26bd05f3399636755
3
+ metadata.gz: ba6901f2b81816e02333d51f9c1e4eb8d5a705a500f8d5485b20897925d1e0a2
4
+ data.tar.gz: b84a7c9aa771b08b204860e6c1961c259d847c044ab26d00b1db16e7fe2fbfc9
5
5
  SHA512:
6
- metadata.gz: 00e3f662232c805327e4468e776cef5d9dad1b7f71fb4ad39bfd9f0451a6f4aca8ae69b2a42390940ad6927550dc22b86f038e5b8831ef012fef955ae5a6f5f3
7
- data.tar.gz: 79e8483d80458612ec4f82154fd469f209d231ad4c83e55ad9f553de98917926598c13f54b878651dd19d0a33afd1ad4401456a165f724ea8f2d87624ad1d4b6
6
+ metadata.gz: 3dc046a756ad593ab46288d1882488ecd1e2c10116698036923f24d694b4c60daf025f798a7184b0b26705154588529a6ade87ea5261d64e81b7b3e2a79222d6
7
+ data.tar.gz: e70343b18f054bc8c402336b0150aed0c33a9638e815c40e9c75a13ff49835ea46498b1d686f91065edd401f834de1302e1d5ff3bd51ca80c2d25192e4441f28
@@ -54,7 +54,7 @@ module EacRubyGemsUtils
54
54
  end
55
55
 
56
56
  def version
57
- /VERSION\s*=\s*[\'\"]([^\'\"]+)[\'\"]/.if_match(version_file.read) { |m| m[1] }
57
+ version_file.value
58
58
  end
59
59
 
60
60
  private
@@ -76,6 +76,10 @@ module EacRubyGemsUtils
76
76
  end
77
77
 
78
78
  def version_file_uncached
79
+ ::EacRubyGemsUtils::Gem::VersionFile.new(version_file_path)
80
+ end
81
+
82
+ def version_file_path_uncached
79
83
  root.join('lib', *namespace_parts, 'version.rb')
80
84
  end
81
85
  end
@@ -0,0 +1,40 @@
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 do |line|
14
+ VERSION_LINE_PATTERN.if_match(line.rstrip, false) do |m|
15
+ ::Gem::Version.new(m[2])
16
+ end
17
+ end
18
+ end
19
+
20
+ def value=(new_value)
21
+ path.write(new_value_content(new_value))
22
+ end
23
+
24
+ private
25
+
26
+ def new_value_content(new_value)
27
+ path.read.each_line
28
+ .map { |line| new_value_line(line, new_value) }
29
+ .join
30
+ end
31
+
32
+ def new_value_line(line, new_value)
33
+ m = VERSION_LINE_PATTERN.match(line)
34
+ return line unless m
35
+
36
+ "#{m[1]}VERSION = '#{new_value}'#{m[3]}"
37
+ end
38
+ end
39
+ end
40
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyGemsUtils
4
- VERSION = '0.6.2'
4
+ VERSION = '0.7.0'
5
5
  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.2
4
+ version: 0.7.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-08-14 00:00:00.000000000 Z
11
+ date: 2020-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_ruby_utils
@@ -55,6 +55,7 @@ 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