dnapi 1.1.88 → 1.1.89

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.
@@ -27,11 +27,13 @@ module DNApi
27
27
  end
28
28
 
29
29
  def self.[](key)
30
- components.detect {|c| c.key_id == key } or raise NoSuchComponent, "unknown component #{key.inspect}"
30
+ components.detect {|c| c.key_id == key }
31
31
  end
32
32
 
33
33
  def self.from(values)
34
- self[values.delete('key').to_sym].new(values)
34
+ if klass = self[values.delete('key').to_sym]
35
+ klass.new(values)
36
+ end
35
37
  end
36
38
 
37
39
  def key
@@ -37,7 +37,10 @@ module DNApi
37
37
  end
38
38
 
39
39
  def add_component(key, component_options={})
40
- c = Component[key.to_sym].new(component_options.merge(:parent => self))
40
+ unless klass = Component[key.to_sym]
41
+ raise Component::NoSuchComponent, "unknown component #{key.inspect}"
42
+ end
43
+ c = klass.new(component_options.merge(:parent => self))
41
44
  unless c.can_belong_to?(self)
42
45
  raise ComponentAttachmentError, "Can't attach #{key.inspect} to a #{self.class}"
43
46
  end
@@ -18,7 +18,7 @@ module DNApi
18
18
  end
19
19
 
20
20
  NAME = 'Ruby'.freeze
21
- RUBYGEMS_VERSION = '1.5.2'.freeze
21
+ RUBYGEMS_VERSION = '1.8.17'.freeze
22
22
 
23
23
  def rubygems_version
24
24
  self.class::RUBYGEMS_VERSION
@@ -86,6 +86,7 @@ module DNApi
86
86
  NAME = 'REE'.freeze
87
87
  VERSION = '1.8.7'.freeze
88
88
  PATCH_LEVEL = '2011.12'.freeze
89
+ RUBYGEMS_VERSION = '1.5.2'.freeze
89
90
 
90
91
  def self.label
91
92
  "#{self::NAME} #{self::PATCH_LEVEL}"
@@ -136,7 +137,6 @@ module DNApi
136
137
 
137
138
  VERSION = '1.9.3'.freeze
138
139
  PATCH_LEVEL = 'p0'.freeze
139
- RUBYGEMS_VERSION = '1.8.11'.freeze
140
140
 
141
141
  def ruby_version
142
142
  "#{version}_#{patch_level}"
@@ -215,6 +215,7 @@ module DNApi
215
215
  VERSION = '2.0.0-r3'.freeze
216
216
  VM_VERSION = '1.8'.freeze
217
217
  PATCH_LEVEL = nil
218
+ RUBYGEMS_VERSION = nil
218
219
 
219
220
  def self.label
220
221
  "#{self::NAME} 2.0 (ruby-1.8.7-p352)"
@@ -250,6 +251,7 @@ module DNApi
250
251
  VERSION = '2.0.0-r3'.freeze
251
252
  VM_VERSION = '1.9'.freeze
252
253
  PATCH_LEVEL = nil
254
+ RUBYGEMS_VERSION = nil
253
255
 
254
256
  def self.label
255
257
  "#{self::NAME} 2.0 (ruby-1.9.2-p136)"
@@ -0,0 +1,13 @@
1
+ module DNApi
2
+ module Components
3
+ class Rubygems < Struct.new(:key, :version)
4
+ include Component
5
+
6
+ desc "A way to set a specific Rubygems version for the environment"
7
+
8
+ key :rubygems
9
+
10
+ belongs_to Environment
11
+ end
12
+ end
13
+ end
@@ -29,13 +29,11 @@ module DNApi
29
29
 
30
30
  def self.from(jexp)
31
31
  _many.each do |assoc|
32
- jexp[assoc.to_s] = jexp[assoc.to_s].map do |item|
32
+ jexp[assoc.to_s] = (jexp[assoc.to_s] || []).map do |item|
33
33
  if klass = map[assoc.to_sym]
34
34
  klass.from(item)
35
- else
36
- raise "No class found for #{assoc.inspect}"
37
35
  end
38
- end
36
+ end.compact
39
37
  end
40
38
 
41
39
  _ones.each do |assoc|
@@ -44,8 +42,6 @@ module DNApi
44
42
  item = jexp[assoc.to_s]
45
43
  if klass = map[assoc.to_sym]
46
44
  klass.from(item)
47
- else
48
- raise "No class found for #{assoc.inspect}"
49
45
  end
50
46
  end
51
47
  end
@@ -1,3 +1,3 @@
1
1
  module DNApi
2
- VERSION = '1.1.88'
2
+ VERSION = '1.1.89'
3
3
  end
@@ -62,5 +62,7 @@ describe DNApi::Component do
62
62
  env.add_component(:lovely_bunch_of_coconuts)
63
63
  end.should raise_error(DNApi::Component::NoSuchComponent)
64
64
  end
65
+
66
+
65
67
  end
66
- end
68
+ end
@@ -70,8 +70,8 @@ describe DNApi::Components::Ruby187 do
70
70
  end
71
71
 
72
72
  describe "#rubygems_version" do
73
- it 'is 1.5.2' do
74
- @ruby.rubygems_version.should == '1.5.2'
73
+ it 'is 1.8.17' do
74
+ @ruby.rubygems_version.should == '1.8.17'
75
75
  end
76
76
  end
77
77
  end
@@ -146,8 +146,8 @@ describe DNApi::Components::Ruby192 do
146
146
  end
147
147
 
148
148
  describe "#rubygems_version" do
149
- it 'is 1.5.2' do
150
- @ruby.rubygems_version.should == '1.5.2'
149
+ it 'is 1.8.17' do
150
+ @ruby.rubygems_version.should == '1.8.17'
151
151
  end
152
152
  end
153
153
  end
@@ -184,8 +184,8 @@ describe DNApi::Components::Ruby193 do
184
184
  end
185
185
 
186
186
  describe "#rubygems_version" do
187
- it 'is 1.8.11' do
188
- @ruby.rubygems_version.should == '1.8.11'
187
+ it 'is 1.8.17' do
188
+ @ruby.rubygems_version.should == '1.8.17'
189
189
  end
190
190
  end
191
191
 
@@ -228,8 +228,8 @@ describe DNApi::Components::Rubinius do
228
228
  end
229
229
 
230
230
  describe "#rubygems_version" do
231
- it 'is 1.5.2' do
232
- @ruby.rubygems_version.should == '1.5.2'
231
+ it 'is nil' do
232
+ @ruby.rubygems_version.should be_nil
233
233
  end
234
234
  end
235
235
  end
@@ -265,8 +265,8 @@ describe DNApi::Components::Rubinius19 do
265
265
  end
266
266
 
267
267
  describe "#rubygems_version" do
268
- it 'is 1.5.2' do
269
- @ruby.rubygems_version.should == '1.5.2'
268
+ it 'is nil' do
269
+ @ruby.rubygems_version.should be_nil
270
270
  end
271
271
  end
272
272
  end
@@ -0,0 +1,14 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe DNApi::Components::Rubygems do
4
+ before do
5
+ @environment = DNApi::Environment.new
6
+ @environment.add_component :rubygems, :version => DNApi::Components::RubyVersion::RUBYGEMS_VERSION
7
+ end
8
+
9
+ it 'can be added to an environment with its version' do
10
+ @environment.should have_component(:rubygems)
11
+ @environment.component(:rubygems).key.should == :rubygems
12
+ @environment.component(:rubygems).version.should == DNApi::Components::RubyVersion::RUBYGEMS_VERSION
13
+ end
14
+ end
@@ -224,4 +224,40 @@ describe DNApi::Environment do
224
224
  end
225
225
  end
226
226
  end
227
+
228
+ describe ".from" do
229
+ it 'creates a new environment with identified components' do
230
+ attrs = {
231
+ :instances => [],
232
+ :apps => [],
233
+ :crons => [],
234
+ :components => [ {:key => :ruby_192} ],
235
+ }
236
+ env = DNApi::Environment.from(JSON.parse(attrs.to_json))
237
+ env.components.size.should == 1
238
+ env.component(:ruby_192).should be_true
239
+ end
240
+
241
+ it 'creates a new environment with unidentified components' do
242
+ attrs = {
243
+ :instances => [],
244
+ :apps => [],
245
+ :crons => [],
246
+ :components => [ {:key => :ruby_192}, {:key => :foo} ],
247
+ }
248
+ env = DNApi::Environment.from(JSON.parse(attrs.to_json))
249
+ env.components.size.should == 1
250
+ env.component(:ruby_192).should be_true
251
+ env.component(:foo).should be_nil
252
+ end
253
+
254
+ it 'creates a new environment with missing children' do
255
+ attrs = {
256
+ :instances => [],
257
+ :apps => [],
258
+ }
259
+ env = DNApi::Environment.from(JSON.parse(attrs.to_json))
260
+ env.crons.should be_empty
261
+ end
262
+ end
227
263
  end
@@ -0,0 +1,16 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe DNApi::VHost do
4
+ describe ".from" do
5
+ it 'creates a new vhost with an ssl cert' do
6
+ attrs = {
7
+ :domain_name => "www.example.org",
8
+ :ssl_cert => {:certificate => "foocert"},
9
+ }
10
+ env = DNApi::VHost.from(JSON.parse(attrs.to_json))
11
+ env.domain_name.should == "www.example.org"
12
+ env.ssl_cert.certificate.should == "foocert"
13
+ env.ssl_cert.certificate_chain.should be_nil
14
+ end
15
+ end
16
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dnapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.88
4
+ version: 1.1.89
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -100,6 +100,7 @@ files:
100
100
  - lib/dnapi/components/passenger3.rb
101
101
  - lib/dnapi/components/php.rb
102
102
  - lib/dnapi/components/ruby.rb
103
+ - lib/dnapi/components/rubygems.rb
103
104
  - lib/dnapi/components/ssmtp.rb
104
105
  - lib/dnapi/components/stunneled.rb
105
106
  - lib/dnapi/components/v8.rb
@@ -130,6 +131,7 @@ files:
130
131
  - spec/components/nodejs_spec.rb
131
132
  - spec/components/passenger3_spec.rb
132
133
  - spec/components/ruby_spec.rb
134
+ - spec/components/rubygems_spec.rb
133
135
  - spec/components/stunneled.rb
134
136
  - spec/components/volume_spec.rb
135
137
  - spec/db_stack_spec.rb
@@ -140,6 +142,7 @@ files:
140
142
  - spec/spec_helper.rb
141
143
  - spec/stack_spec.rb
142
144
  - spec/struct_spec.rb
145
+ - spec/vhost_spec.rb
143
146
  homepage: http://github.com/engineyard/dnapi
144
147
  licenses: []
145
148
  post_install_message:
@@ -160,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
163
  version: 1.3.1
161
164
  requirements: []
162
165
  rubyforge_project:
163
- rubygems_version: 1.8.19
166
+ rubygems_version: 1.8.24
164
167
  signing_key:
165
168
  specification_version: 3
166
169
  summary: API for chef DNA.
@@ -173,6 +176,7 @@ test_files:
173
176
  - spec/components/nodejs_spec.rb
174
177
  - spec/components/passenger3_spec.rb
175
178
  - spec/components/ruby_spec.rb
179
+ - spec/components/rubygems_spec.rb
176
180
  - spec/components/stunneled.rb
177
181
  - spec/components/volume_spec.rb
178
182
  - spec/db_stack_spec.rb
@@ -183,3 +187,4 @@ test_files:
183
187
  - spec/spec_helper.rb
184
188
  - spec/stack_spec.rb
185
189
  - spec/struct_spec.rb
190
+ - spec/vhost_spec.rb