script2md 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5de693fa9d9c989830ce74872592beb9bc0e9684b9faa8e8cf5248a75faacc03
4
- data.tar.gz: 0fd4aaaf8b5fb28da4df2bd6189673438f566021871959474171de42ffa10643
3
+ metadata.gz: f5f221a5f420d71b31254ac4dd8c78414ad98ffd6c5c73306bd9959e5cd62b24
4
+ data.tar.gz: 17e3cd650b792fc86f7bdb7cd6a78f5aa4f417fdfe980b0f69c55ff8639071c9
5
5
  SHA512:
6
- metadata.gz: f01d775172cc4649e8489a1946a4d66d1eb5f332db38daf41ab19a92a0de1abe16ebb43cfb728d65a1cc95ee4ace312c76f783d1df0a31d9f47d3f74feb5f430
7
- data.tar.gz: '06268f2d257d9148bd603758f11557e81cf9c8c2ceb5d7ef991819a162807ca39e5ece487ca31d8af6293e2d39f5597cb4d8c63c3c13c802b4cb34f1db1f8c89'
6
+ metadata.gz: c4d8dbc500b08bdab6172d13d04b8acd3aaa3eb32050378d95ed313ef7fa20731a17aa92080008acea081fb407ca7387b93100f97a2d6c4d776aa10d925e4385
7
+ data.tar.gz: 8dbc4f842a9b12d7f3ca6d578da83f3cda8c858a28959ee50e4eab24df5bb73facf2cde529f558bf5cde49f24be99b64a794b5134b5c6e7db68de8c88011805d
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- script2md (1.1.1)
4
+ script2md (1.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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, source_path: file_path)
18
+ puts Script2md.convert(filebody, language_type: language_type)
19
19
  end
20
20
 
@@ -1,9 +1,12 @@
1
1
  require "script2md/version"
2
2
 
3
3
  module Script2md
4
- def self.convert(text, language_type: nil, source_path: nil)
4
+ def self.convert(text, language_type: nil)
5
+ # FIXME: Prevent gsub! break original text value
6
+ original_script_text = text.clone
7
+
5
8
  output = Convert.new(text, language_type: language_type).convert.text
6
- output = Fill.new(output, source_path: source_path).convert.text if source_path
9
+ output = Fill.new(output, script: original_script_text).convert.text
7
10
  output
8
11
  end
9
12
 
@@ -46,9 +49,9 @@ module Script2md
46
49
  end
47
50
 
48
51
  class Fill
49
- def initialize(text, source_path: nil)
52
+ def initialize(text, script: nil)
50
53
  @text = text
51
- @source_path = source_path
54
+ @script = script
52
55
  end
53
56
 
54
57
  attr_reader :text
@@ -61,13 +64,16 @@ module Script2md
61
64
  private
62
65
 
63
66
  attr_writer :text
64
- attr_accessor :source_path
67
+ attr_accessor :script
65
68
 
66
69
  def fill_command_output!
67
70
  output = ''
68
71
  text.each_line do |line|
69
72
  if line.chomp == '!OUTPUT!'
70
- output += "```\n" + `#{source_path}` + "```\n"
73
+ File.write('./tmpscript', script)
74
+ File.chmod(0700, './tmpscript')
75
+ output += "```\n" + `./tmpscript` + "```\n"
76
+ File.delete('./tmpscript')
71
77
  else
72
78
  output += line
73
79
  end
@@ -1,3 +1,3 @@
1
1
  module Script2md
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  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.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yumainaura