shelly 0.0.20 → 0.0.21.pre

Sign up to get free protection for your applications and to get access to all the features.
data/lib/shelly/app.rb CHANGED
@@ -4,12 +4,8 @@ require 'launchy'
4
4
  module Shelly
5
5
  class App < Base
6
6
  DATABASE_KINDS = %w(postgresql mongodb redis none)
7
- attr_accessor :code_name, :databases, :ruby_version, :environment, :git_url, :domains
8
-
9
- def initialize
10
- @ruby_version = "MRI-1.9.2"
11
- @environment = "production"
12
- end
7
+ attr_accessor :code_name, :databases, :ruby_version, :environment,
8
+ :git_url, :domains
13
9
 
14
10
  def add_git_remote
15
11
  system("git remote rm production > /dev/null 2>&1")
@@ -18,8 +14,6 @@ module Shelly
18
14
 
19
15
  def generate_cloudfile
20
16
  @email = current_user.email
21
- @databases = databases
22
- @domains = domains
23
17
  template = File.read(cloudfile_template_path)
24
18
  cloudfile = ERB.new(template, 0, "%<>-")
25
19
  cloudfile.result(binding)
@@ -30,16 +24,12 @@ module Shelly
30
24
  end
31
25
 
32
26
  def create
33
- attributes = {
34
- :name => code_name,
35
- :code_name => code_name,
36
- :environment => environment,
37
- :ruby_version => ruby_version,
38
- :domain_name => domains ? domains.join(" ") : nil
39
- }
27
+ attributes = {:name => code_name, :code_name => code_name, :domains => domains}
40
28
  response = shelly.create_app(attributes)
41
29
  self.git_url = response["git_url"]
42
- self.domains = response["domain_name"].split if domains.nil?
30
+ self.domains = response["domains"]
31
+ self.ruby_version = response["ruby_version"]
32
+ self.environment = response["environment"]
43
33
  end
44
34
 
45
35
  def create_cloudfile
@@ -7,7 +7,7 @@ module Shelly
7
7
  class Main < Thor
8
8
  include Thor::Actions
9
9
  include Helpers
10
- register(User, "user", "user <command>", "Manages users using this cloud")
10
+ register(User, "user", "user <command>", "Manages users using this app")
11
11
  check_unknown_options!
12
12
 
13
13
  map %w(-v --version) => :version
@@ -50,7 +50,7 @@ module Shelly
50
50
  say "Login successful"
51
51
  say "Uploading your public SSH key"
52
52
  user.upload_ssh_key
53
- say "You have following clouds available:", :green
53
+ say "You have following applications available:", :green
54
54
  user.apps.each do |app|
55
55
  say " #{app["code_name"]}"
56
56
  end
@@ -68,14 +68,14 @@ module Shelly
68
68
  end
69
69
 
70
70
  method_option "code-name", :type => :string, :aliases => "-c",
71
- :desc => "Unique code-name of your cloud"
71
+ :desc => "Unique code_name of your application"
72
72
  method_option :databases, :type => :array, :aliases => "-d",
73
- :banner => Shelly::App::DATABASE_KINDS.join(', '),
73
+ :banner => "#{Shelly::App::DATABASE_KINDS.join(', ')}",
74
74
  :desc => "Array of databases of your choice"
75
75
  method_option :domains, :type => :array,
76
76
  :banner => "CODE-NAME.shellyapp.com, YOUR-DOMAIN.com",
77
77
  :desc => "Array of your domains"
78
- desc "add", "Adds new cloud to Shelly Cloud"
78
+ desc "add", "Adds new application to Shelly Cloud"
79
79
  def add
80
80
  say_error "Must be run inside your project git repository" unless App.inside_git_repository?
81
81
  check_options(options)
@@ -101,7 +101,7 @@ module Shelly
101
101
  if e.validation?
102
102
  e.each_error { |error| say_error "#{error}", :with_exit => false }
103
103
  say_new_line
104
- say_error "Fix erros in the below command and type it again to create your cloud" , :with_exit => false
104
+ say_error "Fix erros in the below command and type it again to create your application" , :with_exit => false
105
105
  say_error "shelly add --code-name=#{@app.code_name} --databases=#{@app.databases.join} --domains=#{@app.code_name}.shellyapp.com"
106
106
  end
107
107
  end
@@ -144,7 +144,7 @@ module Shelly
144
144
 
145
145
  def ask_for_code_name
146
146
  default_code_name = "#{Shelly::App.guess_code_name}-production"
147
- code_name = ask("Cloud code name (#{default_code_name} - default):")
147
+ code_name = ask("Application code name (#{default_code_name} - default):")
148
148
  code_name.blank? ? default_code_name : code_name
149
149
  end
150
150
 
@@ -39,8 +39,7 @@ module Shelly
39
39
  response = shelly.apps_users(clouds)
40
40
  response.inject({}) do |result, app|
41
41
  result[app['code_name']] = app['users'].map do |user|
42
- name = user['name'] ? " (#{user['name']})" : ""
43
- "#{user['email']}" + name
42
+ "#{user['email']} (#{user['name']})"
44
43
  end
45
44
  result
46
45
  end
@@ -1,5 +1,5 @@
1
1
  <%= @code_name %>:
2
- ruby: 1.9.2 # 1.9.2 or ree
2
+ ruby_version: 1.9.2 # 1.9.2 or ree
3
3
  environment: production # RAILS_ENV
4
4
  monitoring_email:
5
5
  - <%= @email %>
@@ -1,3 +1,3 @@
1
1
  module Shelly
2
- VERSION = "0.0.20"
2
+ VERSION = "0.0.21.pre"
3
3
  end
data/shelly.gemspec CHANGED
@@ -22,10 +22,10 @@ Gem::Specification.new do |s|
22
22
  end
23
23
  s.add_development_dependency "fakefs"
24
24
  s.add_development_dependency "fakeweb"
25
- s.add_runtime_dependency "wijet-thor"
25
+ s.add_runtime_dependency "thor"
26
26
  s.add_runtime_dependency "rest-client"
27
27
  s.add_runtime_dependency "json"
28
- s.add_runtime_dependency "launchy"
28
+ s.add_runtime_dependency "wijet-launchy"
29
29
 
30
30
  s.files = `git ls-files`.split("\n")
31
31
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -11,16 +11,6 @@ describe Shelly::App do
11
11
  @app.code_name = "foo-staging"
12
12
  end
13
13
 
14
- describe "being initialized" do
15
- it "should have default ruby_version: MRI-1.9.2" do
16
- @app.ruby_version.should == "MRI-1.9.2"
17
- end
18
-
19
- it "should have default environment: production" do
20
- @app.environment.should == "production"
21
- end
22
- end
23
-
24
14
  describe ".guess_code_name" do
25
15
  it "should return name of current working directory" do
26
16
  Shelly::App.guess_code_name.should == "foo"
@@ -60,7 +50,7 @@ describe Shelly::App do
60
50
  FakeFS.deactivate!
61
51
  expected = <<-config
62
52
  foo-staging:
63
- ruby: 1.9.2 # 1.9.2 or ree
53
+ ruby_version: 1.9.2 # 1.9.2 or ree
64
54
  environment: production # RAILS_ENV
65
55
  monitoring_email:
66
56
  - bob@example.com
@@ -127,21 +117,21 @@ config
127
117
  attributes = {
128
118
  :code_name => "fooo",
129
119
  :name => "fooo",
130
- :environment => "production",
131
- :ruby_version => "MRI-1.9.2",
132
- :domain_name => nil
120
+ :domains => nil
133
121
  }
134
122
  @client.should_receive(:create_app).with(attributes).and_return("git_url" => "git@git.shellycloud.com:fooo.git",
135
- "domain_name" => "fooo.shellyapp.com")
123
+ "domains" => %w(fooo.shellyapp.com))
136
124
  @app.create
137
125
  end
138
126
 
139
- it "should assign returned git_url and domain" do
127
+ it "should assign returned git_url, domains, ruby_version and environment" do
140
128
  @client.stub(:create_app).and_return("git_url" => "git@git.example.com:fooo.git",
141
- "domain_name" => "fooo.shellyapp.com")
129
+ "domains" => ["fooo.shellyapp.com"], "ruby_version" => "1.9.2", "environment" => "production")
142
130
  @app.create
143
131
  @app.git_url.should == "git@git.example.com:fooo.git"
144
132
  @app.domains.should == ["fooo.shellyapp.com"]
133
+ @app.ruby_version.should == "1.9.2"
134
+ @app.environment.should == "production"
145
135
  end
146
136
  end
147
137
 
@@ -152,20 +142,18 @@ config
152
142
  attributes = {
153
143
  :code_name => "boo",
154
144
  :name => "boo",
155
- :environment => "production",
156
- :ruby_version => "MRI-1.9.2",
157
- :domain_name => "boo.shellyapp.com boo.example.com"
145
+ :domains => %w(boo.shellyapp.com boo.example.com)
158
146
  }
159
147
  @client.should_receive(:create_app).with(attributes).and_return("git_url" => "git@git.shellycloud.com:fooo.git",
160
- "domain_name" => "boo.shellyapp.com boo.example.com")
148
+ "domains" => %w(boo.shellyapp.com boo.example.com))
161
149
  @app.create
162
150
  end
163
151
 
164
152
  it "should assign returned git_url and domain" do
165
153
  @client.stub(:create_app).and_return("git_url" => "git@git.example.com:fooo.git",
166
- "domain_name" => "boo.shellyapp.com boo.example.com")
154
+ "domains" => %w(boo.shellyapp.com boo.example.com))
167
155
  @app.create
168
- @app.domains.should == ["boo.shellyapp.com", "boo.example.com"]
156
+ @app.domains.should == %w(boo.shellyapp.com boo.example.com)
169
157
  end
170
158
  end
171
159
  end
@@ -23,11 +23,11 @@ describe Shelly::CLI::Main do
23
23
  it "should display available commands" do
24
24
  expected = <<-OUT
25
25
  Tasks:
26
- shelly add # Adds new cloud to Shelly Cloud
26
+ shelly add # Adds new application to Shelly Cloud
27
27
  shelly help [TASK] # Describe available tasks or one specific task
28
28
  shelly login [EMAIL] # Logs user in to Shelly Cloud
29
29
  shelly register [EMAIL] # Registers new user account on Shelly Cloud
30
- shelly user <command> # Manages users using this cloud
30
+ shelly user <command> # Manages users using this app
31
31
  shelly version # Displays shelly version
32
32
  OUT
33
33
  out = IO.popen("bin/shelly").read.strip
@@ -189,7 +189,7 @@ OUT
189
189
  end
190
190
 
191
191
  it "should display list of applications to which user has access" do
192
- $stdout.should_receive(:puts).with("\e[32mYou have following clouds available:\e[0m")
192
+ $stdout.should_receive(:puts).with("\e[32mYou have following applications available:\e[0m")
193
193
  $stdout.should_receive(:puts).with(" abc")
194
194
  $stdout.should_receive(:puts).with(" fooo")
195
195
  fake_stdin(["megan@example.com", "secret"]) do
@@ -277,7 +277,7 @@ OUT
277
277
  end
278
278
 
279
279
  it "should use code name provided by user" do
280
- $stdout.should_receive(:print).with("Cloud code name (foo-production - default): ")
280
+ $stdout.should_receive(:print).with("Application code name (foo-production - default): ")
281
281
  @app.should_receive(:code_name=).with("mycodename")
282
282
  fake_stdin(["mycodename", ""]) do
283
283
  @main.add
@@ -286,7 +286,7 @@ OUT
286
286
 
287
287
  context "when user provided empty code name" do
288
288
  it "should use 'current_dirname-purpose' as default" do
289
- $stdout.should_receive(:print).with("Cloud code name (foo-production - default): ")
289
+ $stdout.should_receive(:print).with("Application code name (foo-production - default): ")
290
290
  @app.should_receive(:code_name=).with("foo-production")
291
291
  fake_stdin(["", ""]) do
292
292
  @main.add
@@ -331,7 +331,7 @@ OUT
331
331
  exception = Shelly::Client::APIError.new(response.to_json)
332
332
  @app.should_receive(:create).and_raise(exception)
333
333
  $stdout.should_receive(:puts).with("\e[31mCode name has been already taken\e[0m")
334
- $stdout.should_receive(:puts).with("\e[31mFix erros in the below command and type it again to create your cloud\e[0m")
334
+ $stdout.should_receive(:puts).with("\e[31mFix erros in the below command and type it again to create your application\e[0m")
335
335
  $stdout.should_receive(:puts).with("\e[31mshelly add --code-name=foo-production --databases=postgresql --domains=foo-production.shellyapp.com\e[0m")
336
336
  lambda {
337
337
  fake_stdin(["", ""]) do
@@ -16,7 +16,7 @@ describe Shelly::CLI::User do
16
16
  it "should show help" do
17
17
  $stdout.should_receive(:puts).with("Tasks:")
18
18
  $stdout.should_receive(:puts).with(/add \[EMAIL\]\s+# Add new developer to clouds defined in Cloudfile/)
19
- $stdout.should_receive(:puts).with(/list\s+# List users with access to clouds defined in Cloudfile/)
19
+ $stdout.should_receive(:puts).with(/list\s+# List users with access to clouds defined in Cloudfile/)
20
20
  @cli_user.help
21
21
  end
22
22
  end
@@ -56,7 +56,7 @@ describe Shelly::CLI::User do
56
56
  @client.should_receive(:apps).and_return([{"code_name" => "foo-production"}, {"code_name" => "foo-staging"}])
57
57
  @client.stub(:apps_users).and_return(response)
58
58
  $stdout.should_receive(:puts).with("Cloud foo-production:")
59
- $stdout.should_receive(:puts).with(" user@example.com")
59
+ $stdout.should_receive(:puts).with(" user@example.com (username)")
60
60
  $stdout.should_receive(:puts).with("Cloud foo-staging:")
61
61
  $stdout.should_receive(:puts).with(" user2@example.com (username2)")
62
62
  @cli_user.list
@@ -64,7 +64,7 @@ describe Shelly::CLI::User do
64
64
  end
65
65
 
66
66
  def response
67
- [{'code_name' => 'foo-production', 'users' => [{'email' => 'user@example.com'}]},
67
+ [{'code_name' => 'foo-production', 'users' => [{'name' => 'username','email' => 'user@example.com'}]},
68
68
  {'code_name' => 'foo-staging', 'users' => [{'name' => 'username2','email' => 'user2@example.com'}]}]
69
69
  end
70
70
 
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shelly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20
5
- prerelease:
4
+ version: 0.0.21.pre
5
+ prerelease: 7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Shelly Cloud team
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-20 00:00:00.000000000Z
12
+ date: 2011-11-16 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2157193360 !ruby/object:Gem::Requirement
16
+ requirement: &2152869040 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2157193360
24
+ version_requirements: *2152869040
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &2157192880 !ruby/object:Gem::Requirement
27
+ requirement: &2152868540 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2157192880
35
+ version_requirements: *2152868540
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: guard
38
- requirement: &2157192320 !ruby/object:Gem::Requirement
38
+ requirement: &2152868020 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2157192320
46
+ version_requirements: *2152868020
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: guard-rspec
49
- requirement: &2157191000 !ruby/object:Gem::Requirement
49
+ requirement: &2152861100 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2157191000
57
+ version_requirements: *2152861100
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: growl_notify
60
- requirement: &2157190360 !ruby/object:Gem::Requirement
60
+ requirement: &2152860640 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2157190360
68
+ version_requirements: *2152860640
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rb-fsevent
71
- requirement: &2157189940 !ruby/object:Gem::Requirement
71
+ requirement: &2152860220 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2157189940
79
+ version_requirements: *2152860220
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: fakefs
82
- requirement: &2157189500 !ruby/object:Gem::Requirement
82
+ requirement: &2152859800 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2157189500
90
+ version_requirements: *2152859800
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: fakeweb
93
- requirement: &2157188860 !ruby/object:Gem::Requirement
93
+ requirement: &2152859380 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2157188860
101
+ version_requirements: *2152859380
102
102
  - !ruby/object:Gem::Dependency
103
- name: wijet-thor
104
- requirement: &2157188220 !ruby/object:Gem::Requirement
103
+ name: thor
104
+ requirement: &2152858960 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *2157188220
112
+ version_requirements: *2152858960
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: rest-client
115
- requirement: &2157175600 !ruby/object:Gem::Requirement
115
+ requirement: &2152858540 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :runtime
122
122
  prerelease: false
123
- version_requirements: *2157175600
123
+ version_requirements: *2152858540
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: json
126
- requirement: &2157174960 !ruby/object:Gem::Requirement
126
+ requirement: &2152858120 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :runtime
133
133
  prerelease: false
134
- version_requirements: *2157174960
134
+ version_requirements: *2152858120
135
135
  - !ruby/object:Gem::Dependency
136
- name: launchy
137
- requirement: &2157174340 !ruby/object:Gem::Requirement
136
+ name: wijet-launchy
137
+ requirement: &2152857640 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,7 +142,7 @@ dependencies:
142
142
  version: '0'
143
143
  type: :runtime
144
144
  prerelease: false
145
- version_requirements: *2157174340
145
+ version_requirements: *2152857640
146
146
  description: Tool for managing applications and clouds at shellycloud.com
147
147
  email:
148
148
  - support@shellycloud.com
@@ -200,9 +200,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
200
200
  required_rubygems_version: !ruby/object:Gem::Requirement
201
201
  none: false
202
202
  requirements:
203
- - - ! '>='
203
+ - - ! '>'
204
204
  - !ruby/object:Gem::Version
205
- version: '0'
205
+ version: 1.3.1
206
206
  requirements: []
207
207
  rubyforge_project: shelly
208
208
  rubygems_version: 1.8.10