MrMurano 1.10.4 → 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/LICENSE.txt +19 -0
- data/MrMurano.iss +50 -0
- data/README.markdown +2 -0
- data/Rakefile +57 -15
- data/TODO.taskpaper +1 -1
- data/lib/MrMurano/Config.rb +10 -0
- data/lib/MrMurano/Mock.rb +63 -0
- data/lib/MrMurano/Product-1P-Device.rb +0 -17
- data/lib/MrMurano/Product-Resources.rb +1 -1
- data/lib/MrMurano/Product.rb +1 -1
- data/lib/MrMurano/Solution-Endpoint.rb +42 -12
- data/lib/MrMurano/Solution-File.rb +21 -14
- data/lib/MrMurano/Solution-ServiceConfig.rb +2 -1
- data/lib/MrMurano/Solution-Services.rb +18 -0
- data/lib/MrMurano/SyncUpDown.rb +17 -14
- data/lib/MrMurano/commands/gb.rb +33 -0
- data/lib/MrMurano/commands/mock.rb +63 -0
- data/lib/MrMurano/commands/productDeviceIdCmds.rb +10 -3
- data/lib/MrMurano/commands.rb +1 -0
- data/lib/MrMurano/template/mock.erb +9 -0
- data/lib/MrMurano/version.rb +1 -1
- data/lib/MrMurano.rb +0 -1
- data/spec/Config_spec.rb +14 -4
- data/spec/Mock_spec.rb +60 -0
- data/spec/ProductResources_spec.rb +1 -1
- data/spec/Solution-Endpoint_spec.rb +314 -0
- data/spec/cmd_common.rb +44 -0
- data/spec/cmd_config_spec.rb +2 -26
- data/spec/cmd_init_spec.rb +2 -26
- metadata +14 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df22b4d754cd7953bdc3a0eb585237340b1a1bc1
|
4
|
+
data.tar.gz: a1beeba561cee4af0d3269f6b91aa9f97f4233fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93e43f224d125b59114a30ee086b8ce378e02bb40be13813317d9e8d19ba9d74af697af14bef8cc0562c6e9bc234b62f09fdc8d9ef20027d91b0d282baeae467
|
7
|
+
data.tar.gz: aed4c799fe5037211194dd5d16cf3f1ba5bcc935bd3cfc64b5509e913a99062884f4c497d39b87a24c65b590a9bf16889f170d5821af7268636044dbcc161c40
|
data/.gitignore
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2016 Exosite
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
4
|
+
software and associated documentation files (the "Software"), to deal in the
|
5
|
+
Software without restriction, including without limitation the rights to use, copy,
|
6
|
+
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
7
|
+
and to permit persons to whom the Software is furnished to do so, subject to the
|
8
|
+
following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
14
|
+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
15
|
+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
16
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
17
|
+
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
18
|
+
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
19
|
+
|
data/MrMurano.iss
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
[Setup]
|
2
|
+
AppName=MrMurano
|
3
|
+
AppVersion={%MRVERSION}
|
4
|
+
DefaultDirName={pf}\MrMurano
|
5
|
+
DefaultGroupName=MrMurano
|
6
|
+
ChangesEnvironment=yes
|
7
|
+
OutputBaseFileName=MrMuranoSetup
|
8
|
+
AppPublisher=Exosite
|
9
|
+
AppPublisherURL=http://exosite.com/
|
10
|
+
AppCopyright=Copyright (C) 2016 Exosite
|
11
|
+
LicenseFile=LICENSE.txt
|
12
|
+
|
13
|
+
[Files]
|
14
|
+
Source: "mr.exe"; DestDir: "{app}\bin"
|
15
|
+
Source: "LICENSE.txt"; DestDir: "{app}"
|
16
|
+
Source: "ReadMe.txt"; DestDir: "{app}"; Flags: isreadme
|
17
|
+
|
18
|
+
; http://www.jrsoftware.org/ishelp/
|
19
|
+
|
20
|
+
;;;;;;;;;;;;;;;;;;;;;;;;;
|
21
|
+
; http://stackoverflow.com/questions/3304463/how-do-i-modify-the-path-environment-variable-when-running-an-inno-setup-install/3431379
|
22
|
+
[Registry]
|
23
|
+
Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; \
|
24
|
+
ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}\bin"; \
|
25
|
+
Check: NeedsAddPath('{app}\bin')
|
26
|
+
|
27
|
+
;;; Not working.
|
28
|
+
[Code]
|
29
|
+
|
30
|
+
function NeedsAddPath(Param: string): boolean;
|
31
|
+
var
|
32
|
+
OrigPath: string;
|
33
|
+
ParamExpanded: string;
|
34
|
+
begin
|
35
|
+
//expand the setup constants like {app} from Param
|
36
|
+
ParamExpanded := ExpandConstant(Param);
|
37
|
+
if not RegQueryStringValue(HKEY_LOCAL_MACHINE,
|
38
|
+
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
|
39
|
+
'Path', OrigPath)
|
40
|
+
then begin
|
41
|
+
Result := True;
|
42
|
+
exit;
|
43
|
+
end;
|
44
|
+
// look for the path with leading and trailing semicolon and with or without \ ending
|
45
|
+
// Pos() returns 0 if not found
|
46
|
+
Result := Pos(';' + UpperCase(ParamExpanded) + ';', ';' + UpperCase(OrigPath) + ';') = 0;
|
47
|
+
if Result = True then
|
48
|
+
Result := Pos(';' + UpperCase(ParamExpanded) + '\;', ';' + UpperCase(OrigPath) + ';') = 0;
|
49
|
+
end;
|
50
|
+
|
data/README.markdown
CHANGED
@@ -213,6 +213,8 @@ MrMurano uses [git flow](https://github.com/nvie/gitflow#getting-started) for
|
|
213
213
|
|
214
214
|
MrMurano also uses [bundler](http://bundler.io).
|
215
215
|
|
216
|
+
When submitting pull requests, please do them against the develop branch.
|
217
|
+
|
216
218
|
## Windows
|
217
219
|
|
218
220
|
The MrMurano gem will install on Windows.
|
data/Rakefile
CHANGED
@@ -16,13 +16,20 @@ task :echo do
|
|
16
16
|
puts "= #{Bundler::GemHelper.gemspec.version} ="
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
19
|
+
namespace :git do
|
20
|
+
desc "Push only develop, master, and tags to origin"
|
21
|
+
task :origin do
|
22
|
+
sh %{git push origin develop}
|
23
|
+
sh %{git push origin master}
|
24
|
+
sh %{git push origin --tags}
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "Push only develop, master, and tags to upstream"
|
28
|
+
task :upstream do
|
29
|
+
sh %{git push upstream develop}
|
30
|
+
sh %{git push upstream master}
|
31
|
+
sh %{git push upstream --tags}
|
32
|
+
end
|
26
33
|
end
|
27
34
|
|
28
35
|
task :gempush do
|
@@ -38,13 +45,6 @@ task :gemit do
|
|
38
45
|
sh %{git checkout develop}
|
39
46
|
end
|
40
47
|
|
41
|
-
task :wexe do
|
42
|
-
# Need to find all dlls, because ocra isn't finding them for some reason.
|
43
|
-
gemdir = `gem env gemdir`.chomp # XXX can we get that without running commands?
|
44
|
-
gemdlls = Dir[File.join(gemdir, 'extensions', '*')]
|
45
|
-
sh %{ocra bin/mr #{gemdlls.join(' ')}}
|
46
|
-
end
|
47
|
-
|
48
48
|
desc "Prints a cmd to test this in another directory"
|
49
49
|
task :testwith do
|
50
50
|
pwd=Dir.pwd.sub(Dir.home, '~')
|
@@ -52,10 +52,52 @@ task :testwith do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
desc 'Run RSpec'
|
55
|
-
task :
|
55
|
+
task :rspec do
|
56
56
|
Dir.mkdir("report") unless File.directory?("report")
|
57
57
|
sh %{rspec --format html --out report/index.html --format progress}
|
58
58
|
end
|
59
|
+
task :test => [:rspec]
|
60
|
+
|
61
|
+
file "ReadMe.txt" => ['README.markdown'] do |t|
|
62
|
+
File.open(t.prerequisites.first) do |rio|
|
63
|
+
File.open(t.name, 'w') do |wio|
|
64
|
+
wio << rio.read.gsub(/\n/,"\r\n")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
if Gem.win_platform? then
|
70
|
+
file 'mr.exe' => Dir['lib/MrMurano/**/*.rb'] do
|
71
|
+
# Need to find all dlls, because ocra isn't finding them for some reason.
|
72
|
+
gemdir = `gem env gemdir`.chomp
|
73
|
+
gemdlls = Dir[File.join(gemdir, 'extensions', '*')]
|
74
|
+
ENV['RUBYLIB'] = 'lib'
|
75
|
+
sh %{ocra bin/mr #{gemdlls.join(' ')}}
|
76
|
+
end
|
77
|
+
task :wexe => ['mr.exe']
|
78
|
+
|
79
|
+
desc 'Run rspec on cmd tests using mr.exe'
|
80
|
+
task :mr_exe_test => ['mr.exe'] do
|
81
|
+
Dir.mkdir("report") unless File.directory?("report")
|
82
|
+
ENV['CI_MR_EXE'] = '1'
|
83
|
+
files = Dir[File.join('spec', 'cmd_*_spec.rb')]
|
84
|
+
sh %{rspec --format html --out report/mr_exe.html --format progress #{files.join(' ')}}
|
85
|
+
end
|
86
|
+
task :test => [:mr_exe_test]
|
87
|
+
|
88
|
+
installerName = "Output/MrMurano-#{Bundler::GemHelper.gemspec.version.to_s}-Setup.exe"
|
89
|
+
|
90
|
+
desc "Build a Windows installer for MrMurano"
|
91
|
+
task :inno => [installerName]
|
92
|
+
|
93
|
+
file "Output/MrMuranoSetup.exe" => ['mr.exe', 'ReadMe.txt'] do
|
94
|
+
ENV['MRVERSION'] = Bundler::GemHelper.gemspec.version.to_s
|
95
|
+
sh %{"C:\\Program Files (x86)\\Inno Setup 5\\iscc.exe" MrMurano.iss}
|
96
|
+
end
|
97
|
+
file installerName => ['Output/MrMuranoSetup.exe'] do |t|
|
98
|
+
FileUtils.move t.prerequisites.first, t.name, :verbose=>true
|
99
|
+
end
|
100
|
+
end
|
59
101
|
|
60
102
|
# vim: set sw=4 ts=4 :
|
61
103
|
|
data/TODO.taskpaper
CHANGED
@@ -23,7 +23,7 @@ Account:
|
|
23
23
|
- Netrc library (or the netrc format) doesn't allow '#' in passwords. @done(2016-08-10)
|
24
24
|
|
25
25
|
Endpoints:
|
26
|
-
- In fetch(); add content_type to script header if not application/json
|
26
|
+
- In fetch(); add content_type to script header if not application/json @done(2016-12-06)
|
27
27
|
- Add support for multiple endpoints in one file @pri(high) @done(2016-11-18)
|
28
28
|
- Add directory support like in modules @done(2016-07-26)
|
29
29
|
|
data/lib/MrMurano/Config.rb
CHANGED
@@ -90,9 +90,19 @@ module MrMurano
|
|
90
90
|
set('location.specs', 'specs', :defaults)
|
91
91
|
|
92
92
|
set('files.default_page', 'index.html', :defaults)
|
93
|
+
set('files.searchFor', '**/*', :defaults)
|
94
|
+
set('files.ignoring', '', :defaults)
|
93
95
|
|
96
|
+
set('endpoints.searchFor', '*.lua */*.lua', :defaults)
|
97
|
+
set('endpoints.ignoring', '*_test.lua *_spec.lua .*', :defaults)
|
98
|
+
|
99
|
+
set('eventhandler.searchFor', '*.lua */*.lua', :defaults)
|
100
|
+
set('eventhandler.ignoring', '*_test.lua *_spec.lua .*', :defaults)
|
94
101
|
set('eventhandler.skiplist', 'websocket webservice device.service_call', :defaults)
|
95
102
|
|
103
|
+
set('modules.searchFor', '*.lua */*.lua', :defaults)
|
104
|
+
set('modules.ignoring', '*_test.lua *_spec.lua .*', :defaults)
|
105
|
+
|
96
106
|
set('diff.cmd', 'diff -u', :defaults)
|
97
107
|
end
|
98
108
|
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'securerandom'
|
3
|
+
|
4
|
+
module MrMurano
|
5
|
+
class Mock
|
6
|
+
attr_accessor :uuid, :testpoint_file
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
end
|
10
|
+
|
11
|
+
def show
|
12
|
+
file = Pathname.new(get_testpoint_path)
|
13
|
+
if file.exist? then
|
14
|
+
authorization = %{if request.headers["authorization"] == "}
|
15
|
+
file.open('rb') do |io|
|
16
|
+
io.each_line do |line|
|
17
|
+
auth_line = line.include?(authorization)
|
18
|
+
if auth_line then
|
19
|
+
capture = /\=\= "(.*)"/.match(line)
|
20
|
+
return capture.captures[0]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
return false
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_mock_template
|
29
|
+
path = get_mock_template_path()
|
30
|
+
return ::File.read(path)
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_testpoint_path
|
34
|
+
file_name = 'testpoint.post.lua'
|
35
|
+
path = %{#{$cfg['location.endpoints']}/#{file_name}}
|
36
|
+
return path
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_mock_template_path
|
40
|
+
return ::File.join(::File.dirname(__FILE__), 'template', 'mock.erb')
|
41
|
+
end
|
42
|
+
|
43
|
+
def create_testpoint
|
44
|
+
uuid = SecureRandom.uuid
|
45
|
+
template = ERB.new(get_mock_template)
|
46
|
+
endpoint = template.result(binding)
|
47
|
+
|
48
|
+
Pathname.new(get_testpoint_path).open('wb') do |io|
|
49
|
+
io << endpoint
|
50
|
+
end
|
51
|
+
return uuid
|
52
|
+
end
|
53
|
+
|
54
|
+
def remove_testpoint
|
55
|
+
file = Pathname.new(get_testpoint_path)
|
56
|
+
if file.exist? then
|
57
|
+
file.unlink
|
58
|
+
return true
|
59
|
+
end
|
60
|
+
return false
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -90,23 +90,6 @@ module MrMurano
|
|
90
90
|
psn.remove_sn(sn)
|
91
91
|
end
|
92
92
|
|
93
|
-
## Rename a device
|
94
|
-
# +sn+:: Identifier for a device
|
95
|
-
# +newname+:: The new name of the device
|
96
|
-
def rename(sn, newname, rid=nil)
|
97
|
-
newname = sn if newname.nil?
|
98
|
-
rid = sn_rid(sn) if rid.nil?
|
99
|
-
verbose "Setting name of #{sn} to #{newname}"
|
100
|
-
debug " Via RID: #{rid}"
|
101
|
-
do_rpc({
|
102
|
-
:procedure=>:update,
|
103
|
-
:arguments=>[
|
104
|
-
rid,
|
105
|
-
{:name=>newname}
|
106
|
-
]
|
107
|
-
})
|
108
|
-
end
|
109
|
-
|
110
93
|
## Get a tree of info for a device and its resources.
|
111
94
|
# +sn+:: Identifier for a device
|
112
95
|
def twee(sn)
|
@@ -34,7 +34,7 @@ module MrMurano
|
|
34
34
|
name = $cfg['product.spec']
|
35
35
|
prid = $cfg['product.id']
|
36
36
|
name = $cfg["p-#{prid}.spec"] unless prid.nil? or $cfg["p-#{prid}.spec"].nil?
|
37
|
-
raise "No spec file named; run `mr config
|
37
|
+
raise "No spec file named; run `mr config product.spec <specfile>`" if name.nil?
|
38
38
|
|
39
39
|
unless $cfg['location.specs'].nil? then
|
40
40
|
name = ::File.join($cfg['location.specs'], name)
|
data/lib/MrMurano/Product.rb
CHANGED
@@ -111,7 +111,7 @@ module MrMurano
|
|
111
111
|
|
112
112
|
## Write a value to an alias on a device
|
113
113
|
def write(sn, values)
|
114
|
-
post("/write/#{sn}", values)
|
114
|
+
post("/write/#{sn}", values) unless $cfg['tool.dry']
|
115
115
|
end
|
116
116
|
|
117
117
|
## Converts an exoline style spec file into a Murano style one
|
@@ -11,13 +11,18 @@ module MrMurano
|
|
11
11
|
super
|
12
12
|
@uriparts << 'endpoint'
|
13
13
|
@location = $cfg['location.endpoints']
|
14
|
+
|
15
|
+
@match_header = /--#ENDPOINT (?<method>\S+) (?<path>\S+)( (?<ctype>.*))?/
|
14
16
|
end
|
15
17
|
|
16
18
|
##
|
17
19
|
# This gets all data about all endpoints
|
18
20
|
def list
|
19
21
|
get().map do |item|
|
20
|
-
item[:content_type]
|
22
|
+
if item[:content_type].nil? or item[:content_type].empty? then
|
23
|
+
item[:content_type] = 'application/json'
|
24
|
+
end
|
25
|
+
# XXX should this update the script header?
|
21
26
|
item
|
22
27
|
end
|
23
28
|
end
|
@@ -25,18 +30,35 @@ module MrMurano
|
|
25
30
|
def fetch(id)
|
26
31
|
ret = get('/' + id.to_s)
|
27
32
|
ret[:content_type] = 'application/json' if ret[:content_type].empty?
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
33
|
+
|
34
|
+
script = ret[:script].lines.map{|l|l.chomp}
|
35
|
+
|
36
|
+
aheader = (script.first or "")
|
37
|
+
|
38
|
+
rh = ['--#ENDPOINT', ret[:method].upcase, ret[:path]]
|
39
|
+
rh << ret[:content_type] if ret[:content_type] != 'application/json'
|
40
|
+
rheader = rh.join(' ')
|
41
|
+
|
42
|
+
# if header is missing add it.
|
43
|
+
# If header is wrong, replace it.
|
44
|
+
|
45
|
+
md = @match_header.match(aheader)
|
46
|
+
if md.nil? then
|
47
|
+
# header missing.
|
48
|
+
script.unshift rheader
|
49
|
+
elsif md[:method] != ret[:method] or
|
50
|
+
md[:path] != ret[:path] or
|
51
|
+
md[:content_type] != ret[:content_type] then
|
52
|
+
# header is wrong.
|
53
|
+
script[0] = rheader
|
54
|
+
end
|
55
|
+
# otherwise current header is good.
|
56
|
+
|
57
|
+
script = script.join("\n") + "\n"
|
32
58
|
if block_given? then
|
33
|
-
yield
|
34
|
-
yield ret[:script]
|
59
|
+
yield script
|
35
60
|
else
|
36
|
-
|
37
|
-
res << rheader unless dheader =~ aheader
|
38
|
-
res << ret[:script]
|
39
|
-
res
|
61
|
+
script
|
40
62
|
end
|
41
63
|
end
|
42
64
|
|
@@ -82,6 +104,14 @@ module MrMurano
|
|
82
104
|
delete('/' + id.to_s)
|
83
105
|
end
|
84
106
|
|
107
|
+
def searchFor
|
108
|
+
$cfg['endpoints.searchFor'].split
|
109
|
+
end
|
110
|
+
|
111
|
+
def ignoring
|
112
|
+
$cfg['endpoints.ignore'].split
|
113
|
+
end
|
114
|
+
|
85
115
|
def tolocalname(item, key)
|
86
116
|
name = ''
|
87
117
|
name << item[:path].split('/').reject{|i|i.empty?}.join('-')
|
@@ -97,7 +127,7 @@ module MrMurano
|
|
97
127
|
cur = nil
|
98
128
|
lineno=0
|
99
129
|
path.readlines().each do |line|
|
100
|
-
md =
|
130
|
+
md = @match_header.match(line)
|
101
131
|
if not md.nil? then
|
102
132
|
# header line.
|
103
133
|
cur[:line_end] = lineno unless cur.nil?
|
@@ -145,21 +145,28 @@ module MrMurano
|
|
145
145
|
itemA[:checksum] != itemB[:checksum])
|
146
146
|
end
|
147
147
|
|
148
|
-
def
|
149
|
-
|
150
|
-
unless from.exist? then
|
151
|
-
return []
|
152
|
-
end
|
153
|
-
raise "Not a directory: #{from.to_s}" unless from.directory?
|
154
|
-
|
155
|
-
Pathname.glob(from.to_s + '/**/*').reject do |path|
|
156
|
-
path.directory?
|
157
|
-
end.map do |path|
|
158
|
-
name = toRemoteItem(from, path)
|
159
|
-
name[:local_path] = path
|
160
|
-
name
|
161
|
-
end
|
148
|
+
def searchFor
|
149
|
+
$cfg['files.searchFor'].split
|
162
150
|
end
|
151
|
+
def ignoring
|
152
|
+
$cfg['files.ignoring'].split
|
153
|
+
end
|
154
|
+
|
155
|
+
# def localitems(from)
|
156
|
+
# from = Pathname.new(from) unless from.kind_of? Pathname
|
157
|
+
# unless from.exist? then
|
158
|
+
# return []
|
159
|
+
# end
|
160
|
+
# raise "Not a directory: #{from.to_s}" unless from.directory?
|
161
|
+
#
|
162
|
+
# Pathname.glob(from.to_s + '/**/*').reject do |path|
|
163
|
+
# path.directory? or ignoring.any?{|i| ::File.fnmatch(i,path)}
|
164
|
+
# end.map do |path|
|
165
|
+
# name = toRemoteItem(from, path)
|
166
|
+
# name[:local_path] = path
|
167
|
+
# name
|
168
|
+
# end
|
169
|
+
# end
|
163
170
|
|
164
171
|
end
|
165
172
|
SyncRoot.add('files', File, 'S', %{Static Files}, true)
|
@@ -111,7 +111,8 @@ module MrMurano
|
|
111
111
|
def assignTriggers(products)
|
112
112
|
details = fetch(scid)
|
113
113
|
products = [products] unless products.kind_of? Array
|
114
|
-
details[:triggers] = {:pid=>products
|
114
|
+
details[:triggers] = {:pid=>products}
|
115
|
+
details[:parameters] = {:pid=>products}
|
115
116
|
|
116
117
|
put('/'+scid, details)
|
117
118
|
end
|
@@ -25,6 +25,8 @@ module MrMurano
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def fetch(name)
|
28
|
+
raise "Missing name!" if name.nil?
|
29
|
+
raise "Empty name!" if name.empty?
|
28
30
|
ret = get('/'+name)
|
29
31
|
if block_given? then
|
30
32
|
yield ret[:script]
|
@@ -171,6 +173,14 @@ module MrMurano
|
|
171
173
|
end
|
172
174
|
end
|
173
175
|
|
176
|
+
def searchFor
|
177
|
+
$cfg['modules.searchFor'].split
|
178
|
+
end
|
179
|
+
|
180
|
+
def ignoring
|
181
|
+
$cfg['modules.ignoring'].split
|
182
|
+
end
|
183
|
+
|
174
184
|
def toRemoteItem(from, path)
|
175
185
|
name = path.basename.to_s.sub(/\..*/, '')
|
176
186
|
{:name => name}
|
@@ -207,6 +217,14 @@ module MrMurano
|
|
207
217
|
end
|
208
218
|
end
|
209
219
|
|
220
|
+
def searchFor
|
221
|
+
$cfg['eventhandler.searchFor'].split
|
222
|
+
end
|
223
|
+
|
224
|
+
def ignoring
|
225
|
+
$cfg['eventhandler.ignoring'].split
|
226
|
+
end
|
227
|
+
|
210
228
|
def list
|
211
229
|
ret = get()
|
212
230
|
# eventhandler.skiplist is a list of whitespace seperated dot-paired values.
|
data/lib/MrMurano/SyncUpDown.rb
CHANGED
@@ -245,6 +245,17 @@ module MrMurano
|
|
245
245
|
items.values
|
246
246
|
end
|
247
247
|
|
248
|
+
##
|
249
|
+
# Returns array of globs to search for files
|
250
|
+
def searchFor
|
251
|
+
%w{*.lua */*.lua}
|
252
|
+
end
|
253
|
+
|
254
|
+
## Returns array of globs of files to ignore
|
255
|
+
def ignoring
|
256
|
+
%w{*_test.lua *_spec.lua .*}
|
257
|
+
end
|
258
|
+
|
248
259
|
##
|
249
260
|
# Get a list of local items rooted at #from
|
250
261
|
#
|
@@ -254,22 +265,14 @@ module MrMurano
|
|
254
265
|
# @param from Pathname: Directory of items to scan
|
255
266
|
# @return Array: of Hashes of item details
|
256
267
|
def localitems(from)
|
257
|
-
from.
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
path.children
|
263
|
-
else
|
264
|
-
path
|
268
|
+
searchIn = from.to_s
|
269
|
+
sf = searchFor.map{|i| ::File.join(searchIn, i)}
|
270
|
+
Dir[*sf].flatten.compact.reject do |p|
|
271
|
+
::File.directory?(p) or ignoring.any? do |i|
|
272
|
+
::File.fnmatch(i,p)
|
265
273
|
end
|
266
|
-
end.flatten.compact.reject do |path|
|
267
|
-
# TODO: These globs should be in $cfg.
|
268
|
-
path.fnmatch('*_test.lua') or path.basename.fnmatch('.*')
|
269
|
-
end.select do |path|
|
270
|
-
# TODO: These globs should be in $cfg.
|
271
|
-
path.extname == '.lua'
|
272
274
|
end.map do |path|
|
275
|
+
path = Pathname.new(path)
|
273
276
|
item = toRemoteItem(from, path)
|
274
277
|
if item.kind_of?(Array) then
|
275
278
|
item.compact.map{|i| i[:local_path] = path; i}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'pp'
|
2
|
+
|
3
|
+
# You don't need this.
|
4
|
+
# To use this:
|
5
|
+
# - mkdir -p ~/.mrmurano/plugins
|
6
|
+
# - ln gb.rb ~/.mrmurano/plugins
|
7
|
+
|
8
|
+
command :_gb do |c|
|
9
|
+
c.syntax = %{mr _gb <class> <method> (<args>)}
|
10
|
+
c.summary = %{Call internal class methods directly.}
|
11
|
+
c.description = %{Call internal class methods directly.}
|
12
|
+
|
13
|
+
c.action do |args, options|
|
14
|
+
cls = args[0]
|
15
|
+
meth = args[1].to_sym
|
16
|
+
args.shift(2)
|
17
|
+
|
18
|
+
begin
|
19
|
+
gb = Object::const_get("MrMurano::#{cls}").new
|
20
|
+
if gb.respond_to? meth then
|
21
|
+
pp gb.__send__(meth, *args)
|
22
|
+
else
|
23
|
+
say_error "'#{cls}' doesn't '#{meth}'"
|
24
|
+
end
|
25
|
+
rescue Exception => e
|
26
|
+
say_error e.message
|
27
|
+
pp e
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
# vim: set ai et sw=2 ts=2 :
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'MrMurano/Mock'
|
2
|
+
|
3
|
+
command 'mock' do |c|
|
4
|
+
c.syntax = %{mr mock}
|
5
|
+
c.summary = %{Enable or disable testpoint. Show current UUID.}
|
6
|
+
c.description = %{mock lets you enable testpoints to do local lua development}
|
7
|
+
|
8
|
+
c.action do |args, options|
|
9
|
+
::Commander::UI.enable_paging
|
10
|
+
say MrMurano::SubCmdGroupHelp.new(c).get_help
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
command 'mock enable' do |c|
|
15
|
+
c.syntax = %{mr mock enable}
|
16
|
+
c.summary = %{Create a testpoint file.}
|
17
|
+
c.description = %{Run syncup after running this to carry the change through to Murano.
|
18
|
+
Returns the UUID to be used for authenticating.
|
19
|
+
}
|
20
|
+
c.option '--raw', %{print raw uuid}
|
21
|
+
c.action do |args, options|
|
22
|
+
mock = MrMurano::Mock.new
|
23
|
+
uuid = mock.create_testpoint()
|
24
|
+
if options.raw then
|
25
|
+
say uuid
|
26
|
+
else
|
27
|
+
say %{Created testpoint file. Run `mr syncup` to activate. The following is the authorization token:}
|
28
|
+
say %{$ export AUTHORIZATION="#{uuid}"}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
command 'mock disable' do |c|
|
34
|
+
c.syntax = %{mr mock disable}
|
35
|
+
c.summary = %{Remove the testpoint file.}
|
36
|
+
c.description = %{Run syncup after running this to carry the change through to Murano.}
|
37
|
+
|
38
|
+
c.action do |args, options|
|
39
|
+
mock = MrMurano::Mock.new
|
40
|
+
removed = mock.remove_testpoint()
|
41
|
+
if removed then
|
42
|
+
say %{Deleted testpoint file. Run `mr syncup` to remove the testpoint.}
|
43
|
+
else
|
44
|
+
say %{No testpoint file to remove.}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
command 'mock show' do |c|
|
50
|
+
c.syntax = %{mr mock disable}
|
51
|
+
c.summary = %{Remove the testpoint file.}
|
52
|
+
c.description = %{Run syncup after running this to carry the change through to Murano.}
|
53
|
+
|
54
|
+
c.action do |args, options|
|
55
|
+
mock = MrMurano::Mock.new
|
56
|
+
uuid = mock.show()
|
57
|
+
if uuid then
|
58
|
+
say uuid
|
59
|
+
else
|
60
|
+
say %{Could not find testpoint file or UUID in testpoint file.}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|