bgem 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bgem.rb +4 -24
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96d672340c2e0219779613ee0f119d5c568b1aea
|
4
|
+
data.tar.gz: d9687b5b9e364c51ea83422fd9c44ba95fad9a9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b107053c821883afa1c8af1266e9069bff8d8c74d0761af551403f50fbbdaacbcf77587a9afb7c8522ecc153ba3fcdf3a1a18ac86ca4d9b05382b680243b0a44
|
7
|
+
data.tar.gz: a8aa6cca73e13fa4ff93ba59d6e37711feb14436d3392f8c9655e5d141b08ffdf8e1e66131dd618dfd50e6ca6f1c471cf54e591e78556dbee7c3ea9f6b6e99d9
|
data/lib/bgem.rb
CHANGED
@@ -16,27 +16,12 @@ module Bgem
|
|
16
16
|
class << self
|
17
17
|
def run config_file = CONFIG_FILE
|
18
18
|
config = Config.new config_file
|
19
|
-
target = TargetFile.new config.output, config.scope
|
19
|
+
target = TargetFile.new config.output, config.scope
|
20
20
|
target.write SourceFile.new(config.entry).to_s
|
21
21
|
target
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
module CLI
|
26
|
-
def self.run
|
27
|
-
options = parse_argv
|
28
|
-
target = TargetFile.new *options[:output], options[:scope]
|
29
|
-
target.write SourceFile.new(*options[:input]).to_s
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.parse_argv
|
33
|
-
ARGV.map do |string|
|
34
|
-
key, _colon, value = string.partition ':'
|
35
|
-
[key.to_sym, value]
|
36
|
-
end.to_h
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
25
|
class Config
|
41
26
|
def initialize config_file
|
42
27
|
@entry, @output, @scope = SOURCE_FILE, 'output.rb', nil
|
@@ -108,21 +93,16 @@ module Bgem
|
|
108
93
|
end
|
109
94
|
|
110
95
|
class TargetFile
|
111
|
-
def initialize path = 'output.rb', scope
|
96
|
+
def initialize path = 'output.rb', scope
|
112
97
|
@path = Pathname path
|
113
|
-
@scope =
|
114
|
-
when Array
|
115
|
-
scope
|
116
|
-
when String
|
117
|
-
eval scope
|
118
|
-
end
|
98
|
+
@scope = scope
|
119
99
|
end
|
120
100
|
|
121
101
|
def write string
|
122
102
|
@path.dirname.mkpath
|
123
103
|
|
124
104
|
if @scope
|
125
|
-
@scope.
|
105
|
+
@scope.each do |head_of_constant_definition|
|
126
106
|
string = "#{head_of_constant_definition}\n#{string.indent INDENT}\nend"
|
127
107
|
end
|
128
108
|
end
|