RbST 0.6.3 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -8
- data/RbST.gemspec +1 -1
- data/lib/rbst.rb +5 -1
- data/test/test_rbst.rb +11 -11
- 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: be199440ac908673a9af196cdadf479cf6f7448d008bd1bdf8a0157b908647f7
|
4
|
+
data.tar.gz: 0c35550deb7405f3d8a33b49deada4e9a605acafa06964068a7297bf61e8c102
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 906d2aeabbebf82657d2b8a09568037a79ec785a0de7fd98274897ca95bae8c8d52e68bebefda9bfdfe2c96edfe2f767ecf523d3a486adf7156f903d296700c4
|
7
|
+
data.tar.gz: d26d1b628eeaeb450ee77c5632cb0516b0c4ba41b5b3399ff09b0e75b3d40293a9884025fedef29e01cab02781a80c55add15be661ebe4461fffaf7fa6c18eae
|
data/README.md
CHANGED
@@ -47,6 +47,7 @@ You can also use the `convert` class method to output HTML:
|
|
47
47
|
|
48
48
|
```ruby
|
49
49
|
puts RbST.convert('*hello*')
|
50
|
+
#=> "<div class=\"document\">\n<p><em>hello</em></p>\n</div>\n"
|
50
51
|
```
|
51
52
|
|
52
53
|
Arguments can be passed to `#to_html`, `#to_latex`, `new` or `convert`,
|
@@ -54,7 +55,7 @@ accepting symbols or strings for options without arguments and hashes of
|
|
54
55
|
strings or symbols for options with arguments.
|
55
56
|
|
56
57
|
```ruby
|
57
|
-
puts RbST.new(
|
58
|
+
puts RbST.new('.. a comment').to_html('strip-comments')
|
58
59
|
# => '<div class="document">\n</div>'
|
59
60
|
```
|
60
61
|
|
@@ -62,14 +63,14 @@ Options passed as string use hyphens while symbols use underscores. For
|
|
62
63
|
instance, the above could also be written as:
|
63
64
|
|
64
65
|
```ruby
|
65
|
-
puts RbST.new(
|
66
|
+
puts RbST.new('.. a comment').to_html(:strip_comments)
|
66
67
|
# => '<div class="document">\n</div>'
|
67
68
|
```
|
68
69
|
|
69
70
|
Document parts can also be specified with the `:parts` option.
|
70
71
|
|
71
72
|
```ruby
|
72
|
-
puts RbST.new(
|
73
|
+
puts RbST.new('hello world').to_html(:part => :fragment)
|
73
74
|
# => '<p>hello world</p>'
|
74
75
|
```
|
75
76
|
|
@@ -85,21 +86,21 @@ path to the custom script for the format by passing a hash to the
|
|
85
86
|
`RbST.executables=` method:
|
86
87
|
|
87
88
|
```ruby
|
88
|
-
RbST.executables = {:html =>
|
89
|
+
RbST.executables = {:html => '/some/other/path/2html.py'}
|
89
90
|
|
90
91
|
# uses custom executable for outputting html
|
91
|
-
RbST.new(
|
92
|
+
RbST.new('*hello*').to_html
|
92
93
|
|
93
94
|
# uses default executable for latex since a custom one wasn't specified
|
94
|
-
RbST.new(
|
95
|
+
RbST.new('*hello*').to_latex
|
95
96
|
```
|
96
97
|
|
97
98
|
Similarly, if you want to explicitly specify which python executable to
|
98
99
|
use, set the path with the `RbST.python_path=` method:
|
99
100
|
|
100
101
|
```ruby
|
101
|
-
RbST.python_path =
|
102
|
-
RbST.new(
|
102
|
+
RbST.python_path = '/usr/bin/env python3'
|
103
|
+
RbST.new('*hello*').to_latex
|
103
104
|
```
|
104
105
|
|
105
106
|
For more information on reStructuredText, see the
|
data/RbST.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'RbST'
|
5
|
-
s.version = '0.6.
|
5
|
+
s.version = '0.6.4'
|
6
6
|
s.licenses = ['MIT']
|
7
7
|
s.summary = "A Ruby gem for processing reStructuredText via Python's Docutils."
|
8
8
|
s.description = "A Ruby gem for processing reStructuredText via Python's Docutils."
|
data/lib/rbst.rb
CHANGED
@@ -64,7 +64,11 @@ class RbST
|
|
64
64
|
@target = ''
|
65
65
|
target.each_with_index do |path, i|
|
66
66
|
@target += "\n" if i.positive?
|
67
|
-
@target +=
|
67
|
+
@target += begin
|
68
|
+
File.exist?(path) ? File.read(path) : path
|
69
|
+
rescue StandardError
|
70
|
+
path
|
71
|
+
end
|
68
72
|
end
|
69
73
|
end
|
70
74
|
@options = args
|
data/test/test_rbst.rb
CHANGED
@@ -6,7 +6,7 @@ describe RbST do
|
|
6
6
|
def setup
|
7
7
|
[:rst, :html, :latex].each do |f|
|
8
8
|
instance_variable_set(
|
9
|
-
:"@#{f}
|
9
|
+
:"@#{f}_file_path",
|
10
10
|
File.join(File.dirname(__FILE__), 'files', "test.#{f}")
|
11
11
|
)
|
12
12
|
end
|
@@ -16,7 +16,7 @@ describe RbST do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'should call bare rest2parts when passed no options' do
|
19
|
-
converter = RbST.new([@
|
19
|
+
converter = RbST.new([@rst_file_path])
|
20
20
|
converter \
|
21
21
|
.expects(:execute) \
|
22
22
|
.with("python #{@rst2parts_path}/rst2html.py") \
|
@@ -28,7 +28,7 @@ describe RbST do
|
|
28
28
|
executables = { html: '/some/path/2html.py' }
|
29
29
|
default_executables = RbST.executables
|
30
30
|
RbST.executables = executables
|
31
|
-
converter = RbST.new([@
|
31
|
+
converter = RbST.new([@rst_file_path])
|
32
32
|
converter \
|
33
33
|
.expects(:execute) \
|
34
34
|
.with("python #{executables[:html]}") \
|
@@ -48,24 +48,24 @@ describe RbST do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'should convert ReST to html' do
|
51
|
-
html = RbST.new([@
|
51
|
+
html = RbST.new([@rst_file_path]).to_html
|
52
52
|
assert_equal(
|
53
|
-
File.read(@
|
53
|
+
File.read(@html_file_path),
|
54
54
|
html
|
55
55
|
)
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'should convert ReST to LaTeX' do
|
59
|
-
latex = RbST.new([@
|
59
|
+
latex = RbST.new([@rst_file_path]).to_latex
|
60
60
|
assert_equal(
|
61
|
-
File.read(@
|
61
|
+
File.read(@latex_file_path),
|
62
62
|
latex
|
63
63
|
)
|
64
64
|
end
|
65
65
|
|
66
66
|
[:html, :latex].each do |f|
|
67
67
|
it "should accept options on #to_#{f}" do
|
68
|
-
converter = RbST.new([@
|
68
|
+
converter = RbST.new([@rst_file_path])
|
69
69
|
converter \
|
70
70
|
.expects(:execute) \
|
71
71
|
.with("python #{@rst2parts_path}/rst2#{f}.py --raw-enabled") \
|
@@ -141,16 +141,16 @@ describe RbST do
|
|
141
141
|
end
|
142
142
|
|
143
143
|
it 'should preserve file paths in strings without array' do
|
144
|
-
output = RbST.new(@
|
144
|
+
output = RbST.new(@rst_file_path).to_html(part: :fragment)
|
145
145
|
assert_equal(
|
146
|
-
%|<p>#{@
|
146
|
+
%|<p>#{@rst_file_path}</p>\n|,
|
147
147
|
output
|
148
148
|
)
|
149
149
|
end
|
150
150
|
|
151
151
|
it 'should execute with custom python path' do
|
152
152
|
RbST.python_path = '/usr/bin/env python3'
|
153
|
-
converter = RbST.new([@
|
153
|
+
converter = RbST.new([@rst_file_path])
|
154
154
|
converter \
|
155
155
|
.expects(:execute) \
|
156
156
|
.with("/usr/bin/env python3 #{@rst2parts_path}/rst2html.py") \
|