pumper 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/.rspec +3 -0
- data/.travis.yml +9 -0
- data/Gemfile +3 -0
- data/Gemfile.lock.stash +53 -0
- data/LICENSE +22 -0
- data/README.md +2 -0
- data/Rakefile +3 -0
- data/bin/pumper +34 -0
- data/lib/command/base_command.rb +30 -0
- data/lib/command/gem_install_command.rb +11 -0
- data/lib/command/gem_install_to_vendor_command.rb +11 -0
- data/lib/command/gem_rebuild_command.rb +11 -0
- data/lib/command/gem_uninstall_command.rb +11 -0
- data/lib/command/repository.rb +57 -0
- data/lib/command/stash_gemfile_lock_command.rb +11 -0
- data/lib/pumper/configuration.rb +19 -0
- data/lib/pumper/pump.rb +39 -0
- data/lib/pumper/specification.rb +27 -0
- data/lib/pumper/updating_project.rb +44 -0
- data/lib/pumper/version.rb +3 -0
- data/lib/pumper.rb +17 -0
- data/pumper.gemspec +26 -0
- data/spec/fixtures/Gemfile +0 -0
- data/spec/fixtures/simple_gem.gemspec +7 -0
- data/spec/lib/pumper/configuration_spec.rb +15 -0
- data/spec/lib/pumper/pump_spec.rb +96 -0
- data/spec/lib/pumper/specification_spec.rb +10 -0
- data/spec/lib/pumper/updating_project_spec.rb +38 -0
- data/spec/spec_helper.rb +25 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 824a291e503892ccb1b29dcaf6c2f442d4ba31eb
|
4
|
+
data.tar.gz: def9eb660157e7120b8cc01e33d9c2cf92158fd8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a9b691666cbc33b2fa6fe034c13da198e32989f9eeed323ba26d22d83b6a6cb8f90d92d8edf9efdd1c2f4d469a1b052645b6ed6a47b57689e8969cb67cdc8d52
|
7
|
+
data.tar.gz: 5654dda987711919bafc163e3651ee2955c04286f1f38df6e48170b7428fadc1363cee7601969fa1d3575b541450f2545a8aaa25b1570c60fd04d784d71d1ebd
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock.stash
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
pumper (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activesupport (4.2.0)
|
10
|
+
i18n (~> 0.7)
|
11
|
+
json (~> 1.7, >= 1.7.7)
|
12
|
+
minitest (~> 5.1)
|
13
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
14
|
+
tzinfo (~> 1.1)
|
15
|
+
coderay (1.1.0)
|
16
|
+
diff-lcs (1.2.5)
|
17
|
+
i18n (0.7.0)
|
18
|
+
json (1.8.1)
|
19
|
+
method_source (0.8.2)
|
20
|
+
minitest (5.5.0)
|
21
|
+
pry (0.10.1)
|
22
|
+
coderay (~> 1.1.0)
|
23
|
+
method_source (~> 0.8.1)
|
24
|
+
slop (~> 3.4)
|
25
|
+
rspec (3.1.0)
|
26
|
+
rspec-core (~> 3.1.0)
|
27
|
+
rspec-expectations (~> 3.1.0)
|
28
|
+
rspec-mocks (~> 3.1.0)
|
29
|
+
rspec-core (3.1.7)
|
30
|
+
rspec-support (~> 3.1.0)
|
31
|
+
rspec-expectations (3.1.2)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.1.0)
|
34
|
+
rspec-its (1.1.0)
|
35
|
+
rspec-core (>= 3.0.0)
|
36
|
+
rspec-expectations (>= 3.0.0)
|
37
|
+
rspec-mocks (3.1.3)
|
38
|
+
rspec-support (~> 3.1.0)
|
39
|
+
rspec-support (3.1.2)
|
40
|
+
slop (3.6.0)
|
41
|
+
thread_safe (0.3.4)
|
42
|
+
tzinfo (1.2.2)
|
43
|
+
thread_safe (~> 0.1)
|
44
|
+
|
45
|
+
PLATFORMS
|
46
|
+
ruby
|
47
|
+
|
48
|
+
DEPENDENCIES
|
49
|
+
activesupport (~> 4.2)
|
50
|
+
pry
|
51
|
+
pumper!
|
52
|
+
rspec (~> 3.1)
|
53
|
+
rspec-its (~> 1.1)
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Sverchkov Nikolay
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
data/Rakefile
ADDED
data/bin/pumper
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'optparse'
|
3
|
+
require 'pumper'
|
4
|
+
|
5
|
+
options = Hash.new
|
6
|
+
|
7
|
+
opts = OptionParser.new do |opts|
|
8
|
+
opts.banner = %q[Bumper]
|
9
|
+
|
10
|
+
opts.on('-p', '--project PROJECT_PATH', 'Set path to gem bump project') do |project|
|
11
|
+
options[:project] = project
|
12
|
+
end
|
13
|
+
|
14
|
+
# Default find in current folder file *.gemspec
|
15
|
+
opts.on('-s', '--gemspec GEMSPEC_PATH', 'Set path to gemspec') do |gemspec|
|
16
|
+
options[:gemspec] = gemspec
|
17
|
+
end
|
18
|
+
|
19
|
+
opts.on('-g', '--gemset GEMSET', 'Set path to gemspec') do |gemset|
|
20
|
+
options[:gemset] = gemset
|
21
|
+
end
|
22
|
+
|
23
|
+
opts.on('-a', '--absolute_path', 'If project absolute path') do
|
24
|
+
options[:absolute_path] = true
|
25
|
+
end
|
26
|
+
|
27
|
+
opts.on('-e', '--vendor', 'If need add to vendor path') do
|
28
|
+
options[:vendor] = true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
opts.parse!
|
33
|
+
|
34
|
+
Pumper::Pump.new(Pumper::Configuration.configure!(options)).perform
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Command
|
2
|
+
class ExecuteError < StandardError; end
|
3
|
+
|
4
|
+
class BaseCommand
|
5
|
+
attr_reader :rvm_prefix, :options
|
6
|
+
|
7
|
+
def initialize(rvm_prefix = nil, options = {})
|
8
|
+
@rvm_prefix = rvm_prefix
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
12
|
+
def execute
|
13
|
+
system(name) or raise Command::ExecuteError
|
14
|
+
end
|
15
|
+
|
16
|
+
def cancel
|
17
|
+
raise NotImplementedError
|
18
|
+
end
|
19
|
+
|
20
|
+
def name
|
21
|
+
raise NotImplementedError
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def clean(cmd)
|
27
|
+
cmd.gsub(/\s+/, ' ').strip
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Command
|
2
|
+
class GemInstallCommand < BaseCommand
|
3
|
+
def cancel
|
4
|
+
Command::GemUninstallCommand.new(rvm_prefix, { gem_name: options[:gem_name] }).execute
|
5
|
+
end
|
6
|
+
|
7
|
+
def name
|
8
|
+
clean "#{ rvm_prefix } gem install ./pkg/#{ options[:gem_file_name] } && cd #{ options[:project_path] } && #{ rvm_prefix } bundle install"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Command
|
2
|
+
class GemInstallToVendorCommand < BaseCommand
|
3
|
+
def cancel
|
4
|
+
Command::GemUninstallCommand.new(rvm_prefix, { gem_name: options[:gem_name] }).execute
|
5
|
+
end
|
6
|
+
|
7
|
+
def name
|
8
|
+
clean "cp pkg/* #{ options[:project_path] }/vendor/cache && cd #{ options[:project_path] } && #{ rvm_prefix } bundle install --local"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Command
|
2
|
+
class Repository
|
3
|
+
attr_reader :options
|
4
|
+
|
5
|
+
def initialize(options)
|
6
|
+
@options = options
|
7
|
+
@cmds = []
|
8
|
+
end
|
9
|
+
|
10
|
+
def add(cmd, options = {})
|
11
|
+
@cmds << cmd.new(rvm_prefix, options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def execute
|
15
|
+
with_transaction do |trash|
|
16
|
+
while @cmds.any?
|
17
|
+
command = @cmds.shift
|
18
|
+
puts(command.name.brown)
|
19
|
+
|
20
|
+
command.execute
|
21
|
+
trash.unshift(command)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
puts 'Success bump current gem'.green
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def rvm_prefix
|
31
|
+
if options[:gemset]
|
32
|
+
"rvm #{ options[:gemset] } exec "
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def with_transaction
|
37
|
+
trash = []
|
38
|
+
wrapper = Command::StashGemfileLockCommand.new
|
39
|
+
begin
|
40
|
+
wrapper.execute
|
41
|
+
yield(trash)
|
42
|
+
rescue Exception => e
|
43
|
+
trash.each(&:cancel)
|
44
|
+
puts 'Fail bump current gem'.red
|
45
|
+
raise Command::ExecuteError
|
46
|
+
ensure
|
47
|
+
wrapper.cancel
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class String
|
54
|
+
def red; "\033[31m#{self}\033[0m" end
|
55
|
+
def green; "\033[32m#{self}\033[0m" end
|
56
|
+
def brown; "\033[33m#{self}\033[0m" end
|
57
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Pumper
|
2
|
+
class Configuration
|
3
|
+
class ProjectNotSet < StandardError; end
|
4
|
+
|
5
|
+
class << self
|
6
|
+
def configure!(options)
|
7
|
+
validate(options)
|
8
|
+
|
9
|
+
options
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def validate(options)
|
15
|
+
raise ProjectNotSet if options[:project].nil?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/pumper/pump.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
module Pumper
|
2
|
+
class Pump
|
3
|
+
def initialize(options)
|
4
|
+
@options = options
|
5
|
+
end
|
6
|
+
|
7
|
+
def perform
|
8
|
+
project = UpdatingProject.new(options[:project], options[:absolute_path])
|
9
|
+
commands = Command::Repository.new(options)
|
10
|
+
|
11
|
+
commands.add(Command::GemRebuildCommand)
|
12
|
+
commands.add(Command::GemUninstallCommand, { gem_name: specification.name })
|
13
|
+
|
14
|
+
if options[:vendor]
|
15
|
+
commands.add(Command::GemInstallToVendorCommand, { project_path: project.path, gem_name: specification.name })
|
16
|
+
else
|
17
|
+
commands.add(
|
18
|
+
Command::GemInstallCommand,
|
19
|
+
{
|
20
|
+
gem_name: specification.name,
|
21
|
+
gem_file_name: specification.gem_file_name,
|
22
|
+
project_path: project.path
|
23
|
+
}
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
project.bump_version!(specification)
|
28
|
+
commands.execute
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
attr_reader :options
|
34
|
+
|
35
|
+
def specification
|
36
|
+
@specification ||= Specification.new(options[:gemspec])
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'delegate'
|
2
|
+
module Pumper
|
3
|
+
class Specification < SimpleDelegator
|
4
|
+
def initialize(gemspec)
|
5
|
+
specification = File.read(gemspec_file(gemspec))
|
6
|
+
super(eval(specification))
|
7
|
+
end
|
8
|
+
|
9
|
+
def for_gemfile
|
10
|
+
"gem '#{ name }', '~> #{ version }'"
|
11
|
+
end
|
12
|
+
|
13
|
+
def gem_file_name
|
14
|
+
"#{ name }-#{ version }.gem"
|
15
|
+
end
|
16
|
+
|
17
|
+
def version
|
18
|
+
super.to_s
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def gemspec_file(gemspec)
|
24
|
+
gemspec || File.join(Dir.pwd, Dir.glob('*.gemspec'))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Pumper
|
2
|
+
class UpdatingProject
|
3
|
+
class UndefinedGem < StandardError; end
|
4
|
+
|
5
|
+
attr_reader :project
|
6
|
+
|
7
|
+
def initialize(project, is_absolute_path)
|
8
|
+
@project = project
|
9
|
+
@is_absolute_path = is_absolute_path
|
10
|
+
@gemfile = gemfile_path
|
11
|
+
end
|
12
|
+
|
13
|
+
def bump_version!(specification)
|
14
|
+
text = File.read(@gemfile)
|
15
|
+
if gem_defined?(text, specification.name)
|
16
|
+
File.open(@gemfile, 'w') do |file|
|
17
|
+
file.puts(text.gsub(/#{ gem_name(specification.name) }.*/, specification.for_gemfile))
|
18
|
+
end
|
19
|
+
else
|
20
|
+
raise UpdatingProject::UndefinedGem
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def path
|
25
|
+
@is_absolute_path ?
|
26
|
+
@project :
|
27
|
+
File.join(Dir.pwd, "../#{ @project }")
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def gemfile_path
|
33
|
+
"#{ path }/Gemfile"
|
34
|
+
end
|
35
|
+
|
36
|
+
def gem_defined?(gemfile_text, gem)
|
37
|
+
gemfile_text.include?(gem_name(gem))
|
38
|
+
end
|
39
|
+
|
40
|
+
def gem_name(gem)
|
41
|
+
"gem '#{ gem }'"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/pumper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Command
|
2
|
+
autoload :BaseCommand, 'command/base_command'
|
3
|
+
autoload :GemUninstallCommand, 'command/gem_uninstall_command'
|
4
|
+
autoload :GemRebuildCommand, 'command/gem_rebuild_command'
|
5
|
+
autoload :GemInstallCommand, 'command/gem_install_command'
|
6
|
+
autoload :GemInstallToVendorCommand, 'command/gem_install_to_vendor_command'
|
7
|
+
autoload :StashGemfileLockCommand, 'command/stash_gemfile_lock_command'
|
8
|
+
autoload :Repository, 'command/repository'
|
9
|
+
end
|
10
|
+
|
11
|
+
module Pumper
|
12
|
+
autoload :Configuration, 'pumper/configuration'
|
13
|
+
autoload :Specification, 'pumper/specification'
|
14
|
+
autoload :UpdatingProject, 'pumper/updating_project'
|
15
|
+
autoload :Pump, 'pumper/pump'
|
16
|
+
end
|
17
|
+
|
data/pumper.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'pumper/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'pumper'
|
7
|
+
s.version = Pumper::VERSION.dup
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ['Nikolay Sverchkov']
|
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'
|
14
|
+
|
15
|
+
s.rubyforge_project = 'pumper'
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {spec}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ['lib']
|
21
|
+
|
22
|
+
s.add_development_dependency 'rspec', '~> 3.1'
|
23
|
+
s.add_development_dependency 'rspec-its', '~> 1.1'
|
24
|
+
s.add_development_dependency 'pry'
|
25
|
+
s.add_development_dependency 'activesupport', '~> 4.2'
|
26
|
+
end
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
describe Pumper::Configuration do
|
2
|
+
let(:options) { Hash.new }
|
3
|
+
|
4
|
+
subject { described_class.configure!(options) }
|
5
|
+
|
6
|
+
context 'when raise error ProjectNotSet' do
|
7
|
+
it { expect { subject }.to raise_error(Pumper::Configuration::ProjectNotSet) }
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'when valid project' do
|
11
|
+
let(:options) { { project: 'cashier' } }
|
12
|
+
|
13
|
+
it { is_expected.to eq(options) }
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
describe Pumper::Pump, stub_system: true do
|
3
|
+
let(:options) { Hash.new }
|
4
|
+
let(:default_options) { { project: 'simple_project' } }
|
5
|
+
|
6
|
+
let(:pumper) { described_class.new(options.merge(default_options)) }
|
7
|
+
let(:specification) do
|
8
|
+
OpenStruct.new(
|
9
|
+
name: 'simple_gem',
|
10
|
+
version: '1.0',
|
11
|
+
gem_file_name: 'simple_gem-1.0.gem'
|
12
|
+
)
|
13
|
+
end
|
14
|
+
before do
|
15
|
+
allow_any_instance_of(Pumper::Pump).to receive(:specification).and_return(specification)
|
16
|
+
allow_any_instance_of(Pumper::UpdatingProject).to receive(:bump_version!)
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '.perform' do
|
20
|
+
subject do
|
21
|
+
pumper.perform
|
22
|
+
$OUTPUT.join("\n")
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when simple options' do
|
26
|
+
it 'should print base commands' do
|
27
|
+
should eq(
|
28
|
+
<<-output.strip_heredoc.strip
|
29
|
+
mv ./Gemfile.lock ./Gemfile.lock.stash
|
30
|
+
rm -rf pkg && bundle exec rake build
|
31
|
+
gem uninstall simple_gem --all -x
|
32
|
+
gem install ./pkg/simple_gem-1.0.gem && cd #{ Dir.pwd }/../simple_project && bundle install
|
33
|
+
mv ./Gemfile.lock.stash ./Gemfile.lock
|
34
|
+
output
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when vendor options' do
|
40
|
+
let(:options) { { vendor: true } }
|
41
|
+
|
42
|
+
it 'should print vendor commands' do
|
43
|
+
should eq(
|
44
|
+
<<-OUTPUT.strip_heredoc.strip
|
45
|
+
mv ./Gemfile.lock ./Gemfile.lock.stash
|
46
|
+
rm -rf pkg && bundle exec rake build
|
47
|
+
gem uninstall simple_gem --all -x
|
48
|
+
cp pkg/* #{ Dir.pwd }/../simple_project/vendor/cache && cd #{ Dir.pwd }/../simple_project && bundle install --local
|
49
|
+
mv ./Gemfile.lock.stash ./Gemfile.lock
|
50
|
+
OUTPUT
|
51
|
+
)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when gemset options' do
|
56
|
+
let(:options) { { gemset: '1.9.3@simple_project' } }
|
57
|
+
|
58
|
+
it 'should print gemset commands' do
|
59
|
+
should eq(
|
60
|
+
<<-output.strip_heredoc.strip
|
61
|
+
mv ./Gemfile.lock ./Gemfile.lock.stash
|
62
|
+
rm -rf pkg && bundle exec rake build
|
63
|
+
rvm 1.9.3@simple_project exec gem uninstall simple_gem --all -x
|
64
|
+
rvm 1.9.3@simple_project exec gem install ./pkg/simple_gem-1.0.gem && cd #{ Dir.pwd }/../simple_project && rvm 1.9.3@simple_project exec bundle install
|
65
|
+
mv ./Gemfile.lock.stash ./Gemfile.lock
|
66
|
+
output
|
67
|
+
)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'when gem install failed' do
|
72
|
+
before { allow_any_instance_of(Command::GemInstallCommand).to receive(:system).and_return(false) }
|
73
|
+
|
74
|
+
it { expect{ subject }.to raise_error(Command::ExecuteError) }
|
75
|
+
|
76
|
+
describe 'canceled commands' do
|
77
|
+
subject do
|
78
|
+
pumper.perform rescue nil
|
79
|
+
$OUTPUT.join("\n")
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'should brake on install and run cancel commands' do
|
83
|
+
should eq(
|
84
|
+
<<-output.strip_heredoc.strip
|
85
|
+
mv ./Gemfile.lock ./Gemfile.lock.stash
|
86
|
+
rm -rf pkg && bundle exec rake build
|
87
|
+
gem uninstall simple_gem --all -x
|
88
|
+
rm -rf pkg
|
89
|
+
mv ./Gemfile.lock.stash ./Gemfile.lock
|
90
|
+
output
|
91
|
+
)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
describe Pumper::Specification do
|
2
|
+
let(:gemspec) { File.expand_path('../../../fixtures/simple_gem.gemspec', __FILE__) }
|
3
|
+
|
4
|
+
subject { described_class.new(gemspec) }
|
5
|
+
|
6
|
+
its(:name) { is_expected.to eq('simple_gem') }
|
7
|
+
its(:version) { is_expected.to eq('1.2.3') }
|
8
|
+
its(:for_gemfile) { is_expected.to eq("gem 'simple_gem', '~> 1.2.3'") }
|
9
|
+
its(:gem_file_name) { is_expected.to eq('simple_gem-1.2.3.gem') }
|
10
|
+
end
|
@@ -0,0 +1,38 @@
|
|
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) }
|
6
|
+
|
7
|
+
before do
|
8
|
+
File.open(project_gemfile.send(:gemfile_path), 'w') { |f| f.write("gem 'simple_gem'") }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'bump_version!' do
|
12
|
+
subject { File.read("#{ project }/Gemfile") }
|
13
|
+
|
14
|
+
let(:specification) do
|
15
|
+
OpenStruct.new(
|
16
|
+
name: 'simple_gem',
|
17
|
+
for_gemfile: "gem 'simple_gem', '~> 1.1.0'"
|
18
|
+
)
|
19
|
+
end
|
20
|
+
let(:bump_version) { project_gemfile.bump_version!(specification) }
|
21
|
+
|
22
|
+
it { should_not be_include(specification.for_gemfile) }
|
23
|
+
|
24
|
+
context 'when everything is good :)' do
|
25
|
+
before { bump_version }
|
26
|
+
|
27
|
+
it { should be_include(specification.for_gemfile) }
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when Gemfile have not bumped gem' do
|
31
|
+
before do
|
32
|
+
File.open(project_gemfile.send(:gemfile_path), 'w') { |f| f.write('') }
|
33
|
+
end
|
34
|
+
|
35
|
+
it { expect { bump_version }.to raise_error(Pumper::UpdatingProject::UndefinedGem) }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
require 'pry'
|
3
|
+
require 'rspec'
|
4
|
+
require 'pumper'
|
5
|
+
require 'rspec/its'
|
6
|
+
require 'active_support/all'
|
7
|
+
|
8
|
+
Dir['spec/support/**/*.rb'].each do |file|
|
9
|
+
require File.join(File.dirname(__FILE__), '..', file)
|
10
|
+
end
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.before(:each, stub_system: true) do
|
14
|
+
$OUTPUT = []
|
15
|
+
module Kernel
|
16
|
+
def system(cmd)
|
17
|
+
$OUTPUT << cmd
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
config.after(:each, stub_system: true) do
|
23
|
+
$OUTPUT = []
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pumper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nikolay Sverchkov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.1'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec-its
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.2'
|
69
|
+
description: Gem for move another gems to dependent projects
|
70
|
+
email:
|
71
|
+
- ssnikolay@gmail.com
|
72
|
+
executables:
|
73
|
+
- pumper
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".travis.yml"
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock.stash
|
82
|
+
- LICENSE
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/pumper
|
86
|
+
- lib/command/base_command.rb
|
87
|
+
- lib/command/gem_install_command.rb
|
88
|
+
- lib/command/gem_install_to_vendor_command.rb
|
89
|
+
- lib/command/gem_rebuild_command.rb
|
90
|
+
- lib/command/gem_uninstall_command.rb
|
91
|
+
- lib/command/repository.rb
|
92
|
+
- lib/command/stash_gemfile_lock_command.rb
|
93
|
+
- lib/pumper.rb
|
94
|
+
- lib/pumper/configuration.rb
|
95
|
+
- lib/pumper/pump.rb
|
96
|
+
- lib/pumper/specification.rb
|
97
|
+
- lib/pumper/updating_project.rb
|
98
|
+
- lib/pumper/version.rb
|
99
|
+
- pumper.gemspec
|
100
|
+
- spec/fixtures/Gemfile
|
101
|
+
- spec/fixtures/simple_gem.gemspec
|
102
|
+
- spec/lib/pumper/configuration_spec.rb
|
103
|
+
- spec/lib/pumper/pump_spec.rb
|
104
|
+
- spec/lib/pumper/specification_spec.rb
|
105
|
+
- spec/lib/pumper/updating_project_spec.rb
|
106
|
+
- spec/spec_helper.rb
|
107
|
+
homepage: https://github.com/ssnikolay/bumper
|
108
|
+
licenses: []
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project: pumper
|
126
|
+
rubygems_version: 2.2.2
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: Gem for move another gems to dependent projects
|
130
|
+
test_files: []
|