falkorlib 0.3.4 → 0.3.5

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: 04f2741d9368f17031d85aaf70162b520885251a
4
- data.tar.gz: 9a2ff37f2459c2c9ec3014ea5c380cb4ccba4eb2
3
+ metadata.gz: fc6cbdc597210acfacf149662320dba99df4f9ed
4
+ data.tar.gz: 230dfafedd88c62aadda21b76b92efff18730de9
5
5
  SHA512:
6
- metadata.gz: 3a11240f50dec10daa3d9a5bf36ffc95e6c6b314e17a97731e2651db4ed227af5864118e8111599a9aa612032628191555e21796f47559fa4638af86539fdc60
7
- data.tar.gz: be5cb38f44c4926a785f50f2b932f6077b83de6b61cade921e8a685226b8e553b8c5103a8c2e8823ae5a479dbe1d9a1340117625a0e691b331b778ed9c742c47
6
+ metadata.gz: 7e3388f984c3c19619ed8bc534be94029880f118c8f1371efecdfd2028d30e5c4b32ff6ae3605158b3c7ecafa44696cf1eabc89dfcf797b7bfe04de22f8f204e
7
+ data.tar.gz: c847ad5fdcc64f8852d229dc387c046455cbc7fdb19a958201f7a90a551f67261bd7cfbbc489d32e4475dfaa28e48aac8f05c879e9116e49a7b43e5a21214cae
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- falkorlib (0.3.4)
4
+ falkorlib (0.3.5)
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: <Sat 2014-08-30 21:23 svarrette>
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
- metadata["classes"] = classes(moduledir)
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 JSON.pretty_generate( metadata )
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:16 svarrette>
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
- warn "you can now upload the generated file on the puppet forge"
52
- warn " https://forge.puppetlabs.com/"
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).
@@ -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, 4
22
+ MAJOR, MINOR, PATCH = 0, 3, 5
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 21:23 svarrette>
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
- # before :all do
23
- # ENV['GIT_AUTHOR_NAME'] = 'travis' if ENV['GIT_AUTHOR_NAME'].nil?
24
- # ENV['GIT_AUTHOR_EMAIL'] = 'travis@domain.org' if ENV['GIT_AUTHOR_EMAIL'].nil?
25
- # end
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
- # Module name
35
- name = 'toto'
36
- moduledir = File.join(dir, name)
35
+ # Module name
36
+ name = 'toto'
37
+ moduledir = File.join(dir, name)
37
38
 
38
39
  it "#init -- create a puppet module" do
39
- # Prepare answer to the questions
40
- Array.new(32).each { |e| STDIN.should_receive(:gets).and_return('') }
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
- relative_dir = Pathname.new( File.realpath( File.dirname(e) )).relative_path_from Pathname.new(templatedir)
48
- file = e.gsub(/templatename/, "#{name}")
49
- filename = File.basename(file)
50
- filename = File.basename(file, '.erb') unless file =~ /templates\/toto-variables\.erb/
51
- f = File.join(moduledir, relative_dir, filename)
52
- #puts "checking #{f} - #{File.exists?( f )}"
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
- it "#classes -- list classes" do
59
- l = FalkorLib::Puppet::Modules._get_classdefs(moduledir, 'classes')
60
- c = FalkorLib::Puppet::Modules.classes(moduledir)
61
- c.should == l
62
- ref = [
63
- "toto::params",
64
- "toto",
65
- "toto::common",
66
- "toto::debian",
67
- "toto::redhat"
68
- ]
69
- c.size.should == ref.size
70
- c.each { |e| ref.should include(e) }
71
- end
72
-
73
- it "#definitions -- list definitions" do
74
- d = FalkorLib::Puppet::Modules.definitions(moduledir)
75
- d.should == [ "toto::mydef" ]
76
- end
77
-
78
- it "#deps -- list dependencies" do
79
- d = FalkorLib::Puppet::Modules.deps(moduledir)
80
- d.should == []
81
- end
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
 
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.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastien Varrette