pushwagner 0.0.2.2 → 0.0.2.3

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: 3142a8d21b384c10cadfd88fc49d904386cad79d
4
- data.tar.gz: 9a9a00947c2060371ca50c55ecdc0f83be9c40fb
3
+ metadata.gz: fe236d345b1c2f032602d5223892be7ed6cdd787
4
+ data.tar.gz: 81c0457531861318a266868ee36f546d780e0a24
5
5
  SHA512:
6
- metadata.gz: b7a2c24caf3673f67a632abb8540282ac2ac3464b288957282b96723b3433a394ede0810e2ac397fb1fa8e068b0f6a5384f90ab95869fc37be9eed163b79422d
7
- data.tar.gz: 78de40702fca070aa7e87256d89ee36b1b638607fff2f3522ae7faadaf3c31467ea61eb5d9b2c39e5b6b97e03f773ffa5de7ba7b9e3c8ac776480be23707ab6d
6
+ metadata.gz: 2aa8d1dea5ceb4e4d83b1c0135919889c191f74358c823ecb921d5d218af19322130fdf14ff5ed6c2cb8052cc26f3276fe6123794d4c41ffff9365ddd38c3e12
7
+ data.tar.gz: 5005a2be5701ca4e1d5b6ddf75bffb3bdeedb34ba0e9496c22966f7c0b0e0ca6f78ee28a58b4e98eda961839fb98dc80ba620a5eb2addcccde9d6ace5de2c588
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pushwagner (0.0.2.2)
4
+ pushwagner (0.0.2.3)
5
5
  colorize (~> 0.7)
6
6
  net-scp (~> 1.2, >= 1.2.1)
7
7
  net-ssh (~> 3.1, >= 3.1.1)
@@ -11,15 +11,15 @@ GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
13
  coderay (1.1.1)
14
- colorize (0.7.7)
14
+ colorize (0.8.1)
15
15
  diff-lcs (1.2.5)
16
16
  method_source (0.8.2)
17
- mini_portile2 (2.0.0)
17
+ mini_portile2 (2.2.0)
18
18
  net-scp (1.2.1)
19
19
  net-ssh (>= 2.6.5)
20
- net-ssh (3.1.1)
21
- nokogiri (1.6.7.2)
22
- mini_portile2 (~> 2.0.0.rc2)
20
+ net-ssh (3.2.0)
21
+ nokogiri (1.8.0)
22
+ mini_portile2 (~> 2.2.0)
23
23
  pry (0.10.3)
24
24
  coderay (~> 1.1.0)
25
25
  method_source (~> 0.8.1)
@@ -51,4 +51,4 @@ DEPENDENCIES
51
51
  rspec
52
52
 
53
53
  BUNDLED WITH
54
- 1.12.2
54
+ 1.15.1
data/README.md CHANGED
@@ -89,16 +89,16 @@ Sudo support, automatically prompts for passwd, or use: `env PUSHWAGNER_SUDO=sud
89
89
 
90
90
  ````yaml
91
91
  hooks:
92
- local:
93
- before:
94
- - mvn package
95
- after:
96
- - mvn test -Pint
97
- remote:
98
- before:
99
- - /usr/sbin/service foo stop
100
- after:
101
- - /usr/sbin/service foo start
92
+ local:
93
+ before:
94
+ - mvn package
95
+ after:
96
+ - mvn test -Pint
97
+ remote:
98
+ before:
99
+ - /usr/sbin/service foo stop
100
+ after:
101
+ - /usr/sbin/service foo start
102
102
  ````
103
103
 
104
104
  ### Environments
data/bin/pw CHANGED
@@ -2,18 +2,31 @@
2
2
 
3
3
  require 'pushwagner'
4
4
  require 'pushwagner/version'
5
+ require 'optparse'
6
+ require 'ostruct'
5
7
 
6
8
  def get_version
7
9
  Pushwagner.info "You must specify which version you wish to deploy"
8
10
  STDIN.gets.strip
9
11
  end
10
12
 
11
- # TODO: detect version requirement from config
12
- version = 1 # ENV["VERSION"] || get_version
13
+ options = OpenStruct.new
14
+ options.environment = 'default'
15
+ options.version = '1'
16
+ options.config_file = '.pw.yml'
17
+ options.command = 'todo'
13
18
 
14
- env = ARGV[1] || ENV['PW_ENV'] || 'default'
19
+ OptionParser.new do |opts|
20
+ opts.banner = 'Usage: pw <deploy> [options]'
21
+ opts.on('deploy') { |v| options.command = 'deploy'}
22
+ opts.on('-c FILE', 'Use config file') { |v| options.config_file = v }
23
+ opts.on('-e ENV', 'Set environment') { |v| options.environment = v }
24
+ opts.on('-V VERSION', 'Set version') { |v| options.version = v }
25
+ opts.on('-v', '--version', 'Show version') { |v| puts Pushwagner::VERSION; exit }
26
+ opts.on('-h', '--help', 'Show help') { |v| puts puts opts; exit }
27
+ end.parse!
15
28
 
16
- main = Pushwagner::Main.new(:config_file => 'config/deploy.yml', :version => version, :environment => env)
29
+ main = Pushwagner::Main.new(options.to_h)
17
30
 
18
31
  puts (
19
32
  %q{
@@ -27,10 +40,9 @@ puts (
27
40
  puts
28
41
 
29
42
 
30
- # TODO: detect cli from config
31
- case ARGV[0]
43
+ case options.command
32
44
  when "deploy"
33
45
  main.deploy
34
46
  else
35
- Pushwagner.warning "Usage: pw <deploy|todo> [environment]"
47
+ Pushwagner.warning "Usage: pw <command> [options]"
36
48
  end
@@ -2,7 +2,12 @@ module Pushwagner
2
2
 
3
3
  class Main
4
4
  def initialize(opts = {})
5
- @environment = Pushwagner::Environment.new(opts)
5
+ begin
6
+ @environment = Pushwagner::Environment.new(opts)
7
+ rescue => e
8
+ Pushwagner.severe e.message
9
+ raise e
10
+ end
6
11
  end
7
12
 
8
13
  def set_environment(env)
@@ -1,3 +1,3 @@
1
1
  module Pushwagner
2
- VERSION = "0.0.2.2"
2
+ VERSION = "0.0.2.3"
3
3
  end
@@ -4,7 +4,7 @@ require 'pushwagner/environment'
4
4
  describe Pushwagner::Environment do
5
5
  describe "#initialize" do
6
6
  it "requires config_file" do
7
- expect { Pushwagner::Environment.new('config_file' => File.join(config_root, 'nonexisting.yml'))}.to raise_error
7
+ expect { Pushwagner::Environment.new('config_file' => File.join(config_root, 'nonexisting.yml'))}.to raise_error(RuntimeError, /Couldn't find config file in locations: (.*)/)
8
8
  end
9
9
 
10
10
  it "supports config_file" do
@@ -30,14 +30,14 @@ describe Pushwagner::Environment do
30
30
 
31
31
  it "returns empty hash when not configured" do
32
32
  env = Pushwagner::Environment.new(:config_file => File.join(config_root, 'static.yml'), :version => "1foo" )
33
- expect(env.maven?).to be_false
33
+ expect(env.maven?).to be false
34
34
  expect(env.maven).to eq({})
35
35
  end
36
36
  end
37
37
  describe "static files" do
38
38
  it "returns empty hash when not configured" do
39
39
  env = Pushwagner::Environment.new(:config_file => File.join(config_root, 'maven.yml'), :version => "1foo" )
40
- expect(env.static?).to be_false
40
+ expect(env.static?).to be false
41
41
  expect(env.static).to eq({})
42
42
  end
43
43
  it "parses to a hash of files" do
data/spec/hooks_spec.rb CHANGED
@@ -8,7 +8,7 @@ describe Pushwagner::Hooks do
8
8
 
9
9
  describe "#initialize" do
10
10
  it "raises error if invalid environment" do
11
- expect { Pushwagner::Hooks.new(nil) }.to raise_exception
11
+ expect { Pushwagner::Hooks.new(nil) }.to raise_exception(StandardError, /Invalid environment/)
12
12
  end
13
13
 
14
14
  it "returns an empty config with an empty environment" do
@@ -30,14 +30,16 @@ describe Pushwagner::Hooks do
30
30
  describe "#run" do
31
31
  it "requires an argument" do
32
32
  sut = Pushwagner::Hooks.new(env)
33
- expect { sut.run() }.to raise_exception
33
+ expect { sut.run() }.to raise_exception(ArgumentError, /wrong number of arguments/)
34
34
  end
35
35
 
36
36
  it "accepts run :after target" do
37
37
  sut = Pushwagner::Hooks.new(env)
38
38
 
39
- sut.stub_chain("local.run").with(:after).once
40
- sut.stub_chain("remote.run").with(:after).once
39
+ #sut.stub_chain("local.run").with(:after).once
40
+ #sut.stub_chain("remote.run").with(:after).once
41
+ expect(sut.local).to receive(:run).with(:after).once
42
+ expect(sut.remote).to receive(:run).with(:after).once
41
43
 
42
44
  sut.run(:after)
43
45
  end
@@ -45,8 +47,10 @@ describe Pushwagner::Hooks do
45
47
  it "accepts run :before target" do
46
48
  sut = Pushwagner::Hooks.new(env)
47
49
 
48
- sut.stub_chain("local.run").with(:before).once
49
- sut.stub_chain("remote.run").with(:before).once
50
+ #sut.stub_chain("local.run").with(:before).once
51
+ expect(sut.local).to receive(:run).with(:before).once
52
+ expect(sut.remote).to receive(:run).with(:before).once
53
+ #sut.stub_chain("remote.run").with(:before).once
50
54
 
51
55
  sut.run(:before)
52
56
  end
@@ -69,27 +73,19 @@ describe Pushwagner::Hooks::Local do
69
73
  it "requires an argument" do
70
74
  sut = Pushwagner::Hooks::Local.new(env, env.hooks['local'])
71
75
 
72
- expect { sut.run() }.to raise_exception
76
+ expect { sut.run() }.to raise_exception(ArgumentError, /wrong number of arguments/)
73
77
  end
74
78
  it "supports :before hooks" do
75
79
  sut = Pushwagner::Hooks::Local.new(env, env.hooks['local'])
76
80
 
77
- Pushwagner.stub(:info)
78
- Pushwagner.stub(:begin_info)
79
- Pushwagner.stub(:ok)
80
-
81
- sut.should_receive(:system).with('echo "one"').once
81
+ expect(sut).to receive(:system).with('echo "one"').once
82
82
  sut.run(:before)
83
83
  end
84
84
  it "supports :after hooks" do
85
85
  sut = Pushwagner::Hooks::Local.new(env, env.hooks['local'])
86
86
 
87
- Pushwagner.stub(:info)
88
- Pushwagner.stub(:begin_info)
89
- Pushwagner.stub(:ok)
90
-
91
- sut.should_receive(:system).with('echo "two"').once
92
- sut.should_receive(:system).with('echo "three"').once
87
+ expect(sut).to receive(:system).with('echo "two"').once
88
+ expect(sut).to receive(:system).with('echo "three"').once
93
89
  sut.run(:after)
94
90
  end
95
91
  end
@@ -111,21 +107,19 @@ describe Pushwagner::Hooks::Remote do
111
107
  it "requires an argument" do
112
108
  sut = Pushwagner::Hooks::Remote.new(env, env.hooks['remote'])
113
109
 
114
- expect { sut.run() }.to raise_exception
110
+ expect { sut.run() }.to raise_exception(ArgumentError, /wrong number of arguments/)
115
111
  end
116
112
 
117
113
  it "supports :before hooks" do
118
114
  sut = Pushwagner::Hooks::Remote.new(env, env.hooks['remote'])
119
115
 
120
- Pushwagner.stub(:info)
121
- Pushwagner.stub(:begin_info)
122
- Pushwagner.stub(:ok)
123
-
124
116
  # Mock Net::SSH inner interaction smoke test
125
- ssh = mock
126
- ssh.should_receive(:open_channel).exactly(4).times
127
- ssh.should_receive(:loop).exactly(4).times
128
- Net::SSH.should_receive(:start).and_yield(ssh).exactly(4).times
117
+ ssh = double()
118
+
119
+ expect(ssh).to receive(:open_channel).exactly(4).times
120
+ expect(ssh).to receive(:loop).exactly(4).times
121
+
122
+ expect(Net::SSH).to receive(:start).and_yield(ssh).exactly(4).times
129
123
 
130
124
  sut.run(:before)
131
125
  end
@@ -134,9 +128,9 @@ describe Pushwagner::Hooks::Remote do
134
128
  sut = Pushwagner::Hooks::Remote.new(env, env.hooks['remote'])
135
129
 
136
130
  # Mock Net::SSH inner interaction smoke
137
- ssh = mock
138
- ssh.should_receive(:open_channel).never
139
- Net::SSH.should_receive(:start).and_yield(ssh).never
131
+ ssh = double()
132
+ expect(ssh).to receive(:open_channel).never
133
+ expect(Net::SSH).to receive(:start).and_yield(ssh).never
140
134
 
141
135
  sut.run(:after)
142
136
  end
data/spec/maven_spec.rb CHANGED
@@ -43,15 +43,15 @@ describe Pushwagner::Maven do
43
43
  describe "repositories" do
44
44
  it "requires repositories configuration element" do
45
45
  cfg.delete('repositories')
46
- expect {Pushwagner::Maven.new(cfg, "1")}.to raise_error(StandardError)
46
+ expect {Pushwagner::Maven.new(cfg, "1")}.to raise_error(StandardError, /repositories configuration required/)
47
47
  end
48
48
  it "requires 'snapshots' repository" do
49
49
  cfg['repositories'].delete('snapshots')
50
- expect {Pushwagner::Maven.new(cfg, "1")}.to raise_error(StandardError)
50
+ expect {Pushwagner::Maven.new(cfg, "1")}.to raise_error(StandardError, /snapshots repository required/)
51
51
  end
52
52
  it "requires 'releases' repository" do
53
53
  cfg['repositories'].delete('releases')
54
- expect {Pushwagner::Maven.new(cfg, "1")}.to raise_error(StandardError)
54
+ expect {Pushwagner::Maven.new(cfg, "1")}.to raise_error(StandardError, /releases repository required/)
55
55
  end
56
56
  it "parses repositories" do
57
57
  m = Pushwagner::Maven.new(cfg, "1")
@@ -66,7 +66,7 @@ describe Pushwagner::Maven do
66
66
 
67
67
  it "reads releases authentication from maven settings.xml" do
68
68
  m = Pushwagner::Maven.new(cfg, "1")
69
- m.repository.should_receive(:open).
69
+ expect(m.repository).to receive(:open).
70
70
  with(/.*settings.xml$/).
71
71
  and_return(settings)
72
72
 
@@ -75,7 +75,7 @@ describe Pushwagner::Maven do
75
75
 
76
76
  it "reads snapshots authentication from maven settings.xml" do
77
77
  m = Pushwagner::Maven.new(cfg, "1")
78
- m.repository.should_receive(:open).
78
+ expect(m.repository).to receive(:open).
79
79
  with(/.*settings.xml$/).
80
80
  and_return(settings)
81
81
 
@@ -88,8 +88,8 @@ describe Pushwagner::Maven do
88
88
  it "builds maven2-repo-style urls and retrieves metadata" do
89
89
  m = Pushwagner::Maven.new(cfg, "1")
90
90
 
91
- m.repository.should_receive(:authentication).and_return("")
92
- m.repository.should_receive(:open).and_return(metadata)
91
+ expect(m.repository).to receive(:authentication).and_return("")
92
+ expect(m.repository).to receive(:open).and_return(metadata)
93
93
 
94
94
  snapshot = Pushwagner::Maven::Artifact.new("foo", "bar", "1.0-SNAPSHOT")
95
95
  expect(m.repository.absolute_url(snapshot)).to eq("http://w00t.uppercase.no/nexus/content/repositories/snapshots/bar/foo/1.0-SNAPSHOT/foo-1.0-20121114.152717-3.jar")
data/spec/spec_helper.rb CHANGED
@@ -11,6 +11,10 @@ RSpec.configure do |config|
11
11
  end
12
12
 
13
13
  config.expect_with(:rspec) { |c| c.syntax = :expect }
14
+ #config.mock_with :rspec do |mocks|
15
+ # mocks.syntax = :should
16
+ # mocks.yield_receiver_to_any_instance_implementation_blocks = false
17
+ #end
14
18
 
15
19
  def config_root
16
20
  File.join(File.dirname(__FILE__), 'configs')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pushwagner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2.2
4
+ version: 0.0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ole Christian Rynning
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-09 00:00:00.000000000 Z
11
+ date: 2017-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh