RbST 0.6.3 → 0.6.4

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: 3632d5d2bed30d24d169d60781845255f7c66cbe6826aed0906e738315ae8b9c
4
- data.tar.gz: 0b3152c97445b15c1614a2778baa6482ad3420bd9de3d81c54179f69e5475e52
3
+ metadata.gz: be199440ac908673a9af196cdadf479cf6f7448d008bd1bdf8a0157b908647f7
4
+ data.tar.gz: 0c35550deb7405f3d8a33b49deada4e9a605acafa06964068a7297bf61e8c102
5
5
  SHA512:
6
- metadata.gz: f4ea41b4caf0896e0c97df51d717a9206f34ac45d098567876ec7c382f11fe5a60a34906beca6442551dbd8bbbd00b1b43bb1aa7091afa81d8315c84636c624f
7
- data.tar.gz: 9a8a99fdaa8478afd723c7d96cf8e878b685c123639c6dbf9aec183d771f2c141413ce0ef46935ce5e597ad22ccfd5f5fae0ed472fdc6c5fdc6ab048df0af83d
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(".. a comment").to_html('strip-comments')
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(".. a comment").to_html(:strip_comments)
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("hello world").to_html(:part => :fragment)
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 => "/some/other/path/2html.py"}
89
+ RbST.executables = {:html => '/some/other/path/2html.py'}
89
90
 
90
91
  # uses custom executable for outputting html
91
- RbST.new("something").to_html
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("something else").to_latex
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 = "/usr/bin/env python3"
102
- RbST.new("something").to_latex
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'RbST'
5
- s.version = '0.6.3'
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."
@@ -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 += File.exist?(path) ? File.read(path) : path rescue path
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
@@ -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}_file",
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([@rst_file])
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([@rst_file])
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([@rst_file]).to_html
51
+ html = RbST.new([@rst_file_path]).to_html
52
52
  assert_equal(
53
- File.read(@html_file),
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([@rst_file]).to_latex
59
+ latex = RbST.new([@rst_file_path]).to_latex
60
60
  assert_equal(
61
- File.read(@latex_file),
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([@rst_file])
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(@rst_file).to_html(part: :fragment)
144
+ output = RbST.new(@rst_file_path).to_html(part: :fragment)
145
145
  assert_equal(
146
- %|<p>#{@rst_file}</p>\n|,
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([@rst_file])
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") \
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: RbST
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Melody