RbST 0.6.2 → 0.6.3
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/README.md +14 -5
- data/RbST.gemspec +2 -2
- data/lib/rbst.rb +11 -3
- data/test/test_rbst.rb +14 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3632d5d2bed30d24d169d60781845255f7c66cbe6826aed0906e738315ae8b9c
|
4
|
+
data.tar.gz: 0b3152c97445b15c1614a2778baa6482ad3420bd9de3d81c54179f69e5475e52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4ea41b4caf0896e0c97df51d717a9206f34ac45d098567876ec7c382f11fe5a60a34906beca6442551dbd8bbbd00b1b43bb1aa7091afa81d8315c84636c624f
|
7
|
+
data.tar.gz: 9a8a99fdaa8478afd723c7d96cf8e878b685c123639c6dbf9aec183d771f2c141413ce0ef46935ce5e597ad22ccfd5f5fae0ed472fdc6c5fdc6ab048df0af83d
|
data/README.md
CHANGED
@@ -26,18 +26,27 @@ Then run `bundle install`
|
|
26
26
|
|
27
27
|
```ruby
|
28
28
|
require 'rbst'
|
29
|
-
@html = RbST.new('/some/file.rst').to_html
|
30
|
-
# or
|
31
29
|
@latex = RbST.new('*hello*').to_latex
|
32
30
|
```
|
33
31
|
|
34
|
-
This takes the reStructuredText formatted
|
35
|
-
|
32
|
+
This takes the reStructuredText formatted string and converts it to LaTeX.
|
33
|
+
|
34
|
+
The first argument can be either a string or an array of one or more file
|
35
|
+
paths. The files will be concatenated together with a blank line between
|
36
|
+
each and used as input.
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
# One file path as a single-element array.
|
40
|
+
RbST.new(['/path/to/file.rst']).to_html
|
41
|
+
|
42
|
+
# Multiple file paths as an array.
|
43
|
+
RbST.new(['/path/to/file1.rst', '/path/to/file2.rst']).to_html
|
44
|
+
```
|
36
45
|
|
37
46
|
You can also use the `convert` class method to output HTML:
|
38
47
|
|
39
48
|
```ruby
|
40
|
-
puts RbST.convert('
|
49
|
+
puts RbST.convert('*hello*')
|
41
50
|
```
|
42
51
|
|
43
52
|
Arguments can be passed to `#to_html`, `#to_latex`, `new` or `convert`,
|
data/RbST.gemspec
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'RbST'
|
5
|
-
s.version = '0.6.
|
5
|
+
s.version = '0.6.3'
|
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."
|
9
9
|
s.authors = ['William Melody']
|
10
10
|
s.email = 'hi@williammelody.com'
|
11
|
-
s.date = '2020-03-
|
11
|
+
s.date = '2020-03-24'
|
12
12
|
s.extra_rdoc_files = [
|
13
13
|
'LICENSE',
|
14
14
|
'README.md'
|
data/lib/rbst.rb
CHANGED
@@ -54,11 +54,19 @@ class RbST
|
|
54
54
|
@@python_path
|
55
55
|
end
|
56
56
|
|
57
|
-
# Takes a string or file
|
58
|
-
# converter object.
|
57
|
+
# Takes a string or array of file paths plus any additional options and
|
58
|
+
# creates a new converter object.
|
59
59
|
def initialize(*args)
|
60
60
|
target = args.shift
|
61
|
-
|
61
|
+
if target.is_a?(String)
|
62
|
+
@target = target
|
63
|
+
elsif target.is_a?(Array)
|
64
|
+
@target = ''
|
65
|
+
target.each_with_index do |path, i|
|
66
|
+
@target += "\n" if i.positive?
|
67
|
+
@target += File.exist?(path) ? File.read(path) : path rescue path
|
68
|
+
end
|
69
|
+
end
|
62
70
|
@options = args
|
63
71
|
end
|
64
72
|
|
data/test/test_rbst.rb
CHANGED
@@ -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(@rst_file)
|
19
|
+
converter = RbST.new([@rst_file])
|
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(@rst_file)
|
31
|
+
converter = RbST.new([@rst_file])
|
32
32
|
converter \
|
33
33
|
.expects(:execute) \
|
34
34
|
.with("python #{executables[:html]}") \
|
@@ -48,7 +48,7 @@ describe RbST do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'should convert ReST to html' do
|
51
|
-
html = RbST.new(@rst_file).to_html
|
51
|
+
html = RbST.new([@rst_file]).to_html
|
52
52
|
assert_equal(
|
53
53
|
File.read(@html_file),
|
54
54
|
html
|
@@ -56,7 +56,7 @@ describe RbST do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
it 'should convert ReST to LaTeX' do
|
59
|
-
latex = RbST.new(@rst_file).to_latex
|
59
|
+
latex = RbST.new([@rst_file]).to_latex
|
60
60
|
assert_equal(
|
61
61
|
File.read(@latex_file),
|
62
62
|
latex
|
@@ -65,7 +65,7 @@ describe RbST do
|
|
65
65
|
|
66
66
|
[:html, :latex].each do |f|
|
67
67
|
it "should accept options on #to_#{f}" do
|
68
|
-
converter = RbST.new(@rst_file)
|
68
|
+
converter = RbST.new([@rst_file])
|
69
69
|
converter \
|
70
70
|
.expects(:execute) \
|
71
71
|
.with("python #{@rst2parts_path}/rst2#{f}.py --raw-enabled") \
|
@@ -140,9 +140,17 @@ describe RbST do
|
|
140
140
|
)
|
141
141
|
end
|
142
142
|
|
143
|
+
it 'should preserve file paths in strings without array' do
|
144
|
+
output = RbST.new(@rst_file).to_html(part: :fragment)
|
145
|
+
assert_equal(
|
146
|
+
%|<p>#{@rst_file}</p>\n|,
|
147
|
+
output
|
148
|
+
)
|
149
|
+
end
|
150
|
+
|
143
151
|
it 'should execute with custom python path' do
|
144
152
|
RbST.python_path = '/usr/bin/env python3'
|
145
|
-
converter = RbST.new(@rst_file)
|
153
|
+
converter = RbST.new([@rst_file])
|
146
154
|
converter \
|
147
155
|
.expects(:execute) \
|
148
156
|
.with("/usr/bin/env python3 #{@rst2parts_path}/rst2html.py") \
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: RbST
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Melody
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|