MrMurano 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/MrMurano.rb +14 -12
- data/lib/MrMurano/Account.rb +3 -53
- data/lib/MrMurano/{configFile.rb → Config.rb} +0 -0
- data/lib/MrMurano/Product.rb +2 -0
- data/lib/MrMurano/Solution-Endpoint.rb +1 -0
- data/lib/MrMurano/Solution-File.rb +1 -0
- data/lib/MrMurano/Solution-ServiceConfig.rb +1 -52
- data/lib/MrMurano/Solution-Services.rb +1 -0
- data/lib/MrMurano/Solution-Users.rb +1 -0
- data/lib/MrMurano/Solution.rb +3 -0
- data/lib/MrMurano/accountCommand.rb +54 -0
- data/lib/MrMurano/assignCommand.rb +54 -0
- data/lib/MrMurano/exportImport.rb +30 -13
- data/lib/MrMurano/version.rb +1 -1
- data/spec/Account-Passwords_spec.rb +14 -11
- data/spec/ProductBase_spec.rb +0 -3
- data/spec/ProductContent_spec.rb +0 -3
- data/spec/Product_spec.rb +0 -3
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20574af6b6ff5b2c2260cba7d436aa46599cc691
|
4
|
+
data.tar.gz: daca7cfcc9d0814d7423a1a15773aa6a02f65810
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0689228efca83f14f7289376ba2e36f5e5034202fcfda983bb02c3a89382a8fa329c74c614600cb59adccfca8db94d762fd30c5406b221d2d2e3f045ed8fc841
|
7
|
+
data.tar.gz: 0bbf24196e0912384045f251c14b28a79e4dea2b864c62b7d5f3e284c22485260d8affbb54c19a9c60d09b1e251c5eae2eff4942768590d88d5d8e1f9549e927
|
data/lib/MrMurano.rb
CHANGED
@@ -1,24 +1,26 @@
|
|
1
1
|
require 'MrMurano/version'
|
2
2
|
require 'MrMurano/verbosing'
|
3
|
-
require 'MrMurano/hash
|
3
|
+
require 'MrMurano/hash'
|
4
4
|
require 'MrMurano/http'
|
5
|
-
require 'MrMurano/
|
5
|
+
require 'MrMurano/Config'
|
6
6
|
require 'MrMurano/Account'
|
7
7
|
require 'MrMurano/Solution'
|
8
|
-
require 'MrMurano/Solution-Endpoint
|
9
|
-
require 'MrMurano/Solution-File
|
10
|
-
require 'MrMurano/Solution-Services
|
11
|
-
require 'MrMurano/Solution-Users
|
12
|
-
require 'MrMurano/Solution-ServiceConfig
|
8
|
+
require 'MrMurano/Solution-Endpoint'
|
9
|
+
require 'MrMurano/Solution-File'
|
10
|
+
require 'MrMurano/Solution-Services'
|
11
|
+
require 'MrMurano/Solution-Users'
|
12
|
+
require 'MrMurano/Solution-ServiceConfig'
|
13
13
|
require 'MrMurano/Product'
|
14
14
|
|
15
|
+
require 'MrMurano/accountCommand'
|
16
|
+
require 'MrMurano/assignCommand'
|
15
17
|
require 'MrMurano/configCommand'
|
16
18
|
require 'MrMurano/contentCommand'
|
17
19
|
require 'MrMurano/cors'
|
18
20
|
require 'MrMurano/exportImport'
|
19
|
-
require 'MrMurano/keystore
|
20
|
-
require 'MrMurano/logs
|
21
|
-
require 'MrMurano/
|
22
|
-
require 'MrMurano/
|
23
|
-
require 'MrMurano/timeseries
|
21
|
+
require 'MrMurano/keystore'
|
22
|
+
require 'MrMurano/logs'
|
23
|
+
require 'MrMurano/status'
|
24
|
+
require 'MrMurano/sync'
|
25
|
+
require 'MrMurano/timeseries'
|
24
26
|
#require 'MrMurano/shelledCommand'
|
data/lib/MrMurano/Account.rb
CHANGED
@@ -2,10 +2,10 @@ require 'uri'
|
|
2
2
|
require 'net/http'
|
3
3
|
require 'json'
|
4
4
|
require 'date'
|
5
|
-
require 'pp'
|
6
|
-
require 'terminal-table'
|
7
5
|
require 'pathname'
|
8
6
|
require 'yaml'
|
7
|
+
require 'MrMurano/Config'
|
8
|
+
require 'MrMurano/http'
|
9
9
|
|
10
10
|
module MrMurano
|
11
11
|
class Passwords
|
@@ -23,6 +23,7 @@ module MrMurano
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
def save()
|
26
|
+
@path.dirname.mkpath unless @path.dirname.exist?
|
26
27
|
@path.open('wb') do |io|
|
27
28
|
io << @data.to_yaml
|
28
29
|
end
|
@@ -124,55 +125,4 @@ module MrMurano
|
|
124
125
|
end
|
125
126
|
end
|
126
127
|
|
127
|
-
command :account do |c|
|
128
|
-
c.syntax = %{mr account [options]}
|
129
|
-
c.description = %{Show things about your account.}
|
130
|
-
c.option '--businesses', 'Get businesses for user'
|
131
|
-
c.option '--products', 'Get products for user (needs a business)'
|
132
|
-
c.option '--solutions', 'Get solutions for user (needs a business)'
|
133
|
-
c.option '--idonly', 'Only return the ids'
|
134
|
-
|
135
|
-
c.example %{List all businesses}, 'mr account --businesses'
|
136
|
-
c.example %{List solutions}, 'mr account --solutions -c business.id=XXXXXXXX'
|
137
|
-
|
138
|
-
c.action do |args, options|
|
139
|
-
|
140
|
-
acc = MrMurano::Account.new
|
141
|
-
|
142
|
-
if options.businesses then
|
143
|
-
data = acc.businesses
|
144
|
-
if options.idonly then
|
145
|
-
say data.map{|row| row[:bizid]}.join(' ')
|
146
|
-
else
|
147
|
-
busy = data.map{|row| [row[:bizid], row[:role], row[:name]]}
|
148
|
-
table = Terminal::Table.new :rows => busy, :headings => ['Biz ID', 'Role', 'Name']
|
149
|
-
say table
|
150
|
-
end
|
151
|
-
|
152
|
-
elsif options.products then
|
153
|
-
data = acc.products
|
154
|
-
if options.idonly then
|
155
|
-
say data.map{|row| row[:pid]}.join(' ')
|
156
|
-
else
|
157
|
-
busy = data.map{|r| [r[:label], r[:type], r[:pid], r[:modelId]]}
|
158
|
-
table = Terminal::Table.new :rows => busy, :headings => ['Label', 'Type', 'PID', 'ModelID']
|
159
|
-
say table
|
160
|
-
end
|
161
|
-
|
162
|
-
elsif options.solutions then
|
163
|
-
data = acc.solutions
|
164
|
-
if options.idonly then
|
165
|
-
say data.map{|row| row[:apiId]}.join(' ')
|
166
|
-
else
|
167
|
-
busy = data.map{|r| [r[:apiId], r[:domain], r[:type], r[:sid]]}
|
168
|
-
table = Terminal::Table.new :rows => busy, :headings => ['API ID', 'Domain', 'Type', 'SID']
|
169
|
-
say table
|
170
|
-
end
|
171
|
-
|
172
|
-
else
|
173
|
-
say acc.token
|
174
|
-
end
|
175
|
-
|
176
|
-
end
|
177
|
-
end
|
178
128
|
# vim: set ai et sw=2 ts=2 :
|
File without changes
|
data/lib/MrMurano/Product.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'MrMurano/Solution'
|
2
2
|
|
3
3
|
module MrMurano
|
4
4
|
# …/serviceconfig
|
@@ -51,55 +51,4 @@ module MrMurano
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
command 'assign list' do |c|
|
55
|
-
c.syntax = 'mr assign list [options]'
|
56
|
-
c.description = 'List the products that are assigned'
|
57
|
-
c.option '--idonly', 'Only return the ids'
|
58
|
-
c.action do |args, options|
|
59
|
-
sol = MrMurano::SC_Device.new
|
60
|
-
|
61
|
-
trigs = sol.showTriggers()
|
62
|
-
if options.idonly or $cfg['business.id'].nil? then
|
63
|
-
say trigs.join(' ')
|
64
|
-
else
|
65
|
-
acc = MrMurano::Account.new
|
66
|
-
products = acc.products
|
67
|
-
products.select!{|p| trigs.include? p[:modelId] }
|
68
|
-
if products.empty? then
|
69
|
-
say trigs.join(' ')
|
70
|
-
else
|
71
|
-
busy = products.map{|r| [r[:label], r[:type], r[:pid], r[:modelId]]}
|
72
|
-
table = Terminal::Table.new :rows => busy, :headings => ['Label', 'Type', 'PID', 'ModelID']
|
73
|
-
say table
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
alias_command :assign, 'assign list'
|
79
|
-
|
80
|
-
command 'assign set' do |c|
|
81
|
-
c.syntax = 'mr assign set [product]'
|
82
|
-
c.description = 'Assign a product to a eventhandler'
|
83
|
-
|
84
|
-
c.action do |args, options|
|
85
|
-
sol = MrMurano::SC_Device.new
|
86
|
-
|
87
|
-
prname = args.shift
|
88
|
-
if prname.nil? then
|
89
|
-
prid = $cfg['product.id']
|
90
|
-
else
|
91
|
-
acc = MrMurano::Account.new
|
92
|
-
products = acc.products
|
93
|
-
products.select!{|p|
|
94
|
-
p[:label] == prname or p[:modelId] == prname or p[:pid] == prname
|
95
|
-
}
|
96
|
-
prid = products.map{|p| p[:modelId]}
|
97
|
-
end
|
98
|
-
raise "No product ID!" if prid.nil?
|
99
|
-
say "Assigning #{prid} to solution" if $cfg['tool.verbose']
|
100
|
-
sol.assignTriggers(prid) unless $cfg['tool.dry']
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|
104
|
-
|
105
54
|
# vim: set ai et sw=2 ts=2 :
|
data/lib/MrMurano/Solution.rb
CHANGED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'terminal-table'
|
2
|
+
|
3
|
+
command :account do |c|
|
4
|
+
c.syntax = %{mr account [options]}
|
5
|
+
c.description = %{Show things about your account.}
|
6
|
+
c.option '--businesses', 'Get businesses for user'
|
7
|
+
c.option '--products', 'Get products for user (needs a business)'
|
8
|
+
c.option '--solutions', 'Get solutions for user (needs a business)'
|
9
|
+
c.option '--idonly', 'Only return the ids'
|
10
|
+
|
11
|
+
c.example %{List all businesses}, 'mr account --businesses'
|
12
|
+
c.example %{List solutions}, 'mr account --solutions -c business.id=XXXXXXXX'
|
13
|
+
|
14
|
+
c.action do |args, options|
|
15
|
+
|
16
|
+
acc = MrMurano::Account.new
|
17
|
+
|
18
|
+
if options.businesses then
|
19
|
+
data = acc.businesses
|
20
|
+
if options.idonly then
|
21
|
+
say data.map{|row| row[:bizid]}.join(' ')
|
22
|
+
else
|
23
|
+
busy = data.map{|row| [row[:bizid], row[:role], row[:name]]}
|
24
|
+
table = Terminal::Table.new :rows => busy, :headings => ['Biz ID', 'Role', 'Name']
|
25
|
+
say table
|
26
|
+
end
|
27
|
+
|
28
|
+
elsif options.products then
|
29
|
+
data = acc.products
|
30
|
+
if options.idonly then
|
31
|
+
say data.map{|row| row[:pid]}.join(' ')
|
32
|
+
else
|
33
|
+
busy = data.map{|r| [r[:label], r[:type], r[:pid], r[:modelId]]}
|
34
|
+
table = Terminal::Table.new :rows => busy, :headings => ['Label', 'Type', 'PID', 'ModelID']
|
35
|
+
say table
|
36
|
+
end
|
37
|
+
|
38
|
+
elsif options.solutions then
|
39
|
+
data = acc.solutions
|
40
|
+
if options.idonly then
|
41
|
+
say data.map{|row| row[:apiId]}.join(' ')
|
42
|
+
else
|
43
|
+
busy = data.map{|r| [r[:apiId], r[:domain], r[:type], r[:sid]]}
|
44
|
+
table = Terminal::Table.new :rows => busy, :headings => ['API ID', 'Domain', 'Type', 'SID']
|
45
|
+
say table
|
46
|
+
end
|
47
|
+
|
48
|
+
else
|
49
|
+
say acc.token
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
# vim: set ai et sw=2 ts=2 :
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'terminal-table'
|
2
|
+
|
3
|
+
command 'assign list' do |c|
|
4
|
+
c.syntax = 'mr assign list [options]'
|
5
|
+
c.description = 'List the products that are assigned'
|
6
|
+
c.option '--idonly', 'Only return the ids'
|
7
|
+
c.action do |args, options|
|
8
|
+
sol = MrMurano::SC_Device.new
|
9
|
+
|
10
|
+
trigs = sol.showTriggers()
|
11
|
+
if options.idonly or $cfg['business.id'].nil? then
|
12
|
+
say trigs.join(' ')
|
13
|
+
else
|
14
|
+
acc = MrMurano::Account.new
|
15
|
+
products = acc.products
|
16
|
+
products.select!{|p| trigs.include? p[:modelId] }
|
17
|
+
if products.empty? then
|
18
|
+
say trigs.join(' ')
|
19
|
+
else
|
20
|
+
busy = products.map{|r| [r[:label], r[:type], r[:pid], r[:modelId]]}
|
21
|
+
table = Terminal::Table.new :rows => busy, :headings => ['Label', 'Type', 'PID', 'ModelID']
|
22
|
+
say table
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
alias_command :assign, 'assign list'
|
28
|
+
|
29
|
+
command 'assign set' do |c|
|
30
|
+
c.syntax = 'mr assign set [product]'
|
31
|
+
c.description = 'Assign a product to a eventhandler'
|
32
|
+
|
33
|
+
c.action do |args, options|
|
34
|
+
sol = MrMurano::SC_Device.new
|
35
|
+
|
36
|
+
prname = args.shift
|
37
|
+
if prname.nil? then
|
38
|
+
prid = $cfg['product.id']
|
39
|
+
else
|
40
|
+
acc = MrMurano::Account.new
|
41
|
+
products = acc.products
|
42
|
+
products.select!{|p|
|
43
|
+
p[:label] == prname or p[:modelId] == prname or p[:pid] == prname
|
44
|
+
}
|
45
|
+
prid = products.map{|p| p[:modelId]}
|
46
|
+
end
|
47
|
+
raise "No product ID!" if prid.nil?
|
48
|
+
say "Assigning #{prid} to solution" if $cfg['tool.verbose']
|
49
|
+
sol.assignTriggers(prid) unless $cfg['tool.dry']
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
# vim: set ai et sw=2 ts=2 :
|
@@ -4,11 +4,21 @@ require 'fileutils'
|
|
4
4
|
|
5
5
|
command 'config export' do |c|
|
6
6
|
c.syntax = %{mr config export}
|
7
|
-
c.summary = %{Export data to
|
7
|
+
c.summary = %{Export data to Solutionfiles}
|
8
|
+
c.description = %{Export data to Solutionfiles
|
9
|
+
|
10
|
+
This will write to the Solutionfile.json and .Solutionfile.secret used by the
|
11
|
+
exosite-cil tool.
|
12
|
+
|
13
|
+
This also will merge all of the endpoints into a single 'routes.lua' file.
|
14
|
+
}
|
8
15
|
|
9
16
|
c.option '--force', "Overwrite existing files."
|
17
|
+
c.option '--[no-]merge', "Merge endpoints into a single routes.lua file"
|
10
18
|
|
11
19
|
c.action do |args, options|
|
20
|
+
options.defaults :merge => true
|
21
|
+
|
12
22
|
solfile = Pathname.new($cfg['location.base'] + 'Solutionfile.json')
|
13
23
|
solsecret = Pathname.new($cfg['location.base'] + '.Solutionfile.secret')
|
14
24
|
|
@@ -17,24 +27,26 @@ command 'config export' do |c|
|
|
17
27
|
say "Use --force to overwrite"
|
18
28
|
end
|
19
29
|
|
20
|
-
epf = 'routes.lua'
|
21
|
-
File.open(epf, 'w') do |dst|
|
22
|
-
MrMurano::Endpoint.new.locallist.each do |ed|
|
23
|
-
ed[:local_path].open do |fin|
|
24
|
-
FileUtils.copy_stream(fin, dst)
|
25
|
-
end
|
26
|
-
dst << "\n\n"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
30
|
solf = {
|
31
|
-
:routes => 'epf',
|
32
31
|
:assets => $cfg['location.files'],
|
33
32
|
:default_page => $cfg['files.default_page'],
|
34
33
|
:services => {},
|
35
34
|
:modules => {}
|
36
35
|
}
|
37
36
|
|
37
|
+
if options.merge then
|
38
|
+
epf = 'routes.lua'
|
39
|
+
File.open(epf, 'w') do |dst|
|
40
|
+
MrMurano::Endpoint.new.locallist.each do |ed|
|
41
|
+
ed[:local_path].open do |fin|
|
42
|
+
FileUtils.copy_stream(fin, dst)
|
43
|
+
end
|
44
|
+
dst << "\n\n"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
solf[:routes] = epf
|
48
|
+
end
|
49
|
+
|
38
50
|
dpwd = Pathname.new(Dir.pwd)
|
39
51
|
MrMurano::EventHandler.new.locallist.each do |ev|
|
40
52
|
rp = ev[:local_path].relative_path_from(dpwd).to_s
|
@@ -71,7 +83,12 @@ end
|
|
71
83
|
|
72
84
|
command 'config import' do |c|
|
73
85
|
c.syntax = %{mr config import}
|
74
|
-
c.summary = %{Import data from
|
86
|
+
c.summary = %{Import data from Solutionfiles}
|
87
|
+
c.description = %{Import data from Solutionfiles
|
88
|
+
|
89
|
+
This imports from the Solutionfile.json and .Solutionfile.secret that are created
|
90
|
+
by the exosite-cli tool.
|
91
|
+
}
|
75
92
|
|
76
93
|
c.action do |args, options|
|
77
94
|
solfile = ($cfg['location.base'] + 'Solutionfile.json')
|
data/lib/MrMurano/version.rb
CHANGED
@@ -1,16 +1,7 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require 'MrMurano'
|
1
|
+
require 'MrMurano/version'
|
2
|
+
require 'MrMurano/Account'
|
4
3
|
require 'tempfile'
|
5
4
|
|
6
|
-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
7
|
-
# Some kludgery to work around commander. Likely a better way to do this.
|
8
|
-
program :version, MrMurano::VERSION
|
9
|
-
program :description, %{Manage a Solution in Exosite's Murano}
|
10
|
-
command(:nop){ |c| c.action {|a,o|} }
|
11
|
-
default_command :nop
|
12
|
-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
13
|
-
|
14
5
|
RSpec.describe MrMurano::Passwords, "#pwd" do
|
15
6
|
it "Creates a file " do
|
16
7
|
tmpfile = Dir.tmpdir + '/pwtest' # This way because Tempfile.new creates.
|
@@ -24,6 +15,18 @@ RSpec.describe MrMurano::Passwords, "#pwd" do
|
|
24
15
|
end
|
25
16
|
end
|
26
17
|
|
18
|
+
it "Creates a file in a directory that doesn't exist." do
|
19
|
+
tmpfile = Dir.tmpdir + '/deeper/pwtest' # This way because Tempfile.new creates.
|
20
|
+
begin
|
21
|
+
pwd = MrMurano::Passwords.new( tmpfile )
|
22
|
+
pwd.save
|
23
|
+
|
24
|
+
expect( FileTest.exists?(tmpfile) )
|
25
|
+
ensure
|
26
|
+
File.unlink(tmpfile) if File.exists? tmpfile
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
27
30
|
it "Loads a file" do
|
28
31
|
Tempfile.open('test') do |tf|
|
29
32
|
tf << %{---
|
data/spec/ProductBase_spec.rb
CHANGED
data/spec/ProductContent_spec.rb
CHANGED
data/spec/Product_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: MrMurano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Conrad Tadpol Tilstra
|
@@ -185,6 +185,7 @@ files:
|
|
185
185
|
- bin/mr
|
186
186
|
- lib/MrMurano.rb
|
187
187
|
- lib/MrMurano/Account.rb
|
188
|
+
- lib/MrMurano/Config.rb
|
188
189
|
- lib/MrMurano/Product.rb
|
189
190
|
- lib/MrMurano/Solution-Endpoint.rb
|
190
191
|
- lib/MrMurano/Solution-File.rb
|
@@ -192,8 +193,9 @@ files:
|
|
192
193
|
- lib/MrMurano/Solution-Services.rb
|
193
194
|
- lib/MrMurano/Solution-Users.rb
|
194
195
|
- lib/MrMurano/Solution.rb
|
196
|
+
- lib/MrMurano/accountCommand.rb
|
197
|
+
- lib/MrMurano/assignCommand.rb
|
195
198
|
- lib/MrMurano/configCommand.rb
|
196
|
-
- lib/MrMurano/configFile.rb
|
197
199
|
- lib/MrMurano/contentCommand.rb
|
198
200
|
- lib/MrMurano/cors.rb
|
199
201
|
- lib/MrMurano/exportImport.rb
|