shadow_puppet 0.3.2 → 0.3.3

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.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ doc
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "doc"]
2
+ path = doc
3
+ url = git://github.com/railsmachine/shadow_puppet.git
data/Rakefile ADDED
@@ -0,0 +1,100 @@
1
+ require 'rake'
2
+
3
+ require 'jeweler'
4
+ Jeweler::Tasks.new do |gem|
5
+ gem.name = "shadow_puppet"
6
+ gem.summary = %Q{A Ruby Puppet DSL}
7
+ gem.description = %Q{A Ruby Puppet DSL}
8
+ gem.email = "jesse@railsmachine.com"
9
+ gem.homepage = "http://railsmachine.github.com/shadow_puppet"
10
+ gem.rubyforge_project = "moonshine"
11
+ gem.authors = ["Jesse Newland", "Josh Nichols"]
12
+
13
+ gem.version = "0.3.3"
14
+
15
+ gem.add_dependency('puppet', ["= 0.24.8"])
16
+ gem.add_dependency('facter', [">= 1.5.4"])
17
+ gem.add_dependency('highline', [">= 1.5.0"])
18
+ gem.add_dependency('builder', [">= 2.1.2"])
19
+ gem.add_dependency('activesupport', [">= 2.0.0"])
20
+
21
+ gem.rdoc_options << '--inline-source' << '--webcvs=http://github.com/railsmachine/shadow_puppet/tree/master/'
22
+
23
+ gem.add_development_dependency "rspec", ">= 0"
24
+
25
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
26
+ end
27
+ Jeweler::GemcutterTasks.new
28
+
29
+
30
+ begin
31
+ require 'rubygems'
32
+ require 'hanna/rdoctask'
33
+ rescue LoadError
34
+ require 'rake/rdoctask'
35
+ end
36
+ Rake::RDocTask.new(:rdoc) do |rdoc|
37
+ rdoc.rdoc_files.include('lib/shadow_puppet/*.rb')
38
+ rdoc.rdoc_files.include('bin/shadow_puppet')
39
+ rdoc.rdoc_files.include('README.rdoc')
40
+
41
+ rdoc.main = "README.rdoc" # page to start on
42
+ rdoc.title = "ShadowPuppet documentation"
43
+
44
+ rdoc.rdoc_dir = 'doc' # rdoc output folder
45
+ rdoc.options << '--webcvs=http://github.com/railsmachine/shadow_puppet/tree/master/'
46
+ end
47
+
48
+ task :default => :spec
49
+ task :spec do
50
+ system("spec --options spec/spec.opts spec/*_spec.rb") || raise
51
+ end
52
+
53
+ task :build => :cleanup do
54
+ system "gem build *.gemspec"
55
+ end
56
+
57
+ task :install => :build do
58
+ system "sudo gem install *.gem"
59
+ end
60
+
61
+ task :uninstall do
62
+ system "sudo gem uninstall *.gem"
63
+ end
64
+
65
+ task :cleanup do
66
+ system "rm *.gem"
67
+ end
68
+
69
+ task :pull do
70
+ system "git pull origin master"
71
+ system "git pull github master"
72
+ end
73
+
74
+ task :_push do
75
+ system "git push origin master"
76
+ system "git push github master"
77
+ end
78
+
79
+ task :push => [:redoc, :pull, :spec, :_push]
80
+
81
+ task :redoc do
82
+ #clean
83
+ system "git checkout gh-pages && git pull origin gh-pages && git pull github gh-pages"
84
+ system "rm -rf doc"
85
+ system "git checkout master"
86
+ system "rm -rf doc"
87
+
88
+ #doc
89
+ Rake::Task['rdoc'].invoke
90
+
91
+ #switch branch
92
+ system "git checkout gh-pages"
93
+
94
+ #move it all to the root
95
+ system "cp -r doc/* . && rm -rf doc"
96
+
97
+ #commit and push
98
+ system "git commit -am 'regenerate rdocs' && git push origin gh-pages && git push github gh-pages"
99
+ system "git checkout master"
100
+ end
data/bin/shadow_puppet CHANGED
@@ -74,6 +74,14 @@ begin
74
74
  opts.parse!
75
75
 
76
76
  require 'rubygems'
77
+
78
+ # hack around absurd number of deprecation warnings from puppet
79
+ # using `metaclass`
80
+ require 'active_support/core_ext/module/attribute_accessors'
81
+ require 'active_support/core_ext/kernel/reporting'
82
+ require 'active_support/deprecation'
83
+ ActiveSupport::Deprecation.silenced = true
84
+
77
85
  require 'shadow_puppet'
78
86
  require 'active_support/inflector'
79
87
  require 'active_support/core_ext/string/inflections'
@@ -101,4 +109,4 @@ rescue Exception => e
101
109
  puts e.backtrace.join("\n")
102
110
  exit(1)
103
111
  end
104
- end
112
+ end
@@ -0,0 +1,23 @@
1
+ require 'ginger'
2
+
3
+ def create_scenario(version)
4
+ scenario = Ginger::Scenario.new("Rails #{version}")
5
+ scenario[/^activesupport$/] = version
6
+ scenario[/^activerecord$/] = version
7
+ scenario[/^actionpack$/] = version
8
+ scenario[/^actioncontroller$/] = version
9
+ scenario
10
+ end
11
+
12
+ Ginger.configure do |config|
13
+ config.aliases["rails"] = "rails"
14
+
15
+ rails_2_3_5 = create_scenario('2.3.5')
16
+ rails_2_3_8 = create_scenario('2.3.8')
17
+
18
+ rails_3_0_0_beta = create_scenario('3.0.0.beta')
19
+ rails_3_0_0_beta3 = create_scenario('3.0.0.beta3')
20
+
21
+ config.scenarios << rails_2_3_5 << rails_2_3_8 << rails_3_0_0_beta << rails_3_0_0_beta3
22
+ end
23
+
data/lib/shadow_puppet.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  require 'puppet'
2
2
  require 'erb'
3
- require File.join(File.dirname(__FILE__) + '/shadow_puppet', 'core_ext.rb')
4
- require File.join(File.dirname(__FILE__) + '/shadow_puppet', 'manifest.rb')
3
+
4
+ require 'shadow_puppet/core_ext'
5
+ require 'shadow_puppet/manifest'
5
6
 
6
7
  class ShadowPuppet::Manifest::Setup < ShadowPuppet::Manifest
7
8
  recipe :setup_directories
@@ -27,4 +28,4 @@ class ShadowPuppet::Manifest::Setup < ShadowPuppet::Manifest
27
28
  end
28
29
 
29
30
  setup = ShadowPuppet::Manifest::Setup.new
30
- setup.execute
31
+ setup.execute
@@ -1,8 +1,16 @@
1
+ require 'active_support/version'
2
+
1
3
  require 'active_support/core_ext/class/attribute_accessors'
2
4
  require 'active_support/core_ext/array'
3
5
  require 'active_support/inflector'
4
6
  require 'active_support/core_ext/class/inheritable_attributes'
5
- require 'active_support/core_ext/duplicable'
7
+
8
+ if ActiveSupport::VERSION::MAJOR < 3
9
+ require 'active_support/core_ext/duplicable'
10
+ else
11
+ require 'active_support/core_ext/object/duplicable'
12
+ end
13
+
6
14
  class Hash #:nodoc:
7
15
  def deep_merge(other_hash)
8
16
  self.merge(other_hash) do |key, oldval, newval|
@@ -11,9 +19,11 @@ class Hash #:nodoc:
11
19
  oldval.is_a?(Hash) && newval.is_a?(Hash) ? oldval.deep_merge(newval) : newval
12
20
  end
13
21
  end
22
+
14
23
  def deep_merge!(other_hash)
15
24
  replace(deep_merge(other_hash))
16
25
  end
26
+
17
27
  def deep_symbolize_keys
18
28
  self.inject({}) { |result, (key, value)|
19
29
  value = value.deep_symbolize_keys if value.is_a?(Hash)
@@ -21,4 +31,4 @@ class Hash #:nodoc:
21
31
  result
22
32
  }
23
33
  end
24
- end
34
+ end
@@ -24,15 +24,15 @@ module ShadowPuppet
24
24
  # end
25
25
  #
26
26
  # def lamp
27
- # #install a basic LAMP stack
27
+ # # install a basic LAMP stack
28
28
  # end
29
29
  #
30
30
  # def ruby
31
- # #install a ruby interpreter and tools
31
+ # # install a ruby interpreter and tools
32
32
  # end
33
33
  #
34
34
  # def mysql(options)
35
- # #install a mysql server and set the root password to options[:root_password]
35
+ # # install a mysql server and set the root password to options[:root_password]
36
36
  # end
37
37
  #
38
38
  # end
@@ -110,10 +110,10 @@ module ShadowPuppet
110
110
  # Subclasses of the Manifest class properly inherit the parent classes'
111
111
  # calls to recipe.
112
112
  def self.recipe(*methods)
113
- return nil if methods.nil? || methods == []
113
+ return nil if methods.nil? || methods == [] # TODO can probably replace with if methods.blank?
114
114
  options = methods.extract_options!
115
115
  methods.each do |meth|
116
- options = configuration[meth.to_sym] if options == {}
116
+ options = configuration[meth.to_sym] if options == {} # TODO can probably be replaced with options.blank?
117
117
  options ||= {}
118
118
  recipes << [meth.to_sym, options]
119
119
  end
@@ -197,7 +197,7 @@ module ShadowPuppet
197
197
  def self.register_puppet_types
198
198
  Puppet::Type.loadall
199
199
  Puppet::Type.eachtype do |type|
200
- #remove the method rdoc placeholders
200
+ # remove the method rdoc placeholders
201
201
  remove_method(type.name) rescue nil
202
202
  define_method(type.name) do |*args|
203
203
  if args && args.flatten.size == 1
@@ -329,12 +329,12 @@ module ShadowPuppet
329
329
  @scope
330
330
  end
331
331
 
332
- #Create a reference to another Puppet Resource.
332
+ # Create a reference to another Puppet Resource.
333
333
  def reference(type, title)
334
334
  Puppet::Parser::Resource::Reference.new(:type => type.to_s, :title => title.to_s, :scope => scope)
335
335
  end
336
336
 
337
- #Creates a new Puppet Resource.
337
+ # Creates a new Puppet Resource.
338
338
  def new_resource(type, name, params = {})
339
339
  unless obj = @puppet_resources[type][name]
340
340
  obj = Puppet::Parser::Resource.new(
@@ -370,7 +370,3 @@ module ShadowPuppet
370
370
 
371
371
  end
372
372
  end
373
-
374
- Dir.glob(File.join(File.dirname(__FILE__), '..', 'facts', '*.rb')).each do |fact|
375
- require fact
376
- end
@@ -30,7 +30,7 @@ module ShadowPuppet
30
30
  # manifest.files['/etc/motd'].content
31
31
  # manifest.execs['service ssh restart'].onlyif
32
32
  #
33
- # ===Example
33
+ # === Example
34
34
  #
35
35
  # Given this manifest:
36
36
  #
@@ -66,4 +66,4 @@ module ShadowPuppet
66
66
  register_puppet_types_for_testing
67
67
 
68
68
  end
69
- end
69
+ end
@@ -0,0 +1,85 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{shadow_puppet}
8
+ s.version = "0.3.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jesse Newland", "Josh Nichols"]
12
+ s.date = %q{2010-06-29}
13
+ s.default_executable = %q{shadow_puppet}
14
+ s.description = %q{A Ruby Puppet DSL}
15
+ s.email = %q{jesse@railsmachine.com}
16
+ s.executables = ["shadow_puppet"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".gitignore",
23
+ ".gitmodules",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "bin/shadow_puppet",
28
+ "examples/foo.rb",
29
+ "ginger_scenarios.rb",
30
+ "lib/shadow_puppet.rb",
31
+ "lib/shadow_puppet/core_ext.rb",
32
+ "lib/shadow_puppet/manifest.rb",
33
+ "lib/shadow_puppet/test.rb",
34
+ "shadow_puppet.gemspec",
35
+ "spec/fixtures/manifests.rb",
36
+ "spec/manifest_spec.rb",
37
+ "spec/spec.opts",
38
+ "spec/spec_helper.rb",
39
+ "spec/test_spec.rb",
40
+ "spec/type_spec.rb"
41
+ ]
42
+ s.homepage = %q{http://railsmachine.github.com/shadow_puppet}
43
+ s.rdoc_options = ["--charset=UTF-8", "--inline-source", "--webcvs=http://github.com/railsmachine/shadow_puppet/tree/master/"]
44
+ s.require_paths = ["lib"]
45
+ s.rubyforge_project = %q{moonshine}
46
+ s.rubygems_version = %q{1.3.6}
47
+ s.summary = %q{A Ruby Puppet DSL}
48
+ s.test_files = [
49
+ "spec/fixtures/manifests.rb",
50
+ "spec/manifest_spec.rb",
51
+ "spec/spec_helper.rb",
52
+ "spec/test_spec.rb",
53
+ "spec/type_spec.rb",
54
+ "examples/foo.rb"
55
+ ]
56
+
57
+ if s.respond_to? :specification_version then
58
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
59
+ s.specification_version = 3
60
+
61
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
62
+ s.add_runtime_dependency(%q<puppet>, ["= 0.24.8"])
63
+ s.add_runtime_dependency(%q<facter>, [">= 1.5.4"])
64
+ s.add_runtime_dependency(%q<highline>, [">= 1.5.0"])
65
+ s.add_runtime_dependency(%q<builder>, [">= 2.1.2"])
66
+ s.add_runtime_dependency(%q<activesupport>, [">= 2.0.0"])
67
+ s.add_development_dependency(%q<rspec>, [">= 0"])
68
+ else
69
+ s.add_dependency(%q<puppet>, ["= 0.24.8"])
70
+ s.add_dependency(%q<facter>, [">= 1.5.4"])
71
+ s.add_dependency(%q<highline>, [">= 1.5.0"])
72
+ s.add_dependency(%q<builder>, [">= 2.1.2"])
73
+ s.add_dependency(%q<activesupport>, [">= 2.0.0"])
74
+ s.add_dependency(%q<rspec>, [">= 0"])
75
+ end
76
+ else
77
+ s.add_dependency(%q<puppet>, ["= 0.24.8"])
78
+ s.add_dependency(%q<facter>, [">= 1.5.4"])
79
+ s.add_dependency(%q<highline>, [">= 1.5.0"])
80
+ s.add_dependency(%q<builder>, [">= 2.1.2"])
81
+ s.add_dependency(%q<activesupport>, [">= 2.0.0"])
82
+ s.add_dependency(%q<rspec>, [">= 0"])
83
+ end
84
+ end
85
+
@@ -0,0 +1,95 @@
1
+ class BlankManifest < ShadowPuppet::Manifest
2
+ end
3
+
4
+ #this does nothing
5
+ class NoOpManifest < ShadowPuppet::Manifest
6
+ def foo
7
+ exec('foo', :command => 'true')
8
+ end
9
+
10
+ def bar
11
+ exec('bar', :command => 'true')
12
+ end
13
+ end
14
+
15
+ #demonstrate the default method of satifying requirements: instance methods
16
+ class RequiresMetViaMethods < ShadowPuppet::Manifest
17
+ recipe :foo, :bar
18
+
19
+ configure({ :foo => :bar , :nested_hash => { :nested_foo => :bar } })
20
+
21
+ def foo
22
+ exec('foo', :command => 'true')
23
+ end
24
+
25
+ def bar
26
+ exec('bar', :command => 'true')
27
+ end
28
+ end
29
+
30
+ class RequiresMetViaMethodsSubclass < RequiresMetViaMethods
31
+ recipe :baz
32
+
33
+ configure({ :baz => :bar, :nested_hash => { :nested_baz => :bar } })
34
+
35
+ def baz
36
+ exec('baz', :command => 'true')
37
+ end
38
+ end
39
+
40
+ #requirements can also be handled by functions in external modules
41
+ class ProvidedViaModules < ShadowPuppet::Manifest
42
+ module FooRecipe
43
+ def foo
44
+ file('/tmp/moonshine_foo', :ensure => 'present', :content => 'foo')
45
+ end
46
+ end
47
+
48
+ module BarRecipe
49
+ def bar
50
+ file('/tmp/moonshine_bar', :ensure => 'absent')
51
+ end
52
+ end
53
+ include FooRecipe
54
+ include BarRecipe
55
+ recipe :foo, :bar
56
+ end
57
+
58
+ #requirements can also be handled by functions in external modules
59
+ class PassingArguments < ShadowPuppet::Manifest
60
+ def foo(options = {})
61
+ file(options[:name], :ensure => 'present', :content => 'foo')
62
+ end
63
+ recipe :foo, :name => '/tmp/moonshine_foo'
64
+ end
65
+
66
+ # since self.respond_to?(:foo) == false, this raises an error when run
67
+ class RequirementsNotMet < ShadowPuppet::Manifest
68
+ recipe :foo, :bar
69
+
70
+ # def foo
71
+ # end
72
+
73
+ def bar
74
+ #this is okay
75
+ end
76
+ end
77
+
78
+ class ConfigurationWithConvention < ShadowPuppet::Manifest
79
+ configure(:foo => :bar)
80
+ def foo(string)
81
+ file('/tmp/moonshine_foo', :ensure => 'present', :content => string.to_s)
82
+ end
83
+ recipe :foo
84
+ end
85
+
86
+ # setting up a few different resource types to test the test helpers
87
+ class TestHelpers < ShadowPuppet::Manifest
88
+
89
+ def foo
90
+ exec('foo', :command => 'true',:onlyif => 'test `hostname` == "foo"')
91
+ package('bar',:ensure => :installed)
92
+ file('baz', :content => 'bar',:mode => '644',:owner => 'rails')
93
+ end
94
+
95
+ end
@@ -0,0 +1,201 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "A manifest" do
4
+
5
+ describe "when blank" do
6
+
7
+ before(:each) do
8
+ @manifest = BlankManifest.new
9
+ end
10
+
11
+ it "does nothing" do
12
+ @manifest.class.recipes.should == []
13
+ end
14
+
15
+ it "returns true when executed" do
16
+ @manifest.execute.should be_true
17
+ end
18
+
19
+ end
20
+
21
+ describe "without specified recipes" do
22
+
23
+ before(:each) do
24
+ @manifest = NoOpManifest.new
25
+ end
26
+
27
+ it "is executable by default" do
28
+ @manifest.should be_executable
29
+ end
30
+
31
+ describe "when calling instance methods" do
32
+
33
+ before(:each) do
34
+ @manifest.foo
35
+ end
36
+
37
+ it "creates resources" do
38
+ @manifest.execs.keys.sort.should == ['foo']
39
+ end
40
+
41
+ it "applies our customizations to resources" do
42
+ @manifest.execs["foo"].path.should == ENV["PATH"]
43
+ end
44
+
45
+ describe "and then executing" do
46
+
47
+ before(:each) do
48
+ @manifest = @manifest.execute
49
+ end
50
+
51
+ it "returns true" do
52
+ @manifest.should be_true
53
+ end
54
+
55
+ end
56
+
57
+ end
58
+
59
+ end
60
+
61
+ describe "when recipes aren't fullfilled" do
62
+
63
+ before(:each) do
64
+ @manifest = RequirementsNotMet.new
65
+ end
66
+
67
+ it "returns false when executed" do
68
+ @manifest.execute.should be_false
69
+ end
70
+
71
+ it "raises an error when executed!" do
72
+ lambda {
73
+ @manifest.execute!
74
+ }.should raise_error(NameError)
75
+ end
76
+
77
+ end
78
+
79
+ describe "in general" do
80
+
81
+ before(:each) do
82
+ @manifest = RequiresMetViaMethods.new
83
+ end
84
+
85
+ it "knows what it's supposed to do" do
86
+ @manifest.class.recipes.should == [[:foo, {}], [:bar, {}]]
87
+ end
88
+
89
+ it "loading configuration on the class" do
90
+ @manifest.class.configuration[:foo].should == :bar
91
+ end
92
+
93
+ it "can access the same configuration hash on the instance" do
94
+ @manifest.configuration[:foo].should == :bar
95
+ end
96
+
97
+ it "has a name" do
98
+ @manifest.name.should == "#{@manifest.class}##{@manifest.object_id}"
99
+ end
100
+
101
+ describe 'when evaluated' do
102
+
103
+ it "calls specified methods" do
104
+ @manifest.should_receive(:foo)
105
+ @manifest.should_receive(:bar)
106
+ @manifest.send(:evaluate_recipes)
107
+ end
108
+
109
+ it "passes the configuration hash key named by each method if no options given" do
110
+ @manifest = ConfigurationWithConvention.new
111
+ @manifest.should_receive(:foo).with(:bar).exactly(1).times
112
+ @manifest.send(:evaluate_recipes)
113
+ end
114
+
115
+ it "creates new resources" do
116
+ @manifest.should_receive(:new_resource).with(Puppet::Type::Exec, 'foo', :command => 'true').exactly(1).times
117
+ @manifest.should_receive(:new_resource).with(Puppet::Type::Exec, 'bar', :command => 'true').exactly(1).times
118
+ @manifest.send(:evaluate_recipes)
119
+ end
120
+
121
+ it "creates new resources" do
122
+ @manifest.send(:evaluate_recipes)
123
+ @manifest.puppet_resources[Puppet::Type::Exec].keys.sort.should == ['bar', 'foo']
124
+ end
125
+
126
+ it "can acess a flat array of resources" do
127
+ @manifest.send(:flat_resources).should == []
128
+ end
129
+
130
+ end
131
+
132
+ describe "when executed" do
133
+
134
+ it "calls evaluate_recipes and apply" do
135
+ @manifest.should_receive(:evaluate_recipes)
136
+ @manifest.should_receive(:apply)
137
+ @manifest.execute
138
+ end
139
+
140
+ it "returns true" do
141
+ @manifest.execute.should be_true
142
+ end
143
+
144
+ it "cannot be executed again" do
145
+ @manifest.execute.should be_true
146
+ @manifest.execute.should be_false
147
+ end
148
+
149
+ end
150
+
151
+ describe "after execution" do
152
+
153
+ before(:each) do
154
+ @manifest = ProvidedViaModules.new
155
+ @manifest.execute
156
+ end
157
+
158
+ it "allows creation of other similar resources" do
159
+ m = PassingArguments.new
160
+ m.execute.should be_true
161
+ end
162
+
163
+ end
164
+
165
+ end
166
+
167
+ describe "that subclasses an existing manifest" do
168
+
169
+ before(:each) do
170
+ @manifest = RequiresMetViaMethodsSubclass.new
171
+ end
172
+
173
+ it "inherits recipes from the parent class" do
174
+ @manifest.class.recipes.map(&:first).should include(:foo, :bar)
175
+ @manifest.class.recipes.first.first.should == :foo
176
+ end
177
+
178
+ it "appends recipes created in the subclass" do
179
+ @manifest.class.recipes.map(&:first).should include(:baz)
180
+ @manifest.class.recipes.last.first.should == :baz
181
+ end
182
+
183
+ it "merges it's configuration with that of the parent" do
184
+ @manifest.class.configuration[:foo].should == :bar
185
+ @manifest.class.configuration[:baz].should == :bar
186
+ end
187
+
188
+ it "deep_merges it's configuration with that of the parent" do
189
+ @manifest.class.configuration[:nested_hash][:nested_baz].should == :bar
190
+ @manifest.class.configuration[:nested_hash][:nested_foo].should == :bar
191
+ end
192
+
193
+ it "is able to add configuration parameters on the instance" do
194
+ @manifest.configure 'boo' => :bar
195
+ @manifest.configuration[:boo].should == :bar
196
+ @manifest.class.configuration[:boo].should == :bar
197
+ end
198
+
199
+ end
200
+
201
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,4 @@
1
+ --colour
2
+ --format s
3
+ --loadby mtime
4
+ --reverse
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'ginger'
3
+ gem 'rspec'
4
+ require 'spec'
5
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'shadow_puppet.rb')
6
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'shadow_puppet', 'test.rb')
7
+ Dir.glob(File.join(File.dirname(__FILE__), 'fixtures', '*.rb')).each do |manifest|
8
+ require manifest
9
+ end
data/spec/test_spec.rb ADDED
@@ -0,0 +1,42 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "ShadowPuppet's test helpers" do
4
+
5
+ it "should be created when register_puppet_types_for_testing is called" do
6
+ Puppet::Type.newtype(:dummy){ }
7
+ Puppet::Type.type(:dummy).provide(:generic){ }
8
+
9
+ BlankManifest.new.respond_to?(:dummies).should == false
10
+ ShadowPuppet::Manifest.register_puppet_types_for_testing
11
+ BlankManifest.new.respond_to?(:dummies).should == true
12
+ end
13
+
14
+ describe "when used in tests" do
15
+
16
+ before do
17
+ @manifest = TestHelpers.new
18
+ @manifest.foo
19
+ end
20
+
21
+ it "should allow simple resource lookup" do
22
+ @manifest.execs.should == @manifest.puppet_resources[Puppet::Type::Exec]
23
+ @manifest.packages.should == @manifest.puppet_resources[Puppet::Type::Package]
24
+ @manifest.files.should == @manifest.puppet_resources[Puppet::Type::File]
25
+ end
26
+
27
+ # making sure that properties such as, e.g the :onlyif condition of Exec[foo]
28
+ # can be accessed simply as manifest.execs['foo'].onlyif rather than via the
29
+ # param hash
30
+ it "should allow referencing params directly" do
31
+ %w(execs files packages).each do |type|
32
+ @manifest.send(type.to_sym).each do |name,resource|
33
+ resource.params.keys.each do |param|
34
+ resource.send(param.to_sym).should == resource.params[param.to_sym].value
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ end
41
+
42
+ end
data/spec/type_spec.rb ADDED
@@ -0,0 +1,12 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "ShadowPuppet's type loading mechanism" do
4
+ it "should create a new type helper methods when register_puppet_types is called" do
5
+ Puppet::Type.newtype(:dummy_1){ }
6
+ Puppet::Type.type(:dummy_1).provide(:generic){ }
7
+
8
+ BlankManifest.new.respond_to?(:dummy_1).should == false
9
+ ShadowPuppet::Manifest.register_puppet_types
10
+ BlankManifest.new.respond_to?(:dummy_1).should == true
11
+ end
12
+ end
metadata CHANGED
@@ -1,94 +1,141 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shadow_puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 3
8
+ - 3
9
+ version: 0.3.3
5
10
  platform: ruby
6
11
  authors:
7
12
  - Jesse Newland
13
+ - Josh Nichols
8
14
  autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-12-15 00:00:00 -05:00
18
+ date: 2010-06-29 00:00:00 -04:00
13
19
  default_executable: shadow_puppet
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: puppet
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
20
25
  requirements:
21
26
  - - "="
22
27
  - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ - 24
31
+ - 8
23
32
  version: 0.24.8
24
- version:
33
+ type: :runtime
34
+ version_requirements: *id001
25
35
  - !ruby/object:Gem::Dependency
26
36
  name: facter
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
30
39
  requirements:
31
40
  - - ">="
32
41
  - !ruby/object:Gem::Version
42
+ segments:
43
+ - 1
44
+ - 5
45
+ - 4
33
46
  version: 1.5.4
34
- version:
47
+ type: :runtime
48
+ version_requirements: *id002
35
49
  - !ruby/object:Gem::Dependency
36
50
  name: highline
37
- type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
40
53
  requirements:
41
54
  - - ">="
42
55
  - !ruby/object:Gem::Version
56
+ segments:
57
+ - 1
58
+ - 5
59
+ - 0
43
60
  version: 1.5.0
44
- version:
61
+ type: :runtime
62
+ version_requirements: *id003
45
63
  - !ruby/object:Gem::Dependency
46
64
  name: builder
47
- type: :runtime
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
50
67
  requirements:
51
68
  - - ">="
52
69
  - !ruby/object:Gem::Version
70
+ segments:
71
+ - 2
72
+ - 1
73
+ - 2
53
74
  version: 2.1.2
54
- version:
75
+ type: :runtime
76
+ version_requirements: *id004
55
77
  - !ruby/object:Gem::Dependency
56
78
  name: activesupport
57
- type: :runtime
58
- version_requirement:
59
- version_requirements: !ruby/object:Gem::Requirement
79
+ prerelease: false
80
+ requirement: &id005 !ruby/object:Gem::Requirement
60
81
  requirements:
61
82
  - - ">="
62
83
  - !ruby/object:Gem::Version
84
+ segments:
85
+ - 2
86
+ - 0
87
+ - 0
63
88
  version: 2.0.0
64
- version:
89
+ type: :runtime
90
+ version_requirements: *id005
91
+ - !ruby/object:Gem::Dependency
92
+ name: rspec
93
+ prerelease: false
94
+ requirement: &id006 !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ segments:
99
+ - 0
100
+ version: "0"
101
+ type: :development
102
+ version_requirements: *id006
65
103
  description: A Ruby Puppet DSL
66
- email:
67
- - jesse@railsmachine.com
104
+ email: jesse@railsmachine.com
68
105
  executables:
69
106
  - shadow_puppet
70
107
  extensions: []
71
108
 
72
109
  extra_rdoc_files:
110
+ - LICENSE
73
111
  - README.rdoc
74
- - bin/shadow_puppet
75
112
  files:
76
- - README.rdoc
113
+ - .gitignore
114
+ - .gitmodules
77
115
  - LICENSE
116
+ - README.rdoc
117
+ - Rakefile
78
118
  - bin/shadow_puppet
79
119
  - examples/foo.rb
120
+ - ginger_scenarios.rb
80
121
  - lib/shadow_puppet.rb
81
- - lib/shadow_puppet/manifest.rb
82
122
  - lib/shadow_puppet/core_ext.rb
123
+ - lib/shadow_puppet/manifest.rb
83
124
  - lib/shadow_puppet/test.rb
125
+ - shadow_puppet.gemspec
126
+ - spec/fixtures/manifests.rb
127
+ - spec/manifest_spec.rb
128
+ - spec/spec.opts
129
+ - spec/spec_helper.rb
130
+ - spec/test_spec.rb
131
+ - spec/type_spec.rb
84
132
  has_rdoc: true
85
133
  homepage: http://railsmachine.github.com/shadow_puppet
86
134
  licenses: []
87
135
 
88
136
  post_install_message:
89
137
  rdoc_options:
90
- - --main
91
- - README.rdoc
138
+ - --charset=UTF-8
92
139
  - --inline-source
93
140
  - --webcvs=http://github.com/railsmachine/shadow_puppet/tree/master/
94
141
  require_paths:
@@ -97,20 +144,27 @@ required_ruby_version: !ruby/object:Gem::Requirement
97
144
  requirements:
98
145
  - - ">="
99
146
  - !ruby/object:Gem::Version
147
+ segments:
148
+ - 0
100
149
  version: "0"
101
- version:
102
150
  required_rubygems_version: !ruby/object:Gem::Requirement
103
151
  requirements:
104
152
  - - ">="
105
153
  - !ruby/object:Gem::Version
154
+ segments:
155
+ - 0
106
156
  version: "0"
107
- version:
108
157
  requirements: []
109
158
 
110
159
  rubyforge_project: moonshine
111
- rubygems_version: 1.3.3
160
+ rubygems_version: 1.3.6
112
161
  signing_key:
113
- specification_version: 2
162
+ specification_version: 3
114
163
  summary: A Ruby Puppet DSL
115
- test_files: []
116
-
164
+ test_files:
165
+ - spec/fixtures/manifests.rb
166
+ - spec/manifest_spec.rb
167
+ - spec/spec_helper.rb
168
+ - spec/test_spec.rb
169
+ - spec/type_spec.rb
170
+ - examples/foo.rb