MrMurano 1.6.3 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -2
  3. data/Gemfile +1 -1
  4. data/MrMurano.gemspec +1 -1
  5. data/README.markdown +4 -0
  6. data/TODO.taskpaper +17 -4
  7. data/lib/MrMurano/Account.rb +5 -1
  8. data/lib/MrMurano/Config.rb +3 -1
  9. data/lib/MrMurano/Product-Resources.rb +239 -0
  10. data/lib/MrMurano/Product.rb +51 -2
  11. data/lib/MrMurano/Solution-Cors.rb +81 -0
  12. data/lib/MrMurano/Solution-Endpoint.rb +8 -4
  13. data/lib/MrMurano/Solution-File.rb +4 -2
  14. data/lib/MrMurano/Solution-ServiceConfig.rb +74 -1
  15. data/lib/MrMurano/Solution-Services.rb +4 -2
  16. data/lib/MrMurano/Solution-Users.rb +6 -3
  17. data/lib/MrMurano/Solution.rb +6 -274
  18. data/lib/MrMurano/SyncUpDown.rb +433 -0
  19. data/lib/MrMurano/commands/completion.rb +152 -0
  20. data/lib/MrMurano/commands/content.rb +15 -14
  21. data/lib/MrMurano/commands/cors.rb +11 -38
  22. data/lib/MrMurano/commands/exportImport.rb +4 -3
  23. data/lib/MrMurano/commands/keystore.rb +15 -16
  24. data/lib/MrMurano/commands/logs.rb +2 -2
  25. data/lib/MrMurano/commands/productCreate.rb +4 -4
  26. data/lib/MrMurano/commands/productDelete.rb +6 -8
  27. data/lib/MrMurano/commands/productSpec.rb +31 -36
  28. data/lib/MrMurano/commands/productWrite.rb +9 -7
  29. data/lib/MrMurano/commands/serialNumberCmds.rb +4 -4
  30. data/lib/MrMurano/commands/solutionCreate.rb +4 -4
  31. data/lib/MrMurano/commands/solutionDelete.rb +5 -5
  32. data/lib/MrMurano/commands/status.rb +9 -42
  33. data/lib/MrMurano/commands/sync.rb +15 -71
  34. data/lib/MrMurano/commands/timeseries.rb +23 -29
  35. data/lib/MrMurano/commands/tsdb.rb +202 -0
  36. data/lib/MrMurano/commands/zshcomplete.erb +112 -0
  37. data/lib/MrMurano/commands.rb +4 -1
  38. data/lib/MrMurano/http.rb +4 -3
  39. data/lib/MrMurano/makePretty.rb +15 -6
  40. data/lib/MrMurano/verbosing.rb +71 -0
  41. data/lib/MrMurano/version.rb +1 -1
  42. data/lib/MrMurano.rb +1 -0
  43. data/spec/ConfigFile_spec.rb +3 -3
  44. data/spec/ProductContent_spec.rb +2 -2
  45. data/spec/ProductResources_spec.rb +152 -0
  46. data/spec/Product_spec.rb +38 -1
  47. data/spec/Solution-Cors_spec.rb +134 -0
  48. data/spec/Solution-ServiceConfig_spec.rb +198 -0
  49. data/spec/SyncRoot_spec.rb +74 -0
  50. data/spec/cmd_config_spec.rb +51 -0
  51. data/spec/fixtures/.mrmuranorc +9 -0
  52. data/spec/{testfiles → fixtures}/configfile +0 -0
  53. data/spec/fixtures/mrmuranorc_deleted_bob +8 -0
  54. data/spec/fixtures/product_spec_files/example.exoline.spec.yaml +116 -0
  55. data/spec/fixtures/product_spec_files/example.murano.spec.yaml +14 -0
  56. data/spec/fixtures/product_spec_files/gwe.exoline.spec.yaml +21 -0
  57. data/spec/fixtures/product_spec_files/gwe.murano.spec.yaml +16 -0
  58. data/spec/{lightbulb.yaml → fixtures/product_spec_files/lightbulb.yaml} +0 -0
  59. data/spec/spec_helper.rb +4 -4
  60. metadata +47 -19
@@ -3,12 +3,11 @@ command :syncdown do |c|
3
3
  c.syntax = %{mr syncdown [options]}
4
4
  c.description = %{Sync project down from Murano}
5
5
  c.option '--all', 'Sync everything'
6
- c.option '-s','--[no-]files', %{Sync Static Files}
7
- c.option '-a','--[no-]endpoints', %{Sync Endpoints}
8
- c.option '-m','--[no-]modules', %{Sync Modules}
9
- c.option '-e','--[no-]eventhandlers', %{Sync Event Handlers}
10
- c.option '--roles', %{Sync Roles}
11
- c.option '--users', %{Sync Users}
6
+
7
+ # Load options to control which things to sync
8
+ MrMurano::SyncRoot.each_option do |s,l,d|
9
+ c.option s, l, d
10
+ end
12
11
 
13
12
  c.option '--[no-]delete', %{Don't delete things from server}
14
13
  c.option '--[no-]create', %{Don't create things on server}
@@ -17,41 +16,14 @@ command :syncdown do |c|
17
16
  c.example %{Make local be like what is on the server}, %{mr syncdown --all}
18
17
  c.example %{Pull down new things, but don't delete or modify anything}, %{mr syncdown --all --no-delete --no-update}
19
18
  c.example %{Only Pull new static files}, %{mr syncdown --files --no-delete --no-update}
20
-
19
+
21
20
  c.action do |args,options|
22
21
  options.default :delete=>true, :create=>true, :update=>true
23
- MrMurano.checkSAME(options)
24
-
25
- if options.endpoints then
26
- sol = MrMurano::Endpoint.new
27
- sol.syncdown(options)
28
- end
29
-
30
- if options.modules then
31
- sol = MrMurano::Library.new
32
- sol.syncdown(options)
33
- end
34
-
35
- if options.eventhandlers then
36
- sol = MrMurano::EventHandler.new
37
- sol.syncdown(options)
38
- end
39
-
40
- if options.roles then
41
- sol = MrMurano::Role.new
42
- sol.syncdown(options)
43
- end
44
22
 
45
- if options.users then
46
- sol = MrMurano::User.new
23
+ MrMurano::SyncRoot.each_filtered(options.__hash__) do |name, type, klass|
24
+ sol = klass.new
47
25
  sol.syncdown(options)
48
26
  end
49
-
50
- if options.files then
51
- sol = MrMurano::File.new
52
- sol.syncdown(options)
53
- end
54
-
55
27
  end
56
28
  end
57
29
  alias_command :pull, :syncdown, '--no-delete'
@@ -60,12 +32,11 @@ command :syncup do |c|
60
32
  c.syntax = %{mr syncup [options]}
61
33
  c.description = %{Sync project up into Murano}
62
34
  c.option '--all', 'Sync everything'
63
- c.option '-s','--[no-]files', %{Sync Static Files}
64
- c.option '-a','--[no-]endpoints', %{Sync Endpoints}
65
- c.option '-m','--[no-]modules', %{Sync Modules}
66
- c.option '-e','--[no-]eventhandlers', %{Sync Event Handlers}
67
- c.option '--roles', %{Sync Roles}
68
- c.option '--users', %{Sync Users}
35
+
36
+ # Load options to control which things to sync
37
+ MrMurano::SyncRoot.each_option do |s,l,d|
38
+ c.option s, l, d
39
+ end
69
40
 
70
41
  c.option '--[no-]delete', %{Don't delete things from server}
71
42
  c.option '--[no-]create', %{Don't create things on server}
@@ -77,38 +48,11 @@ command :syncup do |c|
77
48
 
78
49
  c.action do |args,options|
79
50
  options.default :delete=>true, :create=>true, :update=>true
80
- MrMurano.checkSAME(options)
81
-
82
- if options.endpoints then
83
- sol = MrMurano::Endpoint.new
84
- sol.syncup(options)
85
- end
86
-
87
- if options.modules then
88
- sol = MrMurano::Library.new
89
- sol.syncup(options)
90
- end
91
-
92
- if options.eventhandlers then
93
- sol = MrMurano::EventHandler.new
94
- sol.syncup(options)
95
- end
96
-
97
- if options.roles then
98
- sol = MrMurano::Role.new
99
- sol.syncup(options)
100
- end
101
51
 
102
- if options.users then
103
- sol = MrMurano::User.new
52
+ MrMurano::SyncRoot.each_filtered(options.__hash__) do |name, type, klass|
53
+ sol = klass.new
104
54
  sol.syncup(options)
105
55
  end
106
-
107
- if options.files then
108
- sol = MrMurano::File.new
109
- sol.syncup(options)
110
- end
111
-
112
56
  end
113
57
  end
114
58
  alias_command :push, :syncup, '--no-delete'
@@ -8,15 +8,15 @@ module MrMurano
8
8
  end
9
9
 
10
10
  def query(query)
11
- post("/#{scid}/call/query", {:q=>query})
11
+ call(:query, :post, {:q=>query})
12
12
  end
13
13
 
14
14
  def write(writestr)
15
- post("/#{scid}/call/write", { :query=>writestr })
15
+ call(:write, :post, { :query=>writestr })
16
16
  end
17
17
 
18
18
  def command(cmd)
19
- post("/#{scid}/call/command", { :q=>cmd})
19
+ call(:command, :post, { :q=>cmd})
20
20
  end
21
21
 
22
22
  end
@@ -25,6 +25,7 @@ end
25
25
  command 'timeseries query' do |c|
26
26
  c.syntax = %{mr timeseries query <query string>}
27
27
  c.description = %{Query the timeseries database}
28
+ c.option '-o', '--output FILE', %{Download to file instead of STDOUT}
28
29
  c.option '--[no-]json', %{Display results as raw json}
29
30
  c.option '--[no-]csv', %{Display results as CSV}
30
31
 
@@ -32,29 +33,28 @@ command 'timeseries query' do |c|
32
33
  options.defalts :json=>false, :csv=>false
33
34
  sol = MrMurano::Timeseries.new
34
35
  ret = sol.query args.join(' ')
35
- if options.json then
36
- puts ret.to_json
37
36
 
38
- elsif options.csv then
39
- (ret[:results] or []).each do |res|
40
- (res[:series] or []).each do |ser|
41
- cols = ser[:columns] #.map{|h| "#{ser[:name]}.#{h}"}
42
- CSV($stdout, :headers=>cols, :write_headers=>true) do |csv|
43
- ser[:values].each{|v| csv << v}
44
- end
45
- end
46
- end
37
+ $cfg['tool.outformat'] = 'json' if options.json
38
+ $cfg['tool.outformat'] = 'best csv' if options.csv
47
39
 
48
- else
40
+ io=nil
41
+ if options.output then
42
+ io = File.open(options.output, 'w')
43
+ end
44
+
45
+ sol.outf(ret, io) do |dd, ios|
49
46
  (ret[:results] or []).each do |res|
50
47
  (res[:series] or []).each do |ser|
51
- cols = ser[:columns]
52
- table = Terminal::Table.new :title=>ser[:name], :headings=>cols, :rows=>ser[:values]
53
- puts table
48
+ sol.tabularize({
49
+ :title=>ser[:name],
50
+ :headers=>ser[:columns],
51
+ :rows=>ser[:values]
52
+ }, ios)
54
53
  end
55
54
  end
56
- # If nothing displayed, Format wasn't what we expected, so do what?
57
55
  end
56
+ io.close unless io.nil?
57
+
58
58
  end
59
59
  end
60
60
  alias_command :tsq, 'timeseries query'
@@ -65,13 +65,10 @@ command 'timeseries write' do |c|
65
65
  c.option '--[no-]json', %{Display results as raw json}
66
66
  c.action do |args,options|
67
67
  options.defalts :json=>false
68
+ $cfg['tool.outformat'] = 'json' if options.json
68
69
  sol = MrMurano::Timeseries.new
69
70
  ret = sol.write args.join(' ')
70
- if options.json then
71
- puts ret.to_json
72
- else
73
- pp ret
74
- end
71
+ sol.outf ret
75
72
  end
76
73
  end
77
74
  alias_command :tsw, 'timeseries write'
@@ -82,13 +79,10 @@ command 'timeseries command' do |c|
82
79
  c.option '--[no-]json', %{Display results as raw json}
83
80
  c.action do |args,options|
84
81
  options.defalts :json=>false
82
+ $cfg['tool.outformat'] = 'json' if options.json
85
83
  sol = MrMurano::Timeseries.new
86
84
  ret = sol.command args.join(' ')
87
- if options.json then
88
- puts ret.to_json
89
- else
90
- pp ret
91
- end
85
+ sol.outf ret
92
86
  end
93
87
  end
94
88
 
@@ -0,0 +1,202 @@
1
+ require 'date'
2
+ require 'MrMurano/Solution-ServiceConfig'
3
+
4
+ module MrMurano
5
+ module ServiceConfigs
6
+ class Tsdb < ServiceConfig
7
+ def initialize
8
+ super
9
+ @serviceName = 'tsdb'
10
+ end
11
+
12
+ def write(data)
13
+ call(:write, :post, data)
14
+ end
15
+
16
+ def query(query)
17
+ call(:query, :post, query)
18
+ end
19
+
20
+ def listTags
21
+ call(:listTags)
22
+ end
23
+
24
+ def listMetrics
25
+ call(:listMetrics)
26
+ end
27
+
28
+
29
+ def str_to_timestamp(str)
30
+ if str =~ /^\d+(u|ms|s)?$/ then
31
+ str
32
+ else
33
+ dt = DateTime.parse(str)
34
+ (dt.to_time.to_f * 1000000).to_i
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ command 'tsdb write' do |c|
42
+ c.syntax = %{mr tsdb write [options] <metric=value>|@<tag=value> … }
43
+ c.summary = %{write data}
44
+ c.description = %{Write data
45
+
46
+ TIMESTAMP is microseconds since unix epoch, or can be suffixed with units.
47
+ Units are u (microseconds), ms (milliseconds), s (seconds)
48
+
49
+ Also, many date-time formats can be parsed and will be converted to microseconds
50
+ }
51
+ c.option '--when TIMESTAMP', %{When this data happened. (defaults to now)}
52
+ # TODO: add option to take data from STDIN.
53
+
54
+ c.action do |args, options|
55
+ sol = MrMurano::ServiceConfigs::Tsdb.new
56
+
57
+ # we have hash of tags, hash of metrics, optional timestamp.
58
+ metrics = {}
59
+ tags = {}
60
+ args.each do |item|
61
+ key, value = item.split('=', 2)
62
+ if key[0] == '@' then
63
+ tags[key[1..-1]] = value.to_s #tags are always strings.
64
+ else
65
+ value = value.to_i if value == value.to_i.to_s
66
+ metrics[key] = value
67
+ end
68
+ end
69
+
70
+ data = {:tags=>tags, :metrics=>metrics}
71
+ if not options.when.nil? and options.when != 'now' then
72
+ data[:ts] = sol.str_to_timestamp(options.when)
73
+ end
74
+
75
+ ret = sol.write(data)
76
+ if ret != {} then
77
+ sol.error ret
78
+ end
79
+ end
80
+ end
81
+
82
+ command 'tsdb query' do |c|
83
+ c.syntax = %{mr tsdb query [options] }
84
+ c.summary = %{query data}
85
+ c.description =%{
86
+
87
+ list metrics to return
88
+ list tag=value to match
89
+
90
+
91
+ FUNCS is a comma seperated list of the aggregate functions.
92
+ FILL is null, none, any integer, previous
93
+
94
+ DURATION is an integer with time unit to indicate relative time before now.
95
+ Units are u (microseconds), ms (milliseconds), s (seconds), m (minutes),
96
+ h (hours), d (days), w (weeks)
97
+
98
+ TIMESTAMP is microseconds since unix epoch, or can be suffixed with units.
99
+ Units are u (microseconds), ms (milliseconds), s (seconds)
100
+
101
+ Also, many date-time formats can be parsed and will be converted to microseconds
102
+ }
103
+ c.option '--start_time TIMESTAMP', %{Start time range}
104
+ c.option '--end_time TIMESTAMP', %{End time range; defaults to now}
105
+ c.option '--relative_start DURATION', %{Start time relative from now}
106
+ c.option '--relative_end DURATION', %{End time relative from now}
107
+ c.option '--sampling_size DURATION', %{The size of time slots used for downsampling}
108
+ c.option '--limit NUM', Integer, %{Limit number of data points returned}
109
+ c.option '--epoch UNIT', ['u','ms','s'], %{Set size of returned timestamps}
110
+ c.option '--mode MODE', ['merge','split'], %{Merge or split each returned metric}
111
+ c.option '--fill FILL', %{Value to fill for time slots with no data points exist in merge mode}
112
+ c.option '--order_by ORDER', ['desc','asc'], %{Return results in ascending or descending time order}
113
+ c.option '--aggregate FUNCS', %{Aggregation functions to apply}
114
+
115
+ c.option '-o', '--output FILE', %{Download to file instead of STDOUT}
116
+
117
+ c.action do |args, options|
118
+ sol = MrMurano::ServiceConfigs::Tsdb.new
119
+
120
+ query = {}
121
+ tags = {}
122
+ metrics = []
123
+ args.each do |arg|
124
+ if arg =~ /=/ then
125
+ # a tag.
126
+ k,v = arg.split('=', 2)
127
+ tags[k] = v
128
+ else
129
+ metrics << arg
130
+ end
131
+ end
132
+ query[:tags] = tags unless tags.empty?
133
+ query[:metrics] = metrics unless metrics.empty?
134
+
135
+ unless options.start_time.nil? then
136
+ query[:start_time] = sol.str_to_timestamp(options.start_time)
137
+ end
138
+ unless options.end_time.nil? then
139
+ query[:end_time] = sol.str_to_timestamp(options.end_time)
140
+ end
141
+
142
+ unless options.relative_start.nil? then
143
+ o = options.relative_start
144
+ o = "-#{o}" unless o[0] == '-'
145
+ query[:relative_start] = o
146
+ end
147
+ unless options.relative_end.nil? then
148
+ o = options.relative_end
149
+ o = "-#{o}" unless o[0] == '-'
150
+ query[:relative_end] = o
151
+ end
152
+ query[:sampling_size] = options.sampling_size unless options.sampling_size.nil?
153
+
154
+ query[:limit] = options.limit unless options.limit.nil?
155
+ query[:epoch] = options.epoch unless options.epoch.nil?
156
+ query[:mode] = options.mode unless options.mode.nil?
157
+ query[:order_by] = options.order_by unless options.order_by.nil?
158
+
159
+ query[:fill] = options.fill unless options.fill.nil?
160
+ unless options.aggregate.nil? then
161
+ query[:aggregate] = options.aggregate.split(',')
162
+ end
163
+
164
+ io=nil
165
+ if options.output then
166
+ io = File.open(options.output, 'w')
167
+ end
168
+ sol.outf sol.query(query) do |dd, ios|
169
+ sol.tabularize({
170
+ :headers=>dd[:columns],
171
+ :rows=>dd[:values]
172
+ }, ios)
173
+ end
174
+ io.close unless io.nil?
175
+ end
176
+ end
177
+
178
+ command 'tsdb list tags' do |c|
179
+ c.syntax = %{mr tsdb list tags [options]}
180
+ c.summary = %{List tags}
181
+
182
+ c.action do |args, options|
183
+ sol = MrMurano::ServiceConfigs::Tsdb.new
184
+ ret = sol.listTags
185
+ # TODO: handle looping if :next != nil
186
+ sol.outf ret[:tags].keys
187
+ end
188
+ end
189
+
190
+ command 'tsdb list metrics' do |c|
191
+ c.syntax = %{mr tsdb list metrics [options]}
192
+ c.summary = %{List metrics}
193
+
194
+ c.action do |args, options|
195
+ sol = MrMurano::ServiceConfigs::Tsdb.new
196
+ ret = sol.listMetrics
197
+ # TODO: handle looping if :next != nil
198
+ sol.outf ret[:metrics]
199
+ end
200
+ end
201
+
202
+ # vim: set ai et sw=2 ts=2 :
@@ -0,0 +1,112 @@
1
+ #compdef <%= program :name %>
2
+
3
+ __<%= program :name %>_common_options=(
4
+ <% for option in @options -%>
5
+ <%- if flatswitches(option).count > 1 -%>
6
+ {<%= flatswitches(option).join(',') %>}<%= takesArg(option) %>:"<%= optionDesc option %>"
7
+ <%- else -%>
8
+ "<%= flatswitches(option).first %><%= takesArg(option) %>:<%= optionDesc option %>"
9
+ <%- end -%>
10
+ <% end %>
11
+ )
12
+
13
+ _<%= program :name %> () {
14
+ local curcontext="$curcontext" state line
15
+ typeset -A opt_args
16
+
17
+ # except this fails when a command only has one arg and then options.
18
+ _arguments -C \
19
+ ':command:->command' \
20
+ '*::options:->options'
21
+ #echo "\n=$curcontext=$state=$words=\n"
22
+ case $state in
23
+ (command)
24
+ local -a list
25
+ list=(
26
+ <%- for name, subs in cmdTree -%>
27
+ <%- cmd = subs["\0cmd"] -%>
28
+ <%- if cmd.nil? -%>
29
+ <%= name %>:' '
30
+ <%-else-%>
31
+ <%= name %>:'<%= cmd.summary || cmd.description.lines[0] -%>'
32
+ <%-end-%>
33
+ <%-end-%>
34
+ )
35
+ _describe -t firstArg 'firstArg' list
36
+ _describe -t options 'global options' __<%= program :name %>_common_options
37
+ ;;
38
+ (options)
39
+ case $line[1] in
40
+ <%- for name, subs in cmdTree -%>
41
+ (<%= name %>)
42
+ __<%=program :name%>-<%= name %>
43
+ ;;
44
+ <%-end-%>
45
+ esac
46
+ ;;
47
+ esac
48
+ }
49
+
50
+ <%- for name, subs in cmdTree -%>
51
+ <%- command = subs["\0cmd"]; subs = subs.reject{|k,_| k == "\0cmd"} -%>
52
+ __<%=program :name%>-<%= name %> () {
53
+ local curcontext="$curcontext" state line
54
+ typeset -A opt_args
55
+
56
+ _arguments -C \
57
+ ':command:->command' \
58
+ '*::options:->options'
59
+
60
+ case $state in
61
+ (command)
62
+ <%- unless subs.empty? -%>
63
+ local -a subcommands
64
+ subcommands=(
65
+ <%- for sname, ssubs in subs -%>
66
+ <%- command = ssubs["\0cmd"] -%>
67
+ <%- if command.nil? then -%>
68
+ <%=sname%>:''
69
+ <%-else-%>
70
+ <%=sname%>:'<%= command.summary || command.description.lines[0] -%>'
71
+ <%-end-%>
72
+ <%-end-%>
73
+ )
74
+ _describe -t commands 'subcommand' subcommands
75
+ <%-end-%>
76
+ _describe -t options 'global options' __<%= program :name %>_common_options
77
+ <%- unless command.nil? or command.options.empty? then -%>
78
+ _arguments \
79
+ <%- for option in command.options -%>
80
+ <%- if flatswitches(option).count > 1 -%>
81
+ {<%= flatswitches(option).join(',') %>}<%= takesArg(option) %>"[<%= optionDesc option %>]: :" \
82
+ <%- else -%>
83
+ "<%= flatswitches(option).first %><%= takesArg(option) %>[<%= optionDesc option %>]: :" \
84
+ <%- end -%>
85
+ <%- end -%>
86
+ <%- end %>
87
+ ;;
88
+ (options)
89
+ case $line[1] in
90
+ <%- for sname, ssubs in subs -%>
91
+ <%- command = ssubs["\0cmd"]; subs = ssubs.reject{|k,_| k == "\0cmd"} -%>
92
+ (<%=sname%>)
93
+ _describe -t options 'global options' __<%= program :name %>_common_options
94
+ <%- unless command.nil? or command.options.empty? then -%>
95
+ _arguments \
96
+ <%- for option in command.options -%>
97
+ <%- if flatswitches(option).count > 1 -%>
98
+ {<%= flatswitches(option).join(',') %>}<%= takesArg(option) %>"[<%= optionDesc option %>]: :" \
99
+ <%- else -%>
100
+ "<%= flatswitches(option).first %><%= takesArg(option) %>[<%= optionDesc option %>]: :" \
101
+ <%- end -%>
102
+ <%- end -%>
103
+ <%- end %>
104
+ ;;
105
+ <%-end-%>
106
+ esac
107
+ ;;
108
+ esac
109
+ }
110
+ <%- end -%>
111
+
112
+ # vim: set ai et sw=2 ts=2 :
@@ -1,4 +1,3 @@
1
-
2
1
  require 'MrMurano/commands/account'
3
2
  require 'MrMurano/commands/assign'
4
3
  require 'MrMurano/commands/config'
@@ -20,3 +19,7 @@ require 'MrMurano/commands/solutionList'
20
19
  require 'MrMurano/commands/status'
21
20
  require 'MrMurano/commands/sync'
22
21
  require 'MrMurano/commands/timeseries'
22
+ require 'MrMurano/commands/tsdb'
23
+
24
+ require 'MrMurano/commands/completion'
25
+
data/lib/MrMurano/http.rb CHANGED
@@ -12,7 +12,7 @@ module MrMurano
12
12
  end
13
13
 
14
14
  def json_opts
15
- return @json_opts unless @json_opts.nil?
15
+ return @json_opts unless not defined?(@json_opts) or @json_opts.nil?
16
16
  @json_opts = {
17
17
  :allow_nan => true,
18
18
  :symbolize_names => true,
@@ -38,7 +38,7 @@ module MrMurano
38
38
 
39
39
  def http
40
40
  uri = URI('https://' + $cfg['net.host'])
41
- if @http.nil? then
41
+ if not defined?(@http) or @http.nil? then
42
42
  @http = Net::HTTP.new(uri.host, uri.port)
43
43
  @http.use_ssl = true
44
44
  @http.start
@@ -111,8 +111,9 @@ module MrMurano
111
111
  end
112
112
  end
113
113
 
114
- def get(path='', &block)
114
+ def get(path='', query=nil, &block)
115
115
  uri = endPoint(path)
116
+ uri.query = URI.encode_www_form(query) unless query.nil?
116
117
  workit(set_def_headers(Net::HTTP::Get.new(uri)), &block)
117
118
  end
118
119
 
@@ -1,14 +1,23 @@
1
1
  require 'date'
2
2
  require 'json'
3
- require 'rainbow/ext/string'
3
+ require 'highline'
4
4
 
5
5
  module MrMurano
6
6
  module Pretties
7
+
8
+ HighLine::Style.new(:name=>:on_aliceblue, :code=>"\e[48;5;231m", :rgb=>[240, 248, 255])
9
+ PRETTIES_COLORSCHEME = HighLine::ColorScheme.new do |cs|
10
+ cs[:subject] = [:red, :on_aliceblue]
11
+ cs[:timestamp] = [:blue]
12
+ cs[:json] = [:magenta]
13
+ end
14
+ HighLine.color_scheme = PRETTIES_COLORSCHEME
15
+
7
16
  def self.makeJsonPretty(data, options)
8
17
  if options.pretty then
9
18
  ret = JSON.pretty_generate(data).to_s
10
- ret[0] = ret[0].color(:magenta)
11
- ret[-1] = ret[-1].color(:magenta)
19
+ ret[0] = HighLine.color(ret[0], :json)
20
+ ret[-1] = HighLine.color(ret[-1], :json)
12
21
  ret
13
22
  else
14
23
  data.to_json
@@ -17,8 +26,8 @@ module MrMurano
17
26
 
18
27
  def self.makePretty(line, options)
19
28
  out=''
20
- out << "#{line[:type] || '--'} ".upcase.color(:red).background(:aliceblue)
21
- out << "[#{line[:subject] || ''}]".color(:red).background(:aliceblue)
29
+ out << HighLine.color("#{line[:type] || '--'} ".upcase, :subject)
30
+ out << HighLine.color("[#{line[:subject] || ''}]", :subject)
22
31
  out << " "
23
32
  if line.has_key?(:timestamp) then
24
33
  if line[:timestamp].kind_of? Numeric then
@@ -33,7 +42,7 @@ module MrMurano
33
42
  else
34
43
  curtime = "<no timestamp>"
35
44
  end
36
- out << curtime.color(:blue)
45
+ out << HighLine.color(curtime, :timestamp)
37
46
  out << ":\n"
38
47
  if line.has_key?(:data) then
39
48
  data = line[:data]