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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1cfdc5eb76bdf8e65e4b5ebc6a391fb8e7479264a0e5a25b614d2b55c89d48d4
4
- data.tar.gz: 02f5c2168a20a15589fb9dac4fa4e33946f08f5c1a57a82cd56dc9c200143b88
3
+ metadata.gz: b887dfcbc28891a097e3384e39fbde0450bc7f116b891296e5cee71ee44ef01a
4
+ data.tar.gz: 49c4de7e841d0f5e2785a78bea539e5865ca2d8e29e94cd5a364b57b3b645e68
5
5
  SHA512:
6
- metadata.gz: c77bfc68a8e2f7322fc767501f78414562d30b9a9a9321637099f91fb2e31bf9af0f1b27fe5d90b53fb33722551f613249a937d2651671f7867aa56493c02ab3
7
- data.tar.gz: b70ea448a5f90a8ccc98e5a590c7bd972d5f03102bf5f99cf6e5cfbfbf74356346624e3305d0ff34f8b87682b9fafbc5e67379822a94319ba6224588e709e7f6
6
+ metadata.gz: f6bd6afa43138e4d999f33d55ece0a9831e640309e83a77379ad7dbe83b1af5b6c3200fae13d8025946c51a8014c0bbba90e03fa8b3d54aa78736f1adf71b21b
7
+ data.tar.gz: f8e848d00f8162014b0fc35578bb63b932cc5453952479ce8919373dc0ac4daf9a9b052c653ae1756f3a51e0fa8f45e7a609806fd4e61e5b58572bff82016547
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- script2md (1.0.2)
4
+ script2md (1.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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
 
@@ -1,3 +1,3 @@
1
1
  module Script2md
2
- VERSION = "1.0.2"
2
+ VERSION = "1.1.0"
3
3
  end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: script2md
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yumainaura