lockfile_preserver 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 152d8431a38ce8589fe96c97747d5ceb805cffa4
4
+ data.tar.gz: f80b6c2c1cf75fa2a310fe2b1fe63f7b5ad0f86e
5
+ SHA512:
6
+ metadata.gz: c94252649df2830bd55397dfd1bf80aac77538a26f179aa15cc1e617ee9428164f6b52e8d6e046fbdc625b10f756c3080ae0cf891262259fb97a813ea72d7724
7
+ data.tar.gz: b167b692972bbd854d2f8b1ef5231898bff7d7c9ad568151cee9f34102db7403c113a2d259f57852b7f3079971edba95e92d0b07496a054fa390cbf9516c2a28
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --require spec_helper
2
+ --format documentation
3
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ sudo: false
2
+ cache: bundler
3
+ language: ruby
4
+ bundler_args: --without debugging
5
+ rvm:
6
+ - 2.3.0
7
+ - 2.2.4
8
+ - ruby-head
9
+ matrix:
10
+ allow_failures:
11
+ - rvm: ruby-head
12
+ fast_finish: true
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in lockfile_preserver.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem "bundler"
8
+ gem "rake"
9
+ gem "rspec", "~> 3.4"
10
+ end
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # LockfilePreserver
2
+
3
+ Preserve `BUNDLED_WITH` section of your lockfile!
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem "lockfile_preserver"
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install lockfile_preserver
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ LockfilePreserver.keep(gemfile, updated_gemfile, :bundled_with)
25
+ ```
26
+
27
+ ## Development
28
+
29
+ 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
+
31
+ 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
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/jollygoodcode/lockfile_preserver.
36
+
37
+ ## The UNLICENSE
38
+
39
+ See [UNLICENSE](/UNLICENSE).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/UNLICENSE ADDED
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <http://unlicense.org>
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "lockfile_preserver"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$"\n\t"
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,45 @@
1
+ module LockfilePreserver
2
+ class BundledWith
3
+ def initialize(original, current)
4
+ @original = original
5
+ @current = current
6
+ end
7
+
8
+ def keep
9
+ if original.include? BUNDLED_WITH
10
+ keep_bundled_with
11
+ else
12
+ remove_bundled_with
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ attr_reader :original, :current
19
+
20
+ BUNDLED_WITH = "BUNDLED WITH".freeze
21
+ REGEXP = %r{\n\nBUNDLED WITH\n\s+(?<version>#{Gem::Version::VERSION_PATTERN})\n*}
22
+ NEW_LINE = "\n".freeze
23
+
24
+ private_constant :BUNDLED_WITH
25
+ private_constant :REGEXP
26
+ private_constant :NEW_LINE
27
+
28
+ def keep_bundled_with
29
+ current.sub(REGEXP, bundled_with)
30
+ end
31
+
32
+ def remove_bundled_with
33
+ current.sub(REGEXP, NEW_LINE)
34
+ end
35
+
36
+ def bundled_with
37
+ "\n\nBUNDLED WITH\n" \
38
+ " #{bundler_version}\n"
39
+ end
40
+
41
+ def bundler_version
42
+ @_bundler_version ||= original.match(REGEXP)[:version]
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,3 @@
1
+ module LockfilePreserver
2
+ VERSION = "1.0.0".freeze
3
+ end
@@ -0,0 +1,12 @@
1
+ require "lockfile_preserver/version"
2
+ require "lockfile_preserver/bundled_with"
3
+
4
+ module LockfilePreserver
5
+ def self.keep(original, updated, section = :bundled_with)
6
+ if section == :bundled_with
7
+ LockfilePreserver::BundledWith.new(original, updated).keep
8
+ else
9
+ abort "We currently only support preserve BUNDLED_WITH section of lockfile."
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,21 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "lockfile_preserver/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "lockfile_preserver"
8
+ spec.version = LockfilePreserver::VERSION
9
+ spec.authors = ["JuanitoFatas"]
10
+ spec.email = ["katehuang0320@gmail.com"]
11
+
12
+ spec.summary = "LockfilePreserver preserves section you don't want to update."
13
+ spec.description = spec.summary
14
+ spec.homepage = "https://github.com/jollygoodcode/lockfile_preserver"
15
+ spec.license = "UNLICENSE"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lockfile_preserver
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - JuanitoFatas
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-03-08 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: LockfilePreserver preserves section you don't want to update.
14
+ email:
15
+ - katehuang0320@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".rspec"
22
+ - ".travis.yml"
23
+ - Gemfile
24
+ - README.md
25
+ - Rakefile
26
+ - UNLICENSE
27
+ - bin/console
28
+ - bin/setup
29
+ - lib/lockfile_preserver.rb
30
+ - lib/lockfile_preserver/bundled_with.rb
31
+ - lib/lockfile_preserver/version.rb
32
+ - lockfile_preserver.gemspec
33
+ homepage: https://github.com/jollygoodcode/lockfile_preserver
34
+ licenses:
35
+ - UNLICENSE
36
+ metadata: {}
37
+ post_install_message:
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubyforge_project:
53
+ rubygems_version: 2.6.1
54
+ signing_key:
55
+ specification_version: 4
56
+ summary: LockfilePreserver preserves section you don't want to update.
57
+ test_files: []