falkorlib 0.3.9 → 0.3.10
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/common.rb +28 -16
- data/lib/falkorlib/puppet/modules.rb +12 -6
- data/lib/falkorlib/tasks/rspec.rake +1 -1
- data/lib/falkorlib/version.rb +1 -1
- data/spec/falkorlib/puppet_modules_spec.rb +6 -5
- data/spec/falkorlib/versioning_puppet_module_spec.rb +2 -2
- data/templates/puppet/modules/Rakefile +3 -0
- data/templates/puppet/modules/metadata.json.erb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4e94c1089995299cfd1bfaa76cdc3637d5f3f22
|
4
|
+
data.tar.gz: fafd75148f4a2c45e26140f55168d88689fb46f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b71d5459bd221b73367900c5010537cb685f6612dbb3bf6beb0db9ecff39d43bd4f51c4b63dd55512e9accd3ce6ad5e1710aca3b6dac2231d293c0070888574
|
7
|
+
data.tar.gz: 965e09a164c35e08a3a8f70e7b62a319defb69ff0e47532d5bb04ebe65236f2d01db8f73f3c61d84ff19b6cbd48260c69981d9e29581c0e0d29cc2a2a83a92ae
|
data/Gemfile.lock
CHANGED
data/lib/falkorlib/common.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
################################################################################
|
3
|
-
# Time-stamp: <
|
3
|
+
# Time-stamp: <Ven 2014-09-05 10:44 svarrette>
|
4
4
|
################################################################################
|
5
5
|
|
6
6
|
require "falkorlib"
|
@@ -270,7 +270,12 @@ module FalkorLib #:nodoc:
|
|
270
270
|
# Supported options:
|
271
271
|
# :erb_exclude [array of strings]: pattern(s) to exclude from erb file
|
272
272
|
# interpretation and thus to copy 'as is'
|
273
|
-
|
273
|
+
# :no_interaction [boolean]: do not interact
|
274
|
+
def init_from_template(templatedir, rootdir, config = {},
|
275
|
+
options = {
|
276
|
+
:erb_exclude => [],
|
277
|
+
:no_interaction => false
|
278
|
+
})
|
274
279
|
error "Unable to find the template directory" unless File.directory?(templatedir)
|
275
280
|
warning "about to initialize/update the directory #{rootdir}"
|
276
281
|
really_continue?
|
@@ -296,34 +301,41 @@ module FalkorLib #:nodoc:
|
|
296
301
|
# Let's go
|
297
302
|
info "updating '#{relative_outdir.to_s}/#{filename}'"
|
298
303
|
puts " using ERB template '#{erbfile}'"
|
299
|
-
write_from_erb_template(erbfile, outfile, config)
|
304
|
+
write_from_erb_template(erbfile, outfile, config, options)
|
300
305
|
end
|
301
306
|
end
|
302
307
|
|
303
|
-
## ERB generation of the file
|
304
|
-
|
308
|
+
## ERB generation of the file `outfile` using the source template file `erbfile`
|
309
|
+
# Supported options:
|
310
|
+
# :no_interaction [boolean]: do not interact
|
311
|
+
def write_from_erb_template(erbfile, outfile, config = {},
|
312
|
+
options = {
|
313
|
+
:no_interaction => false
|
314
|
+
})
|
305
315
|
error "Unable to find the template file #{erbfile}" unless File.exists? (erbfile )
|
306
316
|
template = File.read("#{erbfile}")
|
307
317
|
output = ERB.new(template, nil, '<>')
|
308
|
-
|
318
|
+
content = output.result(binding)
|
309
319
|
if File.exists?( outfile )
|
310
320
|
ref = File.read( outfile )
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
321
|
+
return if ref == content
|
322
|
+
warn "the file '#{outfile}' already exists and will be overwritten."
|
323
|
+
warn "Expected difference: \n------"
|
324
|
+
Diffy::Diff.default_format = :color
|
325
|
+
puts Diffy::Diff.new(ref, content, :context => 1)
|
316
326
|
else
|
317
|
-
|
318
|
-
|
327
|
+
|
328
|
+
watch = options[:no_interaction] ? 'no' : ask( cyan(" ==> Do you want to see the generated file before commiting the writing (y|N)"), 'No')
|
329
|
+
puts content if watch =~ /y.*/i
|
330
|
+
|
319
331
|
end
|
320
|
-
|
332
|
+
proceed = options[:no_interaction] ? 'yes' : ask( cyan(" ==> proceed with the writing (Y|n)"), 'Yes')
|
321
333
|
return if proceed =~ /n.*/i
|
322
334
|
info("=> writing #{outfile}")
|
323
335
|
File.open("#{outfile}", "w+") do |f|
|
324
|
-
|
336
|
+
f.puts content
|
325
337
|
end
|
326
|
-
end
|
338
|
+
end
|
327
339
|
|
328
340
|
|
329
341
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
################################################################################
|
3
|
-
# Time-stamp: <
|
3
|
+
# Time-stamp: <Ven 2014-09-05 10:50 svarrette>
|
4
4
|
################################################################################
|
5
5
|
# Interface for the main Puppet Module operations
|
6
6
|
#
|
@@ -30,7 +30,7 @@ module FalkorLib #:nodoc:
|
|
30
30
|
:source => '',
|
31
31
|
:project_page => '',
|
32
32
|
:issues_url => '',
|
33
|
-
:forge_url => 'https://forge.puppetlabs.com
|
33
|
+
:forge_url => 'https://forge.puppetlabs.com',
|
34
34
|
:dependencies => [],
|
35
35
|
:operatingsystem_support => [],
|
36
36
|
:tags => []
|
@@ -131,7 +131,8 @@ module FalkorLib #:nodoc:
|
|
131
131
|
# Bootstrap the directory
|
132
132
|
templatedir = File.join( FalkorLib.templates, 'puppet', 'modules')
|
133
133
|
init_from_template(templatedir, moduledir, config, {
|
134
|
-
:erb_exclude
|
134
|
+
:erb_exclude => [ 'templates\/[^\/]*variables\.erb$' ],
|
135
|
+
:no_interaction => true
|
135
136
|
})
|
136
137
|
# Rename the files / element templatename
|
137
138
|
Dir["#{moduledir}/**/*"].each do |e|
|
@@ -223,11 +224,15 @@ module FalkorLib #:nodoc:
|
|
223
224
|
File.open(jsonfile,"w") do |f|
|
224
225
|
f.write JSON.pretty_generate( metadata )
|
225
226
|
end
|
227
|
+
run %{ git commit -s -m "Update metadata.json" #{jsonfile} }
|
226
228
|
metadata
|
227
229
|
end # parse
|
228
230
|
|
229
231
|
##Upgrade the repository README etc. with the
|
230
|
-
def upgrade(moduledir = Dir.pwd
|
232
|
+
def upgrade(moduledir = Dir.pwd,
|
233
|
+
options = {
|
234
|
+
:no_interaction => false
|
235
|
+
})
|
231
236
|
name = File.basename( moduledir )
|
232
237
|
error "The module #{name} does not exist" unless File.directory?( moduledir )
|
233
238
|
jsonfile = File.join( moduledir, 'metadata.json')
|
@@ -245,11 +250,12 @@ module FalkorLib #:nodoc:
|
|
245
250
|
|
246
251
|
[ 'README.md', 'doc/contributing.md'].each do |f|
|
247
252
|
info "Upgrade the content of #{f}"
|
248
|
-
ans = ask("procceed?", 'Yes')
|
253
|
+
ans = options[:no_interaction] ? 'Yes' : ask("procceed?", 'Yes')
|
249
254
|
next unless ans =~ /n*/i
|
250
255
|
write_from_erb_template(File.join(templatedir, "#{f}.erb"),
|
251
256
|
File.join(moduledir, f),
|
252
|
-
metadata
|
257
|
+
metadata,
|
258
|
+
options)
|
253
259
|
end
|
254
260
|
end
|
255
261
|
|
@@ -32,7 +32,7 @@ begin
|
|
32
32
|
# Glob pattern to match files.
|
33
33
|
#t.pattern = "spec/**/common_*.rb"
|
34
34
|
#t.pattern = "spec/**/versioning_*spec.rb"
|
35
|
-
#t.pattern = "spec
|
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: <
|
5
|
+
# Time-stamp: <Ven 2014-09-05 10:52 svarrette>
|
6
6
|
#
|
7
7
|
# @description Check the Puppet Modules operations
|
8
8
|
#
|
@@ -40,7 +40,7 @@ describe FalkorLib::Puppet::Modules do
|
|
40
40
|
|
41
41
|
it "#init -- create a puppet module" do
|
42
42
|
# Prepare answer to the questions
|
43
|
-
Array.new(
|
43
|
+
Array.new(16).each { |e| STDIN.should_receive(:gets).and_return('') }
|
44
44
|
FalkorLib::Puppet::Modules.init(moduledir)
|
45
45
|
templatedir = File.join( FalkorLib.templates, 'puppet', 'modules')
|
46
46
|
s = true
|
@@ -52,7 +52,7 @@ describe FalkorLib::Puppet::Modules do
|
|
52
52
|
filename = File.basename(file)
|
53
53
|
filename = File.basename(file, '.erb') unless file =~ /templates\/toto-variables\.erb/
|
54
54
|
f = File.join(moduledir, relative_dir, filename)
|
55
|
-
puts "checking #{f} - #{File.exists?( f )}"
|
55
|
+
#puts "checking #{f} - #{File.exists?( f )}"
|
56
56
|
s &= File.exists?( f )
|
57
57
|
end
|
58
58
|
s.should be_true
|
@@ -89,8 +89,9 @@ describe FalkorLib::Puppet::Modules do
|
|
89
89
|
end
|
90
90
|
|
91
91
|
it "#upgrade" do
|
92
|
-
|
93
|
-
|
92
|
+
d = FalkorLib::Puppet::Modules.upgrade(moduledir, {
|
93
|
+
:no_interaction => true
|
94
|
+
})
|
94
95
|
end
|
95
96
|
|
96
97
|
it "#parse" do
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#########################################
|
3
3
|
# versioning_puppet_module_spec.rb
|
4
4
|
# @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
|
5
|
-
# Time-stamp: <
|
5
|
+
# Time-stamp: <Ven 2014-09-05 10:53 svarrette>
|
6
6
|
#
|
7
7
|
# @description Check the versioning operations on Gems
|
8
8
|
#
|
@@ -53,7 +53,7 @@ describe FalkorLib::Versioning::Puppet do
|
|
53
53
|
|
54
54
|
|
55
55
|
it "#get_version -- get default version #{default_version} after initialization" do
|
56
|
-
Array.new(
|
56
|
+
Array.new(16).each { |e| STDIN.should_receive(:gets).and_return('') }
|
57
57
|
FalkorLib::Puppet::Modules.init(moduledir)
|
58
58
|
v = FalkorLib::Versioning.get_version(moduledir)
|
59
59
|
v.should == default_version
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: falkorlib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastien Varrette
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|