shelly 0.0.18 → 0.0.19

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.rb CHANGED
@@ -5,6 +5,7 @@ require "core_ext/hash"
5
5
  require "shelly/helpers"
6
6
  require "shelly/base"
7
7
  require "thor/options"
8
+ require "thor/arguments"
8
9
 
9
10
  module Shelly
10
11
  autoload :App, "shelly/app"
@@ -1,13 +1,13 @@
1
1
  require "shelly"
2
2
  require "thor/group"
3
- require "shelly/cli/users"
3
+ require "shelly/cli/user"
4
4
 
5
5
  module Shelly
6
6
  module CLI
7
7
  class Main < Thor
8
8
  include Thor::Actions
9
9
  include Helpers
10
- register(Users, "users", "users <command>", "Manages users using this app")
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
@@ -18,7 +18,7 @@ module Shelly
18
18
 
19
19
  desc "register [EMAIL]", "Registers new user account on Shelly Cloud"
20
20
  def register(email = nil)
21
- user = User.new
21
+ user = Shelly::User.new
22
22
  user.ssh_key_registered?
23
23
  say "Registering with email: #{email}" if email
24
24
  user.email = (email || ask_for_email)
@@ -45,7 +45,7 @@ module Shelly
45
45
 
46
46
  desc "login [EMAIL]", "Logins user to Shelly Cloud"
47
47
  def login(email = nil)
48
- user = User.new(email || ask_for_email, ask_for_password(:with_confirmation => false))
48
+ user = Shelly::User.new(email || ask_for_email, ask_for_password(:with_confirmation => false))
49
49
  user.login
50
50
  say "Login successful"
51
51
  say "Uploading your public SSH key"
@@ -70,10 +70,10 @@ module Shelly
70
70
  method_option "code-name", :type => :string, :aliases => "-c",
71
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
- :banner => "CODE-NAME.shellyapp.com YOUR-DOMAIN.com",
76
+ :banner => "CODE-NAME.shellyapp.com, YOUR-DOMAIN.com",
77
77
  :desc => "Array of your domains"
78
78
  desc "add", "Adds new application to Shelly Cloud"
79
79
  def add
@@ -110,8 +110,6 @@ module Shelly
110
110
  no_tasks do
111
111
  def check_options(options)
112
112
  unless options.empty?
113
- options["domains"].map! {|domain| domain.gsub(",", "") } if options["domains"]
114
- options["databases"].map! {|kind| kind.gsub(",", "") } if options["databases"]
115
113
  unless ["code-name", "databases", "domains"].all? do |option|
116
114
  options.include?(option.to_s) && options[option.to_s] != option.to_s
117
115
  end && valid_databases?(options["databases"])
@@ -4,7 +4,7 @@ require "shelly/cloudfile"
4
4
 
5
5
  module Shelly
6
6
  module CLI
7
- class Users < Thor
7
+ class User < Thor
8
8
  namespace :users
9
9
  include Helpers
10
10
 
@@ -32,8 +32,10 @@ module Shelly
32
32
  @user.send_invitation(@cloudfile.clouds, user_email)
33
33
  say "Sending invitation to #{user_email}"
34
34
  rescue Client::APIError => e
35
- say e.message
36
- exit 1
35
+ if e.validation?
36
+ e.each_error { |error| say_error error =~ /already in the project/ ? error.gsub("Email", "User") : error, :with_exit => false }
37
+ exit 1
38
+ end
37
39
  end
38
40
 
39
41
  end
@@ -1,3 +1,3 @@
1
1
  module Shelly
2
- VERSION = "0.0.18"
2
+ VERSION = "0.0.19"
3
3
  end
@@ -0,0 +1,17 @@
1
+ class Thor
2
+ class Arguments
3
+
4
+ private
5
+
6
+ def parse_array(name)
7
+ return shift if peek.is_a?(Array)
8
+ array = []
9
+ while current_is_value?
10
+ results = shift.split(/[\s,]/).reject(&:blank?)
11
+ results.each { |result| array << result }
12
+ end
13
+ array
14
+ end
15
+
16
+ end
17
+ end
@@ -27,7 +27,7 @@ Tasks:
27
27
  shelly help [TASK] # Describe available tasks or one specific task
28
28
  shelly login [EMAIL] # Logins user to Shelly Cloud
29
29
  shelly register [EMAIL] # Registers new user account on Shelly Cloud
30
- shelly users <command> # Manages users using this app
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
@@ -240,6 +240,7 @@ OUT
240
240
  end
241
241
 
242
242
  context "command line options" do
243
+
243
244
  context "invalid params" do
244
245
  it "should show help and exit if not all options are passed" do
245
246
  $stdout.should_receive(:puts).with("\e[31mTry 'shelly help add' for more information\e[0m")
@@ -253,12 +254,6 @@ OUT
253
254
  lambda { @main.add }.should raise_error(SystemExit)
254
255
  end
255
256
 
256
- it "should accept databases separated by comma" do
257
- @main.options = {"code-name" => "foo", "databases" => ["postgresql,", "mongodb"], "domains" => ["foo.example.com"]}
258
- @app.should_receive(:databases=).with(["postgresql", "mongodb"])
259
- @main.add
260
- end
261
-
262
257
  it "should display which parameter was wrong" do
263
258
  expected = "shelly: unrecognized option '--unknown=param'\n" +
264
259
  "Usage: shelly [COMMAND]... [OPTIONS]\n" +
@@ -1,10 +1,10 @@
1
1
  require "spec_helper"
2
- require "shelly/cli/users"
2
+ require "shelly/cli/user"
3
3
 
4
- describe Shelly::CLI::Users do
4
+ describe Shelly::CLI::User do
5
5
  before do
6
6
  FileUtils.stub(:chmod)
7
- @users = Shelly::CLI::Users.new
7
+ @users = Shelly::CLI::User.new
8
8
  @client = mock
9
9
  Shelly::Client.stub(:new).and_return(@client)
10
10
  Shelly::User.stub(:guess_email).and_return("")
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shelly
3
3
  version: !ruby/object:Gem::Version
4
- hash: 59
4
+ hash: 57
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 18
10
- version: 0.0.18
9
+ - 19
10
+ version: 0.0.19
11
11
  platform: ruby
12
12
  authors:
13
13
  - Shelly Cloud team
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-07 00:00:00 Z
18
+ date: 2011-11-14 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rspec
@@ -74,7 +74,7 @@ dependencies:
74
74
  type: :development
75
75
  version_requirements: *id004
76
76
  - !ruby/object:Gem::Dependency
77
- name: fakefs
77
+ name: growl_notify
78
78
  prerelease: false
79
79
  requirement: &id005 !ruby/object:Gem::Requirement
80
80
  none: false
@@ -88,7 +88,7 @@ dependencies:
88
88
  type: :development
89
89
  version_requirements: *id005
90
90
  - !ruby/object:Gem::Dependency
91
- name: fakeweb
91
+ name: rb-fsevent
92
92
  prerelease: false
93
93
  requirement: &id006 !ruby/object:Gem::Requirement
94
94
  none: false
@@ -102,7 +102,7 @@ dependencies:
102
102
  type: :development
103
103
  version_requirements: *id006
104
104
  - !ruby/object:Gem::Dependency
105
- name: thor
105
+ name: fakefs
106
106
  prerelease: false
107
107
  requirement: &id007 !ruby/object:Gem::Requirement
108
108
  none: false
@@ -113,10 +113,10 @@ dependencies:
113
113
  segments:
114
114
  - 0
115
115
  version: "0"
116
- type: :runtime
116
+ type: :development
117
117
  version_requirements: *id007
118
118
  - !ruby/object:Gem::Dependency
119
- name: rest-client
119
+ name: fakeweb
120
120
  prerelease: false
121
121
  requirement: &id008 !ruby/object:Gem::Requirement
122
122
  none: false
@@ -127,10 +127,10 @@ dependencies:
127
127
  segments:
128
128
  - 0
129
129
  version: "0"
130
- type: :runtime
130
+ type: :development
131
131
  version_requirements: *id008
132
132
  - !ruby/object:Gem::Dependency
133
- name: json
133
+ name: thor
134
134
  prerelease: false
135
135
  requirement: &id009 !ruby/object:Gem::Requirement
136
136
  none: false
@@ -144,7 +144,7 @@ dependencies:
144
144
  type: :runtime
145
145
  version_requirements: *id009
146
146
  - !ruby/object:Gem::Dependency
147
- name: launchy
147
+ name: rest-client
148
148
  prerelease: false
149
149
  requirement: &id010 !ruby/object:Gem::Requirement
150
150
  none: false
@@ -157,6 +157,34 @@ dependencies:
157
157
  version: "0"
158
158
  type: :runtime
159
159
  version_requirements: *id010
160
+ - !ruby/object:Gem::Dependency
161
+ name: json
162
+ prerelease: false
163
+ requirement: &id011 !ruby/object:Gem::Requirement
164
+ none: false
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ hash: 3
169
+ segments:
170
+ - 0
171
+ version: "0"
172
+ type: :runtime
173
+ version_requirements: *id011
174
+ - !ruby/object:Gem::Dependency
175
+ name: launchy
176
+ prerelease: false
177
+ requirement: &id012 !ruby/object:Gem::Requirement
178
+ none: false
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ hash: 3
183
+ segments:
184
+ - 0
185
+ version: "0"
186
+ type: :runtime
187
+ version_requirements: *id012
160
188
  description: Tool for managing applications and clouds at shellycloud.com
161
189
  email:
162
190
  - support@shellycloud.com
@@ -180,13 +208,14 @@ files:
180
208
  - lib/shelly/app.rb
181
209
  - lib/shelly/base.rb
182
210
  - lib/shelly/cli/main.rb
183
- - lib/shelly/cli/users.rb
211
+ - lib/shelly/cli/user.rb
184
212
  - lib/shelly/client.rb
185
213
  - lib/shelly/cloudfile.rb
186
214
  - lib/shelly/helpers.rb
187
215
  - lib/shelly/templates/Cloudfile.erb
188
216
  - lib/shelly/user.rb
189
217
  - lib/shelly/version.rb
218
+ - lib/thor/arguments.rb
190
219
  - lib/thor/options.rb
191
220
  - shelly.gemspec
192
221
  - spec/helpers.rb
@@ -194,7 +223,7 @@ files:
194
223
  - spec/shelly/app_spec.rb
195
224
  - spec/shelly/base_spec.rb
196
225
  - spec/shelly/cli/main_spec.rb
197
- - spec/shelly/cli/users_spec.rb
226
+ - spec/shelly/cli/user_spec.rb
198
227
  - spec/shelly/client_spec.rb
199
228
  - spec/shelly/cloudfile_spec.rb
200
229
  - spec/shelly/user_spec.rb
@@ -232,5 +261,14 @@ rubygems_version: 1.8.10
232
261
  signing_key:
233
262
  specification_version: 3
234
263
  summary: Shelly Cloud command line tool
235
- test_files: []
236
-
264
+ test_files:
265
+ - spec/helpers.rb
266
+ - spec/input_faker.rb
267
+ - spec/shelly/app_spec.rb
268
+ - spec/shelly/base_spec.rb
269
+ - spec/shelly/cli/main_spec.rb
270
+ - spec/shelly/cli/user_spec.rb
271
+ - spec/shelly/client_spec.rb
272
+ - spec/shelly/cloudfile_spec.rb
273
+ - spec/shelly/user_spec.rb
274
+ - spec/spec_helper.rb