shelly 0.1.16 → 0.1.17
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/lib/shelly/app.rb +11 -2
- data/lib/shelly/cli/main.rb +5 -2
- data/lib/shelly/version.rb +1 -1
- data/spec/shelly/app_spec.rb +23 -2
- data/spec/shelly/cli/main_spec.rb +2 -3
- metadata +2 -2
data/lib/shelly/app.rb
CHANGED
@@ -9,7 +9,8 @@ module Shelly
|
|
9
9
|
SERVER_SIZES = %w(small large)
|
10
10
|
|
11
11
|
attr_accessor :code_name, :databases, :ruby_version, :environment,
|
12
|
-
:git_url, :domains, :web_server_ip, :mail_server_ip, :size, :thin
|
12
|
+
:git_url, :domains, :web_server_ip, :mail_server_ip, :size, :thin,
|
13
|
+
:redeem_code
|
13
14
|
|
14
15
|
def initialize(code_name = nil)
|
15
16
|
self.code_name = code_name
|
@@ -41,7 +42,7 @@ module Shelly
|
|
41
42
|
end
|
42
43
|
|
43
44
|
def create
|
44
|
-
attributes = {:code_name => code_name}
|
45
|
+
attributes = {:code_name => code_name, :redeem_code => redeem_code}
|
45
46
|
response = shelly.create_app(attributes)
|
46
47
|
self.git_url = response["git_url"]
|
47
48
|
self.domains = response["domains"]
|
@@ -197,6 +198,14 @@ module Shelly
|
|
197
198
|
attributes["state"]
|
198
199
|
end
|
199
200
|
|
201
|
+
def trial?
|
202
|
+
!!attributes["trial"]
|
203
|
+
end
|
204
|
+
|
205
|
+
def credit
|
206
|
+
attributes["credit"]
|
207
|
+
end
|
208
|
+
|
200
209
|
def self.inside_git_repository?
|
201
210
|
system("git status > /dev/null 2>&1")
|
202
211
|
end
|
data/lib/shelly/cli/main.rb
CHANGED
@@ -79,6 +79,8 @@ module Shelly
|
|
79
79
|
:desc => "List of databases of your choice"
|
80
80
|
method_option :size, :type => :string, :aliases => "-s",
|
81
81
|
:desc => "Server size [large, small]"
|
82
|
+
method_option "redeem-code", :type => :string, :aliases => "-r",
|
83
|
+
:desc => "Redeem code for free credits"
|
82
84
|
desc "add", "Add a new cloud"
|
83
85
|
def add
|
84
86
|
check_options(options)
|
@@ -87,6 +89,7 @@ module Shelly
|
|
87
89
|
app.code_name = options["code-name"] || ask_for_code_name
|
88
90
|
app.databases = options["databases"] || ask_for_databases
|
89
91
|
app.size = options["size"] || "large"
|
92
|
+
app.redeem_code = options["redeem-code"]
|
90
93
|
app.create
|
91
94
|
|
92
95
|
if overwrite_remote?(app)
|
@@ -99,10 +102,10 @@ module Shelly
|
|
99
102
|
|
100
103
|
say "Creating Cloudfile", :green
|
101
104
|
app.create_cloudfile
|
102
|
-
if app.
|
105
|
+
if app.trial?
|
103
106
|
say_new_line
|
104
107
|
say "Billing information", :green
|
105
|
-
say "Cloud created with
|
108
|
+
say "Cloud created with #{app.credit} Euro credit."
|
106
109
|
say "Remember to provide billing details before trial ends."
|
107
110
|
say app.edit_billing_url
|
108
111
|
end
|
data/lib/shelly/version.rb
CHANGED
data/spec/shelly/app_spec.rb
CHANGED
@@ -142,6 +142,8 @@ describe Shelly::App do
|
|
142
142
|
@response = {"web_server_ip" => "192.0.2.1",
|
143
143
|
"mail_server_ip" => "192.0.2.3",
|
144
144
|
"state" => "running",
|
145
|
+
"trial" => true,
|
146
|
+
"credit" => 23.0,
|
145
147
|
"git_info" => {
|
146
148
|
"deployed_commit_message" => "Commit message",
|
147
149
|
"deployed_commit_sha" => "52e65ed2d085eaae560cdb81b2b56a7d76",
|
@@ -150,6 +152,23 @@ describe Shelly::App do
|
|
150
152
|
@client.stub(:app).and_return(@response)
|
151
153
|
end
|
152
154
|
|
155
|
+
describe "#trial?" do
|
156
|
+
it "should return true if app is trial" do
|
157
|
+
@app.should be_trial
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should return false if app is not trial" do
|
161
|
+
@client.stub(:app).and_return("trial" => false)
|
162
|
+
@app.should_not be_trial
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
describe "#credit" do
|
167
|
+
it "should return freecredit that app has" do
|
168
|
+
@app.credit.should == 23.0
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
153
172
|
it "should fetch app attributes from API and cache them" do
|
154
173
|
@client.should_receive(:app).with("foo-staging").exactly(:once).and_return(@response)
|
155
174
|
2.times { @app.attributes }
|
@@ -261,8 +280,10 @@ describe Shelly::App do
|
|
261
280
|
describe "#create" do
|
262
281
|
it "should create the app on shelly cloud via API client" do
|
263
282
|
@app.code_name = "fooo"
|
283
|
+
@app.redeem_code = "foo123"
|
264
284
|
attributes = {
|
265
|
-
:code_name => "fooo"
|
285
|
+
:code_name => "fooo",
|
286
|
+
:redeem_code => "foo123"
|
266
287
|
}
|
267
288
|
@client.should_receive(:create_app).with(attributes).and_return("git_url" => "git@git.shellycloud.com:fooo.git",
|
268
289
|
"domains" => %w(fooo.shellyapp.com))
|
@@ -362,5 +383,5 @@ describe Shelly::App do
|
|
362
383
|
Shelly::Cloudfile.should_receive(:new).and_return(cloudfile)
|
363
384
|
@app.create_cloudfile
|
364
385
|
end
|
365
|
-
end
|
386
|
+
end
|
366
387
|
end
|
@@ -402,11 +402,11 @@ OUT
|
|
402
402
|
end
|
403
403
|
|
404
404
|
it "should create the app on shelly cloud and show trial information" do
|
405
|
-
@app.stub(:attributes).and_return({"trial" => true})
|
405
|
+
@app.stub(:attributes).and_return({"trial" => true, "credit" => 40})
|
406
406
|
@client.stub(:shellyapp_url).and_return("http://example.com")
|
407
407
|
@app.should_receive(:create)
|
408
408
|
$stdout.should_receive(:puts).with(green "Billing information")
|
409
|
-
$stdout.should_receive(:puts).with("Cloud created with
|
409
|
+
$stdout.should_receive(:puts).with("Cloud created with 40 Euro credit.")
|
410
410
|
$stdout.should_receive(:puts).with("Remember to provide billing details before trial ends.")
|
411
411
|
$stdout.should_receive(:puts).with("http://example.com/apps/foo-staging/billing/edit")
|
412
412
|
|
@@ -470,7 +470,6 @@ OUT
|
|
470
470
|
invoke(@main, :add)
|
471
471
|
end
|
472
472
|
end
|
473
|
-
|
474
473
|
end
|
475
474
|
end
|
476
475
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shelly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.17
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|