hugo 0.1.6 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -4,6 +4,10 @@ require 'rake'
4
4
  begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gemspec|
7
+ gemspec.add_dependency('amazon-ec2')
8
+ gemspec.add_dependency('net-ssh')
9
+ gemspec.add_dependency('json')
10
+
7
11
  gemspec.name = "hugo"
8
12
  gemspec.summary = "Deploy Your Rack Apps to Cloud"
9
13
  gemspec.description = "A easy to understand DSL that makes it dirt simple to deploy to the cloud."
@@ -4,7 +4,8 @@ class Hugo::App
4
4
  include Singleton
5
5
  include Hugo::Mixin::ParamsValidate
6
6
 
7
-
7
+ attr_accessor :dna
8
+
8
9
  def servers(instances=1)
9
10
  if lb
10
11
  if instances > lb.instances.length
@@ -34,6 +35,16 @@ class Hugo::App
34
35
  end
35
36
 
36
37
 
38
+ def add_recipe(name, options=nil)
39
+ run_list [] if run_list.nil?
40
+ run_list << "recipe[#{name}]"
41
+ if options
42
+ empty_hash = {}
43
+ self.dna = {} if self.dna.nil?
44
+ self.dna.merge!(options)
45
+ end
46
+ end
47
+
37
48
  def name(arg=nil)
38
49
  set_or_return(:name, arg, :kind_of => [String])
39
50
  end
@@ -62,14 +73,6 @@ class Hugo::App
62
73
  set_or_return(:image_id, arg, :kind_of => [String])
63
74
  end
64
75
 
65
- def port(arg=nil)
66
- set_or_return(:port, arg, :kind_of => [String])
67
- end
68
-
69
- def ssl(arg=nil)
70
- set_or_return(:ssl, arg, :kind_of => [String])
71
- end
72
-
73
76
  def application(arg=nil)
74
77
  set_or_return(:application, arg, :kind_of => [String])
75
78
  end
@@ -90,34 +93,10 @@ class Hugo::App
90
93
  set_or_return(:cookbook, arg, :kind_of => [String])
91
94
  end
92
95
 
93
- def key_pair_file(arg=nil)
96
+ def key_path(arg=nil)
94
97
  set_or_return(:key_pair_file, arg, :kind_of => [String])
95
98
  end
96
-
97
- def port(arg=nil)
98
- set_or_return(:port, arg, :kind_of => [String])
99
- end
100
-
101
- def github_url(arg=nil)
102
- set_or_return(:github_url, arg, :kind_of => [String])
103
- end
104
-
105
- def privatekey(arg=nil)
106
- set_or_return(:privatekey, arg, :kind_of => [String])
107
- end
108
-
109
- def publickey(arg=nil)
110
- set_or_return(:publickey, arg, :kind_of => [String])
111
- end
112
-
113
- def gem_list(arg=nil)
114
- set_or_return(:gem_list, arg, :kind_of => [Array])
115
- end
116
-
117
- def package_list(arg=nil)
118
- set_or_return(:package_list, arg, :kind_of => [Array])
119
- end
120
-
99
+
121
100
  def run_list(arg=nil)
122
101
  set_or_return(:run_list, arg, :kind_of => [Array])
123
102
  end
@@ -176,7 +155,7 @@ private
176
155
  commands << 'if [ -d "./hugo-repos" ]; then echo "setup already run"; else sudo gem install chef-deploy --no-ri --no-rdoc; fi'
177
156
  commands << 'if [ -d "./hugo-repos" ]; then echo "setup already run"; else sudo gem install git --no-ri --no-rdoc; fi'
178
157
  commands << "if [ -d \"./hugo-repos\" ]; then echo \"setup already run\"; else git clone #{self.cookbook} ~/hugo-repos; fi"
179
- Hugo::Aws::Ec2.find(instance_id).ssh(commands, nil, key_pair_file)
158
+ Hugo::Aws::Ec2.find(instance_id).ssh(commands, nil, File.join(key_path, key_name))
180
159
  end
181
160
 
182
161
  def deploy_ec2
@@ -184,37 +163,28 @@ private
184
163
  commands = []
185
164
  commands << "cd hugo-repos && git pull"
186
165
  commands << 'sudo chef-solo -c /home/ubuntu/hugo-repos/config/solo.rb -j /home/ubuntu/dna.json'
187
-
188
- ports = [port]
189
- ports << ssl unless ssl.nil?
190
-
191
- database_info = {}
166
+
192
167
  database_info = {
193
168
  :uri => db.uri,
194
169
  :name => db.db,
195
170
  :user => db.user,
196
171
  :password => db.password } unless db.nil?
197
-
198
- dna = { :run_list => run_list,
199
- :package_list => package_list,
200
- :gem_list => gem_list,
201
-
202
- :application => name,
203
- :customer => cloud_name,
204
- :database => database_info,
205
- :web => { :port => port, :ssl => ssl },
172
+
173
+ self.dna = {} if self.dna.nil?
174
+ self.dna.merge!(:run_list => run_list,
206
175
  :git => cookbook,
207
- :github => { :url => github_url,
208
- :publickey => publickey,
209
- :privatekey => privatekey},
210
176
  :access_key => Hugo::Aws::Ec2::ACCESS_KEY,
211
177
  :secret_key => Hugo::Aws::Ec2::SECRET_KEY,
212
- :apache => { :listen_ports => ports },
178
+ :database => database_info,
179
+
180
+ :application => name,
181
+ :customer => cloud_name,
182
+
213
183
  :app => deploy_info
214
- }
184
+ )
215
185
 
216
186
  lb.instances.each do |i|
217
- Hugo::Aws::Ec2.find(i).ssh(commands, dna, key_pair_file)
187
+ Hugo::Aws::Ec2.find(i).ssh(commands, dna, File.join(key_path, key_name))
218
188
  end
219
189
  end
220
190
 
@@ -20,6 +20,27 @@ describe "Hugo App" do
20
20
  Hugo &block
21
21
  end.should_not raise_error
22
22
  end
23
+
24
+ it "should save dna" do
25
+ block = lambda do
26
+ cloud "my_cloud" do
27
+ balancer
28
+ app "testapp" do
29
+ add_recipe "s3fs", :s3 => {:bucket => "samIam"}
30
+ servers 0
31
+ puts run_list
32
+ puts dna.inspect
33
+ end
34
+ end
35
+ end
36
+
37
+ lambda do
38
+ Hugo &block
39
+ end.should_not raise_error
40
+
41
+ #puts @app.dna
42
+ end
43
+
23
44
 
24
45
  it "should raise error for database block not wrapped in cloud block" do
25
46
  block = lambda do
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../lib/hugo")
2
-
3
- Bundler.require_env(:test) # get rspec and webrat in here
2
+ #
3
+ # Bundler.require_env(:test) # get rspec and webrat in here
4
4
 
5
5
 
6
6
  # require 'rubygems'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hugo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Wilson
@@ -10,9 +10,39 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-01-28 00:00:00 -05:00
13
+ date: 2010-02-02 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: amazon-ec2
18
+ type: :runtime
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ version:
26
+ - !ruby/object:Gem::Dependency
27
+ name: net-ssh
28
+ type: :runtime
29
+ version_requirement:
30
+ version_requirements: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ version:
36
+ - !ruby/object:Gem::Dependency
37
+ name: json
38
+ type: :runtime
39
+ version_requirement:
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: "0"
45
+ version:
16
46
  - !ruby/object:Gem::Dependency
17
47
  name: amazon-ec2
18
48
  type: :runtime