falkorlib 0.3.3 → 0.3.4

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: 268cbfbe13bf123bf09deb6b4ecb48ea73bb7c47
4
- data.tar.gz: fd2d6faf23d9a783012e40e85f61be0109939e79
3
+ metadata.gz: 04f2741d9368f17031d85aaf70162b520885251a
4
+ data.tar.gz: 9a2ff37f2459c2c9ec3014ea5c380cb4ccba4eb2
5
5
  SHA512:
6
- metadata.gz: f8c3ef80d9c7704651ac8b20e11ed8ef3e62e0dd884ef57447947bf8ec577094c3668ad6b5492fd0736fdb83b4f123c64997ad14f0e3f3631ac815daecf84390
7
- data.tar.gz: bddd9304358b05d2c26297bf1d067f440588c0f679c86d4c9d60695b769c663fb0f82d9eae8d0d00b919f6d538f1aa42b8b4d802f862563a3e4d81488f59255d
6
+ metadata.gz: 3a11240f50dec10daa3d9a5bf36ffc95e6c6b314e17a97731e2651db4ed227af5864118e8111599a9aa612032628191555e21796f47559fa4638af86539fdc60
7
+ data.tar.gz: be5cb38f44c4926a785f50f2b932f6077b83de6b61cade921e8a685226b8e553b8c5103a8c2e8823ae5a479dbe1d9a1340117625a0e691b331b778ed9c742c47
data/Gemfile.lock CHANGED
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- falkorlib (0.3.3)
4
+ falkorlib (0.3.4)
5
5
  awesome_print (~> 1.2)
6
6
  configatron (~> 3.2)
7
+ diffy (>= 3.0)
7
8
  git_remote_branch (~> 0)
8
9
  json (~> 1.8)
9
10
  license-generator (~> 0)
@@ -22,6 +23,7 @@ GEM
22
23
  coderay (1.1.0)
23
24
  configatron (3.2.0)
24
25
  diff-lcs (1.1.3)
26
+ diffy (3.0.6)
25
27
  docile (1.1.5)
26
28
  ethon (0.7.0)
27
29
  ffi (>= 1.3.0)
data/falkorlib.gemspec CHANGED
@@ -132,6 +132,7 @@ Gem::Specification.new do |s|
132
132
  s.add_runtime_dependency("awesome_print", "~> 1.2")
133
133
  s.add_runtime_dependency("json", "~> 1.8")
134
134
  s.add_runtime_dependency("license-generator", '~> 0')
135
+ s.add_runtime_dependency("diffy", '>= 3.0')
135
136
 
136
137
  #
137
138
  # One call to add_dependency('gem_name', 'gem version requirement') for each
@@ -1,12 +1,12 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Thu 2014-08-28 23:12 svarrette>
3
+ # Time-stamp: <Sat 2014-08-30 21:05 svarrette>
4
4
  ################################################################################
5
5
 
6
6
  require "falkorlib"
7
7
  require 'open3'
8
8
  require 'erb' # required for module generation
9
-
9
+ require 'diffy'
10
10
 
11
11
  module FalkorLib #:nodoc:
12
12
 
@@ -170,7 +170,7 @@ module FalkorLib #:nodoc:
170
170
  # Supported options:
171
171
  # :only_files [boolean]: list only files in the glob
172
172
  # :only_dirs [boolean]: list only directories in the glob
173
- # :pattern_include [array of strings]: pattern(s) to include for listing
173
+ # :pattern_include [array of strings]: pattern(s) to include for listing
174
174
  # :pattern_exclude [array of strings]: pattern(s) to exclude for listing
175
175
  # :text [string]: text to put
176
176
  def list_items(glob_pattern, options = {})
@@ -207,8 +207,8 @@ module FalkorLib #:nodoc:
207
207
  text = options[:text].nil? ? "select the index" : options[:text]
208
208
  default_idx = options[:default].nil? ? 0 : options[:default]
209
209
  raise SystemExit.new('Empty list') if index == 1
210
- #ap list
211
- #ap raw_list
210
+ #ap list
211
+ #ap raw_list
212
212
  # puts list.to_yaml
213
213
  # answer = ask("=> #{text}", "#{default_idx}")
214
214
  # raise SystemExit.new('exiting selection') if answer == '0'
@@ -264,10 +264,10 @@ module FalkorLib #:nodoc:
264
264
  # feed ERB files which **should** have the extension .erb.
265
265
  # The initialization is performed as follows:
266
266
  # * a rsync process is initiated to duplicate the directory structure
267
- # and the symlinks, and exclude .erb files
267
+ # and the symlinks, and exclude .erb files
268
268
  # * each erb files (thus with extension .erb) is interpreted, the
269
269
  # corresponding file is generated without the .erb extension
270
- # Supported options:
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
  def init_from_template(templatedir, rootdir, config = {}, options = {})
@@ -277,65 +277,78 @@ module FalkorLib #:nodoc:
277
277
  run %{ mkdir -p #{rootdir} } unless File.directory?( rootdir )
278
278
  run %{ rsync --exclude '*.erb' -avzu #{templatedir}/ #{rootdir}/ }
279
279
  Dir["#{templatedir}/**/*.erb"].each do |erbfile|
280
- relative_outdir = Pathname.new( File.realpath( File.dirname(erbfile) )).relative_path_from Pathname.new(templatedir)
281
- filename = File.basename(erbfile, '.erb')
282
- outdir = File.realpath( File.join(rootdir, relative_outdir.to_s) )
283
- outfile = File.join(outdir, filename)
284
- unless options[:erb_exclude].nil?
285
- exclude_entry = false
286
- options[:erb_exclude].each do |pattern|
287
- exclude_entry |= erbfile =~ /#{pattern}/
288
- end
289
- if exclude_entry
290
- info "copying non-interpreted ERB file"
291
- # copy this file since it has been probably excluded from teh rsync process
292
- run %{ cp #{erbfile} #{outdir}/ }
293
- next
294
- end
295
- end
296
- # Let's go
297
- info "updating '#{relative_outdir.to_s}/#{filename}'"
298
- puts " using ERB template '#{erbfile}'"
299
- template = File.read("#{erbfile}")
300
- output = ERB.new(template, nil, '<>')
301
- if File.exists?( outfile )
302
- warn "the file '#{outfile}' already exists and will be overwritten."
303
- error "TODO: watch the diff ;)"
304
- else
305
- watch = ask( cyan(" ==> Do you want to see the generated file before commiting the writing (y|N)"), 'No')
306
- puts output.result(binding) if watch =~ /y.*/i
307
- end
308
- proceed = ask( cyan(" ==> proceed with the writing (Y|n)"), 'Yes')
309
- next if proceed =~ /n.*/i
310
- info("=> writing #{outfile}")
311
- File.open("#{outfile}", "w+") do |f|
312
- f.puts output.result(binding)
280
+ relative_outdir = Pathname.new( File.realpath( File.dirname(erbfile) )).relative_path_from Pathname.new(templatedir)
281
+ filename = File.basename(erbfile, '.erb')
282
+ outdir = File.realpath( File.join(rootdir, relative_outdir.to_s) )
283
+ outfile = File.join(outdir, filename)
284
+ unless options[:erb_exclude].nil?
285
+ exclude_entry = false
286
+ options[:erb_exclude].each do |pattern|
287
+ exclude_entry |= erbfile =~ /#{pattern}/
288
+ end
289
+ if exclude_entry
290
+ info "copying non-interpreted ERB file"
291
+ # copy this file since it has been probably excluded from teh rsync process
292
+ run %{ cp #{erbfile} #{outdir}/ }
293
+ next
294
+ end
313
295
  end
314
- end
296
+ # Let's go
297
+ info "updating '#{relative_outdir.to_s}/#{filename}'"
298
+ puts " using ERB template '#{erbfile}'"
299
+ write_from_erb_template(erbfile, outfile, config)
300
+ end
315
301
  end
316
302
 
303
+ ## ERB generation of the file destfile usung the source template file `erbsrc`
304
+ def write_from_erb_template(erbfile, outfile, config = {})
305
+ error "Unable to find the template file #{erbfile}" unless File.exists? (erbfile )
306
+ template = File.read("#{erbfile}")
307
+ output = ERB.new(template, nil, '<>')
308
+ content = output.result(binding)
309
+ if File.exists?( outfile )
310
+ 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)
316
+ 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
319
+ end
320
+ proceed = ask( cyan(" ==> proceed with the writing (Y|n)"), 'Yes')
321
+ return if proceed =~ /n.*/i
322
+ info("=> writing #{outfile}")
323
+ File.open("#{outfile}", "w+") do |f|
324
+ f.puts content
325
+ end
326
+ end
327
+
328
+
329
+
317
330
  ### RVM init
318
331
  def init_rvm(rootdir = Dir.pwd, gemset = '')
319
- rvm_files = {
320
- :version => File.join(rootdir, '.ruby-version'),
321
- :gemset => File.join(rootdir, '.ruby-gemset')
322
- }
323
- unless File.exists?( "#{rvm_files[:version]}")
324
- v = select_from(FalkorLib.config[:rvm][:rubies],
325
- "Select RVM ruby to configure for this directory",
326
- 3)
327
- File.open( rvm_files[:version], 'w') do |f|
328
- f.puts v
329
- end
330
- end
331
- unless File.exists?( "#{rvm_files[:gemset]}")
332
- g = gemset.empty? ? ask("Enter RVM gemset name for this directory", File.basename(rootdir)) : gemset
333
- File.open( rvm_files[:gemset], 'w') do |f|
334
- f.puts g
335
- end
336
- end
337
-
338
- end
332
+ rvm_files = {
333
+ :version => File.join(rootdir, '.ruby-version'),
334
+ :gemset => File.join(rootdir, '.ruby-gemset')
335
+ }
336
+ unless File.exists?( "#{rvm_files[:version]}")
337
+ v = select_from(FalkorLib.config[:rvm][:rubies],
338
+ "Select RVM ruby to configure for this directory",
339
+ 3)
340
+ File.open( rvm_files[:version], 'w') do |f|
341
+ f.puts v
342
+ end
343
+ end
344
+ unless File.exists?( "#{rvm_files[:gemset]}")
345
+ g = gemset.empty? ? ask("Enter RVM gemset name for this directory", File.basename(rootdir)) : gemset
346
+ File.open( rvm_files[:gemset], 'w') do |f|
347
+ f.puts g
348
+ end
349
+ end
350
+
351
+ end
339
352
 
340
353
 
341
354
  end
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Sat 2014-08-30 14:24 svarrette>
3
+ # Time-stamp: <Sat 2014-08-30 21:23 svarrette>
4
4
  ################################################################################
5
5
  # Interface for the main Puppet Module operations
6
6
  #
@@ -29,6 +29,7 @@ module FalkorLib #:nodoc:
29
29
  :source => '',
30
30
  :project_page => '',
31
31
  :issues_url => '',
32
+ :forge_url => 'https://forge.puppetlabs.com/',
32
33
  :dependencies => [],
33
34
  :operatingsystem_support => [],
34
35
  :tags => []
@@ -53,23 +54,23 @@ module FalkorLib #:nodoc:
53
54
  # Management of Puppet Modules operations
54
55
  module Modules
55
56
 
56
- module_function
57
-
57
+ module_function
58
+
58
59
  def _get_classdefs(moduledir = Dir.pwd, type = 'classes')
59
- name = File.basename( moduledir )
60
- error "The module #{name} does not exist" unless File.directory?( moduledir )
61
- t = case type
62
- when /class*/i
63
- 'class'
64
- when /def*/
65
- 'define'
66
- else
67
- ''
68
- end
69
- error "Undefined type #{type}" if t.empty?
60
+ name = File.basename( moduledir )
61
+ error "The module #{name} does not exist" unless File.directory?( moduledir )
62
+ t = case type
63
+ when /class*/i
64
+ 'class'
65
+ when /def*/
66
+ 'define'
67
+ else
68
+ ''
69
+ end
70
+ error "Undefined type #{type}" if t.empty?
70
71
  result = []
71
72
  Dir["#{moduledir}/manifests/**/*.pp"].each do |ppfile|
72
- File.read(ppfile).scan(/^[ \t]*#{t}[\s]+([0-9a-zA-z:-]+).*$/).each do |line|
73
+ File.read(ppfile).scan(/^[ \t]*#{t}[\s]+([0-9a-zA-z:-]+).*$/).each do |line|
73
74
  result << line[0]
74
75
  end
75
76
  end
@@ -88,7 +89,7 @@ module FalkorLib #:nodoc:
88
89
  config = {}
89
90
  login = `whoami`.chomp
90
91
  config[:name] = name unless name.empty?
91
- moduledir = name.empty? ? rootdir : File.join(rootdir, name)
92
+ moduledir = name.empty? ? rootdir : File.join(rootdir, name)
92
93
  FalkorLib::Config::Puppet::Modules::DEFAULTS[:metadata].each do |k,v|
93
94
  next if v.kind_of?(Array) or k == :license
94
95
  next if k == :name and ! name.empty?
@@ -99,6 +100,8 @@ module FalkorLib #:nodoc:
99
100
  File.basename(rootdir).gsub(/^puppet-/, '')
100
101
  when :issues_url
101
102
  config[:project_page].nil? ? v : "#{config[:project_page]}/issues"
103
+ when :forge_url
104
+ v + '/' + config[:name].gsub(/-/,'/')
102
105
  when :description
103
106
  config[:summary].nil? ? v : "#{config[:summary]}"
104
107
  when :source
@@ -109,21 +112,24 @@ module FalkorLib #:nodoc:
109
112
  config[k.to_sym] = ask( "\t" + sprintf("%-20s", "Module #{k}"), default_answer)
110
113
  end
111
114
  name = config[:name].gsub(/.*-/, '')
112
- tags = ask("\tKeywords (comma-separated list of tags)", name)
115
+ tags = ask("\tKeywords (comma-separated list of tags)", name)
113
116
  config[:tags] = tags.split(',')
114
- list_license = FalkorLib::Config::Puppet::Modules::DEFAULTS[:licenses]
115
- default_license = FalkorLib::Config::Puppet::Modules::DEFAULTS[:metadata][:license]
116
- idx = list_license.index(default_license) unless default_license.nil?
117
- license = select_from(list_license,
117
+ list_license = FalkorLib::Config::Puppet::Modules::DEFAULTS[:licenses]
118
+ default_license = FalkorLib::Config::Puppet::Modules::DEFAULTS[:metadata][:license]
119
+ idx = list_license.index(default_license) unless default_license.nil?
120
+ license = select_from(list_license,
118
121
  'Select the license index for the Puppet module:',
119
- idx.nil? ? 1 : idx + 1)
122
+ idx.nil? ? 1 : idx + 1)
120
123
  config[:license] = license.downcase unless license.empty?
121
124
  puts "\t" + sprintf("%-20s", "Module License:") + config[:license]
125
+
126
+ # Supported platforms
127
+ config[:platforms] = [ 'debian' ]
122
128
 
123
129
  #ap config
124
130
  # Bootstrap the directory
125
131
  templatedir = File.join( FalkorLib.templates, 'puppet', 'modules')
126
- init_from_template(templatedir, moduledir, config, {
132
+ init_from_template(templatedir, moduledir, config, {
127
133
  :erb_exclude => [ 'templates\/[^\/]*\.erb$' ]
128
134
  })
129
135
  # Rename the files / element templatename
@@ -143,8 +149,9 @@ module FalkorLib #:nodoc:
143
149
  init_rvm(moduledir)
144
150
  unless FalkorLib::GitFlow.init?(moduledir)
145
151
  warn "Git [Flow] is not initialized in #{moduledir}."
146
- a = ask("Proceed to git-flow initialization (Y|n)", 'Yes')
147
- FalkorLib::GitFlow.init(moduledir) unless a =~ /n.*/i
152
+ a = ask("Proceed to git-flow initialization (y|N)", 'No')
153
+ return if a =~ /n.*/i
154
+ FalkorLib::GitFlow.init(moduledir)
148
155
  end
149
156
 
150
157
  # Propose to commit the key files
@@ -165,96 +172,122 @@ module FalkorLib #:nodoc:
165
172
  def parse(moduledir = Dir.pwd)
166
173
  name = File.basename( moduledir )
167
174
  error "The module #{name} does not exist" unless File.directory?( moduledir )
168
- jsonfile = File.join( moduledir, 'metadata.json')
169
- error "Unable to find #{jsonfile}" unless File.exist?( jsonfile )
170
- metadata = JSON.parse( IO.read( jsonfile ) )
171
- metadata["classes"] = classes(moduledir)
172
- metadata["definitions"] = definitions(moduledir)
173
- deps = deps(moduledir)
174
- listed_deps = metadata["dependencies"]
175
- missed_deps = []
176
- metadata["dependencies"].each do |dep|
177
- lib = dep["name"].gsub(/^[^\/-]+[\/-]/,'')
178
- if deps.include?( lib )
179
- deps.delete( lib )
180
- else
181
- unless lib =~ /stdlib/
182
- warn "The library '#{dep["name"]}' is not analyzed as part of the #{name} module"
183
- missed_deps << dep
184
- end
185
- end
186
- end
187
- if ! deps.empty?
188
- deps.each do |l|
189
- shortname = name.gsub(/.*-/, '')
190
- shortmetaname = metadata["name"].gsub(/.*-/, '')
191
- next if [name, metadata["name"], name.gsub(/.*-/, ''), metadata["name"].gsub(/.*-/, '') ].include? ( l )
192
- warn "The module '#{l}' is missing in the dependencies thus added"
193
- login = ask("[Github] login for the module '#{l}'")
194
- version = ask("Version requirement (ex: '>=1.0.0 <2.0.0' or '1.2.3' or '1.x')")
195
- metadata["dependencies"] << {
196
- "name" => "#{login}/#{l}",
197
- "version_requirement" => "#{version}"
198
- }
199
- end
200
- end
201
- info "Metadata configuration for the module '#{name}'"
202
- puts JSON.pretty_generate( metadata )
203
- warn "About to commit these changes in the '#{name}/metadata.json' file"
204
- really_continue?
205
- File.open(jsonfile,"w") do |f|
206
- f.write JSON.pretty_generate( metadata )
175
+ jsonfile = File.join( moduledir, 'metadata.json')
176
+ error "Unable to find #{jsonfile}" unless File.exist?( jsonfile )
177
+ metadata = JSON.parse( IO.read( jsonfile ) )
178
+ metadata["classes"] = classes(moduledir)
179
+ metadata["definitions"] = definitions(moduledir)
180
+ deps = deps(moduledir)
181
+ listed_deps = metadata["dependencies"]
182
+ missed_deps = []
183
+ metadata["dependencies"].each do |dep|
184
+ lib = dep["name"].gsub(/^[^\/-]+[\/-]/,'')
185
+ if deps.include?( lib )
186
+ deps.delete( lib )
187
+ else
188
+ unless lib =~ /stdlib/
189
+ warn "The library '#{dep["name"]}' is not analyzed as part of the #{name} module"
190
+ missed_deps << dep
191
+ end
192
+ end
193
+ end
194
+ if ! deps.empty?
195
+ deps.each do |l|
196
+ shortname = name.gsub(/.*-/, '')
197
+ shortmetaname = metadata["name"].gsub(/.*-/, '')
198
+ next if [name, metadata["name"], name.gsub(/.*-/, ''), metadata["name"].gsub(/.*-/, '') ].include? ( l )
199
+ warn "The module '#{l}' is missing in the dependencies thus added"
200
+ login = ask("[Github] login for the module '#{l}'")
201
+ version = ask("Version requirement (ex: '>=1.0.0 <2.0.0' or '1.2.3' or '1.x')")
202
+ metadata["dependencies"] << {
203
+ "name" => "#{login}/#{l}",
204
+ "version_requirement" => "#{version}"
205
+ }
206
+ end
207
+ end
208
+ info "Metadata configuration for the module '#{name}'"
209
+ puts JSON.pretty_generate( metadata )
210
+ warn "About to commit these changes in the '#{name}/metadata.json' file"
211
+ really_continue?
212
+ File.open(jsonfile,"w") do |f|
213
+ f.write JSON.pretty_generate( metadata )
214
+ end
215
+ metadata
216
+ end # parse
217
+
218
+ ##Upgrade the repository README etc. with the
219
+ def upgrade(moduledir = Dir.pwd)
220
+ name = File.basename( moduledir )
221
+ error "The module #{name} does not exist" unless File.directory?( moduledir )
222
+ jsonfile = File.join( moduledir, 'metadata.json')
223
+ error "Unable to find #{jsonfile}" unless File.exist?( jsonfile )
224
+ metadata = JSON.parse( IO.read( jsonfile ) )
225
+ templatedir = File.join( FalkorLib.templates, 'puppet', 'modules')
226
+ # convert string keys to symbols
227
+ metadata.keys.each do |k|
228
+ metadata[(k.to_sym rescue k) || k] = metadata.delete(k)
229
+ end
230
+ metadata[:platforms] = []
231
+ metadata[:operatingsystem_support].each do |e|
232
+ metadata[:platforms] << e["operatingsystem"].downcase
207
233
  end
208
234
 
209
- end # parse
235
+ [ 'README.md', 'doc/contributing.md'].each do |f|
236
+ info "Upgrade the content of #{f}"
237
+ write_from_erb_template(File.join(templatedir, "#{f}.erb"),
238
+ File.join(moduledir, f),
239
+ metadata)
240
+ end
241
+ end
242
+
243
+
210
244
 
211
245
 
212
246
  #######
213
247
  # Find the classes of a given module
214
248
  ###
215
249
  def classes(moduledir = Dir.pwd)
216
- _get_classdefs(moduledir, 'classes')
250
+ _get_classdefs(moduledir, 'classes')
217
251
  end
218
252
 
219
253
  #######
220
254
  # Find the definitions of a given module
221
255
  ###
222
256
  def definitions(moduledir = Dir.pwd)
223
- _get_classdefs(moduledir, 'definitions')
257
+ _get_classdefs(moduledir, 'definitions')
224
258
  end
225
259
 
226
260
  #######
227
261
  # Find the dependencies of a given module
228
262
  ###
229
263
  def deps(moduledir = Dir.pwd)
230
- name = File.basename( moduledir )
231
- error "The module #{name} does not exist" unless File.directory?( moduledir )
264
+ name = File.basename( moduledir )
265
+ error "The module #{name} does not exist" unless File.directory?( moduledir )
232
266
 
233
- result = Array.new
234
- result2 = Array.new
235
- resulttmp = Array.new
267
+ result = Array.new
268
+ result2 = Array.new
269
+ resulttmp = Array.new
236
270
 
237
- result << name
271
+ result << name
238
272
 
239
- while result != result2 do
240
- resulttmp = result.dup
241
- (result - result2).each do |x|
242
- Dir["#{moduledir}/**/*.pp"].each do |ppfile|
243
- File.read(ppfile).scan(/^[ \t]*include.*$|^[ \t]*require.*$/).each do |line|
244
- if line.scan(">").length == 0
245
- result << line.gsub(/^[ \t]*(include|require) ([\"']|)([0-9a-zA-Z:{$}\-]*)([\"']|)/, '\3').split("::").first
246
- end
247
- end
248
- end
249
- end
250
- result.uniq!
251
- result2 = resulttmp.dup
252
- end
253
- result.delete "#{name}"
254
- result
273
+ while result != result2 do
274
+ resulttmp = result.dup
275
+ (result - result2).each do |x|
276
+ Dir["#{moduledir}/**/*.pp"].each do |ppfile|
277
+ File.read(ppfile).scan(/^[ \t]*include.*$|^[ \t]*require.*$/).each do |line|
278
+ if line.scan(">").length == 0
279
+ result << line.gsub(/^[ \t]*(include|require) ([\"']|)([0-9a-zA-Z:{$}\-]*)([\"']|)/, '\3').split("::").first
280
+ end
281
+ end
282
+ end
283
+ end
284
+ result.uniq!
285
+ result2 = resulttmp.dup
286
+ end
287
+ result.delete "#{name}"
288
+ result
255
289
  end
256
290
 
257
-
258
- end # module FalkorLib::Puppet::Modules
291
+ end
259
292
  end # module FalkorLib::Puppet
260
293
  end # module FalkorLib
@@ -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: <Thu 2014-08-28 23:04 svarrette>
4
+ # Time-stamp: <Sat 2014-08-30 21:16 svarrette>
5
5
  #
6
6
  # Copyright (c) 2014 Sebastien Varrette <Sebastien.Varrette@uni.lu>
7
7
  # http://varrette.gforge.uni.lu
@@ -13,31 +13,66 @@ require 'falkorlib/puppet'
13
13
 
14
14
  #.....................
15
15
  namespace :bootstrap do
16
- #.....................
17
- namespace :puppet do
18
-
19
- ########### bootstrap:puppet:module ###########
20
- desc "Bootstrap a new Puppet module"
21
- task :module, [:name] do |t, args|
22
- info "#{t.comment}"
23
- name = args.name == 'name' ? ask("Enter the module name") : args.name
24
- error "You need to provide a module name" unless name != ''
25
- error "The module name cannot contain spaces" if name =~ /\s+/
26
- moduledir = File.join( FalkorLib.config[:puppet][:modulesdir], name)
27
- dir = ask("Destination directory:", moduledir)
28
- error "The module '#{name}' already exists" if File.directory?(dir)
29
- FalkorLib::Puppet::Modules.init(dir)
30
- end
16
+ #.....................
17
+ namespace :puppet do
18
+
19
+ ########### bootstrap:puppet:module ###########
20
+ desc "Bootstrap a new Puppet module"
21
+ task :module, [:name] do |t, args|
22
+ info "#{t.comment}"
23
+ name = args.name == 'name' ? ask("Enter the module name") : args.name
24
+ error "You need to provide a module name" unless name != ''
25
+ error "The module name cannot contain spaces" if name =~ /\s+/
26
+ moduledir = File.join( FalkorLib.config[:puppet][:modulesdir], name)
27
+ dir = ask("Destination directory:", moduledir)
28
+ error "The module '#{name}' already exists" if File.directory?(dir)
29
+ FalkorLib::Puppet::Modules.init(dir)
30
+ end
31
31
 
32
32
 
33
- end # namespace bootstrap:puppet
33
+ end # namespace bootstrap:puppet
34
34
  end # namespace bootstrap
35
35
 
36
36
 
37
37
 
38
38
  #.....................
39
39
  namespace :puppet do
40
- include FalkorLib::Common
40
+ include FalkorLib::Common
41
+
42
+ if command?('puppet')
43
+ #.....................
44
+ namespace :module do
45
+
46
+ ########### puppet:module:build ###########
47
+ desc "Build the puppet module to publish it on the Puppet Forge"
48
+ task :build do |t|
49
+ info "#{t.comment}"
50
+ run %{ puppet module build }
51
+ warn "you can now upload the generated file on the puppet forge"
52
+ warn " https://forge.puppetlabs.com/"
53
+ end # task build
54
+
55
+ ########### puppet:module:parse ###########
56
+ desc "Parse a given module"
57
+ task :parse do |t|
58
+ info "#{t.comment}"
59
+ FalkorLib::Puppet::Modules.parse()
60
+ end # task parse
41
61
 
42
62
 
63
+ end
64
+ end # namespace module
43
65
  end # namespace puppet
66
+
67
+ #.....................
68
+ namespace :module do
69
+ namespace :upgrade do
70
+ ########### module:upgrade:readme ###########
71
+ task :readme do |t|
72
+ #info "#{t.comment}"
73
+ FalkorLib::Puppet::Modules.upgrade()
74
+ end
75
+
76
+
77
+ end # namespace upgrade
78
+ end # namespace module
@@ -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).
@@ -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, 3
22
+ MAJOR, MINOR, PATCH = 0, 3, 4
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: <Sat 2014-08-30 15:28 svarrette>
5
+ # Time-stamp: <Sat 2014-08-30 21:23 svarrette>
6
6
  #
7
7
  # @description Check the Puppet Modules operations
8
8
  #
@@ -37,13 +37,8 @@ describe FalkorLib::Puppet::Modules do
37
37
 
38
38
  it "#init -- create a puppet module" do
39
39
  # Prepare answer to the questions
40
- Array.new(11).each { |e| STDIN.should_receive(:gets).and_return('') }
41
- STDIN.should_receive(:gets).and_return('Yes') ## initialize/update the directory
42
- Array.new(14).each { |e| STDIN.should_receive(:gets).and_return('') }
43
- STDIN.should_receive(:gets).and_return('') ## RVM version
44
- STDIN.should_receive(:gets).and_return(name) ## RVM gemset
45
- STDIN.should_receive(:gets).and_return('No')
46
-
40
+ Array.new(32).each { |e| STDIN.should_receive(:gets).and_return('') }
41
+
47
42
  FalkorLib::Puppet::Modules.init(moduledir)
48
43
  templatedir = File.join( FalkorLib.templates, 'puppet', 'modules')
49
44
  s = true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: falkorlib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastien Varrette
@@ -128,6 +128,20 @@ dependencies:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
+ - !ruby/object:Gem::Dependency
132
+ name: diffy
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '3.0'
138
+ type: :runtime
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '3.0'
131
145
  - !ruby/object:Gem::Dependency
132
146
  name: bundler
133
147
  requirement: !ruby/object:Gem::Requirement