gemfile_locker 0.1.0 → 0.2.0

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: 9275a777c8aafc2e556cc83325de9ba87e35c0bc
4
- data.tar.gz: 343d049443e580a7eb6de5164e38d4597168bd05
3
+ metadata.gz: 2f411635748ebab869141b3e36ca6a8ef8cb7e5a
4
+ data.tar.gz: 8269cc977e333fe795775831873f7692184edb00
5
5
  SHA512:
6
- metadata.gz: ff456f46c6bcf7a33eb84faffd600284df75c74e53cab75d432e14bb6cd86906f1aa31fe6392ff74848518c077d425244038da2ab8db43803d0e3bf2c666ed9c
7
- data.tar.gz: 8f74a681efee7ea0a963fdbbb90aed3c917fcf9e322990d4dd845f6b310ff7ccb0badcbd2f66ce4dbf3dff84a6dd34bc7a186d92c1f4eada2acf9e6c411b0902
6
+ metadata.gz: 1845a4763600725c8f58d1f5e6c88579eb710a978e8553af9c9bcfcf27df0dbdd06a4b371cad3399c16a9a62aa284f4d05b7cebc63a213b1e119c4d8b526c639
7
+ data.tar.gz: 75009ff12e89fc6051e68af04d9fed9ade15a008170a636c58409c23f42214e1be13eae4d1feeed7878aaa0c2ab38d4424a7e9b1efd6a7c1dbe0a3687c723da6
data/.travis.yml CHANGED
@@ -3,6 +3,7 @@ cache: bundler
3
3
  language: ruby
4
4
  rvm:
5
5
  - 2.3.0
6
+ - 2.0.0
6
7
  before_install: gem install bundler -v 1.13.6
7
8
  notifications:
8
9
  email: false
data/README.md CHANGED
@@ -4,12 +4,10 @@
4
4
  [![Code Climate](https://codeclimate.com/github/printercu/gemfile_locker/badges/gpa.svg)](https://codeclimate.com/github/printercu/gemfile_locker)
5
5
  [![Build Status](https://travis-ci.org/printercu/gemfile_locker.svg)](https://travis-ci.org/printercu/gemfile_locker)
6
6
 
7
- Tool to manage Gemfile. Lock and unlock all dependencies for safe `bundle update`.
8
-
9
- GemfileLocker can lock all dependencies strictly or semi-strictly (with `~>`),
7
+ It can lock all (or selected) dependencies strictly or semi-strictly (with `~>`),
10
8
  so it gets safe to run `bundle update` anytime.
11
9
 
12
- It can also unlock all dependencies so you can easily update to the latest versions.
10
+ It can also unlock dependencies so you can easily update to the latest versions.
13
11
 
14
12
  ## Installation
15
13
 
@@ -30,21 +28,25 @@ Or install it yourself as:
30
28
  ## Usage
31
29
 
32
30
  ```
33
- gemfile_locker help
31
+ gemfile_locker help [COMMAND]
34
32
 
35
- gemfile_locker lock # Lock all missing versions
33
+ gemfile_locker lock [gem ...] [options] # Lock all missing versions or specified gems.
36
34
 
37
- Options:
38
- --loose/-l [full|patch|minor|major] # Lock with ~>
39
- --force/-f # Lock all gems
40
- --skip/-s # Skip this gems
41
- --only/-o # Lock only this gems
35
+ Options:
36
+ -l, [--loose=LOOSE] # Lock with `~>`. Optionaly provide level (default to patch)
37
+ # Possible values: major, minor, patch, full
38
+ -e, [--except=one two three] # List of gems to skip
39
+ -f, [--force] # Overwrite version definitions
40
+ # (By default it adds only missing version definitions)
41
+ -g, [--gemfile=GEMFILE] # Path to gemfile
42
+ # Default: Gemfile
42
43
 
43
- gemfile_locker unlock # unlock all
44
+ gemfile_locker unlock [gem ...] [options] # Unock all or specified gems.
44
45
 
45
- Options:
46
- --skip/-s # Skip this gems
47
- --only/-o # Unlock only this gems
46
+ Options:
47
+ -e, [--except=one two three] # List of gems to skip
48
+ -g, [--gemfile=GEMFILE] # Path to gemfile
49
+ # Default: Gemfile
48
50
  ```
49
51
 
50
52
  ## Development
@@ -2,16 +2,17 @@ require 'thor'
2
2
 
3
3
  module GemfileLocker
4
4
  class CLI < Thor
5
- desc 'lock [Gemfile]', 'Lock dependencies.'
5
+ class_option :gemfile,
6
+ aliases: '-g',
7
+ default: 'Gemfile',
8
+ desc: 'Path to gemfile'
9
+
10
+ desc 'lock [gem ...] [options]', 'Lock all missing versions or specified gems.'
6
11
  method_option :loose,
7
12
  aliases: '-l',
8
13
  lazy_default: 'patch',
9
14
  enum: %w(major minor patch full),
10
15
  desc: 'Lock with `~>`. Optionaly provide level (default to patch)'
11
- method_option :only,
12
- aliases: '-o',
13
- type: :array,
14
- desc: 'List of gems to process'
15
16
  method_option :except,
16
17
  aliases: '-e',
17
18
  type: :array,
@@ -19,24 +20,22 @@ module GemfileLocker
19
20
  method_option :force,
20
21
  aliases: '-f',
21
22
  type: :boolean,
22
- desc: 'Overwrite version definitions ' \
23
- '(By default it adds only missing version definitions)'
24
- def lock(file = 'Gemfile')
25
- lockfile = File.read("#{file}.lock")
26
- run_editor file, Locker.new(lockfile, options)
23
+ desc: 'Overwrite version definitions'
24
+ def lock(*only)
25
+ gemfile = options[:gemfile]
26
+ lockfile = File.read("#{gemfile}.lock")
27
+ processor_opts = only.any? ? options.merge(only: only) : options
28
+ run_editor gemfile, Locker.new(lockfile, processor_opts)
27
29
  end
28
30
 
29
- desc 'unlock [Gemfile]', 'Unlock dependencies.'
30
- method_option :only,
31
- aliases: '-o',
32
- type: :array,
33
- desc: 'List of gems to process'
31
+ desc 'unlock [gem ...] [options]', 'Unock all or specified gems.'
34
32
  method_option :except,
35
33
  aliases: '-e',
36
34
  type: :array,
37
35
  desc: 'List of gems to skip'
38
- def unlock(file = 'Gemfile')
39
- run_editor file, Unlocker.new(options)
36
+ def unlock(*only)
37
+ processor_opts = only.any? ? options.merge(only: only) : options
38
+ run_editor options[:gemfile], Unlocker.new(processor_opts)
40
39
  end
41
40
 
42
41
  private
@@ -46,7 +46,7 @@ module GemfileLocker
46
46
  def process_gems(string)
47
47
  string.gsub(GEM_LINE_REGEX) do
48
48
  match = Regexp.last_match
49
- data = GEM_MATCH_FIELDS.map { |x| [x, match[x]] }.to_h
49
+ data = Hash[GEM_MATCH_FIELDS.map { |x| [x, match[x]] }]
50
50
  result = yield data
51
51
  result ||= data
52
52
  GEM_MATCH_FIELDS.map { |x| result[x] }.join
@@ -1,5 +1,5 @@
1
1
  module GemfileLocker
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
 
4
4
  def self.gem_version
5
5
  Gem::Version.new VERSION
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemfile_locker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Melentiev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-18 00:00:00.000000000 Z
11
+ date: 2016-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor