pumper 1.0.1 → 1.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: 69929f85b7b5138d6690a442d88f0f7b0aabf63f
4
- data.tar.gz: ee3711908b8207d18225a3a39142bbdd6236afa3
3
+ metadata.gz: b1e4ee75f4f1555555e87943fa4929d98dedce83
4
+ data.tar.gz: 53aa5cd83b1c356a9be30364d95e5aaec872106b
5
5
  SHA512:
6
- metadata.gz: f9c44a677c0e52ef129651c2e5ed36536b2d67ba7c41e887faae8d23d64a5926f0c199ca05be38bf118928997b3836b710b00550a9f4d189b9f92039a1194644
7
- data.tar.gz: ea0ca03f026b3ed476ca7d4831c4fda13f171d97193a3be1a3fa514c71f15776b4c3b21c6b85fcfd8da5ad1cff959628631f2c6ed5e50e0fcb3ba54f1f9f0775
6
+ metadata.gz: 0f519561d129530d470058cc74a62be5732ccbe7f8433afa98a7bd72043c6eca01c47f66b338dec1dbd24354dec7cfbb2f31ff8aea1a5ad06c399ba6f18f79da
7
+ data.tar.gz: f467fc8d265dbf72458b3a2617e9dae0943e34eb247567b3c99fab0313dbdde3855e462312a03689ff46f72791fe681c203965a47d6a7ec16ad379ced4292628
data/README.md CHANGED
@@ -3,7 +3,17 @@
3
3
  Pumper
4
4
  ======
5
5
 
6
- **Pumper**
6
+ **Pumper** helps quickly update developed gem (e.g. <your_gem>)in dependent project (which uses bundler).
7
+
8
+ **Pumper** do:
9
+
10
+ 1. Update <your_gem>'s version in Gemfile of project.
11
+
12
+ 2. Remove any old versions of <your_gem>.
13
+
14
+ 3. Install new build of <your_gem>.
15
+
16
+ Supports install gem to vendor/cache folder and using RVM (see [Options](#options))
7
17
 
8
18
  ## Installation
9
19
 
@@ -13,7 +23,7 @@ Add it to your .gemspec:
13
23
  spec.add_development_dependency 'pumper'
14
24
  ```
15
25
 
16
- Run the following command to install it:
26
+ And run the following command to install it:
17
27
 
18
28
  ```sh
19
29
  $ bundle install
@@ -27,7 +37,7 @@ $ gem install pumper
27
37
 
28
38
  ## Usage
29
39
 
30
- Basic **Pumper** use:
40
+ For basic usage **Pumper** you need to go to gem folder and run:
31
41
 
32
42
  + your_gem
33
43
  - your_gem.gemspec
@@ -51,15 +61,16 @@ Successfully installed your_gem-0.0.1
51
61
  Success bump current gem
52
62
  ```
53
63
 
54
- ### Options
64
+ ### <a name="options"></a> Options
55
65
 
56
66
  Option | Description
57
67
  ------------------------- |:-----------------------------------------------------------
58
- `--project` | Path to ruby project where need update current gem
68
+ `--project` | Path to ruby project where &lt;your_gem> needs update
59
69
  `--absolute_path` | If project path is absolute
60
- `--gemspec` | Path to .gemspec (default search in current folder *.gemspec)
61
70
  `--gemset` | Gemset name (if you use RVM)
62
71
  `--vendor` | If project gems stored in the vendor/cache
72
+ `--config` | If you want to use special config for updating project
73
+
63
74
 
64
75
  Example:
65
76
 
@@ -74,3 +85,22 @@ cp pkg/* /Users/admin/Project/rails_project/vendor/cache && cd /Users/admin/Proj
74
85
  Installing your_gem 0.0.1
75
86
  Success bump current gem
76
87
  ```
88
+
89
+ #### Config option
90
+
91
+ For use `--config` option you need to put `.pumper.yml` to &lt;your_gem> folder and write something like this:
92
+
93
+ ```yml
94
+ projects:
95
+ rails_project:
96
+ path: /Users/admin/Projects/rails_project
97
+ absolute_path: true
98
+ gemset: ruby-2.1.0
99
+ vendor: true
100
+ ```
101
+
102
+ and run
103
+
104
+ ```sh
105
+ $ pumper --config
106
+ ```
data/bin/pumper CHANGED
@@ -5,31 +5,34 @@ require 'pumper'
5
5
  options = Hash.new
6
6
 
7
7
  opts = OptionParser.new do |opts|
8
- opts.banner = %q[Bumper]
8
+ opts.banner = %q[Pumper]
9
9
 
10
10
  opts.on('-p', '--project PROJECT_PATH', 'Path to ruby project where need update current gem') do |project|
11
11
  options[:project] = project
12
12
  end
13
13
 
14
14
  opts.on('-a', '--absolute_path', 'If project path is absolute') do
15
- options[:absolute_path] = true
15
+ options[:is_absolute_path] = true
16
16
  end
17
17
 
18
- # Default find in current folder file *.gemspec
19
- opts.on('-s', '--gemspec GEMSPEC_PATH', 'Path to .gemspec (default search in current folder *.gemspec)') do |gemspec|
20
- options[:gemspec] = gemspec
18
+ opts.on('-c', '--config', 'If use .pumper.yml config') do
19
+ options[:config] = true
21
20
  end
22
21
 
23
22
  opts.on('-g', '--gemset GEMSET', 'Gemset name (if you use rvm)') do |gemset|
24
23
  options[:gemset] = gemset
25
24
  end
26
25
 
27
-
28
26
  opts.on('-e', '--vendor', 'If project gems stored in the vendor/cache') do
29
- options[:vendor] = true
27
+ options[:is_vendor] = true
30
28
  end
31
29
  end
32
30
 
33
31
  opts.parse!
32
+ config_options = Pumper::Configuration.configure!(options)
34
33
 
35
- Pumper::Pump.new(Pumper::Configuration.configure!(options)).perform
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
@@ -1,9 +1,7 @@
1
1
  module Command
2
2
  class Repository
3
- attr_reader :options
4
-
5
- def initialize(options)
6
- @options = options
3
+ def initialize(project)
4
+ @project = project
7
5
  @cmds = []
8
6
  end
9
7
 
@@ -27,9 +25,11 @@ module Command
27
25
 
28
26
  private
29
27
 
28
+ attr_reader :project
29
+
30
30
  def rvm_prefix
31
- if options[:gemset]
32
- "rvm #{ options[:gemset] } exec "
31
+ if project.gemset
32
+ "rvm #{ project.gemset } exec "
33
33
  end
34
34
  end
35
35
 
data/lib/pumper.rb CHANGED
@@ -11,7 +11,7 @@ end
11
11
  module Pumper
12
12
  autoload :Configuration, 'pumper/configuration'
13
13
  autoload :Specification, 'pumper/specification'
14
- autoload :UpdatingProject, 'pumper/updating_project'
14
+ autoload :Project, 'pumper/project'
15
15
  autoload :Pump, 'pumper/pump'
16
16
  end
17
17
 
@@ -1,18 +1,43 @@
1
+ # Parse and validate options
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
5
+ require 'yaml'
6
+
1
7
  module Pumper
2
8
  class Configuration
3
9
  class ProjectNotSet < StandardError; end
10
+ class InvalidOptions < StandardError; end
4
11
 
5
12
  class << self
6
13
  def configure!(options)
7
14
  validate(options)
8
15
 
9
- options
16
+ options[:config] ? parse_from_config : options
10
17
  end
11
18
 
12
19
  private
13
20
 
14
21
  def validate(options)
15
- raise ProjectNotSet if options[:project].nil?
22
+ if options[:config] && (options[:project] || options[:gemset] || options[:vendor])
23
+ raise InvalidOptions.new('Error: config option use without [project|gemset|vendor] options')
24
+ end
25
+
26
+ if options[:project].nil? && options[:config].nil?
27
+ raise ProjectNotSet.new('You need set project (--project <PATH_TO_PROJECT>) or use config')
28
+ end
29
+ end
30
+
31
+ def parse_from_config
32
+ 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
+ )
40
+ end
16
41
  end
17
42
  end
18
43
  end
@@ -1,12 +1,9 @@
1
1
  module Pumper
2
- class UpdatingProject
2
+ class Project < Struct.new(:project, :is_absolute_path, :gemset, :is_vendor)
3
3
  class UndefinedGem < StandardError; end
4
4
 
5
- attr_reader :project
6
-
7
- def initialize(project, is_absolute_path)
8
- @project = project
9
- @is_absolute_path = is_absolute_path
5
+ def initialize(options)
6
+ set_options(options)
10
7
  @gemfile = gemfile_path
11
8
  end
12
9
 
@@ -17,18 +14,24 @@ module Pumper
17
14
  file.puts(text.gsub(/#{ gem_name(specification.name) }.*/, specification.for_gemfile))
18
15
  end
19
16
  else
20
- raise UpdatingProject::UndefinedGem
17
+ raise Project::UndefinedGem
21
18
  end
22
19
  end
23
20
 
24
21
  def path
25
- @is_absolute_path ?
26
- @project :
27
- File.join(Dir.pwd, "../#{ @project }")
22
+ is_absolute_path ?
23
+ project :
24
+ File.join(Dir.pwd, "../#{ project }")
28
25
  end
29
26
 
30
27
  private
31
28
 
29
+ def set_options(options)
30
+ members.each do |member|
31
+ self.send("#{ member }=", options[member])
32
+ end
33
+ end
34
+
32
35
  def gemfile_path
33
36
  "#{ path }/Gemfile"
34
37
  end
data/lib/pumper/pump.rb CHANGED
@@ -5,13 +5,13 @@ module Pumper
5
5
  end
6
6
 
7
7
  def perform
8
- project = UpdatingProject.new(options[:project], options[:absolute_path])
9
- commands = Command::Repository.new(options)
8
+ project = Project.new(options)
9
+ commands = Command::Repository.new(project)
10
10
 
11
11
  commands.add(Command::GemRebuildCommand)
12
12
  commands.add(Command::GemUninstallCommand, { gem_name: specification.name })
13
13
 
14
- if options[:vendor]
14
+ if project.is_vendor
15
15
  commands.add(Command::GemInstallToVendorCommand, { project_path: project.path, gem_name: specification.name })
16
16
  else
17
17
  commands.add(
@@ -33,7 +33,7 @@ module Pumper
33
33
  attr_reader :options
34
34
 
35
35
  def specification
36
- @specification ||= Specification.new(options[:gemspec])
36
+ @specification ||= Specification.new
37
37
  end
38
38
  end
39
39
  end
@@ -1,8 +1,8 @@
1
1
  require 'delegate'
2
2
  module Pumper
3
3
  class Specification < SimpleDelegator
4
- def initialize(gemspec)
5
- specification = File.read(gemspec_file(gemspec))
4
+ def initialize
5
+ specification = File.read(gemspec_file)
6
6
  super(eval(specification))
7
7
  end
8
8
 
@@ -20,8 +20,8 @@ module Pumper
20
20
 
21
21
  private
22
22
 
23
- def gemspec_file(gemspec)
24
- gemspec || File.join(Dir.pwd, Dir.glob('*.gemspec'))
23
+ def gemspec_file
24
+ Dir.glob("#{ Dir.pwd }/*.gemspec").first
25
25
  end
26
26
  end
27
- end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module Pumper
2
- VERSION = '1.0.1'.freeze
3
- end
2
+ VERSION = '1.2.0'.freeze
3
+ end
data/pumper.gemspec CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ['Nikolay Sverchkov']
10
10
  s.email = ['ssnikolay@gmail.com']
11
- s.homepage = 'https://github.com/ssnikolay/bumper'
12
- s.summary = 'Gem for move another gems to dependent projects'
13
- s.description = 'Gem for move another gems to dependent projects'
11
+ s.homepage = 'https://github.com/ssnikolay/pumper'
12
+ s.summary = 'For update gem version in dependent project'
13
+ s.description = 'For update gem version in dependent project'
14
14
 
15
15
  s.rubyforge_project = 'pumper'
16
16
 
@@ -22,5 +22,5 @@ Gem::Specification.new do |s|
22
22
  s.add_development_dependency 'rspec', '~> 3.1'
23
23
  s.add_development_dependency 'rspec-its', '~> 1.1'
24
24
  s.add_development_dependency 'pry'
25
- s.add_development_dependency 'activesupport'
25
+ s.add_development_dependency 'activesupport', ' >= 3'
26
26
  end
@@ -0,0 +1,10 @@
1
+ projects:
2
+ my_app:
3
+ path: /Users/admin/Projects/my_app
4
+ absolute_path: true
5
+ gemset: ruby-1.9.3@my_app
6
+ vendor: true
7
+ my_app2:
8
+ path: /Users/admin/Projects/my_app2
9
+ absolute_path: true
10
+ gemset: ruby-2.1.0@my_app2
@@ -5,6 +5,7 @@ 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
9
  end
9
10
 
10
11
  context 'when valid project' do
@@ -12,4 +13,35 @@ describe Pumper::Configuration do
12
13
 
13
14
  it { is_expected.to eq(options) }
14
15
  end
15
- end
16
+
17
+ context 'when raise error InvalidOptions' do
18
+ let(:options) { { project: 'cashier', config: true, gemset: 'ruby-2.1.0' } }
19
+
20
+ it { expect { subject }.to raise_error(Pumper::Configuration::InvalidOptions) }
21
+ end
22
+
23
+ context 'when --config' do
24
+ let(:options) { { config: true } }
25
+ before do
26
+ pwd = Dir.pwd
27
+ allow(Dir).to receive(:pwd) { "#{ pwd }/spec/fixtures" }
28
+ end
29
+
30
+ it 'should parse yml' do
31
+ is_expected.to eq([
32
+ {
33
+ project: '/Users/admin/Projects/my_app',
34
+ is_absolute_path: true,
35
+ gemset: 'ruby-1.9.3@my_app',
36
+ is_vendor: true
37
+ },
38
+ {
39
+ project: '/Users/admin/Projects/my_app2',
40
+ is_absolute_path: true,
41
+ gemset: 'ruby-2.1.0@my_app2',
42
+ is_vendor: nil
43
+ }
44
+ ])
45
+ end
46
+ end
47
+ end
@@ -1,15 +1,19 @@
1
1
  require 'ostruct'
2
- describe Pumper::UpdatingProject do
3
- let(:project) { File.expand_path('../../../fixtures', __FILE__) }
4
- let(:is_absolute_path) { true }
5
- let(:project_gemfile) { described_class.new(project, is_absolute_path) }
2
+ describe Pumper::Project do
3
+ let(:options) {
4
+ {
5
+ project: File.expand_path('../../../fixtures', __FILE__),
6
+ is_absolute_path: true
7
+ }
8
+ }
9
+ let(:project_gemfile) { described_class.new(options) }
6
10
 
7
11
  before do
8
12
  File.open(project_gemfile.send(:gemfile_path), 'w') { |f| f.write("gem 'simple_gem'") }
9
13
  end
10
14
 
11
15
  describe 'bump_version!' do
12
- subject { File.read("#{ project }/Gemfile") }
16
+ subject { File.read("#{ options[:project] }/Gemfile") }
13
17
 
14
18
  let(:specification) do
15
19
  OpenStruct.new(
@@ -32,7 +36,7 @@ describe Pumper::UpdatingProject do
32
36
  File.open(project_gemfile.send(:gemfile_path), 'w') { |f| f.write('') }
33
37
  end
34
38
 
35
- it { expect { bump_version }.to raise_error(Pumper::UpdatingProject::UndefinedGem) }
39
+ it { expect { bump_version }.to raise_error(Pumper::Project::UndefinedGem) }
36
40
  end
37
41
  end
38
- end
42
+ end
@@ -13,7 +13,7 @@ describe Pumper::Pump, stub_system: true do
13
13
  end
14
14
  before do
15
15
  allow_any_instance_of(Pumper::Pump).to receive(:specification).and_return(specification)
16
- allow_any_instance_of(Pumper::UpdatingProject).to receive(:bump_version!)
16
+ allow_any_instance_of(Pumper::Project).to receive(:bump_version!)
17
17
  end
18
18
 
19
19
  describe '.perform' do
@@ -37,7 +37,7 @@ describe Pumper::Pump, stub_system: true do
37
37
  end
38
38
 
39
39
  context 'when vendor options' do
40
- let(:options) { { vendor: true } }
40
+ let(:options) { { is_vendor: true } }
41
41
 
42
42
  it 'should print vendor commands' do
43
43
  should eq(
@@ -93,4 +93,4 @@ describe Pumper::Pump, stub_system: true do
93
93
  end
94
94
  end
95
95
  end
96
- end
96
+ end
@@ -1,7 +1,10 @@
1
1
  describe Pumper::Specification do
2
- let(:gemspec) { File.expand_path('../../../fixtures/simple_gem.gemspec', __FILE__) }
2
+ subject { described_class.new }
3
3
 
4
- subject { described_class.new(gemspec) }
4
+ before do
5
+ currrent_path = Dir.pwd
6
+ allow(Dir).to receive_messages(pwd: "#{ currrent_path }/spec/fixtures")
7
+ end
5
8
 
6
9
  its(:name) { is_expected.to eq('simple_gem') }
7
10
  its(:version) { is_expected.to eq('1.2.3') }
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.0.1
4
+ version: 1.2.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-10 00:00:00.000000000 Z
11
+ date: 2015-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -58,15 +58,15 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '3'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
69
- description: Gem for move another gems to dependent projects
68
+ version: '3'
69
+ description: For update gem version in dependent project
70
70
  email:
71
71
  - ssnikolay@gmail.com
72
72
  executables:
@@ -92,19 +92,20 @@ files:
92
92
  - lib/command/stash_gemfile_lock_command.rb
93
93
  - lib/pumper.rb
94
94
  - lib/pumper/configuration.rb
95
+ - lib/pumper/project.rb
95
96
  - lib/pumper/pump.rb
96
97
  - lib/pumper/specification.rb
97
- - lib/pumper/updating_project.rb
98
98
  - lib/pumper/version.rb
99
99
  - pumper.gemspec
100
+ - spec/fixtures/.pumper.yml
100
101
  - spec/fixtures/Gemfile
101
102
  - spec/fixtures/simple_gem.gemspec
102
103
  - spec/lib/pumper/configuration_spec.rb
104
+ - spec/lib/pumper/project_spec.rb
103
105
  - spec/lib/pumper/pump_spec.rb
104
106
  - spec/lib/pumper/specification_spec.rb
105
- - spec/lib/pumper/updating_project_spec.rb
106
107
  - spec/spec_helper.rb
107
- homepage: https://github.com/ssnikolay/bumper
108
+ homepage: https://github.com/ssnikolay/pumper
108
109
  licenses: []
109
110
  metadata: {}
110
111
  post_install_message:
@@ -126,5 +127,5 @@ rubyforge_project: pumper
126
127
  rubygems_version: 2.2.2
127
128
  signing_key:
128
129
  specification_version: 4
129
- summary: Gem for move another gems to dependent projects
130
+ summary: For update gem version in dependent project
130
131
  test_files: []