MrMurano 1.4.3 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile +1 -0
  4. data/MrMurano.gemspec +4 -0
  5. data/README.markdown +84 -0
  6. data/Rakefile +4 -3
  7. data/TODO.taskpaper +9 -9
  8. data/bin/mr +2 -0
  9. data/lib/MrMurano/Account.rb +4 -55
  10. data/lib/MrMurano/{configFile.rb → Config.rb} +60 -10
  11. data/lib/MrMurano/Product.rb +16 -4
  12. data/lib/MrMurano/Solution-Endpoint.rb +3 -3
  13. data/lib/MrMurano/Solution-File.rb +4 -10
  14. data/lib/MrMurano/Solution-ServiceConfig.rb +1 -52
  15. data/lib/MrMurano/Solution-Services.rb +44 -8
  16. data/lib/MrMurano/Solution-Users.rb +2 -2
  17. data/lib/MrMurano/Solution.rb +3 -0
  18. data/lib/MrMurano/commands/account.rb +54 -0
  19. data/lib/MrMurano/commands/assign.rb +54 -0
  20. data/lib/MrMurano/{configCommand.rb → commands/config.rb} +0 -0
  21. data/lib/MrMurano/{contentCommand.rb → commands/content.rb} +0 -0
  22. data/lib/MrMurano/{cors.rb → commands/cors.rb} +0 -0
  23. data/lib/MrMurano/commands/domain.rb +17 -0
  24. data/lib/MrMurano/{exportImport.rb → commands/exportImport.rb} +32 -15
  25. data/lib/MrMurano/{keystore.rb → commands/keystore.rb} +0 -0
  26. data/lib/MrMurano/{logs.rb → commands/logs.rb} +0 -0
  27. data/lib/MrMurano/commands/productSpec.rb +94 -0
  28. data/lib/MrMurano/{status.rb → commands/status.rb} +0 -0
  29. data/lib/MrMurano/{sync.rb → commands/sync.rb} +0 -0
  30. data/lib/MrMurano/{timeseries.rb → commands/timeseries.rb} +0 -0
  31. data/lib/MrMurano/commands.rb +14 -0
  32. data/lib/MrMurano/http.rb +24 -3
  33. data/lib/MrMurano/version.rb +1 -1
  34. data/lib/MrMurano.rb +9 -17
  35. data/spec/Account-Passwords_spec.rb +2 -11
  36. data/spec/ConfigFile_spec.rb +48 -0
  37. data/spec/Config_spec.rb +329 -0
  38. data/spec/ProductBase_spec.rb +0 -3
  39. data/spec/ProductContent_spec.rb +0 -3
  40. data/spec/Product_spec.rb +0 -3
  41. data/spec/Solution-ServiceEventHandler_spec.rb +217 -0
  42. data/spec/Solution-ServiceModules_spec.rb +177 -0
  43. data/spec/testfiles/configfile +9 -0
  44. metadata +42 -14
  45. data/lib/MrMurano/shelledCommand.rb +0 -43
@@ -0,0 +1,177 @@
1
+ require 'MrMurano/version'
2
+ require 'MrMurano/Solution-Services'
3
+ require 'tempfile'
4
+
5
+ RSpec.describe MrMurano::Library do
6
+ before(:example) do
7
+ $cfg = MrMurano::Config.new
8
+ $cfg.load
9
+ $cfg['net.host'] = 'bizapi.hosted.exosite.io'
10
+ $cfg['solution.id'] = 'XYZ'
11
+
12
+ @srv = MrMurano::Library.new
13
+ allow(@srv).to receive(:token).and_return("TTTTTTTTTT")
14
+ end
15
+
16
+ it "initializes" do
17
+ uri = @srv.endPoint('/')
18
+ expect(uri.to_s).to eq("https://bizapi.hosted.exosite.io/api:1/solution/XYZ/library/")
19
+ end
20
+
21
+ it "lists" do
22
+ body = {:items=>[{:id=>"9K0",
23
+ :name=>"debug",
24
+ :alias=>"XYZ_debug",
25
+ :solution_id=>"XYZ",
26
+ :created_at=>"2016-07-07T19:16:19.479Z",
27
+ :updated_at=>"2016-09-12T13:26:55.868Z"}],
28
+ :total=>1}
29
+ stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/library").
30
+ with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
31
+ 'Content-Type'=>'application/json'}).
32
+ to_return(body: body.to_json)
33
+
34
+ ret = @srv.list()
35
+ expect(ret).to eq(body[:items])
36
+ end
37
+
38
+ it "fetches" do
39
+ body = {:id=>"9K0",
40
+ :name=>"debug",
41
+ :alias=>"XYZ_debug",
42
+ :solution_id=>"XYZ",
43
+ :created_at=>"2016-07-07T19:16:19.479Z",
44
+ :updated_at=>"2016-09-12T13:26:55.868Z",
45
+ :script=>%{-- lua code is here
46
+ function foo(bar)
47
+ return bar + 1
48
+ end
49
+ }
50
+ }
51
+ stub_request(:get, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/library/9K0").
52
+ with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
53
+ 'Content-Type'=>'application/json'}).
54
+ to_return(body: body.to_json)
55
+
56
+ ret = @srv.fetch('9K0')
57
+ expect(ret).to eq(body[:script])
58
+ end
59
+
60
+ it "removes" do
61
+ stub_request(:delete, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/library/9K0").
62
+ with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
63
+ 'Content-Type'=>'application/json'}).
64
+ to_return(body: "")
65
+
66
+ ret = @srv.remove('9K0')
67
+ expect(ret).to eq({})
68
+ end
69
+
70
+ it "uploads over old version" do
71
+ stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/library/XYZ_debug").
72
+ with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
73
+ 'Content-Type'=>'application/json'}).
74
+ to_return(body: "")
75
+
76
+ Tempfile.open('foo') do |tio|
77
+ tio << %{-- lua code is here
78
+ function foo(bar)
79
+ return bar + 1
80
+ end
81
+ }
82
+ tio.close
83
+
84
+ ret = @srv.upload(tio.path, {:id=>"9K0",
85
+ :name=>"debug",
86
+ :alias=>"XYZ_debug",
87
+ :solution_id=>"XYZ",
88
+ })
89
+ expect(ret)
90
+ end
91
+ end
92
+
93
+ it "uploads when nothing is there" do
94
+ stub_request(:put, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/library/XYZ_debug").
95
+ with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
96
+ 'Content-Type'=>'application/json'}).
97
+ to_return(status: 404)
98
+ stub_request(:post, "https://bizapi.hosted.exosite.io/api:1/solution/XYZ/library/").
99
+ with(:headers=>{'Authorization'=>'token TTTTTTTTTT',
100
+ 'Content-Type'=>'application/json'}).
101
+ to_return(body: "")
102
+
103
+ Tempfile.open('foo') do |tio|
104
+ tio << %{-- lua code is here
105
+ function foo(bar)
106
+ return bar + 1
107
+ end
108
+ }
109
+ tio.close
110
+
111
+ ret = @srv.upload(tio.path, {:id=>"9K0",
112
+ :name=>"debug",
113
+ :alias=>"XYZ_debug",
114
+ :solution_id=>"XYZ",
115
+ })
116
+ expect(ret)
117
+ end
118
+
119
+ end
120
+
121
+ context "compares" do
122
+ before(:example) do
123
+ @iA = {:id=>"9K0",
124
+ :name=>"debug",
125
+ :alias=>"XYZ_debug",
126
+ :solution_id=>"XYZ",
127
+ :created_at=>"2016-07-07T19:16:19.479Z",
128
+ :updated_at=>"2016-09-12T13:26:55.868Z"}
129
+ @iB = {:id=>"9K0",
130
+ :name=>"debug",
131
+ :alias=>"XYZ_debug",
132
+ :solution_id=>"XYZ",
133
+ :created_at=>"2016-07-07T19:16:19.479Z",
134
+ :updated_at=>"2016-09-12T13:26:55.868Z"}
135
+ end
136
+ it "both have updated_at" do
137
+ ret = @srv.docmp(@iA, @iB)
138
+ expect(ret).to eq(false)
139
+ end
140
+
141
+ it "iA is a local file" do
142
+ Tempfile.open('foo') do |tio|
143
+ tio << "something"
144
+ tio.close
145
+ iA = @iA.reject{|k,v| k == :updated_at}.merge({
146
+ :local_path => Pathname.new(tio.path)
147
+ })
148
+ ret = @srv.docmp(iA, @iB)
149
+ expect(ret).to eq(true)
150
+
151
+ iB = @iB.merge({:updated_at=>Pathname.new(tio.path).mtime.getutc})
152
+ ret = @srv.docmp(iA, iB)
153
+ expect(ret).to eq(false)
154
+ end
155
+ end
156
+
157
+ it "iB is a local file" do
158
+ Tempfile.open('foo') do |tio|
159
+ tio << "something"
160
+ tio.close
161
+ iB = @iB.reject{|k,v| k == :updated_at}.merge({
162
+ :local_path => Pathname.new(tio.path)
163
+ })
164
+ ret = @srv.docmp(@iA, iB)
165
+ expect(ret).to eq(true)
166
+
167
+ iA = @iA.merge({:updated_at=>Pathname.new(tio.path).mtime.getutc})
168
+ ret = @srv.docmp(iA, iB)
169
+ expect(ret).to eq(false)
170
+ end
171
+ end
172
+ end
173
+
174
+ # TODO: status tests
175
+
176
+ end
177
+ # vim: set ai et sw=2 ts=2 :
@@ -0,0 +1,9 @@
1
+ [solution]
2
+ id = XXXXXXXXXX
3
+
4
+ [test]
5
+ bob = build
6
+
7
+ [s-fDEADBEEFGAEG]
8
+ spec = bobo.yaml
9
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: MrMurano
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.3
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Conrad Tadpol Tilstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-23 00:00:00.000000000 Z
11
+ date: 2016-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ~>
109
109
  - !ruby/object:Gem::Version
110
110
  version: 2.1.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: dotenv
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 2.1.1
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: 2.1.1
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: bundler
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -166,7 +180,7 @@ dependencies:
166
180
  version: 2.1.0
167
181
  description: "Do more from the command line with Murano\n\n Push and pull data from
168
182
  Murano.\n Get status on what things have changed.\n See a diff of the changes
169
- before you push.\n "
183
+ before you push.\n\n and so much more.\n "
170
184
  email:
171
185
  - tadpol@tadpol.org
172
186
  executables:
@@ -185,6 +199,7 @@ files:
185
199
  - bin/mr
186
200
  - lib/MrMurano.rb
187
201
  - lib/MrMurano/Account.rb
202
+ - lib/MrMurano/Config.rb
188
203
  - lib/MrMurano/Product.rb
189
204
  - lib/MrMurano/Solution-Endpoint.rb
190
205
  - lib/MrMurano/Solution-File.rb
@@ -192,27 +207,35 @@ files:
192
207
  - lib/MrMurano/Solution-Services.rb
193
208
  - lib/MrMurano/Solution-Users.rb
194
209
  - lib/MrMurano/Solution.rb
195
- - lib/MrMurano/configCommand.rb
196
- - lib/MrMurano/configFile.rb
197
- - lib/MrMurano/contentCommand.rb
198
- - lib/MrMurano/cors.rb
199
- - lib/MrMurano/exportImport.rb
210
+ - lib/MrMurano/commands.rb
211
+ - lib/MrMurano/commands/account.rb
212
+ - lib/MrMurano/commands/assign.rb
213
+ - lib/MrMurano/commands/config.rb
214
+ - lib/MrMurano/commands/content.rb
215
+ - lib/MrMurano/commands/cors.rb
216
+ - lib/MrMurano/commands/domain.rb
217
+ - lib/MrMurano/commands/exportImport.rb
218
+ - lib/MrMurano/commands/keystore.rb
219
+ - lib/MrMurano/commands/logs.rb
220
+ - lib/MrMurano/commands/productSpec.rb
221
+ - lib/MrMurano/commands/status.rb
222
+ - lib/MrMurano/commands/sync.rb
223
+ - lib/MrMurano/commands/timeseries.rb
200
224
  - lib/MrMurano/hash.rb
201
225
  - lib/MrMurano/http.rb
202
- - lib/MrMurano/keystore.rb
203
- - lib/MrMurano/logs.rb
204
- - lib/MrMurano/shelledCommand.rb
205
- - lib/MrMurano/status.rb
206
- - lib/MrMurano/sync.rb
207
- - lib/MrMurano/timeseries.rb
208
226
  - lib/MrMurano/verbosing.rb
209
227
  - lib/MrMurano/version.rb
210
228
  - spec/Account-Passwords_spec.rb
229
+ - spec/ConfigFile_spec.rb
230
+ - spec/Config_spec.rb
211
231
  - spec/ProductBase_spec.rb
212
232
  - spec/ProductContent_spec.rb
213
233
  - spec/Product_spec.rb
234
+ - spec/Solution-ServiceEventHandler_spec.rb
235
+ - spec/Solution-ServiceModules_spec.rb
214
236
  - spec/lightbulb.yaml
215
237
  - spec/spec_helper.rb
238
+ - spec/testfiles/configfile
216
239
  homepage: https://github.com/tadpol/MrMurano
217
240
  licenses:
218
241
  - MIT
@@ -239,8 +262,13 @@ specification_version: 4
239
262
  summary: Do more from the command line with Murano
240
263
  test_files:
241
264
  - spec/Account-Passwords_spec.rb
265
+ - spec/ConfigFile_spec.rb
266
+ - spec/Config_spec.rb
242
267
  - spec/ProductBase_spec.rb
243
268
  - spec/ProductContent_spec.rb
244
269
  - spec/Product_spec.rb
270
+ - spec/Solution-ServiceEventHandler_spec.rb
271
+ - spec/Solution-ServiceModules_spec.rb
245
272
  - spec/lightbulb.yaml
246
273
  - spec/spec_helper.rb
274
+ - spec/testfiles/configfile
@@ -1,43 +0,0 @@
1
- require 'pp'
2
-
3
- # XXX This might not work as a command. May need to be a level deeper.
4
- command :shelled do |c|
5
- c.syntax = %{mr <?...> }
6
- c.summary = %{Search the PATHs for a subcommand.}
7
-
8
- c.action do |args, options|
9
- # we are looking for a command in PATH that is longest match to args.
10
- pp args
11
- pp options.inspect
12
-
13
- places = ENV['PATH'].split(':').map {|p| Pathname.new(p)}
14
- pp places
15
-
16
- exit 9
17
- names = args
18
- args = []
19
- while names.count > 0
20
- test = names.join('-')
21
-
22
- places.each do |bindir|
23
- if (bindir + test).exist? then
24
- # Found it.
25
- # TODO: setup ENV
26
-
27
- options.each_pair do |opt,val|
28
- # This could be so much smarter.
29
- args.push "--#{opt}=#{val}"
30
- end
31
- exec (bindir+test).path, *args
32
-
33
- end
34
- end
35
-
36
- args.push names.pop
37
- end
38
-
39
- end
40
-
41
- end
42
-
43
- # vim: set ai et sw=2 ts=2 :