kumogata 0.2.11 → 0.2.12

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: acf2fb5a1777c46b50516cf30d4082fd90517625
4
- data.tar.gz: 570942ed3c3455c5e3bc34fe1b6f5e57412bab90
3
+ metadata.gz: 660efba91fef6116d2af9c902ba7d8ef0e11c456
4
+ data.tar.gz: 7d230216b8843370326fbca927dad8d095ca8ce7
5
5
  SHA512:
6
- metadata.gz: bd3246d8b6e350335c39ceedae160f47ce4bc0ce05c1d8b17056f647eec9d7f62826f828fc663c41c1631fc1582acc5b7e0b1106a691dbce77f5c193e71fcbe5
7
- data.tar.gz: 1fc19204fef197b4a3b535e9fcca171c58eb68dc750e46c1da330e9d36fbe53757cfd16ae4aa7eff6b63196df830d93bbaddfb59536917cd36d39055508e66ad
6
+ metadata.gz: 6f45ee971165149b7a4a8d0c5745af69e44ab8a35e1fe92c356023c8284da8df08d910da2c70befad9e04728b43887b200d65ebc5655a829b7ee52eed1df876a
7
+ data.tar.gz: 0f613dbc268a57ecf8945220c171baf8a0aa2d828d202128d43c291f60ed42a757f0c00d368ab28bb9298ae9aa9575c1e5eafea6d4e3e221ac42eb4a075fe176
data/README.md CHANGED
@@ -5,8 +5,8 @@
5
5
 
6
6
  Kumogata is a tool for [AWS CloudFormation](https://aws.amazon.com/cloudformation/).
7
7
 
8
- [![Gem Version](https://badge.fury.io/rb/kumogata.png?201403062105)](http://badge.fury.io/rb/kumogata)
9
- [![Build Status](https://drone.io/github.com/winebarrel/kumogata/status.png?201403062105)](https://drone.io/github.com/winebarrel/kumogata/latest)
8
+ [![Gem Version](https://badge.fury.io/rb/kumogata.png?201403062244)](http://badge.fury.io/rb/kumogata)
9
+ [![Build Status](https://drone.io/github.com/winebarrel/kumogata/status.png?201403062244)](https://drone.io/github.com/winebarrel/kumogata/latest)
10
10
 
11
11
  It can define a template in Ruby DSL, such as:
12
12
 
data/kumogata.gemspec CHANGED
@@ -19,12 +19,12 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_dependency 'aws-sdk'
22
+ spec.add_dependency 'coderay'
22
23
  spec.add_dependency 'diffy'
23
24
  spec.add_dependency 'dslh', '>= 0.2.4'
24
25
  spec.add_dependency 'hashie'
25
26
  spec.add_dependency 'highline'
26
27
  spec.add_dependency 'json'
27
- spec.add_dependency 'json_color'
28
28
  spec.add_dependency 'term-ansicolor'
29
29
  spec.add_dependency 'uuidtools'
30
30
  spec.add_development_dependency 'bundler'
@@ -29,9 +29,9 @@ class Kumogata::Client
29
29
  template = open_template(path_or_url)
30
30
 
31
31
  if ruby_template?(path_or_url)
32
- colorize_json(JSON.pretty_generate(template))
32
+ JSON.pretty_generate(template).colorize_as(:json)
33
33
  else
34
- devaluate_template(template).chomp
34
+ devaluate_template(template).chomp.colorize_as(:ruby)
35
35
  end
36
36
  end
37
37
 
@@ -54,27 +54,27 @@ class Kumogata::Client
54
54
 
55
55
  def list(stack_name = nil)
56
56
  stacks = describe_stacks(stack_name)
57
- colorize_json(JSON.pretty_generate(stacks))
57
+ JSON.pretty_generate(stacks).colorize_as(:json)
58
58
  end
59
59
 
60
60
  def export(stack_name)
61
61
  template = export_template(stack_name)
62
- devaluate_template(template).chomp
62
+ devaluate_template(template).chomp.colorize_as(:ruby)
63
63
  end
64
64
 
65
65
  def show_events(stack_name)
66
66
  events = describe_events(stack_name)
67
- colorize_json(JSON.pretty_generate(events))
67
+ JSON.pretty_generate(events).colorize_as(:json)
68
68
  end
69
69
 
70
70
  def show_outputs(stack_name)
71
71
  outputs = describe_outputs(stack_name)
72
- colorize_json(JSON.pretty_generate(outputs))
72
+ JSON.pretty_generate(outputs).colorize_as(:json)
73
73
  end
74
74
 
75
75
  def show_resources(stack_name)
76
76
  resources = describe_resources(stack_name)
77
- colorize_json(JSON.pretty_generate(resources))
77
+ JSON.pretty_generate(resources).colorize_as(:json)
78
78
  end
79
79
 
80
80
  def diff(path_or_url1, path_or_url2)
@@ -409,10 +409,10 @@ class Kumogata::Client
409
409
  puts <<-EOS
410
410
 
411
411
  Outputs:
412
- #{colorize_json(JSON.pretty_generate(outputs))}
412
+ #{JSON.pretty_generate(outputs).colorize_as(:json)}
413
413
 
414
414
  Stack Resource Summaries:
415
- #{colorize_json(JSON.pretty_generate(summaries))}
415
+ #{JSON.pretty_generate(summaries).colorize_as(:json)}
416
416
 
417
417
  (Save to `#{@options.result_log}`)
418
418
  EOS
@@ -431,15 +431,4 @@ Stack Resource Summaries:
431
431
  i[0, 1].upcase + i[1..-1].downcase
432
432
  }.join
433
433
  end
434
-
435
- def colorize_json(str)
436
- if $stdout.tty? and @options.color?
437
- begin
438
- return JsonColor.colorize(str)
439
- rescue Racc::ParseError
440
- end
441
- end
442
-
443
- return str
444
- end
445
434
  end
@@ -25,6 +25,14 @@ class String
25
25
  EOS
26
26
  end
27
27
 
28
+ def colorize_as(lang)
29
+ if @@colorize
30
+ CodeRay.scan(self, lang).terminal
31
+ else
32
+ self
33
+ end
34
+ end
35
+
28
36
  def encode64
29
37
  Base64.encode64(self).delete("\n")
30
38
  end
@@ -1,3 +1,3 @@
1
1
  module Kumogata
2
- VERSION = '0.2.11'
2
+ VERSION = '0.2.12'
3
3
  end
data/lib/kumogata.rb CHANGED
@@ -3,12 +3,12 @@ require 'kumogata/version'
3
3
 
4
4
  require 'aws-sdk'
5
5
  require 'base64'
6
+ require 'coderay'
6
7
  require 'diffy'
7
8
  require 'dslh'
8
9
  require 'hashie'
9
10
  require 'highline/import'
10
11
  require 'json'
11
- require 'json_color'
12
12
  require 'logger'
13
13
  require 'open-uri'
14
14
  require 'optparse'
@@ -21,3 +21,19 @@ require 'kumogata/client'
21
21
  require 'kumogata/ext/json_ext'
22
22
  require 'kumogata/ext/string_ext'
23
23
  require 'kumogata/logger'
24
+
25
+ CodeRay::Encoders::Terminal::TOKEN_COLORS[:key] = {
26
+ :self => "\e[1;34m",
27
+ :char => "\e[1;34m",
28
+ :delimiter => "\e[1;34m",
29
+ }
30
+
31
+ CodeRay::Encoders::Terminal::TOKEN_COLORS[:string] = {
32
+ :self => "\e[32m",
33
+ :modifier => "\e[1;32m",
34
+ :char => "\e[1;32m",
35
+ :delimiter => "\e[1;32m",
36
+ :escape => "\e[1;32m",
37
+ }
38
+
39
+ CodeRay::Encoders::Terminal::TOKEN_COLORS[:keyword] = "\e[31m"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kumogata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.11
4
+ version: 0.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: diffy
28
+ name: coderay
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '>='
@@ -39,35 +39,35 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: dslh
42
+ name: diffy
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '>='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.2.4
47
+ version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.2.4
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: hashie
56
+ name: dslh
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '>='
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 0.2.4
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 0.2.4
69
69
  - !ruby/object:Gem::Dependency
70
- name: highline
70
+ name: hashie
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - '>='
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: json
84
+ name: highline
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - '>='
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: json_color
98
+ name: json
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - '>='