MuranoCLI 2.2.4 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/.agignore +3 -0
  3. data/.gitignore +18 -1
  4. data/.rubocop.yml +222 -0
  5. data/.trustme.sh +185 -0
  6. data/.trustme.vim +24 -0
  7. data/Gemfile +23 -4
  8. data/LICENSE.txt +1 -1
  9. data/MuranoCLI.gemspec +43 -8
  10. data/README.markdown +9 -11
  11. data/Rakefile +187 -143
  12. data/TODO.taskpaper +2 -2
  13. data/bin/murano +51 -52
  14. data/docs/basic_example.rst +436 -0
  15. data/docs/completions/murano_completion-bash +3484 -0
  16. data/docs/demo.md +32 -32
  17. data/docs/develop.rst +391 -0
  18. data/lib/MrMurano.rb +21 -7
  19. data/lib/MrMurano/Account.rb +159 -174
  20. data/lib/MrMurano/Business.rb +381 -0
  21. data/lib/MrMurano/Config-Migrate.rb +32 -26
  22. data/lib/MrMurano/Config.rb +407 -128
  23. data/lib/MrMurano/Content.rb +191 -0
  24. data/lib/MrMurano/Gateway.rb +489 -0
  25. data/lib/MrMurano/Keystore.rb +48 -0
  26. data/lib/MrMurano/Passwords.rb +103 -0
  27. data/lib/MrMurano/ProjectFile.rb +121 -79
  28. data/lib/MrMurano/ReCommander.rb +114 -10
  29. data/lib/MrMurano/Setting.rb +90 -0
  30. data/lib/MrMurano/Solution-ServiceConfig.rb +89 -45
  31. data/lib/MrMurano/Solution-Services.rb +461 -166
  32. data/lib/MrMurano/Solution-Users.rb +70 -31
  33. data/lib/MrMurano/Solution.rb +372 -13
  34. data/lib/MrMurano/SolutionId.rb +73 -0
  35. data/lib/MrMurano/SyncRoot.rb +137 -0
  36. data/lib/MrMurano/SyncUpDown.rb +594 -284
  37. data/lib/MrMurano/Webservice-Cors.rb +71 -0
  38. data/lib/MrMurano/Webservice-Endpoint.rb +234 -0
  39. data/lib/MrMurano/Webservice-File.rb +193 -0
  40. data/lib/MrMurano/Webservice.rb +51 -0
  41. data/lib/MrMurano/commands.rb +18 -15
  42. data/lib/MrMurano/commands/business.rb +300 -6
  43. data/lib/MrMurano/commands/completion-bash.erb +166 -0
  44. data/lib/MrMurano/commands/{zshcomplete.erb → completion-zsh.erb} +0 -0
  45. data/lib/MrMurano/commands/completion.rb +76 -39
  46. data/lib/MrMurano/commands/config.rb +108 -44
  47. data/lib/MrMurano/commands/content.rb +115 -72
  48. data/lib/MrMurano/commands/cors.rb +29 -14
  49. data/lib/MrMurano/commands/devices.rb +286 -0
  50. data/lib/MrMurano/commands/domain.rb +52 -12
  51. data/lib/MrMurano/commands/gb.rb +24 -9
  52. data/lib/MrMurano/commands/globals.rb +64 -0
  53. data/lib/MrMurano/commands/init.rb +377 -155
  54. data/lib/MrMurano/commands/keystore.rb +92 -82
  55. data/lib/MrMurano/commands/link.rb +300 -0
  56. data/lib/MrMurano/commands/login.rb +74 -11
  57. data/lib/MrMurano/commands/logs.rb +63 -32
  58. data/lib/MrMurano/commands/mock.rb +57 -29
  59. data/lib/MrMurano/commands/password.rb +57 -39
  60. data/lib/MrMurano/commands/postgresql.rb +127 -94
  61. data/lib/MrMurano/commands/settings.rb +203 -0
  62. data/lib/MrMurano/commands/show.rb +79 -38
  63. data/lib/MrMurano/commands/solution.rb +423 -5
  64. data/lib/MrMurano/commands/solution_picker.rb +547 -0
  65. data/lib/MrMurano/commands/status.rb +195 -61
  66. data/lib/MrMurano/commands/sync.rb +78 -39
  67. data/lib/MrMurano/commands/timeseries.rb +71 -55
  68. data/lib/MrMurano/commands/tsdb.rb +113 -87
  69. data/lib/MrMurano/commands/usage.rb +57 -15
  70. data/lib/MrMurano/hash.rb +100 -10
  71. data/lib/MrMurano/http.rb +187 -43
  72. data/lib/MrMurano/makePretty.rb +16 -14
  73. data/lib/MrMurano/optparse.rb +2178 -0
  74. data/lib/MrMurano/progress.rb +138 -0
  75. data/lib/MrMurano/schema/resource-v1.0.0.yaml +32 -0
  76. data/lib/MrMurano/template/projectFile.murano.erb +16 -13
  77. data/lib/MrMurano/verbosing.rb +166 -29
  78. data/lib/MrMurano/version.rb +30 -1
  79. data/spec/Account-Passwords_spec.rb +21 -4
  80. data/spec/Account_spec.rb +69 -146
  81. data/spec/Business_spec.rb +290 -0
  82. data/spec/ConfigFile_spec.rb +1 -0
  83. data/spec/ConfigMigrate_spec.rb +12 -8
  84. data/spec/Config_spec.rb +40 -34
  85. data/spec/Content_spec.rb +363 -0
  86. data/spec/GatewayBase_spec.rb +54 -0
  87. data/spec/GatewayDevice_spec.rb +321 -0
  88. data/spec/GatewayResource_spec.rb +266 -0
  89. data/spec/GatewaySettings_spec.rb +120 -0
  90. data/spec/Http_spec.rb +18 -8
  91. data/spec/Mock_spec.rb +2 -2
  92. data/spec/ProjectFile_spec.rb +25 -14
  93. data/spec/Setting_spec.rb +110 -0
  94. data/spec/Solution-ServiceConfig_spec.rb +44 -5
  95. data/spec/Solution-ServiceEventHandler_spec.rb +23 -14
  96. data/spec/Solution-ServiceModules_spec.rb +47 -37
  97. data/spec/Solution-UsersRoles_spec.rb +10 -8
  98. data/spec/Solution_spec.rb +17 -8
  99. data/spec/SyncRoot_spec.rb +46 -20
  100. data/spec/SyncUpDown_spec.rb +437 -201
  101. data/spec/Verbosing_spec.rb +12 -4
  102. data/spec/{Solution-Cors_spec.rb → Webservice-Cors_spec.rb} +23 -20
  103. data/spec/{Solution-Endpoint_spec.rb → Webservice-Endpoint_spec.rb} +43 -41
  104. data/spec/{Solution-File_spec.rb → Webservice-File_spec.rb} +44 -33
  105. data/spec/Webservice-Setting_spec.rb +89 -0
  106. data/spec/_workspace.rb +4 -4
  107. data/spec/cmd_business_spec.rb +9 -4
  108. data/spec/cmd_common.rb +44 -1
  109. data/spec/cmd_content_spec.rb +43 -17
  110. data/spec/cmd_cors_spec.rb +4 -4
  111. data/spec/cmd_device_spec.rb +61 -16
  112. data/spec/cmd_domain_spec.rb +29 -6
  113. data/spec/cmd_init_spec.rb +281 -126
  114. data/spec/cmd_keystore_spec.rb +3 -3
  115. data/spec/cmd_link_spec.rb +98 -0
  116. data/spec/cmd_password_spec.rb +1 -1
  117. data/spec/cmd_setting_application_spec.rb +260 -0
  118. data/spec/cmd_setting_product_spec.rb +220 -0
  119. data/spec/cmd_status_spec.rb +223 -114
  120. data/spec/cmd_syncdown_spec.rb +115 -35
  121. data/spec/cmd_syncup_spec.rb +68 -15
  122. data/spec/cmd_usage_spec.rb +35 -8
  123. data/spec/fixtures/dumped_config +6 -4
  124. data/spec/fixtures/gateway_resource_files/resources.notyaml +12 -0
  125. data/spec/fixtures/gateway_resource_files/resources.yaml +13 -0
  126. data/spec/fixtures/gateway_resource_files/resources_invalid.yaml +13 -0
  127. data/spec/fixtures/mrmuranorc_deleted_bob +0 -2
  128. data/spec/fixtures/product_spec_files/lightbulb.yaml +20 -13
  129. data/spec/fixtures/{syncable_content → syncable_conflict}/services/devdata.lua +1 -1
  130. data/spec/fixtures/{syncable_content → syncable_conflict}/services/timers.lua +0 -0
  131. data/spec/spec_helper.rb +5 -0
  132. metadata +262 -171
  133. data/bin/mr +0 -8
  134. data/lib/MrMurano/Product-1P-Device.rb +0 -145
  135. data/lib/MrMurano/Product-Resources.rb +0 -205
  136. data/lib/MrMurano/Product.rb +0 -358
  137. data/lib/MrMurano/Solution-Cors.rb +0 -47
  138. data/lib/MrMurano/Solution-Endpoint.rb +0 -191
  139. data/lib/MrMurano/Solution-File.rb +0 -166
  140. data/lib/MrMurano/commands/assign.rb +0 -57
  141. data/lib/MrMurano/commands/businessList.rb +0 -45
  142. data/lib/MrMurano/commands/product.rb +0 -14
  143. data/lib/MrMurano/commands/productCreate.rb +0 -39
  144. data/lib/MrMurano/commands/productDelete.rb +0 -33
  145. data/lib/MrMurano/commands/productDevice.rb +0 -87
  146. data/lib/MrMurano/commands/productDeviceIdCmds.rb +0 -89
  147. data/lib/MrMurano/commands/productList.rb +0 -45
  148. data/lib/MrMurano/commands/productWrite.rb +0 -27
  149. data/lib/MrMurano/commands/solutionCreate.rb +0 -41
  150. data/lib/MrMurano/commands/solutionDelete.rb +0 -34
  151. data/lib/MrMurano/commands/solutionList.rb +0 -45
  152. data/spec/ProductBase_spec.rb +0 -113
  153. data/spec/ProductContent_spec.rb +0 -162
  154. data/spec/ProductResources_spec.rb +0 -329
  155. data/spec/Product_1P_Device_spec.rb +0 -202
  156. data/spec/Product_1P_RPC_spec.rb +0 -175
  157. data/spec/Product_spec.rb +0 -153
  158. data/spec/Solution-ServiceDevice_spec.rb +0 -176
  159. data/spec/cmd_assign_spec.rb +0 -51
@@ -1,24 +1,31 @@
1
+ require 'tempfile'
1
2
  require 'MrMurano/version'
3
+ require 'MrMurano/ProjectFile'
2
4
  require 'MrMurano/Solution-ServiceConfig'
3
- require 'tempfile'
5
+ require 'MrMurano/SyncRoot'
4
6
  require '_workspace'
5
7
 
6
8
  RSpec.describe MrMurano::ServiceConfig do
7
9
  include_context "WORKSPACE"
8
10
  before(:example) do
11
+ MrMurano::SyncRoot.instance.reset
9
12
  $cfg = MrMurano::Config.new
10
13
  $cfg.load
11
14
  $project = MrMurano::ProjectFile.new
12
15
  $project.load
13
16
  $cfg['net.host'] = 'bizapi.hosted.exosite.io'
14
- $cfg['solution.id'] = 'XYZ'
17
+ # serviceconfig works on all solution types.
18
+ $cfg['product.id'] = 'XYZ'
19
+ $cfg['application.id'] = 'XYZ'
15
20
 
16
- @srv = MrMurano::ServiceConfig.new
21
+ # ServiceConfig needs an sid, else one could instantiate
22
+ # ServiceConfigApplication or ServiceConfigProduct.
23
+ @srv = MrMurano::ServiceConfig.new('XYZ')
17
24
  allow(@srv).to receive(:token).and_return("TTTTTTTTTT")
18
25
  end
19
26
 
20
27
  it "initializes" do
21
- uri = @srv.endPoint('/')
28
+ uri = @srv.endpoint('/')
22
29
  expect(uri.to_s).to eq("https://bizapi.hosted.exosite.io/api:1/solution/XYZ/serviceconfig/")
23
30
  end
24
31
 
@@ -38,7 +45,7 @@ RSpec.describe MrMurano::ServiceConfig do
38
45
  'Content-Type'=>'application/json'}).
39
46
  to_return(body: body.to_json)
40
47
 
41
- ret = @srv.list()
48
+ ret = @srv.list
42
49
  expect(ret).to eq(body[:items])
43
50
  end
44
51
 
@@ -61,6 +68,38 @@ RSpec.describe MrMurano::ServiceConfig do
61
68
  expect(ret).to eq(body)
62
69
  end
63
70
 
71
+ it "creates" do
72
+ body = {:id=>"9K0",
73
+ :name=>"debug",
74
+ :alias=>"XYZ_debug",
75
+ :solution_id=>"XYZ",
76
+ :service=>"device",
77
+ :status=>"ready",
78
+ :created_at=>"2016-07-07T19:16:19.479Z",
79
+ :updated_at=>"2016-09-12T13:26:55.868Z"
80
+ }
81
+ # VERIFY/2017-07-03: Does this POST now need a trailing path delimiter?
82
+ #stub_request(:post, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/serviceconfig").
83
+ stub_request(:post, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/serviceconfig/").
84
+ with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
85
+ 'Content-Type'=>'application/json'}).
86
+ to_return(body: body.to_json)
87
+
88
+ ret = @srv.create('p4q0m2ruyoxierh')
89
+ expect(ret).to eq(body)
90
+ end
91
+
92
+ it "removes" do
93
+ body = {}
94
+ stub_request(:delete, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/serviceconfig/9K0").
95
+ with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
96
+ 'Content-Type'=>'application/json'}).
97
+ to_return(body: body.to_json)
98
+
99
+ ret = @srv.remove('9K0')
100
+ expect(ret).to eq(body)
101
+ end
102
+
64
103
  it "gets id from service" do
65
104
  body = {:items=>[{:id=>"9K0",
66
105
  :name=>"debug",
@@ -1,6 +1,7 @@
1
+ require 'tempfile'
1
2
  require 'MrMurano/version'
3
+ require 'MrMurano/ProjectFile'
2
4
  require 'MrMurano/Solution-Services'
3
- require 'tempfile'
4
5
  require '_workspace'
5
6
 
6
7
  RSpec.describe MrMurano::EventHandler do
@@ -11,14 +12,20 @@ RSpec.describe MrMurano::EventHandler do
11
12
  $project = MrMurano::ProjectFile.new
12
13
  $project.load
13
14
  $cfg['net.host'] = 'bizapi.hosted.exosite.io'
14
- $cfg['solution.id'] = 'XYZ'
15
-
16
- @srv = MrMurano::EventHandler.new
15
+ $cfg['application.id'] = 'XYZ'
16
+
17
+ # 2017-06-23: EventHandler is an intermediate class now, and we
18
+ # cannot use it because its @project_section is not defined.
19
+ #@srv = MrMurano::EventHandler.new
20
+ # It shouldn't matter which final event handler class we use:
21
+ # the only different is if it uses application.id or product.id.
22
+ @srv = MrMurano::EventHandlerSolnApp.new
23
+ #@srv = MrMurano::EventHandlerSolnPrd.new
17
24
  allow(@srv).to receive(:token).and_return("TTTTTTTTTT")
18
25
  end
19
26
 
20
27
  it "initializes" do
21
- uri = @srv.endPoint('/')
28
+ uri = @srv.endpoint('/')
22
29
  expect(uri.to_s).to eq("https://bizapi.hosted.exosite.io/api:1/solution/XYZ/eventhandler/")
23
30
  end
24
31
 
@@ -37,7 +44,7 @@ RSpec.describe MrMurano::EventHandler do
37
44
  'Content-Type'=>'application/json'}).
38
45
  to_return(body: body.to_json)
39
46
 
40
- ret = @srv.list()
47
+ ret = @srv.list
41
48
  expect(ret).to eq(body[:items])
42
49
  end
43
50
 
@@ -268,30 +275,30 @@ end
268
275
 
269
276
  it "raises on alias without service" do
270
277
  expect {
271
- @srv.mkname( MrMurano::EventHandler::EventHandlerItem.new(:event=>'bob') )
278
+ @srv.mkname(MrMurano::EventHandler::EventHandlerItem.new(:event=>'bob'))
272
279
  }.to raise_error %{Missing parts! {"event":"bob"}}
273
280
  end
274
281
 
275
282
  it "raises on alias without event" do
276
283
  expect {
277
- @srv.mkalias( MrMurano::EventHandler::EventHandlerItem.new(:service=>'bob') )
284
+ @srv.mkalias(MrMurano::EventHandler::EventHandlerItem.new(:service=>'bob'))
278
285
  }.to raise_error %{Missing parts! {"service":"bob"}}
279
286
  end
280
287
 
281
288
  it "raises on name without service" do
282
289
  expect {
283
- @srv.mkalias( MrMurano::EventHandler::EventHandlerItem.new(:event=>'bob') )
290
+ @srv.mkalias(MrMurano::EventHandler::EventHandlerItem.new(:event=>'bob'))
284
291
  }.to raise_error %{Missing parts! {"event":"bob"}}
285
292
  end
286
293
 
287
294
  it "raises on name without event" do
288
295
  expect {
289
- @srv.mkname( MrMurano::EventHandler::EventHandlerItem.new(:service=>'bob') )
296
+ @srv.mkname(MrMurano::EventHandler::EventHandlerItem.new(:service=>'bob'))
290
297
  }.to raise_error %{Missing parts! {"service":"bob"}}
291
298
  end
292
299
  end
293
300
 
294
- context "toRemoteItem" do
301
+ context "to_remote_item" do
295
302
  before(:example) do
296
303
  allow(@srv).to receive(:warning)
297
304
  end
@@ -304,9 +311,10 @@ end
304
311
  }.gsub(/^\s+/,'')
305
312
  tio.close
306
313
 
307
- ret = @srv.toRemoteItem(nil, tio.path)
314
+ ret = @srv.to_remote_item(nil, tio.path)
308
315
  expect(ret).to eq({:service=>'device',
309
316
  :event=>'datapoint',
317
+ :type=>nil,
310
318
  :line=>0,
311
319
  :line_end=>3,
312
320
  :local_path=>Pathname.new(tio.path),
@@ -323,7 +331,7 @@ end
323
331
  }.gsub(/^\s+/,'')
324
332
  tio.close
325
333
 
326
- ret = @srv.toRemoteItem(nil, tio.path)
334
+ ret = @srv.to_remote_item(nil, tio.path)
327
335
  expect(ret).to eq(nil)
328
336
  end
329
337
  end
@@ -337,11 +345,12 @@ end
337
345
  }.gsub(/^\s+/,'')
338
346
  tio.close
339
347
 
340
- ret = @srv.toRemoteItem(nil, tio.path)
348
+ ret = @srv.to_remote_item(nil, tio.path)
341
349
  expect(ret).to eq(
342
350
  MrMurano::EventHandler::EventHandlerItem.new(
343
351
  :service=>'device',
344
352
  :event=>'datapoint',
353
+ :type=>nil,
345
354
  :line=>1,
346
355
  :line_end=>3,
347
356
  :local_path=>Pathname.new(tio.path),
@@ -1,9 +1,10 @@
1
+ require 'tempfile'
1
2
  require 'MrMurano/version'
3
+ require 'MrMurano/ProjectFile'
2
4
  require 'MrMurano/Solution-Services'
3
- require 'tempfile'
4
5
  require '_workspace'
5
6
 
6
- RSpec.describe MrMurano::Library do
7
+ RSpec.describe MrMurano::Module do
7
8
  include_context "WORKSPACE"
8
9
  before(:example) do
9
10
  $cfg = MrMurano::Config.new
@@ -11,15 +12,15 @@ RSpec.describe MrMurano::Library do
11
12
  $project = MrMurano::ProjectFile.new
12
13
  $project.load
13
14
  $cfg['net.host'] = 'bizapi.hosted.exosite.io'
14
- $cfg['solution.id'] = 'XYZ'
15
+ $cfg['application.id'] = 'XYZ'
15
16
 
16
- @srv = MrMurano::Library.new
17
+ @srv = MrMurano::Module.new
17
18
  allow(@srv).to receive(:token).and_return("TTTTTTTTTT")
18
19
  end
19
20
 
20
21
  it "initializes" do
21
- uri = @srv.endPoint('/')
22
- expect(uri.to_s).to eq("https://bizapi.hosted.exosite.io/api:1/solution/XYZ/library/")
22
+ uri = @srv.endpoint('/')
23
+ expect(uri.to_s).to eq("https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/")
23
24
  end
24
25
 
25
26
  it "lists" do
@@ -30,12 +31,12 @@ RSpec.describe MrMurano::Library do
30
31
  :created_at=>"2016-07-07T19:16:19.479Z",
31
32
  :updated_at=>"2016-09-12T13:26:55.868Z"}],
32
33
  :total=>1}
33
- stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/library").
34
+ stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module").
34
35
  with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
35
36
  'Content-Type'=>'application/json'}).
36
37
  to_return(body: body.to_json)
37
38
 
38
- ret = @srv.list()
39
+ ret = @srv.list
39
40
  expect(ret).to eq(body[:items])
40
41
  end
41
42
 
@@ -53,7 +54,7 @@ RSpec.describe MrMurano::Library do
53
54
  end
54
55
  }
55
56
  }
56
- stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/library/9K0").
57
+ stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0").
57
58
  with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
58
59
  'Content-Type'=>'application/json'}).
59
60
  to_return(body: body.to_json)
@@ -75,7 +76,7 @@ RSpec.describe MrMurano::Library do
75
76
  end
76
77
  }
77
78
  }
78
- stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/library/9K0").
79
+ stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0").
79
80
  with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
80
81
  'Content-Type'=>'application/json'}).
81
82
  to_return(body: body.to_json)
@@ -93,7 +94,7 @@ RSpec.describe MrMurano::Library do
93
94
  :created_at=>"2016-07-07T19:16:19.479Z",
94
95
  :updated_at=>"2016-09-12T13:26:55.868Z",
95
96
  }
96
- stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/library/9K0").
97
+ stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0").
97
98
  with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
98
99
  'Content-Type'=>'application/json'}).
99
100
  to_return(body: body.to_json)
@@ -103,7 +104,7 @@ RSpec.describe MrMurano::Library do
103
104
  end
104
105
 
105
106
  it "Displays error if wrong result type" do
106
- stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/library/9K0").
107
+ stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0").
107
108
  with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
108
109
  'Content-Type'=>'application/json'}).
109
110
  to_return(body: "this isn't what we expected")
@@ -112,13 +113,15 @@ RSpec.describe MrMurano::Library do
112
113
  $stderr = StringIO.new
113
114
  ret = @srv.fetch('9K0')
114
115
  expect(ret).to eq('')
115
- expect($stderr.string).to eq(%{\e[31mUnexpected result type, assuming empty instead: this isn't what we expected\e[0m\n})
116
+ expect($stderr.string).to start_with(
117
+ %{\e[31m#{MrMurano::SolutionId::UNEXPECTED_TYPE_OR_ERROR_MSG}}
118
+ )
116
119
  $stderr = saved
117
120
  end
118
121
  end
119
122
 
120
123
  it "removes" do
121
- stub_request(:delete, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/library/9K0").
124
+ stub_request(:delete, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/9K0").
122
125
  with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
123
126
  'Content-Type'=>'application/json'}).
124
127
  to_return(body: "")
@@ -129,7 +132,7 @@ RSpec.describe MrMurano::Library do
129
132
 
130
133
  context "uploads" do
131
134
  it "over old version" do
132
- stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/library/XYZ_debug").
135
+ stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug").
133
136
  with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
134
137
  'Content-Type'=>'application/json'}).
135
138
  to_return(body: "")
@@ -143,7 +146,7 @@ RSpec.describe MrMurano::Library do
143
146
  tio.close
144
147
 
145
148
  ret = @srv.upload(tio.path,
146
- MrMurano::Library::LibraryItem.new(
149
+ MrMurano::Module::ModuleItem.new(
147
150
  :id=>"9K0",
148
151
  :name=>"debug",
149
152
  :alias=>"XYZ_debug",
@@ -154,11 +157,11 @@ RSpec.describe MrMurano::Library do
154
157
  end
155
158
 
156
159
  it "when nothing is there" do
157
- stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/library/XYZ_debug").
160
+ stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug").
158
161
  with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
159
162
  'Content-Type'=>'application/json'}).
160
163
  to_return(status: 404)
161
- stub_request(:post, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/library/").
164
+ stub_request(:post, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/").
162
165
  with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
163
166
  'Content-Type'=>'application/json'}).
164
167
  to_return(body: "")
@@ -173,7 +176,7 @@ RSpec.describe MrMurano::Library do
173
176
 
174
177
  ret = @srv.upload(
175
178
  tio.path,
176
- MrMurano::Library::LibraryItem.new(
179
+ MrMurano::Module::ModuleItem.new(
177
180
  :id=>"9K0",
178
181
  :name=>"debug",
179
182
  :alias=>"XYZ_debug",
@@ -184,7 +187,7 @@ RSpec.describe MrMurano::Library do
184
187
  end
185
188
 
186
189
  it "shows other errors" do
187
- stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/library/XYZ_debug").
190
+ stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug").
188
191
  with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
189
192
  'Content-Type'=>'application/json'}).
190
193
  to_return(status: 418, body: %{{"teapot":true}})
@@ -199,7 +202,7 @@ RSpec.describe MrMurano::Library do
199
202
 
200
203
  expect(@srv).to receive(:error).and_return(nil)
201
204
  ret = @srv.upload(tio.path,
202
- MrMurano::Library::LibraryItem.new(
205
+ MrMurano::Module::ModuleItem.new(
203
206
  :id=>"9K0",
204
207
  :name=>"debug",
205
208
  :alias=>"XYZ_debug",
@@ -210,7 +213,7 @@ RSpec.describe MrMurano::Library do
210
213
  end
211
214
 
212
215
  it "over old version; replacing cache miss" do
213
- stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/library/XYZ_debug").
216
+ stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug").
214
217
  with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
215
218
  'Content-Type'=>'application/json'}).
216
219
  to_return(body: "")
@@ -223,10 +226,10 @@ RSpec.describe MrMurano::Library do
223
226
  }
224
227
  tio.close
225
228
 
226
- cacheFile = $cfg.file_at(@srv.cacheFileName)
229
+ cacheFile = $cfg.file_at(@srv.cache_file_name)
227
230
  FileUtils.touch(cacheFile.to_path)
228
231
  ret = @srv.upload(tio.path,
229
- MrMurano::Library::LibraryItem.new(
232
+ MrMurano::Module::ModuleItem.new(
230
233
  :id=>"9K0",
231
234
  :name=>"debug",
232
235
  :alias=>"XYZ_debug",
@@ -237,7 +240,7 @@ RSpec.describe MrMurano::Library do
237
240
  end
238
241
 
239
242
  it "over old version; replacing cache hit" do
240
- stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/library/XYZ_debug").
243
+ stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/module/XYZ_debug").
241
244
  with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
242
245
  'Content-Type'=>'application/json'}).
243
246
  to_return(body: "")
@@ -250,14 +253,14 @@ RSpec.describe MrMurano::Library do
250
253
  }
251
254
  tio.close
252
255
 
253
- cacheFile = $cfg.file_at(@srv.cacheFileName)
256
+ cacheFile = $cfg.file_at(@srv.cache_file_name)
254
257
  cacheFile.open('w') do |cfio|
255
258
  cfio << {tio.path=>{:sha1=>"6",
256
259
  :updated_at=>Time.now.getutc.to_datetime.iso8601(3)}
257
260
  }.to_yaml
258
261
  end
259
262
  ret = @srv.upload(tio.path,
260
- MrMurano::Library::LibraryItem.new(
263
+ MrMurano::Module::ModuleItem.new(
261
264
  :id=>"9K0",
262
265
  :name=>"debug",
263
266
  :alias=>"XYZ_debug",
@@ -306,7 +309,7 @@ RSpec.describe MrMurano::Library do
306
309
  end
307
310
 
308
311
  it "cache miss" do
309
- cacheFile = $cfg.file_at(@srv.cacheFileName)
312
+ cacheFile = $cfg.file_at(@srv.cache_file_name)
310
313
  FileUtils.touch(cacheFile.to_path)
311
314
  Tempfile.open('foo') do |tio|
312
315
  tio << "something"
@@ -324,7 +327,7 @@ RSpec.describe MrMurano::Library do
324
327
  end
325
328
 
326
329
  it "cache hit" do
327
- cacheFile = $cfg.file_at(@srv.cacheFileName)
330
+ cacheFile = $cfg.file_at(@srv.cache_file_name)
328
331
  Tempfile.open('foo') do |tio|
329
332
  tio << "something"
330
333
  tio.close
@@ -370,7 +373,7 @@ RSpec.describe MrMurano::Library do
370
373
  end
371
374
 
372
375
  it "cache miss" do
373
- cacheFile = $cfg.file_at(@srv.cacheFileName)
376
+ cacheFile = $cfg.file_at(@srv.cache_file_name)
374
377
  FileUtils.touch(cacheFile.to_path)
375
378
  Tempfile.open('foo') do |tio|
376
379
  tio << "something"
@@ -388,7 +391,7 @@ RSpec.describe MrMurano::Library do
388
391
  end
389
392
 
390
393
  it "cache hit" do
391
- cacheFile = $cfg.file_at(@srv.cacheFileName)
394
+ cacheFile = $cfg.file_at(@srv.cache_file_name)
392
395
  Tempfile.open('foo') do |tio|
393
396
  tio << "something"
394
397
  tio.close
@@ -442,22 +445,29 @@ RSpec.describe MrMurano::Library do
442
445
 
443
446
  it "raises on alias without name" do
444
447
  expect {
445
- @srv.mkname( MrMurano::Library::EventHandlerItem.new() )
448
+ @srv.mkname(MrMurano::Module::EventHandlerItem.new())
446
449
  }.to raise_error(NameError)
447
450
  end
448
451
 
449
452
  it "raises on name without name" do
450
453
  expect {
451
- @srv.mkalias( MrMurano::Library::EventHandlerItem.new() )
454
+ @srv.mkalias(MrMurano::Module::EventHandlerItem.new())
452
455
  }.to raise_error(NameError)
453
456
  end
454
457
  end
455
458
 
456
- context "toRemoteItem" do
459
+ context "to_remote_item" do
457
460
  it "reads one" do
458
- path = Pathname.new(@projectDir) + 'test.lua'
459
- ret = @srv.toRemoteItem(nil, path)
460
- expect(ret).to eq({:name=>'test'})
461
+ root = Pathname.new(@project_dir)
462
+ path = Pathname.new(@project_dir) + 'test.lua'
463
+ ret = @srv.to_remote_item(root, path)
464
+ expect(ret).to eq(name: 'test')
465
+ end
466
+ it "reads sub folder one" do
467
+ root = Pathname.new(@project_dir)
468
+ path = Pathname.new(@project_dir) + 'src/test.lua'
469
+ ret = @srv.to_remote_item(root, path)
470
+ expect(ret).to eq(name: 'src.test')
461
471
  end
462
472
  end
463
473
  end