MuranoCLI 3.2.1.pre.beta.4 → 3.2.1.pre.beta.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/Gemfile +4 -3
  4. data/HISTORY.md +826 -0
  5. data/Rakefile +415 -47
  6. data/docs/release.rst +275 -0
  7. data/lib/MrMurano/Account.rb +46 -47
  8. data/lib/MrMurano/AccountBase.rb +1 -0
  9. data/lib/MrMurano/Business.rb +183 -44
  10. data/lib/MrMurano/Config.rb +1 -0
  11. data/lib/MrMurano/Exchange.rb +3 -4
  12. data/lib/MrMurano/Solution-Services.rb +25 -7
  13. data/lib/MrMurano/Webservice-File.rb +5 -7
  14. data/lib/MrMurano/commands/business.rb +231 -24
  15. data/lib/MrMurano/commands/child.rb +3 -3
  16. data/lib/MrMurano/commands/element.rb +1 -0
  17. data/lib/MrMurano/commands/settings.rb +7 -0
  18. data/lib/MrMurano/http.rb +1 -3
  19. data/lib/MrMurano/progress.rb +12 -2
  20. data/lib/MrMurano/verbosing.rb +7 -7
  21. data/lib/MrMurano/version.rb +1 -1
  22. data/spec/Account_spec.rb +9 -0
  23. data/spec/ProjectFile_spec.rb +7 -9
  24. data/spec/Webservice-File_spec.rb +2 -1
  25. data/spec/cmd_business_spec.rb +1 -1
  26. data/spec/cmd_common.rb +75 -30
  27. data/spec/cmd_content_spec.rb +3 -1
  28. data/spec/cmd_cors_spec.rb +3 -1
  29. data/spec/cmd_device_spec.rb +7 -5
  30. data/spec/cmd_domain_spec.rb +6 -2
  31. data/spec/cmd_help_spec.rb +13 -6
  32. data/spec/cmd_init_spec.rb +19 -10
  33. data/spec/cmd_keystore_spec.rb +3 -1
  34. data/spec/cmd_link_spec.rb +5 -5
  35. data/spec/cmd_setting_application_spec.rb +13 -16
  36. data/spec/cmd_setting_product_spec.rb +14 -14
  37. data/spec/cmd_status_spec.rb +6 -2
  38. data/spec/cmd_syncdown_application_spec.rb +3 -1
  39. data/spec/cmd_syncdown_both_spec.rb +6 -2
  40. data/spec/cmd_syncdown_unit_spec.rb +3 -0
  41. data/spec/cmd_syncup_spec.rb +8 -4
  42. data/spec/cmd_usage_spec.rb +10 -2
  43. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value 0.webmock +98 -0
  44. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value 1.webmock +98 -0
  45. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value No.webmock +98 -0
  46. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value Yes.webmock +98 -0
  47. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value bob.webmock +72 -0
  48. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value false.webmock +98 -0
  49. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value off.webmock +98 -0
  50. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value on STDIN.webmock +98 -0
  51. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value on.webmock +98 -0
  52. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a bool value true.webmock +98 -0
  53. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a json array blob with STDIN.webmock +98 -0
  54. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) a json array blob.webmock +98 -0
  55. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) an array.webmock +98 -0
  56. data/spec/fixtures/snapshots/murano application setting Writes (using Webservice.cors) appends an array.webmock +98 -0
  57. data/spec/fixtures/snapshots/murano application setting reads Webservice.cors to a file.webmock +72 -0
  58. data/spec/fixtures/snapshots/murano application setting reads Webservice.cors.webmock +72 -0
  59. data/spec/fixtures/snapshots/murano business list as json.webmock +27 -0
  60. data/spec/fixtures/snapshots/murano business list as table.webmock +27 -0
  61. data/spec/fixtures/snapshots/murano business list fewer fields.webmock +27 -0
  62. data/spec/fixtures/snapshots/murano business list only ids.webmock +27 -0
  63. data/spec/fixtures/snapshots/murano business list output to file.webmock +27 -0
  64. data/spec/fixtures/snapshots/murano business without project help.webmock +9 -0
  65. data/spec/fixtures/snapshots/murano config Needs a key.webmock +9 -0
  66. data/spec/fixtures/snapshots/murano config Reads a key.webmock +9 -0
  67. data/spec/fixtures/snapshots/murano config Removes a key.webmock +9 -0
  68. data/spec/fixtures/snapshots/murano config Sets a key.webmock +9 -0
  69. data/spec/fixtures/snapshots/murano config Sets a user key.webmock +9 -0
  70. data/spec/fixtures/snapshots/murano content life cycle.webmock +144 -0
  71. data/spec/fixtures/snapshots/murano cors sets CORS.webmock +78 -0
  72. data/spec/fixtures/snapshots/murano cors show CORS.webmock +64 -0
  73. data/spec/fixtures/snapshots/murano device activates.webmock +86 -0
  74. data/spec/fixtures/snapshots/murano device enables a batch.webmock +76 -0
  75. data/spec/fixtures/snapshots/murano device enables and lists.webmock +78 -0
  76. data/spec/fixtures/snapshots/murano device writes and reads.webmock +136 -0
  77. data/spec/fixtures/snapshots/murano domain show domain.webmock +101 -0
  78. data/spec/fixtures/snapshots/murano element edit unknown as unknown element.webmock +43 -0
  79. data/spec/fixtures/snapshots/murano element show --help.webmock +9 -0
  80. data/spec/fixtures/snapshots/murano element show as csv.webmock +43 -0
  81. data/spec/fixtures/snapshots/murano element show as default-table.webmock +43 -0
  82. data/spec/fixtures/snapshots/murano element show as json.webmock +43 -0
  83. data/spec/fixtures/snapshots/murano element show as table truncate.webmock +43 -0
  84. data/spec/fixtures/snapshots/murano element show as table wrap.webmock +43 -0
  85. data/spec/fixtures/snapshots/murano element show as yaml.webmock +43 -0
  86. data/spec/fixtures/snapshots/murano element show using ambiguous name.webmock +43 -0
  87. data/spec/fixtures/snapshots/murano element without project usage.webmock +9 -0
  88. data/spec/fixtures/snapshots/murano exchange with project list as json.webmock +59 -0
  89. data/spec/fixtures/snapshots/murano exchange with project list as table.webmock +59 -0
  90. data/spec/fixtures/snapshots/murano exchange with project list fewer fields.webmock +59 -0
  91. data/spec/fixtures/snapshots/murano exchange with project list only ids.webmock +59 -0
  92. data/spec/fixtures/snapshots/murano exchange with project list output to file.webmock +59 -0
  93. data/spec/fixtures/snapshots/murano exchange with project list purchase is already added ID.webmock +83 -0
  94. data/spec/fixtures/snapshots/murano exchange with project list purchase is ambiguous name.webmock +59 -0
  95. data/spec/fixtures/snapshots/murano exchange without project help.webmock +9 -0
  96. data/spec/fixtures/snapshots/murano help using commander as --help.webmock +9 -0
  97. data/spec/fixtures/snapshots/murano help using commander no args.webmock +9 -0
  98. data/spec/fixtures/snapshots/murano help using subshell no args.webmock +9 -0
  99. data/spec/fixtures/snapshots/murano help using subshell with --help.webmock +9 -0
  100. data/spec/fixtures/snapshots/murano init Won't init in HOME (gracefully).webmock +9 -0
  101. data/spec/fixtures/snapshots/murano init in empty directory with existing project.webmock +201 -0
  102. data/spec/fixtures/snapshots/murano init in empty directory without existing project.webmock +193 -0
  103. data/spec/fixtures/snapshots/murano init in existing project directory with ProjectFile.webmock +213 -0
  104. data/spec/fixtures/snapshots/murano init in existing project directory with SolutionFile 0.2.0.webmock +213 -0
  105. data/spec/fixtures/snapshots/murano init in existing project directory with SolutionFile 0.3.0.webmock +213 -0
  106. data/spec/fixtures/snapshots/murano init in existing project directory without ProjectFile.webmock +213 -0
  107. data/spec/fixtures/snapshots/murano keystore can call other commands.webmock +108 -0
  108. data/spec/fixtures/snapshots/murano keystore clearAll.webmock +124 -0
  109. data/spec/fixtures/snapshots/murano keystore deletes.webmock +112 -0
  110. data/spec/fixtures/snapshots/murano keystore gets.webmock +96 -0
  111. data/spec/fixtures/snapshots/murano keystore infos.webmock +96 -0
  112. data/spec/fixtures/snapshots/murano keystore lists.webmock +96 -0
  113. data/spec/fixtures/snapshots/murano link with project links and lists.webmock +149 -0
  114. data/spec/fixtures/snapshots/murano link with project unlinks.webmock +165 -0
  115. data/spec/fixtures/snapshots/murano link without project help.webmock +9 -0
  116. data/spec/fixtures/snapshots/murano link without project subshell vs inline using commander will not list.webmock +27 -0
  117. data/spec/fixtures/snapshots/murano link without project subshell vs inline using subshell will not list.webmock +27 -0
  118. data/spec/fixtures/snapshots/murano logs when project is setup tail log.webmock +9 -0
  119. data/spec/fixtures/snapshots/murano password Lists when no file.webmock +9 -0
  120. data/spec/fixtures/snapshots/murano password deletes a password.webmock +9 -0
  121. data/spec/fixtures/snapshots/murano password sets a password.webmock +9 -0
  122. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a forced string value on STDIN.webmock +90 -0
  123. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a forced string value.webmock +90 -0
  124. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value fiftyHalf.webmock +64 -0
  125. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value float 12.67.webmock +90 -0
  126. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value integer 12.webmock +90 -0
  127. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a number value on STDIN.webmock +90 -0
  128. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) a string value.webmock +90 -0
  129. data/spec/fixtures/snapshots/murano product setting Writes (using Device2.identity_format) merges into a dictionary.webmock +90 -0
  130. data/spec/fixtures/snapshots/murano single sync without ProjectFile syncdown.webmock +322 -0
  131. data/spec/fixtures/snapshots/murano status with ProjectFile status.webmock +153 -0
  132. data/spec/fixtures/snapshots/murano status with Solutionfile 0.2.0 status.webmock +153 -0
  133. data/spec/fixtures/snapshots/murano status with Solutionfile 0.3.0 status.webmock +153 -0
  134. data/spec/fixtures/snapshots/murano status without ProjectFile matches file path.webmock +153 -0
  135. data/spec/fixtures/snapshots/murano status without ProjectFile matches route.webmock +153 -0
  136. data/spec/fixtures/snapshots/murano status without ProjectFile status.webmock +153 -0
  137. data/spec/fixtures/snapshots/murano syncdown stubbed without ProjectFile syncdown.webmock +151 -0
  138. data/spec/fixtures/snapshots/murano syncdown without ProjectFile syncdown.webmock +479 -0
  139. data/spec/fixtures/snapshots/murano syncup without ProjectFile syncup.webmock +357 -0
  140. data/spec/fixtures/snapshots/murano token with project list as table.webmock +9 -0
  141. data/spec/fixtures/snapshots/murano token without project help.webmock +9 -0
  142. data/spec/fixtures/snapshots/murano usage show usage.webmock +93 -0
  143. data/spec/spec_helper.rb +9 -3
  144. data/spec/webmock_snapshot.rb +296 -0
  145. metadata +133 -2
@@ -21,22 +21,48 @@ command :business do |c|
21
21
  c.description = %(
22
22
  Commands for working with businesses.
23
23
 
24
- If you need to set the business ID, try some of the following:
24
+ Getting and Setting the Business ID
25
+ -----------------------------------
25
26
 
26
- - Get a list of Business IDs: #{MrMurano::EXE_NAME} business list
27
+ - Get a list of Business IDs:
27
28
 
28
- - Specify the ID explictly: #{MrMurano::EXE_NAME} <cmd> --config business.id=<ID>
29
- Add the ID to a project config: #{MrMurano::EXE_NAME} config business.id <ID>
30
- Add the ID to the user config: #{MrMurano::EXE_NAME} config business.id <ID> --user
31
- Setup a project interactively: #{MrMurano::EXE_NAME} init
29
+ #{MrMurano::EXE_NAME} business list
32
30
 
33
- - Working with enterprise network child businesses:
34
- Get a list of child business IDs: #{MrMurano::EXE_NAME} network children
35
- Specify the child ID explicitly #{MrMurano::EXE_NAME} <cmd> --config business.child=<ID>
36
- Add the child ID to a project config: #{MrMurano::EXE_NAME} config business.child <ID>
37
- Add the child ID to the user config: #{MrMurano::EXE_NAME} config business.child <ID> --user
31
+ - Specify the Business ID at runtime:
38
32
 
33
+ #{MrMurano::EXE_NAME} <cmd> --config business.id=<ID>
39
34
 
35
+ Add the Business ID to a project config:
36
+
37
+ #{MrMurano::EXE_NAME} config business.id <ID>
38
+
39
+ Add the Business ID to the user config:
40
+
41
+ #{MrMurano::EXE_NAME} config business.id <ID> --user
42
+
43
+ Setup a project interactively (choose the Business ID from a list):
44
+
45
+ #{MrMurano::EXE_NAME} init
46
+
47
+
48
+ Working with Enterprise Network Child Businesses
49
+ ------------------------------------------------
50
+
51
+ - Get a list of child business IDs:
52
+
53
+ #{MrMurano::EXE_NAME} network children
54
+
55
+ - Specify the child ID explicitly:
56
+
57
+ #{MrMurano::EXE_NAME} <cmd> --config business.child=<ID>
58
+
59
+ Add the child ID to a project config:
60
+
61
+ #{MrMurano::EXE_NAME} config business.child <ID>
62
+
63
+ Add the child ID to the user config:
64
+
65
+ #{MrMurano::EXE_NAME} config business.child <ID> --user
40
66
  ).strip
41
67
  c.project_not_required = true
42
68
  c.subcmdgrouphelp = true
@@ -55,6 +81,8 @@ def cmd_table_output_add_options(c)
55
81
  # MAYBE/2017-08-15: Rename to --id-only.
56
82
  c.option '--idonly', 'Only return the IDs'
57
83
  c.option '--[no-]brief', 'Show fewer fields: show only IDs and names'
84
+ c.option '--network', 'Fetch and show Business Network details'
85
+ c.option '--detailed', 'Fetch and show all Business information'
58
86
  # MAYBE/2017-08-17: Move -o option to globals.rb and apply to all commands.
59
87
  c.option '-o', '--output FILE', 'Download to file instead of STDOUT'
60
88
  end
@@ -103,7 +131,9 @@ end
103
131
 
104
132
  command 'business list' do |c|
105
133
  c.syntax = %(murano business list [--options])
106
- c.summary = %(List businesses)
134
+ # (lb): Use leading space so there's more than one space in --help
135
+ # after the command name.
136
+ c.summary = %( List businesses)
107
137
  c.description = %(
108
138
  List businesses.
109
139
 
@@ -169,9 +199,6 @@ arguments. For example,
169
199
  ).strip
170
200
  c.project_not_required = true
171
201
 
172
- # Add --network option
173
- c.option('--network')
174
-
175
202
  cmd_table_output_add_options(c)
176
203
 
177
204
  c.action do |args, options|
@@ -183,17 +210,16 @@ alias_command 'businesses list', 'business list'
183
210
 
184
211
  command 'business find' do |c|
185
212
  c.syntax = %(murano business find [--options] [<name-or-ID,...>])
186
- c.summary = %(Find business by name or ID)
213
+ # (lb): Use leading space so there's more than one space in --help
214
+ # after the command name.
215
+ c.summary = %( Find business by name or ID)
187
216
  c.description = %(
188
- Find business by name or ID.
217
+ Find business by name or ID.
189
218
  ).strip
190
219
  c.project_not_required = true
191
220
 
192
221
  cmd_table_output_add_options(c)
193
222
 
194
- # Add --network option
195
- c.option('--network')
196
-
197
223
  # Add --business/-id/-name options.
198
224
  cmd_option_business_pickers(c)
199
225
 
@@ -211,6 +237,128 @@ Find business by name or ID.
211
237
  end
212
238
  end
213
239
 
240
+ command 'business show' do |c|
241
+ c.syntax = %(murano business show)
242
+ # (lb): Use leading space so there's more than one space in --help
243
+ # after the command name.
244
+ c.summary = %( Show information about the active Business)
245
+ c.description = %(
246
+ Show details about the active Business.
247
+ ).strip
248
+ c.project_not_required = true
249
+
250
+ c.action do |args, options|
251
+ c.verify_arg_count!(args)
252
+
253
+ options.network = true
254
+ options.detailed = true
255
+
256
+ biz = MrMurano::Business.new
257
+ biz.must_business_id!
258
+
259
+ MrMurano::Verbose.whirly_start 'Fetching business details...'
260
+ biz.overview(detailed: true, networks: true)
261
+ MrMurano::Verbose.whirly_stop
262
+
263
+ acc = MrMurano::Account.new
264
+ cmd_business_output_businesses(acc, [biz], options)
265
+ end
266
+ end
267
+
268
+ command 'business members' do |c|
269
+ c.syntax = %(murano business members)
270
+ # (lb): Use leading space so there's more than one space in --help
271
+ # after the command name.
272
+ c.summary = %( Show Business members)
273
+ c.description = %(
274
+ Show Business members.
275
+ ).strip
276
+ c.project_not_required = true
277
+
278
+ c.action do |args, options|
279
+ c.verify_arg_count!(args)
280
+
281
+ biz = MrMurano::Business.new
282
+ biz.must_business_id!
283
+
284
+ MrMurano::Verbose.whirly_start 'Fetching business members...'
285
+ members = biz.fetch_member
286
+ MrMurano::Verbose.whirly_stop
287
+
288
+ acc = MrMurano::Account.new
289
+ cmd_business_output_members(acc, members, options)
290
+ end
291
+ end
292
+
293
+ command 'business set name' do |c|
294
+ c.syntax = %(murano business set name <name>)
295
+ # (lb): Use leading space so there's more than one space in --help
296
+ # after the command name.
297
+ c.summary = %( Change Business name)
298
+ c.description = %(
299
+ Change Business name.
300
+ ).strip
301
+ c.project_not_required = true
302
+
303
+ c.action do |args, _options|
304
+ c.verify_arg_count!(args, 1, ['Missing <Business name>'])
305
+ new_name = args[0]
306
+
307
+ biz = MrMurano::Business.new
308
+ biz.must_business_id!
309
+
310
+ MrMurano::Verbose.whirly_start 'Setting Business name...'
311
+ biz.name = new_name
312
+ MrMurano::Verbose.whirly_stop
313
+ end
314
+ end
315
+
316
+ command 'business set email' do |c|
317
+ c.syntax = %(murano business set email <name>)
318
+ # (lb): Use leading space so there's more than one space in --help
319
+ # after the command name.
320
+ c.summary = %( Change Business billing email)
321
+ c.description = %(
322
+ Change Business billing email.
323
+ ).strip
324
+ c.project_not_required = true
325
+
326
+ c.action do |args, _options|
327
+ c.verify_arg_count!(args, 1, ['Missing <billing email>'])
328
+ new_email = args[0]
329
+
330
+ biz = MrMurano::Business.new
331
+ biz.must_business_id!
332
+
333
+ MrMurano::Verbose.whirly_start 'Setting Business billing email...'
334
+ biz.email = new_email
335
+ MrMurano::Verbose.whirly_stop
336
+ end
337
+ end
338
+
339
+ command 'business set contact' do |c|
340
+ c.syntax = %(murano business set contact <contact>)
341
+ # (lb): Use leading space so there's more than one space in --help
342
+ # after the command name.
343
+ c.summary = %( Change Business billing contact)
344
+ c.description = %(
345
+ Change Business billing contact.
346
+ ).strip
347
+ c.project_not_required = true
348
+
349
+ c.action do |args, _options|
350
+ c.verify_arg_count!(args, 1, ['Missing <billing contact>'])
351
+ new_contact = args[0]
352
+
353
+ biz = MrMurano::Business.new
354
+ biz.must_business_id!
355
+
356
+ MrMurano::Verbose.whirly_start 'Setting Business billing contact...'
357
+ biz.contact = new_contact
358
+ MrMurano::Verbose.whirly_stop
359
+ end
360
+ end
361
+
214
362
  # *** Business actions helpers
215
363
  # ----------------------------
216
364
 
@@ -338,7 +486,13 @@ def cmd_business_find_businesses(acc, args, options)
338
486
  end
339
487
 
340
488
  MrMurano::Verbose.whirly_start 'Looking for businesses...'
341
- bizz = acc.businesses(bid: bid, name: name, fuzzy: fuzzy, options: options)
489
+ bizz = acc.businesses(
490
+ bid: bid,
491
+ name: name,
492
+ fuzzy: fuzzy,
493
+ detailed: options.detailed,
494
+ networks: options.network
495
+ )
342
496
  MrMurano::Verbose.whirly_stop
343
497
 
344
498
  bizz
@@ -360,12 +514,22 @@ def cmd_business_header_and_bizz(bizz, options)
360
514
  case hdr
361
515
  when :bizid
362
516
  0
363
- when :role
364
- 1
365
517
  when :name
518
+ 1
519
+ when :tier
366
520
  2
367
- else
521
+ when :contact
368
522
  3
523
+ when :email
524
+ 4
525
+ when :role
526
+ 5
527
+ when :network_relationship
528
+ 6
529
+ when :network_name
530
+ 7
531
+ else
532
+ 8
369
533
  end
370
534
  end
371
535
  bizz = bizz.map { |biz| headers.map { |key| biz.meta[key] } }
@@ -392,3 +556,46 @@ def cmd_business_output_businesses(acc, bizz, options)
392
556
  io.close unless io.nil?
393
557
  end
394
558
 
559
+ def cmd_business_members_header(members)
560
+ # (lb): Skip: :membership, which is just the bizid and role
561
+ # regurgitated (and it's also deprecated).
562
+ culled = members.dup.each { |member| member.delete(:membership) }
563
+
564
+ # Sort by role, then email.
565
+ culled.sort_by! { |member| [member[:role], member[:email]] }
566
+
567
+ headers = (culled[0] && culled[0].keys) || []
568
+ headers.sort_by! do |hdr|
569
+ case hdr
570
+ when :role
571
+ 0
572
+ when :email
573
+ 1
574
+ when :name
575
+ 2
576
+ when :pending
577
+ 3
578
+ else
579
+ 4
580
+ end
581
+ end
582
+ culled = culled.map { |member| headers.map { |key| member[key] } }
583
+
584
+ [headers, culled]
585
+ end
586
+
587
+ def cmd_business_output_members(acc, members, options)
588
+ headers, members = cmd_business_members_header(members)
589
+ io = File.open(options.output, 'w') if options.output
590
+ acc.outf(members, io) do |dd, ios|
591
+ acc.tabularize(
592
+ {
593
+ headers: headers.map(&:to_s),
594
+ rows: dd,
595
+ },
596
+ ios,
597
+ )
598
+ end
599
+ io.close unless io.nil?
600
+ end
601
+
@@ -43,7 +43,7 @@ command 'child show' do |c|
43
43
  def show_child
44
44
  biz = MrMurano::Business.new
45
45
  biz.must_business_id!
46
- biz.must_child!
46
+ biz.must_child_id!
47
47
  MrMurano::Verbose.whirly_start 'Fetching network child business...'
48
48
  business_network = biz.get_business_network(biz.bid)
49
49
  all_child_businesses = biz.view_child_businesses(biz.bid)
@@ -100,7 +100,7 @@ command 'child add' do |c|
100
100
  new_member_email = args[0]
101
101
  biz = MrMurano::Business.new
102
102
  biz.must_business_id!
103
- biz.must_child!
103
+ biz.must_child_id!
104
104
  MrMurano::Verbose.whirly_start 'Adding member to child business...'
105
105
  response = biz.add_member_to_child_business(biz.bid, biz.cid, new_member_email)
106
106
  MrMurano::Verbose.whirly_stop
@@ -136,7 +136,7 @@ command 'child remove' do |c|
136
136
  member_email = args[0]
137
137
  biz = MrMurano::Business.new
138
138
  biz.must_business_id!
139
- biz.must_child!
139
+ biz.must_child_id!
140
140
  MrMurano::Verbose.whirly_start 'Removing member from child business...'
141
141
  response = biz.remove_member_from_child_business(biz.bid, biz.cid, member_email)
142
142
  MrMurano::Verbose.whirly_stop
@@ -6,6 +6,7 @@
6
6
  # Unauthorized copying of this file is strictly prohibited.
7
7
 
8
8
  require 'highline'
9
+ require 'json'
9
10
  require 'pathname'
10
11
  require 'tempfile'
11
12
  require 'tty-editor'
@@ -96,6 +96,8 @@ If a sub-key doesn't exist, that entire path will be created as dicts.
96
96
  c.option '--bool', %(Set Value type to boolean)
97
97
  c.option '--num', %(Set Value type to number)
98
98
  c.option '--string', %(Set Value type to string (this is default))
99
+ # (lb): Ha! The global --json shadows this one! So this option serves
100
+ # just for showing up in the --help. In the action, we'll kludge this.
99
101
  c.option '--json', %(Value is parsed as JSON)
100
102
  c.option '--array', %(Set Value type to array of strings)
101
103
  c.option '--dict', %(Set Value type to a dictionary of strings)
@@ -123,6 +125,11 @@ If a sub-key doesn't exist, that entire path will be created as dicts.
123
125
  append: false,
124
126
  merge: false,
125
127
  )
128
+ # (lb): As mentioned above, above the option, there are two --json options,
129
+ # one global (for --json output), and the one here. The global option is
130
+ # handled by lib/MrMurano/commands/globals.rb, and then it's removed from
131
+ # args. So do a bit of deducing here.
132
+ options.json = $cfg['tool.outformat'] == 'json'
126
133
 
127
134
  service, pref = args.shift.split('.')
128
135
  subkey = args.shift
data/lib/MrMurano/http.rb CHANGED
@@ -76,9 +76,7 @@ module MrMurano
76
76
  end
77
77
 
78
78
  # (lb): Ideally, we'd refactor and these wouldn't be static class methods.
79
- def self.curldebug_after(request, response)
80
- @http_complete = [] unless defined? @http_complete
81
- @http_complete.push([request, response])
79
+ def self.curldebug_after(_request, response)
82
80
  return response unless $cfg['tool.curldebug'] && $cfg['tool.curlfancy']
83
81
  MrMurano::Http.curldebug_elapsed
84
82
  if response.nil?
@@ -85,7 +85,7 @@ module MrMurano
85
85
  # Note that Whirly adds '...', so add its length, too.
86
86
  # rubocop:disable Performance/FixedSize
87
87
  # Do not compute the size of statically sized objects.
88
- @whirly_cols = @whirly_msg.length + '...'.length
88
+ @whirly_cols = strip_color(@whirly_msg).length + '...'.length
89
89
  end
90
90
 
91
91
  def whirly_stop(force: false)
@@ -125,7 +125,7 @@ module MrMurano
125
125
  # Clear the line.
126
126
  Whirly.configure(status: ' ' * @whirly_cols)
127
127
  Whirly.configure(status: @whirly_msg)
128
- @whirly_cols = @whirly_msg.length + '...'.length
128
+ @whirly_cols = strip_color(@whirly_msg).length + '...'.length
129
129
  end
130
130
  end
131
131
 
@@ -149,6 +149,16 @@ module MrMurano
149
149
  yield
150
150
  whirly_unpause
151
151
  end
152
+
153
+ # (lb): MAYBE: Move strip_color to a string helper module...
154
+ # like lib/MrMurano/variegated/...?
155
+ def self.strip_color(str)
156
+ str.gsub(/\e\[[;0-9]+m/, '')
157
+ end
158
+
159
+ def strip_color(str)
160
+ MrMurano::Progress.strip_color(str)
161
+ end
152
162
  end
153
163
  end
154
164
 
@@ -59,7 +59,7 @@ module MrMurano
59
59
 
60
60
  def self.assert(condition, msg='')
61
61
  return if condition
62
- msg = "Assertion raised! #{caller[1]}\n" + msg
62
+ msg = "Assertion raised! #{caller(1..1)}\n" + msg
63
63
  whirly_interject { warn(HighLine.color(msg, :red)) }
64
64
  raise msg
65
65
  end
@@ -214,18 +214,18 @@ module MrMurano
214
214
  def dump_output_file(obj, outf, fmt, **opts)
215
215
  case fmt
216
216
  when :json
217
- dump_file_json(obj, outf, **opts)
217
+ MrMurano::Verbose.dump_file_json(obj, outf, **opts)
218
218
  when :yaml
219
- dump_file_yaml(obj, outf)
219
+ MrMurano::Verbose.dump_file_yaml(obj, outf)
220
220
  when :plain
221
- dump_file_plain(obj, outf)
221
+ MrMurano::Verbose.dump_file_plain(obj, outf)
222
222
  else
223
223
  error_file_format!(fmt)
224
224
  end
225
225
  outf.flush
226
226
  end
227
227
 
228
- def dump_file_json(obj, outf, pretty: false)
228
+ def self.dump_file_json(obj, outf, pretty: false)
229
229
  if pretty
230
230
  outf.write(JSON.pretty_generate(obj))
231
231
  else
@@ -233,11 +233,11 @@ module MrMurano
233
233
  end
234
234
  end
235
235
 
236
- def dump_file_yaml(obj, outf)
236
+ def self.dump_file_yaml(obj, outf)
237
237
  YAML.dump(obj, outf)
238
238
  end
239
239
 
240
- def dump_file_plain(obj, outf)
240
+ def self.dump_file_plain(obj, outf)
241
241
  outf.write(obj)
242
242
  end
243
243
 
@@ -26,7 +26,7 @@ module MrMurano
26
26
  # '3.0.0-beta.2' is changed to '3.0.0.pre.beta.2'
27
27
  # which breaks our build (which expects the version to match herein).
28
28
  # So stick to using the '.pre.X' syntax, which ruby/gems knows.
29
- VERSION = '3.2.1.pre.beta.4'
29
+ VERSION = '3.2.1.pre.beta.5'
30
30
  EXE_NAME = File.basename($PROGRAM_NAME)
31
31
  SIGN_UP_URL = 'https://exosite.com/signup/'
32
32
  end
data/spec/Account_spec.rb CHANGED
@@ -38,6 +38,14 @@ RSpec.describe MrMurano::Account, 'token' do
38
38
  # Reset the Net::HTTP object, which was configured with the old net.host, etc.
39
39
  MrMurano::HttpAuthed.instance.http_reset
40
40
 
41
+ # (lb): 2018-08-09: With the new snapshot infrastructure, the token gets saved
42
+ # to the snapshot after the example runs. However, for examples that expect to
43
+ # start with no token, running the snapshot loads the token even though it should
44
+ # not be loaded. To work around that, delete the token here. (I have a feeling
45
+ # there's a better way to handle this, but I'm not sure offhand; this works for
46
+ # now, so going with it!)
47
+ ENV.delete('MURANO_TOKEN')
48
+
41
49
  stub_request_email_password
42
50
 
43
51
  $project = MrMurano::ProjectFile.new
@@ -153,6 +161,7 @@ end
153
161
 
154
162
  RSpec.describe MrMurano::Account do
155
163
  include_context 'WORKSPACE'
164
+
156
165
  before(:example) do
157
166
  @saved_cfg = ENV['MURANO_CONFIGFILE']
158
167
  ENV['MURANO_CONFIGFILE'] = nil
@@ -43,16 +43,12 @@ RSpec.describe MrMurano::ProjectFile do
43
43
  expect(@pjf).to receive(
44
44
  :default_value_for
45
45
  ).with('assets.location').and_return('here')
46
- expect(@pjf.get(
47
- 'assets.location'
48
- )).to eq('here')
46
+ expect(@pjf.get('assets.location')).to eq('here')
49
47
 
50
48
  expect(@pjf).to receive(
51
49
  :default_value_for
52
50
  ).with('assets.include').and_return(['here'])
53
- expect(@pjf.get(
54
- 'assets.include'
55
- )).to eq(['here'])
51
+ expect(@pjf.get('assets.include')).to eq(['here'])
56
52
 
57
53
  expect(@pjf).to receive(
58
54
  :default_value_for
@@ -168,9 +164,11 @@ RSpec.describe MrMurano::ProjectFile do
168
164
  expect($cfg).to receive(:get).with(
169
165
  'endpoints.searchFor'
170
166
  ).and_return('beef and potatoes')
171
- expect(@pjf.default_value_for(
172
- 'routes.include'
173
- )).to eq(%w[beef and potatoes])
167
+ expect(
168
+ @pjf.default_value_for(
169
+ 'routes.include'
170
+ )
171
+ ).to eq(%w[beef and potatoes])
174
172
  end
175
173
  end
176
174
  end
@@ -261,6 +261,7 @@ RSpec.describe MrMurano::Webservice::File do
261
261
 
262
262
  it 'gets item' do
263
263
  prj = Pathname.new(@project_dir).realpath
264
+ just_some_text = %(Just some text)
264
265
  want = [
265
266
  MrMurano::Webservice::File::FileItem.new(
266
267
  path: '/files/one.text',
@@ -270,7 +271,7 @@ RSpec.describe MrMurano::Webservice::File do
270
271
  #checksum: 'd1af3dadf08479a1d43b282f95d61dda8efda5e7'
271
272
  # You can calculate this with `md5sum one.text`
272
273
  checksum: 'e9ea4a5be73a09f541ad0b611083f0df',
273
- size: %(Just some text).length,
274
+ size: just_some_text.length,
274
275
  ),
275
276
  ]
276
277
  ret = @srv.to_remote_items(prj, @lp)
@@ -24,7 +24,7 @@ RSpec.describe 'murano business', :cmd, :needs_password do
24
24
  expect(err).to eq('')
25
25
  olines = out.lines
26
26
  expect(olines[0]).to match(/^(\+-+){3}\+$/)
27
- expect(olines[1]).to match(/^\| bizid\s+\| role\s+\| name\s+\|$/)
27
+ expect(olines[1]).to match(/^\| bizid\s+\| name\s+\| role\s+\|$/)
28
28
  expect(olines[2]).to match(/^(\+-+){3}\+$/)
29
29
  expect(olines[-1]).to match(/^(\+-+){3}\+$/)
30
30
  end