falkorlib 0.3.9 → 0.3.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 552344c4593779ef9a71c505a6cf36944076085a
4
- data.tar.gz: c2b78c907bd0a3793919e86285b8fc05d3329248
3
+ metadata.gz: d4e94c1089995299cfd1bfaa76cdc3637d5f3f22
4
+ data.tar.gz: fafd75148f4a2c45e26140f55168d88689fb46f6
5
5
  SHA512:
6
- metadata.gz: 80190e05c95c7615078dbf48e6fe15a8cefa4b3262d4031e3f9dff71031188a6f5c820d427cf13c2bf77c9ce6c286a1ec1a096d6aa27dc6bbe387c1b9cd15206
7
- data.tar.gz: e954e17b3e2f48867d0bb968cdd70c9c8c005dfe1e68203d6b89fe4f94c341a92ab90fc078bb15a2b9812f2fd56f245ce7a8535bd487f7f9e1799aef3f4925b4
6
+ metadata.gz: 0b71d5459bd221b73367900c5010537cb685f6612dbb3bf6beb0db9ecff39d43bd4f51c4b63dd55512e9accd3ce6ad5e1710aca3b6dac2231d293c0070888574
7
+ data.tar.gz: 965e09a164c35e08a3a8f70e7b62a319defb69ff0e47532d5bb04ebe65236f2d01db8f73f3c61d84ff19b6cbd48260c69981d9e29581c0e0d29cc2a2a83a92ae
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- falkorlib (0.3.9)
4
+ falkorlib (0.3.10)
5
5
  awesome_print (~> 1.2)
6
6
  configatron (~> 3.2)
7
7
  diffy (>= 3.0)
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Dim 2014-08-31 22:32 svarrette>
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
- def init_from_template(templatedir, rootdir, config = {}, options = {})
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 destfile usung the source template file `erbsrc`
304
- def write_from_erb_template(erbfile, outfile, config = {})
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
- content = output.result(binding)
318
+ content = output.result(binding)
309
319
  if File.exists?( outfile )
310
320
  ref = File.read( outfile )
311
- return if ref == content
312
- warn "the file '#{outfile}' already exists and will be overwritten."
313
- warn "Expected difference: \n------"
314
- Diffy::Diff.default_format = :color
315
- puts Diffy::Diff.new(ref, content, :context => 1)
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
- watch = ask( cyan(" ==> Do you want to see the generated file before commiting the writing (y|N)"), 'No')
318
- puts content if watch =~ /y.*/i
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
- proceed = ask( cyan(" ==> proceed with the writing (Y|n)"), 'Yes')
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
- f.puts content
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: <Lun 2014-09-01 21:46 svarrette>
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 => [ 'templates\/[^\/]*variables\.erb$' ]
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/**/*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).
@@ -19,7 +19,7 @@ module FalkorLib #:nodoc:
19
19
  # MAJOR: Defines the major version
20
20
  # MINOR: Defines the minor version
21
21
  # PATCH: Defines the patch version
22
- MAJOR, MINOR, PATCH = 0, 3, 9
22
+ MAJOR, MINOR, PATCH = 0, 3, 10
23
23
 
24
24
  module_function
25
25
 
@@ -2,7 +2,7 @@
2
2
  #########################################
3
3
  # puppet_modules_spec.rb
4
4
  # @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
5
- # Time-stamp: <Lun 2014-09-01 21:51 svarrette>
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(36).each { |e| STDIN.should_receive(:gets).and_return('') }
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
- Array.new(3).each { |e| STDIN.should_receive(:gets).and_return('') }
93
- d = FalkorLib::Puppet::Modules.upgrade(moduledir)
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: <Lun 2014-09-01 21:51 svarrette>
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(36).each { |e| STDIN.should_receive(:gets).and_return('') }
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
@@ -26,3 +26,6 @@ require 'falkorlib/tasks/puppet'
26
26
  ##############################################################################
27
27
  #TOP_SRCDIR = File.expand_path(File.join(File.dirname(__FILE__), "."))
28
28
 
29
+ require 'rake/clean'
30
+
31
+ CLEAN.add 'pkg'
@@ -9,6 +9,7 @@
9
9
  "source": "<%= config[:source] %>",
10
10
  "project_page": "<%= config[:project_page] %>",
11
11
  "issues_url": "<%= config[:issues_url] %>",
12
+ "forge_url": "<%= config[:forge_url] %>",
12
13
  "dependencies": [
13
14
  {
14
15
  "name": "puppetlabs-stdlib",
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.9
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-01 00:00:00.000000000 Z
11
+ date: 2014-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake