texmath-ruby 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -18
- data/.travis.yml +6 -7
- data/.yardopts +1 -0
- data/Gemfile +2 -1
- data/README.md +5 -0
- data/lib/texmath/converter.rb +13 -13
- data/lib/texmath/errors.rb +0 -12
- data/lib/texmath/version.rb +1 -1
- data/test/texmath/converter_test.rb +5 -5
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9dff5d67a42043b1dad540fbb1c500a1fe71757
|
4
|
+
data.tar.gz: 997738f9777aad5628ffa7ced78dd1eb5f483c97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fd78686649201beaa36df08738e147aa473875d5c4279ef8393b4c4525035f19372c383c3c560a7902f015d7cf9e4b9076ddc584588717f5e5d0303d303149b
|
7
|
+
data.tar.gz: 41fd4df99d55b4cbc009d5159d3ee90decd2b2ec702d746c156f33864380713e859bae8e2f98a462c25eda65d168c46ffaea941388154c5a28030bdcb56363d9
|
data/.gitignore
CHANGED
@@ -1,22 +1,5 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
1
|
.bundle
|
4
|
-
.config
|
5
|
-
.yardoc
|
6
2
|
Gemfile.lock
|
7
|
-
|
8
|
-
_yardoc
|
9
|
-
coverage
|
3
|
+
.yardoc/
|
10
4
|
doc/
|
11
|
-
lib/bundler/man
|
12
5
|
pkg
|
13
|
-
rdoc
|
14
|
-
spec/reports
|
15
|
-
test/tmp
|
16
|
-
test/version_tmp
|
17
|
-
tmp
|
18
|
-
*.bundle
|
19
|
-
*.so
|
20
|
-
*.o
|
21
|
-
*.a
|
22
|
-
mkmf.log
|
data/.travis.yml
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
+
- 1.9.3
|
3
4
|
- 2.0.0
|
4
|
-
- 2.1
|
5
|
-
-
|
6
|
-
- jruby-20mode # JRuby in 1.9 mode
|
7
|
-
- rbx
|
5
|
+
- 2.1
|
6
|
+
- 2.2
|
8
7
|
matrix:
|
9
|
-
|
10
|
-
- rvm: ruby-head
|
8
|
+
fast_finish: true
|
11
9
|
cache: bundler
|
12
10
|
before_install:
|
13
11
|
- sudo apt-get install haskell-platform
|
14
12
|
- cabal update
|
15
|
-
- cabal install texmath
|
13
|
+
- cabal install -fexecutable texmath
|
14
|
+
- export PATH=$HOME/.cabal/bin:$PATH
|
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--markup markdown
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# texmath-ruby
|
2
2
|
|
3
|
+
[![Build Status](https://img.shields.io/travis/hollingberry/texmath-ruby.svg)](https://travis-ci.org/hollingberry/texmath-ruby)
|
4
|
+
[![Gem Version](https://img.shields.io/gem/v/texmath-ruby.svg)](https://rubygems.org/gems/texmath-ruby)
|
5
|
+
[![Gem Downloads](https://img.shields.io/gem/dt/texmath-ruby.svg)](https://rubygems.org/gems/texmath-ruby)
|
6
|
+
[![Code Climate](https://img.shields.io/codeclimate/github/kabisaict/flow.svg)](http://codeclimate.com/github/hollingberry/texmath-ruby)
|
7
|
+
|
3
8
|
A wrapper for [TeXMath](https://github.com/jgm/texmath), a Haskell library for
|
4
9
|
converting between formats used to represent mathematics.
|
5
10
|
|
data/lib/texmath/converter.rb
CHANGED
@@ -30,13 +30,13 @@ module TeXMath
|
|
30
30
|
|
31
31
|
##
|
32
32
|
# Create a new Converter.
|
33
|
-
# @
|
34
|
-
# @
|
35
|
-
# @
|
36
|
-
def initialize(
|
37
|
-
@executable = executable
|
38
|
-
self.reader = from
|
39
|
-
self.writer = to
|
33
|
+
# @option options [String] :executable ('texmath') the executable path
|
34
|
+
# @option options [Symbol] :from (:tex) the source format
|
35
|
+
# @option options [Symbol] :to (:mathml) the destination format
|
36
|
+
def initialize(options = {})
|
37
|
+
@executable = options.fetch(:executable, 'texmath')
|
38
|
+
self.reader = options.fetch(:from, :tex)
|
39
|
+
self.writer = options.fetch(:to, :mathml)
|
40
40
|
end
|
41
41
|
|
42
42
|
attr_reader :executable
|
@@ -50,23 +50,23 @@ module TeXMath
|
|
50
50
|
stdin.close
|
51
51
|
output = stdout.read
|
52
52
|
error = stderr.read
|
53
|
-
raise ConversionError
|
53
|
+
raise ConversionError, error unless error.empty?
|
54
54
|
return output.strip
|
55
55
|
end
|
56
56
|
rescue Errno::ENOENT
|
57
|
-
raise NoExecutableError
|
57
|
+
raise NoExecutableError, "Can't find the '#{executable}' executable."
|
58
58
|
end
|
59
59
|
|
60
60
|
attr_reader :reader, :writer
|
61
61
|
|
62
62
|
def reader=(format)
|
63
|
-
return @reader = format if READERS.
|
64
|
-
raise
|
63
|
+
return @reader = format if READERS.key?(format.to_s)
|
64
|
+
raise ArgumentError, "Can't find '#{format}' reader."
|
65
65
|
end
|
66
66
|
|
67
67
|
def writer=(format)
|
68
|
-
return @writer = format if WRITERS.
|
69
|
-
raise
|
68
|
+
return @writer = format if WRITERS.key?(format.to_s)
|
69
|
+
raise ArgumentError, "Can't find '#{format}' writer."
|
70
70
|
end
|
71
71
|
|
72
72
|
private
|
data/lib/texmath/errors.rb
CHANGED
@@ -7,16 +7,4 @@ module TeXMath
|
|
7
7
|
##
|
8
8
|
# Error raised when the `texmath` executable can't be found.
|
9
9
|
class NoExecutableError < StandardError; end
|
10
|
-
|
11
|
-
##
|
12
|
-
# Error raised when an invalid reader or writer format is specified.
|
13
|
-
class InvalidFormatError < StandardError; end
|
14
|
-
|
15
|
-
##
|
16
|
-
# Error raised when an invalid reader format is specified.
|
17
|
-
class InvalidReaderError < InvalidFormatError; end
|
18
|
-
|
19
|
-
##
|
20
|
-
# Error raised when an invalid writer format is specified.
|
21
|
-
class InvalidWriterError < InvalidFormatError; end
|
22
10
|
end
|
data/lib/texmath/version.rb
CHANGED
@@ -37,30 +37,30 @@ class ConverterTest < Minitest::Test
|
|
37
37
|
|
38
38
|
def test_executable_not_found
|
39
39
|
assert_raises NoExecutableError, "Can't find the 'ogremath' executable." do
|
40
|
-
Converter.new('ogremath').convert('\sqrt{3}')
|
40
|
+
Converter.new(executable: 'ogremath').convert('\sqrt{3}')
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
def test_string_reader_not_found
|
45
|
-
assert_raises
|
45
|
+
assert_raises ArgumentError, "Can't find 'pears' reader." do
|
46
46
|
Converter.new(from: 'pears', to: :mathml)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_string_writer_not_found
|
51
|
-
assert_raises
|
51
|
+
assert_raises ArgumentError, "Can't find 'pears' writer." do
|
52
52
|
Converter.new(from: :tex, to: 'pears')
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
def test_symbol_reader_not_found
|
57
|
-
assert_raises
|
57
|
+
assert_raises ArgumentError, "Can't find 'pears' reader." do
|
58
58
|
Converter.new(from: :pears, to: :mathml)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
def test_symbol_writer_not_found
|
63
|
-
assert_raises
|
63
|
+
assert_raises ArgumentError, "Can't find 'pears' writer." do
|
64
64
|
Converter.new(from: :tex, to: :pears)
|
65
65
|
end
|
66
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: texmath-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Casper Hollingberry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Convert math markup between LaTeX, MathML, and OMML using Ruby. A wrapper
|
14
14
|
for TeXMath, a Haskell library written by the creator of Pandoc.
|
@@ -20,6 +20,7 @@ extra_rdoc_files: []
|
|
20
20
|
files:
|
21
21
|
- ".gitignore"
|
22
22
|
- ".travis.yml"
|
23
|
+
- ".yardopts"
|
23
24
|
- Gemfile
|
24
25
|
- LICENSE.txt
|
25
26
|
- README.md
|
@@ -52,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
53
|
version: '0'
|
53
54
|
requirements: []
|
54
55
|
rubyforge_project:
|
55
|
-
rubygems_version: 2.
|
56
|
+
rubygems_version: 2.4.5
|
56
57
|
signing_key:
|
57
58
|
specification_version: 4
|
58
59
|
summary: Convert math markup between LaTeX, MathML, and OMML.
|
@@ -60,3 +61,4 @@ test_files:
|
|
60
61
|
- test/support/formats.rb
|
61
62
|
- test/test_helper.rb
|
62
63
|
- test/texmath/converter_test.rb
|
64
|
+
has_rdoc:
|