script2md 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/exe/script2md +1 -1
- data/lib/script2md/version.rb +1 -1
- data/lib/script2md.rb +34 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b887dfcbc28891a097e3384e39fbde0450bc7f116b891296e5cee71ee44ef01a
|
4
|
+
data.tar.gz: 49c4de7e841d0f5e2785a78bea539e5865ca2d8e29e94cd5a364b57b3b645e68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6bd6afa43138e4d999f33d55ece0a9831e640309e83a77379ad7dbe83b1af5b6c3200fae13d8025946c51a8014c0bbba90e03fa8b3d54aa78736f1adf71b21b
|
7
|
+
data.tar.gz: f8e848d00f8162014b0fc35578bb63b932cc5453952479ce8919373dc0ac4daf9a9b052c653ae1756f3a51e0fa8f45e7a609806fd4e61e5b58572bff82016547
|
data/Gemfile.lock
CHANGED
data/exe/script2md
CHANGED
@@ -15,6 +15,6 @@ require 'open-uri'
|
|
15
15
|
file_path = ARGV[0]
|
16
16
|
language_type = file_path.match(/\.([a-z]+)\z/)[1] || nil
|
17
17
|
filebody = File.read(file_path)
|
18
|
-
puts Script2md.convert(filebody, language_type: language_type)
|
18
|
+
puts Script2md.convert(filebody, language_type: language_type, source_path: file_path)
|
19
19
|
end
|
20
20
|
|
data/lib/script2md/version.rb
CHANGED
data/lib/script2md.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require "script2md/version"
|
2
2
|
|
3
3
|
module Script2md
|
4
|
-
def self.convert(text, language_type: nil)
|
4
|
+
def self.convert(text, language_type: nil, source_path: nil)
|
5
5
|
output = Convert.new(text, language_type: language_type).convert.text
|
6
|
+
output = Fill.new(output, source_path: source_path).convert.text if source_path
|
6
7
|
output
|
7
8
|
end
|
8
9
|
|
@@ -43,4 +44,36 @@ module Script2md
|
|
43
44
|
text.gsub!(/\A[\n\r]+|[\n\r]+\z/, '')
|
44
45
|
end
|
45
46
|
end
|
47
|
+
|
48
|
+
class Fill
|
49
|
+
def initialize(text, source_path: nil)
|
50
|
+
@text = text
|
51
|
+
@source_path = source_path
|
52
|
+
end
|
53
|
+
|
54
|
+
attr_reader :text
|
55
|
+
|
56
|
+
def convert
|
57
|
+
fill_command_output!
|
58
|
+
self
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
attr_writer :text
|
64
|
+
attr_accessor :source_path
|
65
|
+
|
66
|
+
def fill_command_output!
|
67
|
+
output = ''
|
68
|
+
text.each_line do |line|
|
69
|
+
if line == '!OUTPUT!'
|
70
|
+
output += "```\n" + `#{source_path}` + "```\n"
|
71
|
+
else
|
72
|
+
output += line
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
self.text = output
|
77
|
+
end
|
78
|
+
end
|
46
79
|
end
|