lockfile_preserver 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 152d8431a38ce8589fe96c97747d5ceb805cffa4
4
- data.tar.gz: f80b6c2c1cf75fa2a310fe2b1fe63f7b5ad0f86e
3
+ metadata.gz: 1bbb130278a37b895922f1f2684152b36defecf7
4
+ data.tar.gz: a33a854a9028cbf70baf46c68b64eacac5613f7b
5
5
  SHA512:
6
- metadata.gz: c94252649df2830bd55397dfd1bf80aac77538a26f179aa15cc1e617ee9428164f6b52e8d6e046fbdc625b10f756c3080ae0cf891262259fb97a813ea72d7724
7
- data.tar.gz: b167b692972bbd854d2f8b1ef5231898bff7d7c9ad568151cee9f34102db7403c113a2d259f57852b7f3079971edba95e92d0b07496a054fa390cbf9516c2a28
6
+ metadata.gz: b917123ac6a7e962d89fa5dc564d69e87c75dd5da7445a2bb95b5527b1d694cfc071d9d6e3af35a958a7d6510b55b0083f699651869d4e7ae976016e211ea403
7
+ data.tar.gz: 51cfefd14596e786e9dc4765302fcea8f72df7fe23e2522a23356a1b1452e490e5f9cf3dcf4fbaac58fe9a57ffb5ade0970ac18a9e191a4c87b96ef9c00ee220
data/.gitignore CHANGED
@@ -7,4 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
- Gemfile.lock
10
+ /spec/examples.txt
data/.rspec CHANGED
@@ -1,3 +1,2 @@
1
1
  --require spec_helper
2
- --format documentation
3
2
  --color
data/.travis.yml CHANGED
@@ -3,8 +3,10 @@ cache: bundler
3
3
  language: ruby
4
4
  bundler_args: --without debugging
5
5
  rvm:
6
+ - 2.3.1
6
7
  - 2.3.0
7
8
  - 2.2.4
9
+ - 2.1.9
8
10
  - ruby-head
9
11
  matrix:
10
12
  allow_failures:
data/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # CHANGELOG
2
+
3
+ ## Unreleased
4
+
5
+ ## 1.0.1 - 2016.06.02
6
+
7
+ - Introduce `LockfilePreserver::RubyVersion` [#2][pr2]
8
+ - Introduce `LockfilePreserver::Pipeline` [#2][pr2]
9
+ - Refactor spec fixture originations [#2][pr2]
10
+ - `.keep` now accepts `:ruby_version` to preserve Ruby Version section from the lockfile [#2][pr2]
11
+ - new `.keep_all` method to preserve BUNDLED WITH and RUBY VERSION section from the lockfile [#2][pr2]
12
+
13
+ [pr2]: https://github.com/jollygoodcode/lockfile_preserver/pull/2
14
+
15
+ ## 1.0.0 - 2016.03.08
16
+
17
+ Init LockfilePreserver.
data/Gemfile CHANGED
@@ -7,4 +7,5 @@ group :development do
7
7
  gem "bundler"
8
8
  gem "rake"
9
9
  gem "rspec", "~> 3.4"
10
+ gem "pry"
10
11
  end
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # LockfilePreserver
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/lockfile_preserver.svg)](https://badge.fury.io/rb/lockfile_preserver)
4
+ [![Build Status](https://travis-ci.org/jollygoodcode/lockfile_preserver.svg?branch=master)](https://travis-ci.org/jollygoodcode/lockfile_preserver)
5
+ [![Code Climate](https://codeclimate.com/github/jollygoodcode/lockfile_preserver/badges/gpa.svg)](https://codeclimate.com/github/jollygoodcode/lockfile_preserver)
6
+
3
7
  Preserve `BUNDLED_WITH` section of your lockfile!
4
8
 
5
9
  ## Installation
@@ -20,16 +24,42 @@ Or install it yourself as:
20
24
 
21
25
  ## Usage
22
26
 
27
+ Given a folder where `Gemfile` has some outdated gems:
28
+
29
+ ```
30
+ .
31
+ ├── Gemfile
32
+ └── Gemfile.lock
33
+ ```
34
+
23
35
  ```ruby
24
- LockfilePreserver.keep(gemfile, updated_gemfile, :bundled_with)
36
+ lockfile = IO.read "Gemfile.lock"
25
37
  ```
26
38
 
39
+ Then we do a `bundle update`. The lockfile has been updated:
40
+
41
+ ```ruby
42
+ updated_lockfile = IO.read "Gemfile.lock"
43
+ ```
44
+
45
+ Preserve `BUNDLED_WITH` changes to your lockfile:
46
+
47
+ ```ruby
48
+ LockfilePreserver.keep(lockfile, updated_lockfile)
49
+ ```
50
+
51
+ That's it!
52
+
27
53
  ## Development
28
54
 
29
55
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
56
 
31
57
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
58
 
59
+ ## Credits
60
+
61
+ A huge THANK YOU to all our [contributors](https://github.com/jollygoodcode/dasherize/graphs/contributors)! :heart:
62
+
33
63
  ## Contributing
34
64
 
35
65
  Bug reports and pull requests are welcome on GitHub at https://github.com/jollygoodcode/lockfile_preserver.
@@ -37,3 +67,9 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/jollyg
37
67
  ## The UNLICENSE
38
68
 
39
69
  See [UNLICENSE](/UNLICENSE).
70
+
71
+ ## Maintained by Jolly Good Code
72
+
73
+ [![Jolly Good Code](https://cloud.githubusercontent.com/assets/1000669/9362336/72f9c406-46d2-11e5-94de-5060e83fcf83.jpg)](http://www.jollygoodcode.com)
74
+
75
+ We specialise in rapid development of high quality MVPs. [Hire us](http://www.jollygoodcode.com/#get-in-touch) to turn your product idea into reality.
data/circle.yml ADDED
@@ -0,0 +1,3 @@
1
+ test:
2
+ override:
3
+ - bundle exec rspec
@@ -1,8 +1,8 @@
1
1
  module LockfilePreserver
2
2
  class BundledWith
3
- def initialize(original, current)
3
+ def initialize(original, updated)
4
4
  @original = original
5
- @current = current
5
+ @updated = updated
6
6
  end
7
7
 
8
8
  def keep
@@ -15,7 +15,7 @@ module LockfilePreserver
15
15
 
16
16
  private
17
17
 
18
- attr_reader :original, :current
18
+ attr_reader :original, :updated
19
19
 
20
20
  BUNDLED_WITH = "BUNDLED WITH".freeze
21
21
  REGEXP = %r{\n\nBUNDLED WITH\n\s+(?<version>#{Gem::Version::VERSION_PATTERN})\n*}
@@ -26,11 +26,11 @@ module LockfilePreserver
26
26
  private_constant :NEW_LINE
27
27
 
28
28
  def keep_bundled_with
29
- current.sub(REGEXP, bundled_with)
29
+ updated.sub(REGEXP, bundled_with)
30
30
  end
31
31
 
32
32
  def remove_bundled_with
33
- current.sub(REGEXP, NEW_LINE)
33
+ updated.sub(REGEXP, NEW_LINE)
34
34
  end
35
35
 
36
36
  def bundled_with
@@ -0,0 +1,21 @@
1
+ module LockfilePreserver
2
+ class Pipeline
3
+ def initialize(preservers)
4
+ @preservers = preservers
5
+ end
6
+
7
+ def call(original, updated)
8
+ result = updated
9
+
10
+ preservers.each do |preserver|
11
+ result = preserver.new(original, result).keep
12
+ end
13
+
14
+ result
15
+ end
16
+
17
+ private
18
+
19
+ attr_reader :preservers
20
+ end
21
+ end
@@ -0,0 +1,46 @@
1
+ module LockfilePreserver
2
+ class RubyVersion
3
+ def initialize(original, updated)
4
+ @original = original
5
+ @updated = updated
6
+ end
7
+
8
+ def keep
9
+ if original.include? RUBY_VERSION
10
+ keep_ruby_version
11
+ else
12
+ remove_ruby_version
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ attr_reader :original, :updated
19
+
20
+ RUBY_VERSION = "RUBY VERSION".freeze
21
+ VERSION_PATTERN = %r{.+}
22
+ REGEXP = %r{\n\nRUBY VERSION\n\s+(?<version>#{VERSION_PATTERN})\n*}
23
+ NEW_LINE = "\n".freeze
24
+
25
+ private_constant :RUBY_VERSION
26
+ private_constant :REGEXP
27
+ private_constant :NEW_LINE
28
+
29
+ def keep_ruby_version
30
+ updated.sub(REGEXP, ruby_version_section)
31
+ end
32
+
33
+ def remove_ruby_version
34
+ updated.sub(REGEXP, NEW_LINE)
35
+ end
36
+
37
+ def ruby_version_section
38
+ "\n\nRUBY VERSION\n" \
39
+ " #{ruby_version}\n"
40
+ end
41
+
42
+ def ruby_version
43
+ @_ruby_version ||= original.match(REGEXP)[:version]
44
+ end
45
+ end
46
+ end
@@ -1,3 +1,3 @@
1
1
  module LockfilePreserver
2
- VERSION = "1.0.0".freeze
2
+ VERSION = "1.0.1".freeze
3
3
  end
@@ -1,12 +1,25 @@
1
1
  require "lockfile_preserver/version"
2
+ require "lockfile_preserver/pipeline"
2
3
  require "lockfile_preserver/bundled_with"
4
+ require "lockfile_preserver/ruby_version"
3
5
 
4
6
  module LockfilePreserver
5
7
  def self.keep(original, updated, section = :bundled_with)
6
8
  if section == :bundled_with
7
9
  LockfilePreserver::BundledWith.new(original, updated).keep
8
- else
9
- abort "We currently only support preserve BUNDLED_WITH section of lockfile."
10
+ elsif section == :ruby_version
11
+ LockfilePreserver::RubyVersion.new(original, updated).keep
12
+ elsif
13
+ abort %(We currently only support preserve "BUNDLED WITH" & "RUBY VERSION" section of lockfile.)
10
14
  end
11
15
  end
16
+
17
+ def self.keep_all(original, updated)
18
+ pipeline = Pipeline.new [
19
+ LockfilePreserver::BundledWith,
20
+ LockfilePreserver::RubyVersion
21
+ ]
22
+
23
+ pipeline.call(original, updated)
24
+ end
12
25
  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.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - JuanitoFatas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-08 00:00:00.000000000 Z
11
+ date: 2016-06-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: LockfilePreserver preserves section you don't want to update.
14
14
  email:
@@ -20,14 +20,18 @@ files:
20
20
  - ".gitignore"
21
21
  - ".rspec"
22
22
  - ".travis.yml"
23
+ - CHANGELOG.md
23
24
  - Gemfile
24
25
  - README.md
25
26
  - Rakefile
26
27
  - UNLICENSE
27
28
  - bin/console
28
29
  - bin/setup
30
+ - circle.yml
29
31
  - lib/lockfile_preserver.rb
30
32
  - lib/lockfile_preserver/bundled_with.rb
33
+ - lib/lockfile_preserver/pipeline.rb
34
+ - lib/lockfile_preserver/ruby_version.rb
31
35
  - lib/lockfile_preserver/version.rb
32
36
  - lockfile_preserver.gemspec
33
37
  homepage: https://github.com/jollygoodcode/lockfile_preserver
@@ -50,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
54
  version: '0'
51
55
  requirements: []
52
56
  rubyforge_project:
53
- rubygems_version: 2.6.1
57
+ rubygems_version: 2.6.4
54
58
  signing_key:
55
59
  specification_version: 4
56
60
  summary: LockfilePreserver preserves section you don't want to update.