MrMurano 1.1.4 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a5093bd76cafdb8ab726abb77602c2b19b1fb2e
4
- data.tar.gz: 763e072b76d582ad97046a89e194e12551f1ce23
3
+ metadata.gz: becf766cb2d799e7cd09460a9d1a9b0907074c49
4
+ data.tar.gz: 007d4c8c73d94cb48a67a048bb8af95bdf3b3914
5
5
  SHA512:
6
- metadata.gz: 09131c8d2d1a5acee4b297f55a90fa3ea2bc284940dd95de6d7c361572a567366625768f4b3b39c9cb15772a42e8a27eeb876a4342e21227bc800bddf557bec5
7
- data.tar.gz: 7294edb4f8bd9fe50685d11a1cf51f3670c9dbe49d1109ba60c31c919368375e96827fd886c2b905a916db1756e016c1dcfeaa83654c728f7a3dc00bf59dad41
6
+ metadata.gz: de75b5e29711198f832c96668eca04c83cee6b284c0287ad05e6b3480158f3cb816d41204d518f29989ffa9ff44cb25f1276377e65114a9cd71acc01a0cdff0b
7
+ data.tar.gz: 7e73558588ce36f65fd90f524f5e870aeae5c69dc27408a1abd5ab8a266f7a1612c887bcb8902d9ac5b54040f9898bd686cf05c0fff8fd536daa2469b2792356
data/Gemfile CHANGED
@@ -6,6 +6,7 @@ gem 'commander', '~> 4.4.0'
6
6
  gem 'terminal-table', '~> 1.4.5'
7
7
  gem 'mime-types', '~> 1.25.1'
8
8
  gem 'mime-types-data', '~> 3.2016'
9
- gem 'http-form_data', '~> 1.0.1'
10
9
  gem 'inifile', '~> 3.0'
10
+ gem 'http-form_data', '~> 1.0.1'
11
+ gem 'rainbow', '~> 2.1.0'
11
12
 
data/MrMurano.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.homepage = 'https://github.com/tadpol/MrMurano'
12
12
  s.summary = 'Do more from the command line with Murano'
13
13
  s.description = %{Do more from the command line with Murano
14
-
14
+
15
15
  Push and pull data from Murano.
16
16
  Get status on what things have changed.
17
17
  See a diff of the changes before you push.
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
28
28
  s.add_runtime_dependency('mime-types-data', '~> 3.2016')
29
29
  s.add_runtime_dependency('inifile', '~> 3.0')
30
30
  s.add_runtime_dependency('http-form_data', '~> 1.0.1')
31
+ s.add_runtime_dependency('rainbow', '~> 2.1.0')
31
32
 
32
33
  s.add_development_dependency('bundler', '~> 1.7.6')
33
34
  s.add_development_dependency('rspec', '~> 3.2')
data/lib/MrMurano.rb CHANGED
@@ -8,6 +8,7 @@ require 'MrMurano/Solution-File.rb'
8
8
  require 'MrMurano/Solution-Services.rb'
9
9
  require 'MrMurano/Solution-Users.rb'
10
10
  require 'MrMurano/Solution-ServiceConfig.rb'
11
+ require 'MrMurano/logs.rb'
11
12
  require 'MrMurano/sync.rb'
12
13
  require 'MrMurano/status.rb'
13
14
  #require 'MrMurano/shelledCommand'
@@ -98,6 +98,7 @@ module MrMurano
98
98
 
99
99
  def load_specific(file)
100
100
  spc = ConfigFile.new(:specified, Pathname.new(file))
101
+ spc.load
101
102
  @paths.insert(1, spc)
102
103
  end
103
104
 
@@ -0,0 +1,67 @@
1
+ require 'date'
2
+ require 'json'
3
+ require 'rainbow/ext/string'
4
+
5
+ command :logs do |c|
6
+ c.syntax = %{mr logs [options]}
7
+ c.description = %{Get the logs for a solution}
8
+ c.option '-f','--follow', %{Follow logs from server}
9
+ c.option '--pollrate RATE', Integer, %{Seconds to sleep between polls}
10
+ c.option('--[no-]color', %{Toggle colorizing of logs}) {
11
+ Rainbow.enabled = false
12
+ }
13
+ c.option '--[no-]pretty', %{Reformat JSON blobs in logs.}
14
+ c.option '--[no-]localtime', %{Adjust Timestamps to be in local time}
15
+
16
+ c.action do |args,options|
17
+ options.default :pretty=>true, :localtime=>true, :pollrate=>5
18
+
19
+ lasttime = ""
20
+
21
+ sol = MrMurano::Solution.new
22
+ begin
23
+ ret = sol.get('/logs') # TODO: ('/logs?polling=true') Currently ignored.
24
+
25
+ if ret.kind_of?(Hash) and ret.has_key?('items') then
26
+ ret['items'].reverse.each do |line|
27
+ curtime = ""
28
+
29
+ line.sub!(/^\[[^\]]*\]/) {|m| m.color(:red).background(:aliceblue)}
30
+ line.sub!(/\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d+)(?:\+\d\d:\d\d)/) {|m|
31
+ if options.localtime then
32
+ m = DateTime.parse(m).to_time.localtime.to_datetime.iso8601(3)
33
+ end
34
+ curtime = m
35
+ m.color(:blue)
36
+ }
37
+
38
+ line.gsub!(/\{(?>[^}{]+|\g<0>)*\}/m) do |m|
39
+ if options.pretty then
40
+ js = JSON.parse(m, {:allow_nan=>true, :create_additions=>false})
41
+ ret = JSON.pretty_generate(js).to_s
42
+ ret[0] = ret[0].color(:magenta)
43
+ ret[-1] = ret[-1].color(:magenta)
44
+ ret
45
+ else
46
+ m.sub!(/^{/){|ml| ml.color(:magenta)}
47
+ m.sub!(/}$/){|ml| ml.color(:magenta)}
48
+ m
49
+ end
50
+ end
51
+
52
+ if curtime > lasttime then
53
+ lasttime = curtime
54
+ puts line
55
+ end
56
+ end
57
+ else
58
+ say_error "Couldn't get logs: #{ret}"
59
+ break
60
+ end
61
+
62
+ sleep(options.pollrate) if options.follow
63
+ end while options.follow
64
+
65
+ end
66
+ end
67
+ # vim: set ai et sw=2 ts=2 :
@@ -1,4 +1,4 @@
1
1
  module MrMurano
2
- VERSION = '1.1.4'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
4
4
 
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.1.4
4
+ version: 1.2.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-08-24 00:00:00.000000000 Z
11
+ date: 2016-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ~>
95
95
  - !ruby/object:Gem::Version
96
96
  version: 1.0.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: rainbow
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: 2.1.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 2.1.0
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: bundler
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -136,8 +150,8 @@ dependencies:
136
150
  - - '>='
137
151
  - !ruby/object:Gem::Version
138
152
  version: '0'
139
- description: "Do more from the command line with Murano\n \n Push and pull data
140
- from Murano.\n Get status on what things have changed.\n See a diff of the changes
153
+ description: "Do more from the command line with Murano\n\n Push and pull data from
154
+ Murano.\n Get status on what things have changed.\n See a diff of the changes
141
155
  before you push.\n "
142
156
  email:
143
157
  - tadpol@tadpol.org
@@ -163,6 +177,7 @@ files:
163
177
  - lib/MrMurano/Solution.rb
164
178
  - lib/MrMurano/configFile.rb
165
179
  - lib/MrMurano/hash.rb
180
+ - lib/MrMurano/logs.rb
166
181
  - lib/MrMurano/shelledCommand.rb
167
182
  - lib/MrMurano/status.rb
168
183
  - lib/MrMurano/sync.rb