falkorlib 0.3.4 → 0.3.5
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/falkorlib/puppet/modules.rb +15 -3
- data/lib/falkorlib/tasks/puppet_modules.rake +12 -4
- data/lib/falkorlib/tasks/rspec.rake +1 -1
- data/lib/falkorlib/version.rb +1 -1
- data/spec/falkorlib/puppet_modules_spec.rb +66 -41
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc6cbdc597210acfacf149662320dba99df4f9ed
|
4
|
+
data.tar.gz: 230dfafedd88c62aadda21b76b92efff18730de9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e3388f984c3c19619ed8bc534be94029880f118c8f1371efecdfd2028d30e5c4b32ff6ae3605158b3c7ecafa44696cf1eabc89dfcf797b7bfe04de22f8f204e
|
7
|
+
data.tar.gz: c847ad5fdcc64f8852d229dc387c046455cbc7fdb19a958201f7a90a551f67261bd7cfbbc489d32e4475dfaa28e48aac8f05c879e9116e49a7b43e5a21214cae
|
data/Gemfile.lock
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
################################################################################
|
3
|
-
# Time-stamp: <Sat 2014-08-30
|
3
|
+
# Time-stamp: <Sat 2014-08-30 22:00 svarrette>
|
4
4
|
################################################################################
|
5
5
|
# Interface for the main Puppet Module operations
|
6
6
|
#
|
@@ -10,6 +10,7 @@ require "falkorlib/common"
|
|
10
10
|
|
11
11
|
require "pathname"
|
12
12
|
require 'json'
|
13
|
+
require 'diffy'
|
13
14
|
|
14
15
|
include FalkorLib::Common
|
15
16
|
|
@@ -175,7 +176,8 @@ module FalkorLib #:nodoc:
|
|
175
176
|
jsonfile = File.join( moduledir, 'metadata.json')
|
176
177
|
error "Unable to find #{jsonfile}" unless File.exist?( jsonfile )
|
177
178
|
metadata = JSON.parse( IO.read( jsonfile ) )
|
178
|
-
|
179
|
+
ref = JSON.pretty_generate( metadata )
|
180
|
+
metadata["classes"] = classes(moduledir)
|
179
181
|
metadata["definitions"] = definitions(moduledir)
|
180
182
|
deps = deps(moduledir)
|
181
183
|
listed_deps = metadata["dependencies"]
|
@@ -205,8 +207,16 @@ module FalkorLib #:nodoc:
|
|
205
207
|
}
|
206
208
|
end
|
207
209
|
end
|
210
|
+
content = JSON.pretty_generate( metadata )
|
208
211
|
info "Metadata configuration for the module '#{name}'"
|
209
|
-
puts
|
212
|
+
puts content
|
213
|
+
if ref == content
|
214
|
+
warn "No difference to commit"
|
215
|
+
return
|
216
|
+
end
|
217
|
+
info "Differences with the previous file"
|
218
|
+
Diffy::Diff.default_format = :color
|
219
|
+
puts Diffy::Diff.new(ref, content, :context => 1)
|
210
220
|
warn "About to commit these changes in the '#{name}/metadata.json' file"
|
211
221
|
really_continue?
|
212
222
|
File.open(jsonfile,"w") do |f|
|
@@ -234,6 +244,8 @@ module FalkorLib #:nodoc:
|
|
234
244
|
|
235
245
|
[ 'README.md', 'doc/contributing.md'].each do |f|
|
236
246
|
info "Upgrade the content of #{f}"
|
247
|
+
ans = ask("procceed?", 'Yes')
|
248
|
+
next unless ans =~ /n*/i
|
237
249
|
write_from_erb_template(File.join(templatedir, "#{f}.erb"),
|
238
250
|
File.join(moduledir, f),
|
239
251
|
metadata)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
################################################################################
|
3
3
|
# puppet_modules.rake - Special tasks for the management of Puppet modules
|
4
|
-
# Time-stamp: <Sat 2014-08-30 21:
|
4
|
+
# Time-stamp: <Sat 2014-08-30 21:52 svarrette>
|
5
5
|
#
|
6
6
|
# Copyright (c) 2014 Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
7
7
|
# http://varrette.gforge.uni.lu
|
@@ -33,7 +33,7 @@ namespace :bootstrap do
|
|
33
33
|
end # namespace bootstrap:puppet
|
34
34
|
end # namespace bootstrap
|
35
35
|
|
36
|
-
|
36
|
+
require 'json'
|
37
37
|
|
38
38
|
#.....................
|
39
39
|
namespace :puppet do
|
@@ -48,8 +48,14 @@ namespace :puppet do
|
|
48
48
|
task :build do |t|
|
49
49
|
info "#{t.comment}"
|
50
50
|
run %{ puppet module build }
|
51
|
-
|
52
|
-
|
51
|
+
if File.exists? ('metadata.json')
|
52
|
+
metadata = JSON.parse( IO.read( 'metadata.json' ) )
|
53
|
+
name = metadata["name"]
|
54
|
+
version = metadata["version"]
|
55
|
+
url = metadata["forge_url"].nil? ? "https://forge.puppetlabs.com/#{name.gsub(/-/,'/')}" : metadata["forge_url"]
|
56
|
+
warn "you can now upload the generated file 'pkg/#{name}-#{version}.tar.gz' on the puppet forge"
|
57
|
+
warn " #{url}"
|
58
|
+
end
|
53
59
|
end # task build
|
54
60
|
|
55
61
|
########### puppet:module:parse ###########
|
@@ -76,3 +82,5 @@ namespace :module do
|
|
76
82
|
|
77
83
|
end # namespace upgrade
|
78
84
|
end # namespace module
|
85
|
+
|
86
|
+
task 'version:release' => 'puppet:module:build'
|
@@ -32,7 +32,7 @@ begin
|
|
32
32
|
# Glob pattern to match files.
|
33
33
|
#t.pattern = "spec/**/test_*.rb"
|
34
34
|
#t.pattern = "spec/**/*_spec.rb"
|
35
|
-
t.pattern = "spec/**/puppet*spec.rb"
|
35
|
+
#t.pattern = "spec/**/puppet*spec.rb"
|
36
36
|
|
37
37
|
# Whether or not to fail Rake when an error occurs (typically when
|
38
38
|
# examples fail).
|
data/lib/falkorlib/version.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#########################################
|
3
3
|
# puppet_modules_spec.rb
|
4
4
|
# @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
5
|
-
# Time-stamp: <Sat 2014-08-30
|
5
|
+
# Time-stamp: <Sat 2014-08-30 22:18 svarrette>
|
6
6
|
#
|
7
7
|
# @description Check the Puppet Modules operations
|
8
8
|
#
|
@@ -13,16 +13,17 @@
|
|
13
13
|
require 'spec_helper'
|
14
14
|
require 'tmpdir'
|
15
15
|
require 'falkorlib/puppet'
|
16
|
+
require 'json'
|
16
17
|
|
17
18
|
describe FalkorLib::Puppet::Modules do
|
18
19
|
include FalkorLib::Common
|
19
20
|
|
20
21
|
dir = Dir.mktmpdir
|
21
22
|
#afile = File.join(dir, 'a_file')
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
# before :all do
|
24
|
+
# ENV['GIT_AUTHOR_NAME'] = 'travis' if ENV['GIT_AUTHOR_NAME'].nil?
|
25
|
+
# ENV['GIT_AUTHOR_EMAIL'] = 'travis@domain.org' if ENV['GIT_AUTHOR_EMAIL'].nil?
|
26
|
+
# end
|
26
27
|
|
27
28
|
after :all do
|
28
29
|
FileUtils.remove_entry_secure dir
|
@@ -31,55 +32,79 @@ describe FalkorLib::Puppet::Modules do
|
|
31
32
|
#############################################################
|
32
33
|
context "Test Puppet Module creation within temporary directory " do
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
# Module name
|
36
|
+
name = 'toto'
|
37
|
+
moduledir = File.join(dir, name)
|
37
38
|
|
38
39
|
it "#init -- create a puppet module" do
|
39
|
-
|
40
|
-
|
41
|
-
|
40
|
+
# Prepare answer to the questions
|
41
|
+
Array.new(32).each { |e| STDIN.should_receive(:gets).and_return('') }
|
42
|
+
|
42
43
|
FalkorLib::Puppet::Modules.init(moduledir)
|
43
44
|
templatedir = File.join( FalkorLib.templates, 'puppet', 'modules')
|
44
45
|
s = true
|
45
46
|
Dir["#{templatedir}/**/*"].each do |e|
|
46
47
|
next if File.directory?(e)
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
48
|
+
relative_dir = Pathname.new( File.realpath( File.dirname(e) )).relative_path_from Pathname.new(templatedir)
|
49
|
+
file = e.gsub(/templatename/, "#{name}")
|
50
|
+
filename = File.basename(file)
|
51
|
+
filename = File.basename(file, '.erb') unless file =~ /templates\/toto-variables\.erb/
|
52
|
+
f = File.join(moduledir, relative_dir, filename)
|
53
|
+
#puts "checking #{f} - #{File.exists?( f )}"
|
53
54
|
s &= File.exists?( f )
|
54
55
|
end
|
55
56
|
s.should be_true
|
56
57
|
end
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
59
|
+
it "#classes -- list classes" do
|
60
|
+
l = FalkorLib::Puppet::Modules._get_classdefs(moduledir, 'classes')
|
61
|
+
c = FalkorLib::Puppet::Modules.classes(moduledir)
|
62
|
+
c.should == l
|
63
|
+
ref = [
|
64
|
+
"toto::params",
|
65
|
+
"toto",
|
66
|
+
"toto::common",
|
67
|
+
"toto::debian",
|
68
|
+
"toto::redhat"
|
69
|
+
]
|
70
|
+
c.size.should == ref.size
|
71
|
+
c.each { |e| ref.should include(e) }
|
72
|
+
end
|
73
|
+
|
74
|
+
it "#definitions -- list definitions" do
|
75
|
+
d = FalkorLib::Puppet::Modules.definitions(moduledir)
|
76
|
+
d.should == [ "toto::mydef" ]
|
77
|
+
end
|
78
|
+
|
79
|
+
it "#deps -- list dependencies" do
|
80
|
+
d = FalkorLib::Puppet::Modules.deps(moduledir)
|
81
|
+
d.should == []
|
82
|
+
end
|
82
83
|
|
84
|
+
it "#upgrade" do
|
85
|
+
Array.new(3).each { |e| STDIN.should_receive(:gets).and_return('') }
|
86
|
+
d = FalkorLib::Puppet::Modules.upgrade(moduledir)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "#parse" do
|
90
|
+
STDIN.should_receive(:gets).and_return('')
|
91
|
+
jsonfile = File.join( moduledir, 'metadata.json')
|
92
|
+
ref = JSON.parse( IO.read( jsonfile ) )
|
93
|
+
metadata = FalkorLib::Puppet::Modules.parse(moduledir)
|
94
|
+
diff = (metadata.to_a - ref.to_a).flatten
|
95
|
+
diff.should == [
|
96
|
+
'classes',
|
97
|
+
'toto::params',
|
98
|
+
'toto',
|
99
|
+
'toto::common',
|
100
|
+
'toto::debian',
|
101
|
+
'toto::redhat',
|
102
|
+
'definitions',
|
103
|
+
'toto::mydef',
|
104
|
+
]
|
105
|
+
|
106
|
+
|
107
|
+
end
|
83
108
|
|
84
109
|
|
85
110
|
|