ellen 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -2
- data/README.md +3 -0
- data/lib/ellen/adapters/base.rb +18 -0
- data/lib/ellen/env.rb +36 -0
- data/lib/ellen/robot.rb +5 -0
- data/lib/ellen/version.rb +1 -1
- data/lib/ellen.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29ad3aa6bd8349d58077ff020f9bea37e7fca57b
|
4
|
+
data.tar.gz: b37cbe10c8c7878b2b3a7b036b64b4307128c1c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ec91fd6d9acf7d972d68d4493f5cfb058671361a47e6eee34b7f909d2c489c546b4691b195a619f15f851cb2e03444eb9c4152bfebb7532123c5ab0299892dc
|
7
|
+
data.tar.gz: ee94c91e91fc28f5188810ad31b35947c239f32445119dd7c91173976e05bbb005fcfbabfa3f95a3d674dd1b37bd4c4111ad6e981a9d94ddbfecf6ffd5028191
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/lib/ellen/adapters/base.rb
CHANGED
@@ -16,6 +16,18 @@ module Ellen
|
|
16
16
|
def inherited(child)
|
17
17
|
Ellen.adapters[child.name.split("::").last.underscore] = child
|
18
18
|
end
|
19
|
+
|
20
|
+
def env(key, description, options = {})
|
21
|
+
envs << Env.new(key, description, options)
|
22
|
+
end
|
23
|
+
|
24
|
+
def envs
|
25
|
+
@envs ||= []
|
26
|
+
end
|
27
|
+
|
28
|
+
def usage
|
29
|
+
envs.map(&:to_usage).join("\n")
|
30
|
+
end
|
19
31
|
end
|
20
32
|
|
21
33
|
attr_reader :robot, :options
|
@@ -28,6 +40,12 @@ module Ellen
|
|
28
40
|
def say(body, options = {})
|
29
41
|
Ellen.logger.info("Not implemented #{self.class}##{__method__} was called")
|
30
42
|
end
|
43
|
+
|
44
|
+
def validate
|
45
|
+
self.class.envs.each(&:validate)
|
46
|
+
rescue Env::MissingRequiredKeyError => exception
|
47
|
+
Ellen.die("#{exception}\n#{self.class.usage}")
|
48
|
+
end
|
31
49
|
end
|
32
50
|
end
|
33
51
|
end
|
data/lib/ellen/env.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
module Ellen
|
2
|
+
class Env
|
3
|
+
attr_reader :key, :description, :options
|
4
|
+
|
5
|
+
def initialize(key, description, options = {})
|
6
|
+
@key = key.to_s
|
7
|
+
@description = description
|
8
|
+
@options = options
|
9
|
+
end
|
10
|
+
|
11
|
+
def validate
|
12
|
+
error if required? && missing?
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_usage
|
16
|
+
" %-20s - %s" % [key, description]
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def required?
|
22
|
+
!options[:optional]
|
23
|
+
end
|
24
|
+
|
25
|
+
def missing?
|
26
|
+
!ENV[key]
|
27
|
+
end
|
28
|
+
|
29
|
+
def error
|
30
|
+
raise MissingRequiredKeyError, %<ENV["#{key}"] is required but missing>
|
31
|
+
end
|
32
|
+
|
33
|
+
class MissingRequiredKeyError < StandardError
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/ellen/robot.rb
CHANGED
@@ -13,6 +13,7 @@ module Ellen
|
|
13
13
|
def run
|
14
14
|
bundle
|
15
15
|
setup
|
16
|
+
validate
|
16
17
|
adapt
|
17
18
|
end
|
18
19
|
|
@@ -46,5 +47,9 @@ module Ellen
|
|
46
47
|
Ellen.handlers.map {|handler_class| handler_class.new(self) }
|
47
48
|
end
|
48
49
|
memoize :handlers
|
50
|
+
|
51
|
+
def validate
|
52
|
+
adapter.validate
|
53
|
+
end
|
49
54
|
end
|
50
55
|
end
|
data/lib/ellen/version.rb
CHANGED
data/lib/ellen.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ellen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- lib/ellen/commands/base.rb
|
134
134
|
- lib/ellen/commands/generate.rb
|
135
135
|
- lib/ellen/commands/run.rb
|
136
|
+
- lib/ellen/env.rb
|
136
137
|
- lib/ellen/handlers/base.rb
|
137
138
|
- lib/ellen/handlers/help.rb
|
138
139
|
- lib/ellen/logger.rb
|