pumper 1.2.0 → 1.3.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: b1e4ee75f4f1555555e87943fa4929d98dedce83
4
- data.tar.gz: 53aa5cd83b1c356a9be30364d95e5aaec872106b
3
+ metadata.gz: e13030d4ff0a6db3a8def41fe5a5fe6f171a284a
4
+ data.tar.gz: 0faf78957bb24122e6ec617f8498c65534a8aa8f
5
5
  SHA512:
6
- metadata.gz: 0f519561d129530d470058cc74a62be5732ccbe7f8433afa98a7bd72043c6eca01c47f66b338dec1dbd24354dec7cfbb2f31ff8aea1a5ad06c399ba6f18f79da
7
- data.tar.gz: f467fc8d265dbf72458b3a2617e9dae0943e34eb247567b3c99fab0313dbdde3855e462312a03689ff46f72791fe681c203965a47d6a7ec16ad379ced4292628
6
+ metadata.gz: 4fe385d88d0cc688144c3351f588007353ee2c4ebd6cae67eb3f0a23d44af085a5a241d88020cbb59c11573d489ae542abf14f619821a6c4de76bb7bf71d690e
7
+ data.tar.gz: e6633941855111492eb4639935aa23674d9476d4211d7a573768eb11f39c61326571c6f61082ff0472f6798a5b92bfae8eebebb4297c9bf0b4d52108f0c644cd
data/README.md CHANGED
@@ -67,9 +67,10 @@ Success bump current gem
67
67
  ------------------------- |:-----------------------------------------------------------
68
68
  `--project` | Path to ruby project where <your_gem> needs update
69
69
  `--absolute_path` | If project path is absolute
70
- `--gemset` | Gemset name (if you use RVM)
71
- `--vendor` | If project gems stored in the vendor/cache
70
+ `--gemset` | Gemset's name (if you use RVM)
71
+ `--vendor` | If project's gems stored in the vendor/cache
72
72
  `--config` | If you want to use special config for updating project
73
+ `--list` | Select projects from `.pumper.yml` (use with --config)
73
74
 
74
75
 
75
76
  Example:
@@ -97,10 +98,19 @@ projects:
97
98
  absolute_path: true
98
99
  gemset: ruby-2.1.0
99
100
  vendor: true
101
+ another_project:
102
+ path: /Users/admin/Projects/another_project
103
+
100
104
  ```
101
105
 
102
106
  and run
103
107
 
104
108
  ```sh
105
109
  $ pumper --config
106
- ```
110
+ =>
111
+ # Update all (rails_project, another_project)
112
+
113
+ $ pumper --config --list rails_project
114
+ =>
115
+ # Update only rails_project
116
+ ```
data/bin/pumper CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'optparse'
3
3
  require 'pumper'
4
-
5
4
  options = Hash.new
6
5
 
7
6
  opts = OptionParser.new do |opts|
@@ -15,24 +14,34 @@ opts = OptionParser.new do |opts|
15
14
  options[:is_absolute_path] = true
16
15
  end
17
16
 
18
- opts.on('-c', '--config', 'If use .pumper.yml config') do
17
+ opts.on('-g', '--gemset GEMSET', "Gemset's name (if you use rvm)") do |gemset|
18
+ options[:gemset] = gemset
19
+ end
20
+
21
+ opts.on('-e', '--vendor', "If project's gems stored in the vendor/cache") do
22
+ options[:is_vendor] = true
23
+ end
24
+
25
+ opts.on('-c', '--config', 'If you use .pumper.yml config') do
19
26
  options[:config] = true
20
27
  end
21
28
 
22
- opts.on('-g', '--gemset GEMSET', 'Gemset name (if you use rvm)') do |gemset|
23
- options[:gemset] = gemset
29
+ opts.on('-l', '--list projectN[,projectN+1]', Array, 'List of projects (use with --config)') do |list|
30
+ options[:list] = list
24
31
  end
25
32
 
26
- opts.on('-e', '--vendor', 'If project gems stored in the vendor/cache') do
27
- options[:is_vendor] = true
33
+ opts.on_tail('-h', '--help', 'Show this message') do
34
+ puts opts
35
+ exit
36
+ end
37
+
38
+ opts.on_tail('--version', 'Show version') do
39
+ puts Pumper::VERSION
40
+ exit
28
41
  end
29
42
  end
30
43
 
31
44
  opts.parse!
32
45
  config_options = Pumper::Configuration.configure!(options)
33
46
 
34
- if options[:config]
35
- config_options.each { |options| Pumper::Pump.new(options).perform }
36
- else
37
- Pumper::Pump.new(config_options).perform
38
- end
47
+ config_options.each { |options| Pumper::Pump.new(options).perform }
@@ -1,7 +1,6 @@
1
1
  # Parse and validate options
2
2
  # * _options_ - user's set options
3
- # Return array of options hash (from .pumper.yml) if set --config
4
- # Return options hash unless set --config
3
+ # Return array of options hash (from .pumper.yml if set --config)
5
4
  require 'yaml'
6
5
 
7
6
  module Pumper
@@ -13,32 +12,49 @@ module Pumper
13
12
  def configure!(options)
14
13
  validate(options)
15
14
 
16
- options[:config] ? parse_from_config : options
15
+ options[:config] ? by_config(options[:list]) : [ options ]
17
16
  end
18
17
 
19
18
  private
20
19
 
21
20
  def validate(options)
22
21
  if options[:config] && (options[:project] || options[:gemset] || options[:vendor])
23
- raise InvalidOptions.new('Error: config option use without [project|gemset|vendor] options')
22
+ raise InvalidOptions.new('Error: config option must be used without [project|gemset|vendor] options')
23
+ end
24
+
25
+ if options[:list] && options[:config].nil?
26
+ raise InvalidOptions.new('Option --list should be used with --config')
24
27
  end
25
28
 
26
29
  if options[:project].nil? && options[:config].nil?
27
- raise ProjectNotSet.new('You need set project (--project <PATH_TO_PROJECT>) or use config')
30
+ raise ProjectNotSet.new('You need to set project (--project <PATH_TO_PROJECT>) or use --config')
28
31
  end
29
32
  end
30
33
 
31
- def parse_from_config
34
+ def by_config(list)
35
+ config = parse_config
36
+ slice_config =
37
+ list.nil? ? config : slice(config, list)
38
+
39
+ slice_config.values
40
+ end
41
+
42
+ def parse_config
32
43
  file = File.read(File.join(Dir.pwd, '.pumper.yml'))
33
- YAML.load(file)['projects'].each_with_object([]) do |(_, option), arr|
34
- arr.push(
35
- project: option['path'],
36
- is_absolute_path: option['absolute_path'],
37
- gemset: option['gemset'],
38
- is_vendor: option['vendor']
39
- )
44
+ YAML.load(file)['projects'].each_with_object({}) do |(project, option), hash|
45
+ hash[project] =
46
+ {
47
+ project: option['path'],
48
+ is_absolute_path: option['absolute_path'],
49
+ gemset: option['gemset'],
50
+ is_vendor: option['vendor']
51
+ }
40
52
  end
41
53
  end
54
+
55
+ def slice(config, list)
56
+ config.select { |project, _| list.include?(project) }
57
+ end
42
58
  end
43
59
  end
44
- end
60
+ end
@@ -1,3 +1,3 @@
1
1
  module Pumper
2
- VERSION = '1.2.0'.freeze
2
+ VERSION = '1.3.0'.freeze
3
3
  end
@@ -5,23 +5,32 @@ describe Pumper::Configuration do
5
5
 
6
6
  context 'when raise error ProjectNotSet' do
7
7
  it { expect { subject }.to raise_error(Pumper::Configuration::ProjectNotSet) }
8
- it { expect { subject }.to raise_exception('You need to set project (--project <PATH_TO_PROJECT>) or use config') }
8
+ it { expect { subject }.to raise_exception('You need to set project (--project <PATH_TO_PROJECT>) or use --config') }
9
9
  end
10
10
 
11
11
  context 'when valid project' do
12
12
  let(:options) { { project: 'cashier' } }
13
13
 
14
- it { is_expected.to eq(options) }
14
+ it { is_expected.to eq([ options ]) }
15
15
  end
16
16
 
17
- context 'when raise error InvalidOptions' do
18
- let(:options) { { project: 'cashier', config: true, gemset: 'ruby-2.1.0' } }
17
+ context 'raise error InvalidOptions' do
18
+ context 'when set project and config options' do
19
+ let(:options) { { project: 'cashier', config: true, gemset: 'ruby-2.1.0' } }
19
20
 
20
- it { expect { subject }.to raise_error(Pumper::Configuration::InvalidOptions) }
21
+ it { expect { subject }.to raise_exception('Error: config option must be used without [project|gemset|vendor] options') }
22
+ end
23
+
24
+ context 'when list option without config' do
25
+ let(:options) { { list: ['cashier'] } }
26
+
27
+ it { expect { subject }.to raise_exception('Option --list should be used with --config') }
28
+ end
21
29
  end
22
30
 
23
31
  context 'when --config' do
24
32
  let(:options) { { config: true } }
33
+
25
34
  before do
26
35
  pwd = Dir.pwd
27
36
  allow(Dir).to receive(:pwd) { "#{ pwd }/spec/fixtures" }
@@ -43,5 +52,20 @@ describe Pumper::Configuration do
43
52
  }
44
53
  ])
45
54
  end
55
+
56
+ context 'when --list' do
57
+ let(:options) { { config: true, list: ['my_app2'] } }
58
+
59
+ it 'should select only list projects' do
60
+ is_expected.to eq([
61
+ {
62
+ project: '/Users/admin/Projects/my_app2',
63
+ is_absolute_path: true,
64
+ gemset: 'ruby-2.1.0@my_app2',
65
+ is_vendor: nil
66
+ }
67
+ ])
68
+ end
69
+ end
46
70
  end
47
71
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pumper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikolay Sverchkov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-19 00:00:00.000000000 Z
11
+ date: 2015-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec