bgem 0.0.3 → 0.0.4
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 +42 -33
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a70b7967fc8d90e3bcc7532b61bfca8853acd161
|
4
|
+
data.tar.gz: 0c01f06e669f2a09d1fa22d683f64b006b707288
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c740b22218e8e13d3ae22c292258982a706348859433a8cba36d9e0fd3504ee75d969a7823756cbfd10794fcdb12267e23ea5c96eb0181620aa2487274e0a3a8
|
7
|
+
data.tar.gz: 663f242e757c4b0144ef346c36c7e39c5b7e5e8f82fda4da43f2a106d8ff92c86a937f275d7e75a7560cdc333bba118c992e84bb3b8e1bccbd74a59fe0562dbf
|
data/lib/bgem.rb
CHANGED
@@ -12,39 +12,6 @@ module Bgem
|
|
12
12
|
INDENT = 2
|
13
13
|
SOURCE_FILE = Dir['src/*.rb'][0]
|
14
14
|
|
15
|
-
class SourceFile
|
16
|
-
def initialize file = SOURCE_FILE, indent: 0
|
17
|
-
@file, @indent = (Pathname file), indent
|
18
|
-
@source = @file.read
|
19
|
-
@constant, @type, _rb = @file.basename.to_s.split '.'
|
20
|
-
end
|
21
|
-
|
22
|
-
def to_s
|
23
|
-
"#{@type} #{@constant}\n#{source}end".indent @indent
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
def source
|
28
|
-
source = @source.indent INDENT
|
29
|
-
source.prepend "#{before}\n\n" unless before.empty?
|
30
|
-
source.concat "\n#{after}\n" unless after.empty?
|
31
|
-
source
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.concatenate_source_files *symbols
|
35
|
-
symbols.each do |symbol|
|
36
|
-
define_method symbol do
|
37
|
-
pattern = @file.dirname.join "#{__method__}.#{@constant}/*.rb"
|
38
|
-
Pathname.glob(pattern).map do |file|
|
39
|
-
self.class.new(file, indent: INDENT).to_s
|
40
|
-
end.join "\n\n"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
concatenate_source_files :before, :after
|
46
|
-
end
|
47
|
-
|
48
15
|
module CLI
|
49
16
|
def self.run
|
50
17
|
options = parse_argv
|
@@ -78,4 +45,46 @@ module Bgem
|
|
78
45
|
@path.write string
|
79
46
|
end
|
80
47
|
end
|
48
|
+
|
49
|
+
class SourceFile
|
50
|
+
def initialize file = SOURCE_FILE, indent: 0
|
51
|
+
@file, @indent = (Pathname file), indent
|
52
|
+
@source = @file.read
|
53
|
+
head, @type, _rb = @file.basename.to_s.split '.'
|
54
|
+
@constant, _colon, @ancestor = head.partition ':'
|
55
|
+
end
|
56
|
+
|
57
|
+
def to_s
|
58
|
+
"#{head}#{source}end".indent @indent
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
def head
|
63
|
+
if @ancestor.empty?
|
64
|
+
"#{@type} #{@constant}\n"
|
65
|
+
else
|
66
|
+
"#{@type} #{@constant} < #{@ancestor}\n"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def source
|
71
|
+
source = @source.indent INDENT
|
72
|
+
source.prepend "#{before}\n\n" unless before.empty?
|
73
|
+
source.concat "\n#{after}\n" unless after.empty?
|
74
|
+
source
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.concatenate_source_files *symbols
|
78
|
+
symbols.each do |symbol|
|
79
|
+
define_method symbol do
|
80
|
+
pattern = @file.dirname.join "#{__method__}.#{@constant}/*.rb"
|
81
|
+
Pathname.glob(pattern).map do |file|
|
82
|
+
self.class.new(file, indent: INDENT).to_s
|
83
|
+
end.join "\n\n"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
concatenate_source_files :before, :after
|
89
|
+
end
|
81
90
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bgem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anatoly Chernow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|