kumogata2 0.1.0 → 0.1.1

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: e68a1cac5efe71e08f2d002ac2884c76818bb6fb
4
- data.tar.gz: a6373ae6c26e04b76775d44e75d257d2be92e9eb
3
+ metadata.gz: 2d28ad2995283dcefcf8a822715ba90cdeed0b49
4
+ data.tar.gz: 2c6d91189979a68e1d967254d95b67363b97f581
5
5
  SHA512:
6
- metadata.gz: 8851364eb886e8254f807432d5c33c4fe26988473d094b8e8a6b5a320ed27dafdda4d75b87b75be4727f87564a938e647f5a0a9d2f29a3ee3cfabbb15369b216
7
- data.tar.gz: 5c1dc3f643cf26808396fc84a7c951e72109ec1e05f0c62773a6d6a84aefb3875d8fe40e2cfba84ee7b27b626786cceb192735c1abda7717fde38015a2b9cd3a
6
+ metadata.gz: 2a8518aa53c27bd97b4bc237381666cd8791d3b4854d43b40377239816f7db9eb3fea7c41aaad28d582afcda0e8af2b87801b6c122b2becd81ef32c9d9c87cd8
7
+ data.tar.gz: f9459e808285698de5cac3e90a13c37ea882c069847e325964a79a21f02814315ad40356e6bd7eea35c3ec554a33bcdc07af2e82f52bcaad56529a24e0d51483
data/README.md CHANGED
@@ -72,6 +72,24 @@ Options:
72
72
  --[no-]debug
73
73
  ```
74
74
 
75
+ ### Create resources
76
+
77
+ $ kumogata create template.rb
78
+
79
+ If you want to save the stack, please specify the stack name:
80
+
81
+ $ kumogata create template.rb any_stack_name
82
+
83
+ If you want to pass parameters, please use `-p` option:
84
+
85
+ $ kumogata create template.rb -p "InstanceType=m1.large,KeyName=any_other_key"
86
+
87
+
88
+ **Notice**
89
+
90
+ **The stack will be delete if you do not specify the stack name explicitly.**
91
+ (And only the resources will remain)
92
+
75
93
  ## Plugin
76
94
 
77
95
  Kumogata2 can be extended with plug-ins, such as the following:
data/exe/kumogata2 CHANGED
@@ -22,8 +22,10 @@ def main(argv)
22
22
  elsif output_result and out
23
23
  puts out
24
24
  end
25
- rescue => e
26
- $stderr.puts("[ERROR] #{e.message}".red)
25
+ rescue Exception => e
26
+ if not e.kind_of?(Interrupt) and not e.kind_of?(SystemExit)
27
+ $stderr.puts("[ERROR] #{e.message}".red)
28
+ end
27
29
 
28
30
  if debug
29
31
  raise e
data/lib/kumogata2.rb CHANGED
@@ -1,10 +1,12 @@
1
1
  require 'aws-sdk'
2
2
  require 'coderay'
3
3
  require 'diffy'
4
+ require 'hashie'
4
5
  require 'highline/import'
5
6
  require 'json'
6
7
  require 'logger'
7
8
  require 'open-uri'
9
+ require 'optparse'
8
10
  require 'securerandom'
9
11
  require 'singleton'
10
12
  require 'term/ansicolor'
@@ -1,6 +1,3 @@
1
- require 'optparse'
2
- require 'hashie'
3
-
4
1
  module Kumogata2::CLI
5
2
  class OptionParser
6
3
  DEFAULT_OPTIONS = {
@@ -93,7 +90,8 @@ module Kumogata2::CLI
93
90
  options[:aws][:credentials][:path] = v
94
91
  end
95
92
 
96
- opt.on('' , '--output-format FORMAT', Kumogata2::Plugin.plugin_exts) do |v|
93
+ plugin_exts = Kumogata2::Plugin.plugins.flat_map(&:ext).uniq
94
+ opt.on('' , '--output-format FORMAT', plugin_exts) do |v|
97
95
  options[:output_format] = v
98
96
  end
99
97
 
@@ -183,10 +181,6 @@ module Kumogata2::CLI
183
181
  options.output_result = output
184
182
 
185
183
  [command, arguments, options, output]
186
- rescue => e
187
- $stderr.puts("[ERROR] #{e.message}")
188
- raise e if options[:debug]
189
- exit_parse!(1)
190
184
  end
191
185
 
192
186
  private
@@ -220,8 +214,11 @@ module Kumogata2::CLI
220
214
  }.join("\n"))
221
215
 
222
216
  opt.separator ''
223
- opt.separator 'Support Format: '
224
- opt.separator ' ' + Kumogata2::Plugin.plugin_exts.join(', ')
217
+ opt.separator 'Plugins: '
218
+
219
+ Kumogata2::Plugin.plugins.each do |plugin|
220
+ opt.separator " #{plugin.name}: #{plugin.ext.join(', ')}"
221
+ end
225
222
 
226
223
  opt.separator ''
227
224
  opt.separator 'Options:'
@@ -354,7 +354,7 @@ class Kumogata2::Client
354
354
  return @plugin_by_ext.fetch(ext)
355
355
  end
356
356
 
357
- plugin_class = Kumogata2::Plugin.find(ext)
357
+ plugin_class = Kumogata2::Plugin.find_by_ext(ext)
358
358
  plugin = plugin_class ? plugin_class.new(@options) : nil
359
359
  @plugin_by_ext[ext] = plugin
360
360
  end
@@ -2,32 +2,33 @@ module Kumogata2::Plugin
2
2
  class << self
3
3
  def register(name, exts, klass)
4
4
  name = name.to_s
5
- @plugins ||= {}
5
+ @plugins ||= Hashie::Mash.new
6
6
 
7
7
  if @plugins.has_key?(name)
8
- raise "Plugin has already been registered: #{name}"
8
+ Kumogata2::Logger::Helper.log(:warn, "Plugin has already been registered: #{name}", color: :yellow)
9
9
  end
10
10
 
11
11
  @plugins[name] = {
12
- class: klass,
12
+ name: name,
13
+ type: klass,
13
14
  ext: exts.map(&:to_s),
14
15
  }
15
16
  end
16
17
 
17
- def find(ext)
18
- plgns = @plugins.to_a.reverse
19
-
20
- plugin_name, plugin_attrs = plgns.find do |name, attrs|
21
- attrs[:ext].include?(ext)
18
+ def find_by_ext(ext)
19
+ plgn = self.plugins.reverse.find do |i|
20
+ i.ext.include?(ext)
22
21
  end
23
22
 
24
- plugin_attrs ? plugin_attrs[:class] : nil
23
+ plgn ? plgn.type : nil
24
+ end
25
+
26
+ def plugin_by_name
27
+ @plugins
25
28
  end
26
29
 
27
- def plugin_exts
28
- @plugins.flat_map {|name, attrs|
29
- attrs[:ext]
30
- }.uniq
30
+ def plugins
31
+ @plugins.map {|_, v| v }
31
32
  end
32
33
 
33
34
  def load_plugins
@@ -35,7 +36,7 @@ module Kumogata2::Plugin
35
36
 
36
37
  plgns.each do |plgns_spec|
37
38
  name = plgns_spec.name
38
- path = File.join(name.split('-').slice(0, 3))
39
+ path = File.join(name.split('-', 3))
39
40
 
40
41
  begin
41
42
  require path
@@ -1,3 +1,3 @@
1
1
  module Kumogata2
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kumogata2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-30 00:00:00.000000000 Z
11
+ date: 2016-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk