lockfile_preserver 1.0.1 → 1.0.2

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
  SHA1:
3
- metadata.gz: 1bbb130278a37b895922f1f2684152b36defecf7
4
- data.tar.gz: a33a854a9028cbf70baf46c68b64eacac5613f7b
3
+ metadata.gz: ddb4c0329e70fd936e7eb4fa7957cc3f33e06780
4
+ data.tar.gz: ed55e9704d554d5aa2e9d74cdbfc8a9f8670f35b
5
5
  SHA512:
6
- metadata.gz: b917123ac6a7e962d89fa5dc564d69e87c75dd5da7445a2bb95b5527b1d694cfc071d9d6e3af35a958a7d6510b55b0083f699651869d4e7ae976016e211ea403
7
- data.tar.gz: 51cfefd14596e786e9dc4765302fcea8f72df7fe23e2522a23356a1b1452e490e5f9cf3dcf4fbaac58fe9a57ffb5ade0970ac18a9e191a4c87b96ef9c00ee220
6
+ metadata.gz: bb27c3f6afb95d6ca3c866accbe5c7d61359e0c70d89dd679005f5b1270ffbccb2c98bc20afbc6e6421437ca0c1a3ee8bc0af3bb87504fdc543b50942f72e39b
7
+ data.tar.gz: c64ed4c48a2a0ed6c1e8da3eb52c1d16b77bc224a2e8f53c4d95245f306cd5561dbca39282fe66c47cf0d107df46259ce0ca009358b4120b1b83800a25fcfc82
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 1.0.2 - 2016.06.14
6
+
7
+ - Fix `LockfilePreserver::RubyVersion` does not add `RUBY VERSION` section back to lockfile bug [#3](https://github.com/jollygoodcode/lockfile_preserver/pull/3)
8
+
5
9
  ## 1.0.1 - 2016.06.02
6
10
 
7
11
  - Introduce `LockfilePreserver::RubyVersion` [#2][pr2]
@@ -27,9 +27,41 @@ module LockfilePreserver
27
27
  private_constant :NEW_LINE
28
28
 
29
29
  def keep_ruby_version
30
+ if updated.include? RUBY_VERSION
31
+ retains_ruby_version
32
+ else
33
+ add_ruby_version
34
+ end
35
+ end
36
+
37
+ def retains_ruby_version
30
38
  updated.sub(REGEXP, ruby_version_section)
31
39
  end
32
40
 
41
+ # How RUBY VERSION added to lockfile: https://git.io/voWNN
42
+ def add_ruby_version
43
+ updated_lines = updated.lines
44
+
45
+ # Find BUNDLED WITH line
46
+ bundled_with_index = updated.lines.index { |line| line.include? "BUNDLED WITH" }
47
+
48
+ # RUBY VERSION should be added before BUNDLED WITH
49
+ add_ruby_version_index = bundled_with_index-1
50
+
51
+ # Find where to add RUBY VERSION section
52
+ while updated_lines[add_ruby_version_index] != "\n"
53
+ add_ruby_version_index -= 1
54
+ end
55
+
56
+ # Add RUBY VERSION section
57
+ updated_lines.insert(
58
+ add_ruby_version_index, "\nRUBY VERSION\n", " #{ruby_version}\n"
59
+ )
60
+
61
+ # Reconstruct lockfile
62
+ updated_lines.join
63
+ end
64
+
33
65
  def remove_ruby_version
34
66
  updated.sub(REGEXP, NEW_LINE)
35
67
  end
@@ -1,3 +1,3 @@
1
1
  module LockfilePreserver
2
- VERSION = "1.0.1".freeze
2
+ VERSION = "1.0.2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lockfile_preserver
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - JuanitoFatas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-02 00:00:00.000000000 Z
11
+ date: 2016-06-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: LockfilePreserver preserves section you don't want to update.
14
14
  email:
@@ -54,8 +54,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
54
  version: '0'
55
55
  requirements: []
56
56
  rubyforge_project:
57
- rubygems_version: 2.6.4
57
+ rubygems_version: 2.4.5.1
58
58
  signing_key:
59
59
  specification_version: 4
60
60
  summary: LockfilePreserver preserves section you don't want to update.
61
61
  test_files: []
62
+ has_rdoc: