sc2md 1.1.3 → 1.2.0

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: '08ffc90e06c5e78fca5aece37673ce50c266d3a649649602cb5e19a963385b1f'
4
- data.tar.gz: 8d56680acbccf7327cfeec94d33efeef45ba4f89d4bfa02c458297039af1afeb
3
+ metadata.gz: fcf0d136870976d4f48bf1c71e2558d8faa225e109c588efa6c837962ac30261
4
+ data.tar.gz: 625b45e31301ff37ff35cfab2542ec684d688f508cc358efbaa68719ded1cc4a
5
5
  SHA512:
6
- metadata.gz: 9ce3730fb018005809b8a7f21bf9434876b331aa68ed2fe09dba99e830f27244ef3f3c61d2b42c8129a0241081009f8f4e881db998d89fc11940858d46a8036b
7
- data.tar.gz: 78380838d9eba3a20a1c7cbae9f276f0dd236a5bded5e7f8e26206b89318e0790b9953414476da0a167ee9a5ff97e07cdf66efece5bae440034237a766db1d54
6
+ metadata.gz: 0da1540ec755f0c55267253c4f475b1986e0c0d91c6632f7376d4a14845e732d25587c05e3530f4c25d073a6b4b6554eddf6be19bf3bc72de9aa29d86d24f9cd
7
+ data.tar.gz: 1ce7161e45700745a6ff18f987689c1d956d10f50bd807ae06304315db96cc33353f1941db99f8024fd12dbf490e9049375d4ee910b73991dd81424c0661411a
data/.rubygems.url CHANGED
@@ -1 +1 @@
1
- https://rubygems.org/gems/script2md
1
+ https://rubygems.org/gems/sc2md
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sc2md (1.1.3)
4
+ sc2md (1.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
- # Script2md
1
+ # sc2md
2
2
 
3
- It is a Simple Ruby gem.
3
+ Simple Ruby gem.
4
+
5
+ It means **Script to Markdown**.
4
6
 
5
7
  Convert script file ( e.g `.sh` `.rb` ) to Markdown file.
6
8
 
@@ -11,17 +13,9 @@ It just only replace script comment line with markdown plain text, and script co
11
13
  Add this line to your application's Gemfile:
12
14
 
13
15
  ```ruby
14
- gem 'script2md'
16
+ gem 'sc2md'
15
17
  ```
16
18
 
17
- And then execute:
18
-
19
- $ bundle
20
-
21
- Or install it yourself as:
22
-
23
- $ gem install script2md
24
-
25
19
  ## Usage
26
20
 
27
21
  ### Command
@@ -33,10 +27,16 @@ sc2md spec/fixtures/example.sh
33
27
  or
34
28
 
35
29
  ```
36
- sc2md https://raw.githubusercontent.com/YumaInaura/script2md/master/spec/fixtures/example.sh
30
+ sc2md https://raw.githubusercontent.com/YumaInaura/sc2md/master/spec/fixtures/example.sh
37
31
  ```
38
32
 
39
- ### IN FILE
33
+ #### Output to file
34
+
35
+ ```
36
+ sc2md spec/fixtures/example.sh > converted.md
37
+ ```
38
+
39
+ ### Input file example
40
40
 
41
41
  ```sh
42
42
  #!/bin/bash -eu
@@ -58,7 +58,7 @@ echo some command
58
58
  echo "i wanna conver to markdown this file"
59
59
  ```
60
60
 
61
- ### OUT FILE
61
+ ### Output file example
62
62
 
63
63
  ```
64
64
  # Header1
@@ -91,4 +91,3 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
91
91
 
92
92
  Bug reports and pull requests are welcome on GitHub. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
93
93
 
94
-
data/example.sh CHANGED
@@ -1,3 +1,16 @@
1
- #!/bin/bash -eux
1
+ #!/bin/bash -eu
2
2
 
3
- bundle exec ruby exe/sc2md spec/fixtures/example.sh
3
+ for script_file in $(find ./spec/fixtures -type f -maxdepth 1 | grep -v '\.md'); do
4
+ echo "============================"
5
+ echo "Convert $script_file"
6
+
7
+ echo "----------------------------"
8
+ echo "Input"
9
+ echo "----------------------------"
10
+ cat "$script_file"
11
+
12
+ echo "----------------------------"
13
+ echo "Output"
14
+ echo "----------------------------"
15
+ bundle exec ruby exe/sc2md "$script_file"
16
+ done
data/lib/script2md.rb CHANGED
@@ -2,17 +2,14 @@ require "script2md/version"
2
2
 
3
3
  module Script2md
4
4
  def self.convert(text, language_type: nil)
5
- # FIXME: Prevent gsub! break original text value
6
- original_script_text = text.clone
7
-
8
5
  output = Convert.new(text, language_type: language_type).convert.text
9
- output = Fill.new(output, script: original_script_text).convert.text
6
+ output = Fill.new(output, script: text).convert.text
10
7
  output
11
8
  end
12
9
 
13
10
  class Convert
14
11
  def initialize(text, language_type: nil)
15
- @text = text
12
+ @text = text.clone
16
13
  @language_type = language_type
17
14
  end
18
15
 
@@ -35,12 +32,12 @@ module Script2md
35
32
  end
36
33
 
37
34
  def code_into_codeblock!
38
- text.gsub!(/(^(?!#).+$\n?)((^(?!#).*$\n?)*(^(?!#).+$))?/, "```#{language_type}\n\\0\n```")
35
+ text.gsub!(/(^(?!##).+$\n?)((^(?!##).*$\n?)*(^(?!##).+$))?/, "```#{language_type}\n\\0\n```")
39
36
  end
40
37
 
41
38
  def headling_comment_to_plaintext!
42
- text.gsub!(/^#\s+?$/, "")
43
- text.gsub!(/^#\s+?([^\n\r]+)$/, "\\1")
39
+ text.gsub!(/^##\s+?$/, "")
40
+ text.gsub!(/^##\s+?([^\n\r]+)$/, "\\1")
44
41
  end
45
42
 
46
43
  def format!
@@ -50,7 +47,7 @@ module Script2md
50
47
 
51
48
  class Fill
52
49
  def initialize(text, script: nil)
53
- @text = text
50
+ @text = text.clone
54
51
  @script = script
55
52
  end
56
53
 
@@ -1,3 +1,3 @@
1
1
  module Script2md
2
- VERSION = "1.1.3"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sc2md
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yumainaura
@@ -74,7 +74,6 @@ executables:
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
- - "+x"
78
77
  - ".github.url"
79
78
  - ".gitignore"
80
79
  - ".rspec"
data/+x DELETED
File without changes