cf 4.1.5.rc6 → 4.1.5.rc7

Sign up to get free protection for your applications and to get access to all the features.
data/lib/cf.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require "cf/version"
2
2
 
3
+ require "cf/object_extensions"
4
+
3
5
  require "cf/cli"
4
6
 
5
7
  command_files = "../cf/cli/{app,route,domain,organization,space,service,start,user}/*.rb"
@@ -24,11 +24,6 @@ module CF
24
24
  end
25
25
 
26
26
  def display_target
27
- if client.nil?
28
- fail "No target has been specified."
29
- return
30
- end
31
-
32
27
  if quiet?
33
28
  line client.target
34
29
  else
@@ -12,10 +12,8 @@ module CF::Start
12
12
  :from_given => by_name(:space)
13
13
 
14
14
  def target
15
- unless input.has?(:url) || input.has?(:organization) || \
16
- input.has?(:space)
17
- display_target
18
- display_org_and_space unless quiet?
15
+ unless input.has?(:url) || input.has?(:organization) || input.has?(:space)
16
+ TargetPrettifier.prettify(client, self)
19
17
  return
20
18
  end
21
19
 
@@ -23,7 +21,7 @@ module CF::Start
23
21
  target = sane_target_url(input[:url])
24
22
  with_progress("Setting target to #{c(target, :name)}") do
25
23
  begin
26
- CFoundry::Client.new(target) # check that it's valid before setting
24
+ CFoundry::Client.get(target) # check that it's valid before setting
27
25
  rescue CFoundry::TargetRefused
28
26
  fail "Target refused connection."
29
27
  rescue CFoundry::InvalidTarget
@@ -35,7 +33,6 @@ module CF::Start
35
33
  end
36
34
 
37
35
  return unless client.logged_in?
38
-
39
36
  if input.has?(:organization) || input.has?(:space)
40
37
  CF::Populators::Target.new(input).populate_and_save!
41
38
  end
@@ -45,21 +42,9 @@ module CF::Start
45
42
  invalidate_client
46
43
 
47
44
  line
48
- display_target
49
- display_org_and_space
45
+ TargetPrettifier.prettify(client, self)
50
46
  end
51
47
 
52
- private
53
-
54
- def display_org_and_space
55
- if (org = client.current_organization)
56
- line "organization: #{c(org.name, :name)}"
57
- end
58
-
59
- if (space = client.current_space)
60
- line "space: #{c(space.name, :name)}"
61
- end
62
- rescue CFoundry::APIError
63
- end
48
+ public :c
64
49
  end
65
50
  end
@@ -0,0 +1,16 @@
1
+ class TargetPrettifier
2
+ def self.prettify(client, outputter)
3
+ outputter.line("Target Information (where will apps be pushed):")
4
+ outputter.line(" CF instance: #{print_var(client.try(:target), outputter)} (API version: #{print_var(client.try(:version), outputter)})")
5
+ outputter.line(" user: #{print_var(client.try(:current_user).try(:email), outputter)}")
6
+ outputter.line(" target app space: #{print_var(client.try(:current_space).try(:name), outputter)} (org: #{print_var(client.try(:current_organization).try(:name), outputter)})")
7
+ end
8
+
9
+ def self.print_var(object_name, outputter)
10
+ if object_name
11
+ outputter.c(object_name, :good)
12
+ else
13
+ outputter.c('N/A', :bad)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ class Object
2
+ def try(*args)
3
+ send(*args)
4
+ end
5
+ end
6
+
7
+ class NilClass
8
+ def try(*args)
9
+ nil
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module CF
2
- VERSION = "4.1.5.rc6".freeze
2
+ VERSION = "4.1.5.rc7".freeze
3
3
  end
@@ -0,0 +1,60 @@
1
+ require "spec_helper"
2
+
3
+ module CF::Start
4
+ describe TargetPrettifier do
5
+ let(:user) do
6
+ build(:user).tap { |u| u.stub(:email => 'user@example.com') }
7
+ end
8
+ let(:space) { build(:space) }
9
+ let(:organization) { build(:organization) }
10
+ let(:target) { "http://example.com" }
11
+ let(:client) do
12
+ double(:client,
13
+ target: target,
14
+ current_user: user,
15
+ current_organization: organization,
16
+ current_space: space,
17
+ version: 2
18
+ )
19
+ end
20
+ let(:outputter) { double(:outputter, line: nil, fail: nil) }
21
+
22
+ before do
23
+ outputter.stub(:c) { |to_colorize| to_colorize }
24
+ end
25
+
26
+ describe "displaying the target (no args)" do
27
+ it "prints things nicely" do
28
+ TargetPrettifier.prettify(client, outputter)
29
+ desired_result = <<-STR
30
+ Target Information (where will apps be pushed):
31
+ CF instance: #{client.target} (API version: 2)
32
+ user: #{user.email}
33
+ target app space: #{space.name} (org: #{organization.name})
34
+ STR
35
+ desired_result.each_line do |line|
36
+ outputter.should have_received(:line).with(line.chomp)
37
+ end
38
+ end
39
+
40
+ context "when nothing is specified" do
41
+ let(:user) { nil }
42
+ let(:space) { nil }
43
+ let(:organization) { nil }
44
+
45
+ it "prints things nicely" do
46
+ TargetPrettifier.prettify(client, outputter)
47
+ desired_result = <<-STR
48
+ Target Information (where will apps be pushed):
49
+ CF instance: http://example.com (API version: 2)
50
+ user: N/A
51
+ target app space: N/A (org: N/A)
52
+ STR
53
+ desired_result.each_line do |line|
54
+ outputter.should have_received(:line).with(line.chomp)
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -41,7 +41,7 @@ module CF
41
41
  stub_home_dir_with { "#{SPEC_ROOT}/fixtures/fake_home_dirs/new" }
42
42
 
43
43
  context "when the user is authenticated and has an organization" do
44
- let(:user) { build(:user) }
44
+ let(:user) { build(:user).tap{ |u| u.stub(:email => "user@example.com") } }
45
45
  let(:organization) { build(:organization, :name => "My Org", :guid => "organization-id-1", :users => [user], :spaces => [space]) }
46
46
  let(:space) { build(:space, :name => "Staging", :guid => "space-id-2", :developers => [user]) }
47
47
 
@@ -103,15 +103,18 @@ module CF
103
103
  expect(output).to say("space: #{space.name}")
104
104
  end
105
105
  end
106
- end
107
-
108
- context "when client is nil" do
109
- let(:client) { nil }
110
- subject { cf ["target"] }
111
106
 
112
- it 'prints an error' do
113
- subject
114
- expect(error_output).to say("No target has been specified.")
107
+ describe "displaying the target (no args)" do
108
+ it "prints things nicely" do
109
+ client.stub(:current_space) { space }
110
+ cf %W{target}
111
+ expect(output).to say(<<-STR)
112
+ Target Information (where will apps be pushed):
113
+ CF instance: #{client.target} (API version: 2)
114
+ user: #{user.email}
115
+ target app space: #{space.name} (org: #{organization.name})
116
+ STR
117
+ end
115
118
  end
116
119
  end
117
120
  end
@@ -0,0 +1,17 @@
1
+ require "spec_helper"
2
+
3
+ describe "try" do
4
+ it "calls through with arguments on non-nil objects" do
5
+ "hi".try(:sub, 'i', 'o').should == "ho"
6
+ end
7
+
8
+ it "it throws a no method found error if the method does not exist" do
9
+ expect {
10
+ "hi".try(:fake_method)
11
+ }.to raise_error(NoMethodError)
12
+ end
13
+
14
+ it "returns nil for nil" do
15
+ nil.try(:sub, 'i', 'o').should == nil
16
+ end
17
+ end
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cf
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.5.rc6
4
+ version: 4.1.5.rc7
5
+ prerelease: 6
5
6
  platform: ruby
6
7
  authors:
7
8
  - Cloud Foundry Team
@@ -14,6 +15,7 @@ dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: addressable
16
17
  requirement: !ruby/object:Gem::Requirement
18
+ none: false
17
19
  requirements:
18
20
  - - ~>
19
21
  - !ruby/object:Gem::Version
@@ -21,6 +23,7 @@ dependencies:
21
23
  type: :runtime
22
24
  prerelease: false
23
25
  version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
24
27
  requirements:
25
28
  - - ~>
26
29
  - !ruby/object:Gem::Version
@@ -28,6 +31,7 @@ dependencies:
28
31
  - !ruby/object:Gem::Dependency
29
32
  name: caldecott-client
30
33
  requirement: !ruby/object:Gem::Requirement
34
+ none: false
31
35
  requirements:
32
36
  - - ~>
33
37
  - !ruby/object:Gem::Version
@@ -35,6 +39,7 @@ dependencies:
35
39
  type: :runtime
36
40
  prerelease: false
37
41
  version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
38
43
  requirements:
39
44
  - - ~>
40
45
  - !ruby/object:Gem::Version
@@ -42,6 +47,7 @@ dependencies:
42
47
  - !ruby/object:Gem::Dependency
43
48
  name: cfoundry
44
49
  requirement: !ruby/object:Gem::Requirement
50
+ none: false
45
51
  requirements:
46
52
  - - ! '>='
47
53
  - !ruby/object:Gem::Version
@@ -52,6 +58,7 @@ dependencies:
52
58
  type: :runtime
53
59
  prerelease: false
54
60
  version_requirements: !ruby/object:Gem::Requirement
61
+ none: false
55
62
  requirements:
56
63
  - - ! '>='
57
64
  - !ruby/object:Gem::Version
@@ -62,6 +69,7 @@ dependencies:
62
69
  - !ruby/object:Gem::Dependency
63
70
  name: interact
64
71
  requirement: !ruby/object:Gem::Requirement
72
+ none: false
65
73
  requirements:
66
74
  - - ~>
67
75
  - !ruby/object:Gem::Version
@@ -69,6 +77,7 @@ dependencies:
69
77
  type: :runtime
70
78
  prerelease: false
71
79
  version_requirements: !ruby/object:Gem::Requirement
80
+ none: false
72
81
  requirements:
73
82
  - - ~>
74
83
  - !ruby/object:Gem::Version
@@ -76,6 +85,7 @@ dependencies:
76
85
  - !ruby/object:Gem::Dependency
77
86
  name: json_pure
78
87
  requirement: !ruby/object:Gem::Requirement
88
+ none: false
79
89
  requirements:
80
90
  - - ~>
81
91
  - !ruby/object:Gem::Version
@@ -83,6 +93,7 @@ dependencies:
83
93
  type: :runtime
84
94
  prerelease: false
85
95
  version_requirements: !ruby/object:Gem::Requirement
96
+ none: false
86
97
  requirements:
87
98
  - - ~>
88
99
  - !ruby/object:Gem::Version
@@ -90,6 +101,7 @@ dependencies:
90
101
  - !ruby/object:Gem::Dependency
91
102
  name: mothership
92
103
  requirement: !ruby/object:Gem::Requirement
104
+ none: false
93
105
  requirements:
94
106
  - - ! '>='
95
107
  - !ruby/object:Gem::Version
@@ -100,6 +112,7 @@ dependencies:
100
112
  type: :runtime
101
113
  prerelease: false
102
114
  version_requirements: !ruby/object:Gem::Requirement
115
+ none: false
103
116
  requirements:
104
117
  - - ! '>='
105
118
  - !ruby/object:Gem::Version
@@ -110,6 +123,7 @@ dependencies:
110
123
  - !ruby/object:Gem::Dependency
111
124
  name: multi_json
112
125
  requirement: !ruby/object:Gem::Requirement
126
+ none: false
113
127
  requirements:
114
128
  - - ~>
115
129
  - !ruby/object:Gem::Version
@@ -117,6 +131,7 @@ dependencies:
117
131
  type: :runtime
118
132
  prerelease: false
119
133
  version_requirements: !ruby/object:Gem::Requirement
134
+ none: false
120
135
  requirements:
121
136
  - - ~>
122
137
  - !ruby/object:Gem::Version
@@ -124,6 +139,7 @@ dependencies:
124
139
  - !ruby/object:Gem::Dependency
125
140
  name: rest-client
126
141
  requirement: !ruby/object:Gem::Requirement
142
+ none: false
127
143
  requirements:
128
144
  - - ~>
129
145
  - !ruby/object:Gem::Version
@@ -131,6 +147,7 @@ dependencies:
131
147
  type: :runtime
132
148
  prerelease: false
133
149
  version_requirements: !ruby/object:Gem::Requirement
150
+ none: false
134
151
  requirements:
135
152
  - - ~>
136
153
  - !ruby/object:Gem::Version
@@ -138,6 +155,7 @@ dependencies:
138
155
  - !ruby/object:Gem::Dependency
139
156
  name: uuidtools
140
157
  requirement: !ruby/object:Gem::Requirement
158
+ none: false
141
159
  requirements:
142
160
  - - ~>
143
161
  - !ruby/object:Gem::Version
@@ -145,6 +163,7 @@ dependencies:
145
163
  type: :runtime
146
164
  prerelease: false
147
165
  version_requirements: !ruby/object:Gem::Requirement
166
+ none: false
148
167
  requirements:
149
168
  - - ~>
150
169
  - !ruby/object:Gem::Version
@@ -152,6 +171,7 @@ dependencies:
152
171
  - !ruby/object:Gem::Dependency
153
172
  name: anchorman
154
173
  requirement: !ruby/object:Gem::Requirement
174
+ none: false
155
175
  requirements:
156
176
  - - ! '>='
157
177
  - !ruby/object:Gem::Version
@@ -159,6 +179,7 @@ dependencies:
159
179
  type: :development
160
180
  prerelease: false
161
181
  version_requirements: !ruby/object:Gem::Requirement
182
+ none: false
162
183
  requirements:
163
184
  - - ! '>='
164
185
  - !ruby/object:Gem::Version
@@ -166,6 +187,7 @@ dependencies:
166
187
  - !ruby/object:Gem::Dependency
167
188
  name: blue-shell
168
189
  requirement: !ruby/object:Gem::Requirement
190
+ none: false
169
191
  requirements:
170
192
  - - ! '>='
171
193
  - !ruby/object:Gem::Version
@@ -173,6 +195,7 @@ dependencies:
173
195
  type: :development
174
196
  prerelease: false
175
197
  version_requirements: !ruby/object:Gem::Requirement
198
+ none: false
176
199
  requirements:
177
200
  - - ! '>='
178
201
  - !ruby/object:Gem::Version
@@ -180,6 +203,7 @@ dependencies:
180
203
  - !ruby/object:Gem::Dependency
181
204
  name: factory_girl
182
205
  requirement: !ruby/object:Gem::Requirement
206
+ none: false
183
207
  requirements:
184
208
  - - ! '>='
185
209
  - !ruby/object:Gem::Version
@@ -187,6 +211,7 @@ dependencies:
187
211
  type: :development
188
212
  prerelease: false
189
213
  version_requirements: !ruby/object:Gem::Requirement
214
+ none: false
190
215
  requirements:
191
216
  - - ! '>='
192
217
  - !ruby/object:Gem::Version
@@ -194,6 +219,7 @@ dependencies:
194
219
  - !ruby/object:Gem::Dependency
195
220
  name: fakefs
196
221
  requirement: !ruby/object:Gem::Requirement
222
+ none: false
197
223
  requirements:
198
224
  - - ~>
199
225
  - !ruby/object:Gem::Version
@@ -201,6 +227,7 @@ dependencies:
201
227
  type: :development
202
228
  prerelease: false
203
229
  version_requirements: !ruby/object:Gem::Requirement
230
+ none: false
204
231
  requirements:
205
232
  - - ~>
206
233
  - !ruby/object:Gem::Version
@@ -208,6 +235,7 @@ dependencies:
208
235
  - !ruby/object:Gem::Dependency
209
236
  name: ffaker
210
237
  requirement: !ruby/object:Gem::Requirement
238
+ none: false
211
239
  requirements:
212
240
  - - '='
213
241
  - !ruby/object:Gem::Version
@@ -215,6 +243,7 @@ dependencies:
215
243
  type: :development
216
244
  prerelease: false
217
245
  version_requirements: !ruby/object:Gem::Requirement
246
+ none: false
218
247
  requirements:
219
248
  - - '='
220
249
  - !ruby/object:Gem::Version
@@ -222,6 +251,7 @@ dependencies:
222
251
  - !ruby/object:Gem::Dependency
223
252
  name: gem-release
224
253
  requirement: !ruby/object:Gem::Requirement
254
+ none: false
225
255
  requirements:
226
256
  - - ! '>='
227
257
  - !ruby/object:Gem::Version
@@ -229,6 +259,7 @@ dependencies:
229
259
  type: :development
230
260
  prerelease: false
231
261
  version_requirements: !ruby/object:Gem::Requirement
262
+ none: false
232
263
  requirements:
233
264
  - - ! '>='
234
265
  - !ruby/object:Gem::Version
@@ -236,6 +267,7 @@ dependencies:
236
267
  - !ruby/object:Gem::Dependency
237
268
  name: rake
238
269
  requirement: !ruby/object:Gem::Requirement
270
+ none: false
239
271
  requirements:
240
272
  - - ~>
241
273
  - !ruby/object:Gem::Version
@@ -243,6 +275,7 @@ dependencies:
243
275
  type: :development
244
276
  prerelease: false
245
277
  version_requirements: !ruby/object:Gem::Requirement
278
+ none: false
246
279
  requirements:
247
280
  - - ~>
248
281
  - !ruby/object:Gem::Version
@@ -250,6 +283,7 @@ dependencies:
250
283
  - !ruby/object:Gem::Dependency
251
284
  name: rspec
252
285
  requirement: !ruby/object:Gem::Requirement
286
+ none: false
253
287
  requirements:
254
288
  - - ~>
255
289
  - !ruby/object:Gem::Version
@@ -257,6 +291,7 @@ dependencies:
257
291
  type: :development
258
292
  prerelease: false
259
293
  version_requirements: !ruby/object:Gem::Requirement
294
+ none: false
260
295
  requirements:
261
296
  - - ~>
262
297
  - !ruby/object:Gem::Version
@@ -264,6 +299,7 @@ dependencies:
264
299
  - !ruby/object:Gem::Dependency
265
300
  name: rspec-instafail
266
301
  requirement: !ruby/object:Gem::Requirement
302
+ none: false
267
303
  requirements:
268
304
  - - ~>
269
305
  - !ruby/object:Gem::Version
@@ -271,6 +307,7 @@ dependencies:
271
307
  type: :development
272
308
  prerelease: false
273
309
  version_requirements: !ruby/object:Gem::Requirement
310
+ none: false
274
311
  requirements:
275
312
  - - ~>
276
313
  - !ruby/object:Gem::Version
@@ -278,6 +315,7 @@ dependencies:
278
315
  - !ruby/object:Gem::Dependency
279
316
  name: webmock
280
317
  requirement: !ruby/object:Gem::Requirement
318
+ none: false
281
319
  requirements:
282
320
  - - ~>
283
321
  - !ruby/object:Gem::Version
@@ -285,6 +323,7 @@ dependencies:
285
323
  type: :development
286
324
  prerelease: false
287
325
  version_requirements: !ruby/object:Gem::Requirement
326
+ none: false
288
327
  requirements:
289
328
  - - ~>
290
329
  - !ruby/object:Gem::Version
@@ -370,6 +409,7 @@ files:
370
409
  - lib/cf/cli/start/login.rb
371
410
  - lib/cf/cli/start/logout.rb
372
411
  - lib/cf/cli/start/target.rb
412
+ - lib/cf/cli/start/target_prettifier.rb
373
413
  - lib/cf/cli/start/targets.rb
374
414
  - lib/cf/cli/user/base.rb
375
415
  - lib/cf/cli/user/create.rb
@@ -379,6 +419,7 @@ files:
379
419
  - lib/cf/cli.rb
380
420
  - lib/cf/constants.rb
381
421
  - lib/cf/errors.rb
422
+ - lib/cf/object_extensions.rb
382
423
  - lib/cf/plugin.rb
383
424
  - lib/cf/spacing.rb
384
425
  - lib/cf/spec_helper.rb
@@ -518,12 +559,14 @@ files:
518
559
  - spec/cf/cli/start/info_spec.rb
519
560
  - spec/cf/cli/start/login_spec.rb
520
561
  - spec/cf/cli/start/logout_spec.rb
562
+ - spec/cf/cli/start/target_prettifier_spec.rb
521
563
  - spec/cf/cli/start/target_spec.rb
522
564
  - spec/cf/cli/user/create_spec.rb
523
565
  - spec/cf/cli/user/help_spec.rb
524
566
  - spec/cf/cli/user/passwd_spec.rb
525
567
  - spec/cf/cli/user/register_spec.rb
526
568
  - spec/cf/cli_spec.rb
569
+ - spec/cf/object_extensions_spec.rb
527
570
  - spec/console/console_spec.rb
528
571
  - spec/factories/cfoundry/v2/apps_factory.rb
529
572
  - spec/factories/cfoundry/v2/clients_factory.rb
@@ -566,26 +609,30 @@ files:
566
609
  - bin/cf
567
610
  homepage: http://github.com/cloudfoundry/cf
568
611
  licenses: []
569
- metadata: {}
570
612
  post_install_message:
571
613
  rdoc_options: []
572
614
  require_paths:
573
615
  - lib
574
616
  required_ruby_version: !ruby/object:Gem::Requirement
617
+ none: false
575
618
  requirements:
576
619
  - - ! '>='
577
620
  - !ruby/object:Gem::Version
578
621
  version: '0'
622
+ segments:
623
+ - 0
624
+ hash: -2597973038898250794
579
625
  required_rubygems_version: !ruby/object:Gem::Requirement
626
+ none: false
580
627
  requirements:
581
628
  - - ! '>'
582
629
  - !ruby/object:Gem::Version
583
630
  version: 1.3.1
584
631
  requirements: []
585
632
  rubyforge_project: cf
586
- rubygems_version: 2.0.3
633
+ rubygems_version: 1.8.25
587
634
  signing_key:
588
- specification_version: 4
635
+ specification_version: 3
589
636
  summary: Friendly command-line interface for Cloud Foundry.
590
637
  test_files:
591
638
  - spec/admin/curl_spec.rb
@@ -692,12 +739,14 @@ test_files:
692
739
  - spec/cf/cli/start/info_spec.rb
693
740
  - spec/cf/cli/start/login_spec.rb
694
741
  - spec/cf/cli/start/logout_spec.rb
742
+ - spec/cf/cli/start/target_prettifier_spec.rb
695
743
  - spec/cf/cli/start/target_spec.rb
696
744
  - spec/cf/cli/user/create_spec.rb
697
745
  - spec/cf/cli/user/help_spec.rb
698
746
  - spec/cf/cli/user/passwd_spec.rb
699
747
  - spec/cf/cli/user/register_spec.rb
700
748
  - spec/cf/cli_spec.rb
749
+ - spec/cf/object_extensions_spec.rb
701
750
  - spec/console/console_spec.rb
702
751
  - spec/factories/cfoundry/v2/apps_factory.rb
703
752
  - spec/factories/cfoundry/v2/clients_factory.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: e8807a41f79e55ef1f7374cc6e5c0a5c14c57004
4
- data.tar.gz: 6daff8418840423d98aa28ff883567661e4bc92a
5
- SHA512:
6
- metadata.gz: 1db10b928373eb25b9a9372ae70142295cd896d253e361f97fbf5fb6b52d45b09a480ab3fdd291afa57e9e53196d02c4759cec302a181e92b0c99de1cd900acf
7
- data.tar.gz: fd679453636c15f57b02c96631593bc6a017e8586c135325dbe9d442cf55d09de78bb2fae7b56eb1207108e5fad49a1c94759a4a8c07b8c83940879237f92021