lambit 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.evnrc.example +1 -0
- data/.gitignore +18 -0
- data/.ruby-version.example +1 -0
- data/.travis.yml +0 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +11 -0
- data/LICENSE +20 -0
- data/README.md +74 -0
- data/Rakefile.rb +0 -0
- data/bin/lambit +91 -0
- data/lambit.gemspec +32 -0
- data/lambit.yml.example +96 -0
- data/lib/lambit.rb +6 -0
- data/lib/lambit/aws.rb +9 -0
- data/lib/lambit/aws/cloud_watch/alarm.rb +59 -0
- data/lib/lambit/aws/cloud_watch_events/rule.rb +62 -0
- data/lib/lambit/aws/lambda/function.rb +53 -0
- data/lib/lambit/aws/lambda/permission.rb +52 -0
- data/lib/lambit/aws/s3/bucket_notification_configuration.rb +81 -0
- data/lib/lambit/commands.rb +6 -0
- data/lib/lambit/commands/build.rb +128 -0
- data/lib/lambit/commands/common.rb +92 -0
- data/lib/lambit/commands/lambdas.rb +411 -0
- data/lib/lambit/commands/subcommand.rb +87 -0
- data/lib/lambit/common.rb +6 -0
- data/lib/lambit/common/config.rb +45 -0
- data/lib/lambit/common/hash_helper.rb +48 -0
- data/lib/lambit/common/logger.rb +24 -0
- data/lib/lambit/common/string_helper.rb +39 -0
- data/lib/lambit/version.rb +5 -0
- data/test/test_helper.rb +0 -0
- metadata +174 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'singleton'
|
5
|
+
|
6
|
+
module Lambit
|
7
|
+
module Common
|
8
|
+
class Config
|
9
|
+
include Singleton
|
10
|
+
|
11
|
+
attr_reader :global_options
|
12
|
+
attr_reader :config
|
13
|
+
|
14
|
+
def init_config(options)
|
15
|
+
@global_options = options
|
16
|
+
project_path = options['project-path']
|
17
|
+
config_filename = options['config-filename'] || 'lambit.yml'
|
18
|
+
|
19
|
+
config_path = ::File.join(project_path, config_filename)
|
20
|
+
exit_now!("#{config_filename} file not found!") unless File.exist?(config_path)
|
21
|
+
@config = YAML.load_file(config_path)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.config
|
27
|
+
return Lambit::Common::Config.instance.config
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.global_options
|
31
|
+
return Lambit::Common::Config.instance.global_options
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.is_verbose?
|
35
|
+
return Lambit::Common::Config.instance.global_options[:verbose]
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.is_dry_run?
|
39
|
+
return Lambit::Common::Config.instance.global_options['dry-run']
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.is_debug?
|
43
|
+
return Lambit::Common::Config.instance.global_options[:debug]
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Lambit
|
4
|
+
module Common
|
5
|
+
module HashHelper
|
6
|
+
refine ::Hash do
|
7
|
+
def symbolize_keys
|
8
|
+
self.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
9
|
+
end
|
10
|
+
|
11
|
+
def symbolize_keys_deep
|
12
|
+
h = self.symbolize_keys
|
13
|
+
h.each do |k, v|
|
14
|
+
if v.respond_to?(:has_key?)
|
15
|
+
h[k.to_sym] = v.symbolize_keys_deep
|
16
|
+
elsif v.respond_to?(:each)
|
17
|
+
v.each_with_index do |item, index|
|
18
|
+
if item.respond_to?(:has_key?)
|
19
|
+
v[index] = item.symbolize_keys_deep
|
20
|
+
else
|
21
|
+
v[index] = item
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def difference(other)
|
29
|
+
reject do |k,v|
|
30
|
+
other.has_key? k
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.recursive_merge!(other_hash)
|
35
|
+
other_hash.each_pair do |k, v|
|
36
|
+
cur_val = self[k]
|
37
|
+
if cur_val.is_a?(Hash) && v.is_a?(Hash)
|
38
|
+
self[k] = recursive_merge!(cur_val, v)
|
39
|
+
elsif !v.nil?
|
40
|
+
self[k] = v
|
41
|
+
end
|
42
|
+
end
|
43
|
+
self
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'logger'
|
4
|
+
require 'singleton'
|
5
|
+
|
6
|
+
$stdout.sync = true
|
7
|
+
|
8
|
+
module Lambit
|
9
|
+
module Common
|
10
|
+
class SimpleLogger < ::Logger
|
11
|
+
include Singleton
|
12
|
+
|
13
|
+
def initialize(logdev=nil, shift_age=nil, shift_size=nil)
|
14
|
+
super
|
15
|
+
@logdev = ::Logger::LogDevice.new(STDOUT)
|
16
|
+
@level = INFO
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.logger
|
22
|
+
return Lambit::Common::SimpleLogger.instance
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Lambit
|
4
|
+
module Common
|
5
|
+
module StringHelper
|
6
|
+
refine ::String do
|
7
|
+
def randcase
|
8
|
+
dup.split('').map do |char|
|
9
|
+
if rand(1..10) > 5
|
10
|
+
char.upcase
|
11
|
+
else
|
12
|
+
char.downcase
|
13
|
+
end
|
14
|
+
end.join
|
15
|
+
end
|
16
|
+
|
17
|
+
def classify
|
18
|
+
self.split('_').collect(&:capitalize).join
|
19
|
+
end
|
20
|
+
|
21
|
+
def underscore
|
22
|
+
self.gsub(/::/, '/').
|
23
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
24
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
25
|
+
tr("-", "_").
|
26
|
+
downcase
|
27
|
+
end
|
28
|
+
|
29
|
+
def titleize
|
30
|
+
self.gsub(/\b('?[a-z])/) { $1.capitalize }
|
31
|
+
end
|
32
|
+
|
33
|
+
def titleize_words
|
34
|
+
self.gsub(/\w+/) { |s| s.capitalize }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/test/test_helper.rb
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lambit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Will Drew
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: gli
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.13'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: aws-sdk
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.7'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.7'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.10'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.10'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: mocha
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.1'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.1'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: shoulda-context
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.2'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.2'
|
111
|
+
description: ''
|
112
|
+
email:
|
113
|
+
- willdrew@gmail.com
|
114
|
+
executables:
|
115
|
+
- lambit
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".evnrc.example"
|
120
|
+
- ".gitignore"
|
121
|
+
- ".ruby-version.example"
|
122
|
+
- ".travis.yml"
|
123
|
+
- CHANGELOG.md
|
124
|
+
- Gemfile
|
125
|
+
- LICENSE
|
126
|
+
- README.md
|
127
|
+
- Rakefile.rb
|
128
|
+
- bin/lambit
|
129
|
+
- lambit.gemspec
|
130
|
+
- lambit.yml.example
|
131
|
+
- lib/lambit.rb
|
132
|
+
- lib/lambit/aws.rb
|
133
|
+
- lib/lambit/aws/cloud_watch/alarm.rb
|
134
|
+
- lib/lambit/aws/cloud_watch_events/rule.rb
|
135
|
+
- lib/lambit/aws/lambda/function.rb
|
136
|
+
- lib/lambit/aws/lambda/permission.rb
|
137
|
+
- lib/lambit/aws/s3/bucket_notification_configuration.rb
|
138
|
+
- lib/lambit/commands.rb
|
139
|
+
- lib/lambit/commands/build.rb
|
140
|
+
- lib/lambit/commands/common.rb
|
141
|
+
- lib/lambit/commands/lambdas.rb
|
142
|
+
- lib/lambit/commands/subcommand.rb
|
143
|
+
- lib/lambit/common.rb
|
144
|
+
- lib/lambit/common/config.rb
|
145
|
+
- lib/lambit/common/hash_helper.rb
|
146
|
+
- lib/lambit/common/logger.rb
|
147
|
+
- lib/lambit/common/string_helper.rb
|
148
|
+
- lib/lambit/version.rb
|
149
|
+
- test/test_helper.rb
|
150
|
+
homepage: https://github.com/willdrew/lambit
|
151
|
+
licenses: []
|
152
|
+
metadata: {}
|
153
|
+
post_install_message:
|
154
|
+
rdoc_options: []
|
155
|
+
require_paths:
|
156
|
+
- lib
|
157
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - ">="
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: 1.9.3
|
162
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 1.3.6
|
167
|
+
requirements: []
|
168
|
+
rubyforge_project:
|
169
|
+
rubygems_version: 2.4.5.1
|
170
|
+
signing_key:
|
171
|
+
specification_version: 4
|
172
|
+
summary: ''
|
173
|
+
test_files:
|
174
|
+
- test/test_helper.rb
|