kumogata2 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,48 @@
1
+ module Kumogata2::Plugin
2
+ class << self
3
+ def register(name, exts, klass)
4
+ name = name.to_s
5
+ @plugins ||= {}
6
+
7
+ if @plugins.has_key?(name)
8
+ raise "Plugin has already been registered: #{name}"
9
+ end
10
+
11
+ @plugins[name] = {
12
+ class: klass,
13
+ ext: exts.map(&:to_s),
14
+ }
15
+ end
16
+
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)
22
+ end
23
+
24
+ plugin_attrs ? plugin_attrs[:class] : nil
25
+ end
26
+
27
+ def plugin_exts
28
+ @plugins.flat_map {|name, attrs|
29
+ attrs[:ext]
30
+ }.uniq
31
+ end
32
+
33
+ def load_plugins
34
+ plgns = Gem::Specification.find_all.select {|i| i.name =~ /\Akumogata2-plugin-/ }
35
+
36
+ plgns.each do |plgns_spec|
37
+ name = plgns_spec.name
38
+ path = File.join(name.split('-').slice(0, 3))
39
+
40
+ begin
41
+ require path
42
+ rescue LoadError => e
43
+ Kumogata2::Logger::Helper.log(:warn, "Cannot load plugin: #{name}: #{e}", color: :yellow)
44
+ end
45
+ end
46
+ end
47
+ end # of class methods
48
+ end # Kumogata2::Plugin
@@ -0,0 +1,36 @@
1
+ class Kumogata2::Utils
2
+ class << self
3
+ def camelize(str)
4
+ str.to_s.split(/[-_]/).map {|i|
5
+ i[0, 1].upcase + i[1..-1].downcase
6
+ }.join
7
+ end
8
+
9
+ def filter_backtrace(backtrace)
10
+ filter_path = ['(eval)']
11
+
12
+ if defined?(Gem)
13
+ filter_path.concat(Gem.path)
14
+ filter_path << Gem.bindir
15
+ end
16
+
17
+ RbConfig::CONFIG.select {|k, v|
18
+ k.to_s =~ /libdir/
19
+ }.each {|k, v| filter_path << v }
20
+
21
+ filter_path = filter_path.map {|i| /\A#{Regexp.escape(i)}/ }
22
+
23
+ backtrace.select do |path|
24
+ path = path.split(':', 2).first
25
+ not filter_path.any? {|i| i =~ path }
26
+ end
27
+ end
28
+
29
+ def get_user_host
30
+ user = `whoami`.strip rescue ''
31
+ host = `hostname`.strip rescue ''
32
+ user_host = [user, host].select {|i| not i.empty? }.join('-')
33
+ user_host.empty? ? nil : user_host
34
+ end
35
+ end # of class methods
36
+ end
@@ -0,0 +1,3 @@
1
+ module Kumogata2
2
+ VERSION = '0.1.0'
3
+ end
data/lib/kumogata2.rb ADDED
@@ -0,0 +1,21 @@
1
+ require 'aws-sdk'
2
+ require 'coderay'
3
+ require 'diffy'
4
+ require 'highline/import'
5
+ require 'json'
6
+ require 'logger'
7
+ require 'open-uri'
8
+ require 'securerandom'
9
+ require 'singleton'
10
+ require 'term/ansicolor'
11
+
12
+ require 'kumogata2/version'
13
+ require 'kumogata2/ext/coderay_ext'
14
+ require 'kumogata2/ext/string_ext'
15
+ require 'kumogata2/logger'
16
+ require 'kumogata2/utils'
17
+
18
+ require 'kumogata2/plugin'
19
+ require 'kumogata2/plugin/json'
20
+
21
+ require 'kumogata2/client'
metadata ADDED
@@ -0,0 +1,206 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kumogata2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Genki Sugawara
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-04-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aws-sdk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.3.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.3.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: coderay
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: diffy
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: hashie
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: highline
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: term-ansicolor
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: bundler
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '3.0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '3.0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: kumogata2-plugin-ruby
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: Kumogata2 is a tool for AWS CloudFormation.
154
+ email:
155
+ - sugawara@cookpad.com
156
+ executables:
157
+ - kumogata2
158
+ extensions: []
159
+ extra_rdoc_files: []
160
+ files:
161
+ - ".gitignore"
162
+ - ".rspec"
163
+ - ".travis.yml"
164
+ - Gemfile
165
+ - LICENSE.txt
166
+ - README.md
167
+ - Rakefile
168
+ - bin/console
169
+ - bin/setup
170
+ - exe/kumogata2
171
+ - kumogata2.gemspec
172
+ - lib/kumogata2.rb
173
+ - lib/kumogata2/cli/option_parser.rb
174
+ - lib/kumogata2/client.rb
175
+ - lib/kumogata2/ext/coderay_ext.rb
176
+ - lib/kumogata2/ext/string_ext.rb
177
+ - lib/kumogata2/logger.rb
178
+ - lib/kumogata2/plugin.rb
179
+ - lib/kumogata2/plugin/json.rb
180
+ - lib/kumogata2/utils.rb
181
+ - lib/kumogata2/version.rb
182
+ homepage: https://github.com/winebarrel/kumogata2
183
+ licenses:
184
+ - MIT
185
+ metadata: {}
186
+ post_install_message:
187
+ rdoc_options: []
188
+ require_paths:
189
+ - lib
190
+ required_ruby_version: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ required_rubygems_version: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ version: '0'
200
+ requirements: []
201
+ rubyforge_project:
202
+ rubygems_version: 2.4.5.1
203
+ signing_key:
204
+ specification_version: 4
205
+ summary: Kumogata2 is a tool for AWS CloudFormation.
206
+ test_files: []