puppet-blacksmith 2.0.2 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NTAzNDJmZTgyMGJhYjE3MmY2ZDM1MzM0MjI0ZmYzYTBhNWM5ZjIxOQ==
5
+ data.tar.gz: !binary |-
6
+ M2RmMDlkZTljMzcwOWVlY2I5MzQ5MjJlYjEzMWE3YjAyYzAxZDkyMg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ Yjc3MDI2MDNiMWQwY2RiNzcyNjgzYmE1MWExMmM2Nzg3ZDY2MWQ2NWE4MmIz
10
+ YmU3ZmFiYTEzNzNiMTI5OGRiNzc4MjZjMTk0MzhhZjhiOTBiN2JlOTY0MDMz
11
+ Mjk3MDdkZTlhZThlMzJiZWFhM2I2NDY1MjMwMTFlMTBhZWFmMjU=
12
+ data.tar.gz: !binary |-
13
+ N2JlMTY5Y2I3YjU5Y2M0Yzg4Mzg0Nzc4YmE5Yjc1NDEwYzcxNDIxYzRiNDBk
14
+ YjBmNmE2Y2Y0MTQ2YWE0ZmQ3Y2ViODZmMmM1M2IwYmQyY2U0OTQ1NmQ4MmYz
15
+ Yzg5ODEzN2ZmNWE4NDVmM2RmM2EzZTY1YTkzZWIyNGQzNDY0NzE=
@@ -1,4 +1,4 @@
1
- require_relative 'puppet_blacksmith/error'
2
- require_relative 'puppet_blacksmith/forge'
3
- require_relative 'puppet_blacksmith/git'
4
- require_relative 'puppet_blacksmith/modulefile'
1
+ require 'puppet_blacksmith/error'
2
+ require 'puppet_blacksmith/forge'
3
+ require 'puppet_blacksmith/git'
4
+ require 'puppet_blacksmith/modulefile'
@@ -72,8 +72,8 @@ module Blacksmith
72
72
  raise Blacksmith::Error, <<-eos
73
73
  Could not find Puppet Forge credentials file '#{credentials_file}'
74
74
  Please create it
75
- ---
76
- forge: https://forge.puppetlabs.com
75
+ ---
76
+ url: https://forge.puppetlabs.com
77
77
  username: myuser
78
78
  password: mypassword
79
79
  eos
@@ -25,18 +25,26 @@ module Blacksmith
25
25
  s
26
26
  end
27
27
 
28
+ def git_cmd_with_path(cmd)
29
+ "git --git-dir=#{File.join(path, '.git')} --work-tree=#{path} #{cmd}"
30
+ end
31
+
28
32
  def exec_git(cmd)
29
33
  out = ""
30
34
  err = ""
35
+ exit_status = nil
36
+ new_cmd = git_cmd_with_path(cmd)
31
37
  # wait_thr is nil in JRuby < 1.7.5 see http://jira.codehaus.org/browse/JRUBY-6409
32
- new_cmd = "git --git-dir=#{File.join(path, '.git')} --work-tree=#{path} #{cmd}"
33
38
  Open3.popen3(new_cmd) do |stdin, stdout, stderr, wait_thr|
34
39
  out = stdout.read
35
40
  err = stderr.read
36
- # exit_status = wait_thr.value
41
+ exit_status = wait_thr.nil? ? nil : wait_thr.value
42
+ end
43
+ if exit_status.nil?
44
+ raise Blacksmith::Error, err unless err.empty?
45
+ elsif !exit_status.success?
46
+ raise Blacksmith::Error, err.empty? ? "Command #{new_cmd} failed with exit status #{exit_status}" : err
37
47
  end
38
- exit_status = $?
39
- raise Blacksmith::Error, err unless exit_status.success?
40
48
  return out
41
49
  end
42
50
  end
@@ -10,6 +10,8 @@
10
10
  # require 'puppet/error'
11
11
  # require 'puppet/module_tool'
12
12
  require 'puppet'
13
+ require 'puppet/module_tool'
14
+
13
15
  Puppet[:confdir] = "."
14
16
 
15
17
  module Blacksmith
@@ -1,5 +1,5 @@
1
1
  require 'rake'
2
- require_relative '../puppet_blacksmith'
2
+ require 'puppet_blacksmith'
3
3
 
4
4
  namespace :module do
5
5
  desc "Bump module version to the next minor"
@@ -1,3 +1,3 @@
1
1
  module Blacksmith
2
- VERSION = '2.0.2'
2
+ VERSION = '2.1.0'
3
3
  end
data/spec/data/Modulefile CHANGED
@@ -1,7 +1,6 @@
1
1
  name 'maestrodev-test'
2
2
  version '1.0.0'
3
3
 
4
- author 'maestrodev'
5
4
  license 'Apache License, Version 2.0'
6
5
  project_page 'http://github.com/maestrodev/puppet-blacksmith'
7
6
  source 'http://github.com/maestrodev/puppet-blacksmith'
@@ -11,6 +11,23 @@ describe 'Blacksmith::Forge' do
11
11
  let(:version) { "1.0.0" }
12
12
  let(:package) { File.dirname(__FILE__) + '/../data/maestrodev-ant-1.0.4.tar.gz' }
13
13
 
14
+ describe 'missing credentials file' do
15
+ before do
16
+ File.stub(:expand_path => '/home/mr_puppet/.puppetforge.yml')
17
+ end
18
+
19
+ context "when the credentials file is missing" do
20
+ before do
21
+
22
+ end
23
+
24
+ it "should raise an error" do
25
+ expect { foo = Blacksmith::Forge.new(nil, password, forge) }.to raise_error(/Could not find Puppet Forge credentials file '\/home\/mr\_puppet\/.puppetforge.yml'\s*Please create it\s*---\s*url: https:\/\/forge.puppetlabs.com\s*username: myuser\s*password: mypassword/)
26
+ end
27
+ end
28
+
29
+ end
30
+
14
31
  describe 'push' do
15
32
 
16
33
  before do
@@ -29,7 +46,7 @@ describe 'Blacksmith::Forge' do
29
46
  end
30
47
 
31
48
  it "should push the module" do
32
-
49
+
33
50
  end
34
51
  end
35
52
 
@@ -21,4 +21,45 @@ describe 'Blacksmith::Git' do
21
21
  out.chomp.should match(/^v1.0.0$/)
22
22
  end
23
23
  end
24
+
25
+ describe 'exec_git' do
26
+ let(:cmd) { 'log' }
27
+ let(:stdin) { nil }
28
+ let(:stdout) { '' }
29
+ let(:stderr) { '' }
30
+ let(:exit_code) { double('exit_code', :success? => true) }
31
+ let(:wait_thr) { double('wait_thr', :value => exit_code) }
32
+
33
+ context 'when git succeeds' do
34
+ before do
35
+ Open3.stub(:popen3).and_yield(nil, double(:read => stdout), double(:read => stderr), wait_thr)
36
+ expect { subject.exec_git(cmd) }.to_not raise_error
37
+ end
38
+
39
+ context 'when stderr is empty' do
40
+ it {}
41
+ end
42
+
43
+ context 'when stderr is not empty' do
44
+ let(:stderr) { 'some error' }
45
+ it {}
46
+ end
47
+
48
+ end
49
+
50
+ context 'when git fails' do
51
+ before { subject.stub(:git_cmd_with_path => cmd) }
52
+
53
+ # this spec fails on jruby, can't detect exit code of script
54
+ context 'when stderr is empty' do
55
+ let(:cmd) { "git" } # exits with 1
56
+ it { expect { subject.exec_git(cmd) }.to raise_error(Blacksmith::Error, /^Command .* failed with exit status.*1$/) }
57
+ end
58
+
59
+ context 'when stderr is not empty' do
60
+ let(:cmd) { "git help xxxx" } # exits with 1 and prints to stdout
61
+ it { expect { subject.exec_git(cmd) }.to raise_error(Blacksmith::Error, /No manual entry for gitxxx/) }
62
+ end
63
+ end
64
+ end
24
65
  end
@@ -7,7 +7,7 @@ describe 'Blacksmith::Modulefile' do
7
7
 
8
8
  context 'when modulefile is parsed' do
9
9
  it { subject.metadata.version.should eql("1.0.0") }
10
- it { subject.metadata.username.should eql("maestrodev") }
10
+ it { subject.metadata.author.should eql("maestrodev") }
11
11
  it { subject.metadata.name.should eql("test") }
12
12
  end
13
13
 
metadata CHANGED
@@ -1,115 +1,141 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-blacksmith
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
5
- prerelease:
4
+ version: 2.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - MaestroDev
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-23 00:00:00.000000000 Z
11
+ date: 2014-06-04 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rest-client
16
- requirement: &18291200 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *18291200
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: puppet
27
- requirement: &18289080 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - ! '>='
31
32
  - !ruby/object:Gem::Version
32
33
  version: 2.7.16
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *18289080
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 2.7.16
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: nokogiri
38
- requirement: &18288080 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
45
  - - ! '>='
42
46
  - !ruby/object:Gem::Version
43
47
  version: '0'
44
48
  type: :runtime
45
49
  prerelease: false
46
- version_requirements: *18288080
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
47
55
  - !ruby/object:Gem::Dependency
48
56
  name: rake
49
- requirement: &18377600 !ruby/object:Gem::Requirement
50
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
51
58
  requirements:
52
59
  - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  type: :development
56
63
  prerelease: false
57
- version_requirements: *18377600
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: puppetlabs_spec_helper
60
- requirement: &18373140 !ruby/object:Gem::Requirement
61
- none: false
71
+ requirement: !ruby/object:Gem::Requirement
62
72
  requirements:
63
73
  - - ! '>='
64
74
  - !ruby/object:Gem::Version
65
75
  version: '0'
66
76
  type: :development
67
77
  prerelease: false
68
- version_requirements: *18373140
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: cucumber
71
- requirement: &18319260 !ruby/object:Gem::Requirement
72
- none: false
85
+ requirement: !ruby/object:Gem::Requirement
73
86
  requirements:
74
87
  - - ! '>='
75
88
  - !ruby/object:Gem::Version
76
89
  version: '0'
77
90
  type: :development
78
91
  prerelease: false
79
- version_requirements: *18319260
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
80
97
  - !ruby/object:Gem::Dependency
81
98
  name: aruba
82
- requirement: &18313840 !ruby/object:Gem::Requirement
83
- none: false
99
+ requirement: !ruby/object:Gem::Requirement
84
100
  requirements:
85
101
  - - ! '>='
86
102
  - !ruby/object:Gem::Version
87
103
  version: '0'
88
104
  type: :development
89
105
  prerelease: false
90
- version_requirements: *18313840
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
91
111
  - !ruby/object:Gem::Dependency
92
112
  name: rspec
93
- requirement: &18390180 !ruby/object:Gem::Requirement
94
- none: false
113
+ requirement: !ruby/object:Gem::Requirement
95
114
  requirements:
96
115
  - - ! '>='
97
116
  - !ruby/object:Gem::Version
98
117
  version: 2.7.0
99
118
  type: :development
100
119
  prerelease: false
101
- version_requirements: *18390180
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: 2.7.0
102
125
  - !ruby/object:Gem::Dependency
103
126
  name: webmock
104
- requirement: &18388580 !ruby/object:Gem::Requirement
105
- none: false
127
+ requirement: !ruby/object:Gem::Requirement
106
128
  requirements:
107
129
  - - ! '>='
108
130
  - !ruby/object:Gem::Version
109
131
  version: '0'
110
132
  type: :development
111
133
  prerelease: false
112
- version_requirements: *18388580
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
113
139
  description: Puppet module tools for development and Puppet Forge management
114
140
  email:
115
141
  - info@maestrodev.com
@@ -117,53 +143,49 @@ executables: []
117
143
  extensions: []
118
144
  extra_rdoc_files: []
119
145
  files:
146
+ - LICENSE
120
147
  - lib/puppet_blacksmith.rb
148
+ - lib/puppet_blacksmith/error.rb
121
149
  - lib/puppet_blacksmith/forge.rb
150
+ - lib/puppet_blacksmith/git.rb
122
151
  - lib/puppet_blacksmith/modulefile.rb
123
152
  - lib/puppet_blacksmith/rake_tasks.rb
124
153
  - lib/puppet_blacksmith/version.rb
125
- - lib/puppet_blacksmith/error.rb
126
- - lib/puppet_blacksmith/git.rb
127
- - LICENSE
128
- - spec/spec_helper.rb
129
- - spec/puppet_blacksmith/git_spec.rb
154
+ - spec/data/Modulefile
155
+ - spec/data/forge_error.html
156
+ - spec/data/maestrodev-ant-1.0.4.tar.gz
130
157
  - spec/puppet_blacksmith/forge_spec.rb
158
+ - spec/puppet_blacksmith/git_spec.rb
131
159
  - spec/puppet_blacksmith/modulefile_spec.rb
132
- - spec/data/maestrodev-ant-1.0.4.tar.gz
133
- - spec/data/forge_error.html
134
- - spec/data/Modulefile
160
+ - spec/spec_helper.rb
135
161
  homepage: http://github.com/maestrodev/puppet-blacksmith
136
162
  licenses: []
163
+ metadata: {}
137
164
  post_install_message:
138
165
  rdoc_options: []
139
166
  require_paths:
140
167
  - lib
141
168
  required_ruby_version: !ruby/object:Gem::Requirement
142
- none: false
143
169
  requirements:
144
170
  - - ! '>='
145
171
  - !ruby/object:Gem::Version
146
172
  version: '0'
147
- segments:
148
- - 0
149
- hash: 936353051533112818
150
173
  required_rubygems_version: !ruby/object:Gem::Requirement
151
- none: false
152
174
  requirements:
153
175
  - - ! '>='
154
176
  - !ruby/object:Gem::Version
155
177
  version: '0'
156
178
  requirements: []
157
179
  rubyforge_project:
158
- rubygems_version: 1.8.6
180
+ rubygems_version: 2.2.2
159
181
  signing_key:
160
- specification_version: 3
182
+ specification_version: 4
161
183
  summary: Tasks to manage Puppet module builds
162
184
  test_files:
163
185
  - spec/spec_helper.rb
164
- - spec/puppet_blacksmith/git_spec.rb
165
- - spec/puppet_blacksmith/forge_spec.rb
166
- - spec/puppet_blacksmith/modulefile_spec.rb
167
186
  - spec/data/maestrodev-ant-1.0.4.tar.gz
168
187
  - spec/data/forge_error.html
169
188
  - spec/data/Modulefile
189
+ - spec/puppet_blacksmith/forge_spec.rb
190
+ - spec/puppet_blacksmith/modulefile_spec.rb
191
+ - spec/puppet_blacksmith/git_spec.rb