agate 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -3
- data/CHANGELOG.md +5 -0
- data/README.md +14 -10
- data/agate.gemspec +4 -4
- data/bin/agate +1 -1
- data/lib/agate.rb +0 -1
- data/lib/agate/cli.rb +12 -14
- data/lib/agate/formatter/html.rb +5 -1
- data/lib/agate/formatter/plain.rb +18 -0
- data/lib/agate/parser.rb +8 -3
- data/lib/agate/version.rb +1 -1
- data/spec/agate/cli_spec.rb +72 -0
- data/spec/agate/formatter/html_spec.rb +13 -0
- data/spec/agate/formatter/plain_spec.rb +12 -0
- data/spec/agate/parser_spec.rb +55 -0
- data/spec/spec_helper.rb +1 -3
- metadata +29 -24
- data/spec/lib/parser_spec.rb +0 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 082fa68e924d6ca49504cc5b5add126064803671
|
4
|
+
data.tar.gz: 5c19845e152f54b321f964f5f0d44dcea4f18250
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abedee9fda0c7d0d3fa0c3d1547fcf86fceb29fedacc11cbc312a920d43c44477277b278d05391935a68f1f4e1a47d7ae9bcc953ef0a7d7448f7342211407d28
|
7
|
+
data.tar.gz: a6a2e3352ae201ab8ac4eb8104f52fed3e52cbf195e1fdde4d8ca8cd0b1000e7c78ae69449dd7795359bf7d89395eaa088f91fe9e5ac072174631ae6ba789a5c
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,14 +1,18 @@
|
|
1
1
|
# [Agate](http://en.wikipedia.org/w/index.php?title=Ruby_character&oldid=540994629#History)
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/agate.
|
4
|
-
[![Build Status](https://travis-ci.org/jbhannah/agate.
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/agate.svg)](http://badge.fury.io/rb/agate)
|
4
|
+
[![Build Status](https://travis-ci.org/jbhannah/agate.svg?branch=master)](https://travis-ci.org/jbhannah/agate)
|
5
5
|
[![Dependency Status](https://gemnasium.com/jbhannah/agate.png)](https://gemnasium.com/jbhannah/agate)
|
6
|
-
[![Code Climate](https://codeclimate.com/github/jbhannah/agate.
|
7
|
-
[![Coverage Status](https://
|
6
|
+
[![Code Climate](https://codeclimate.com/github/jbhannah/agate/badges/gpa.svg)](https://codeclimate.com/github/jbhannah/agate)
|
7
|
+
[![Coverage Status](https://img.shields.io/coveralls/jbhannah/agate.svg)](https://coveralls.io/r/jbhannah/agate?branch=master)
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Format ruby characters (currently only furigana) in text for display. **Requires
|
10
|
+
Ruby 1.9 or later (or compatible engine).**
|
11
|
+
|
12
|
+
## Formatters
|
13
|
+
|
14
|
+
* Plain text (echoes back passed text)
|
15
|
+
* [HTML5 (`ruby` element)][]
|
12
16
|
|
13
17
|
## Usage
|
14
18
|
|
@@ -31,8 +35,8 @@ require "agate"
|
|
31
35
|
options = {
|
32
36
|
# can be any single character or pair of characters which surround ruby characters in text to parse
|
33
37
|
:delimiters => "【】" # default delimiters
|
34
|
-
# markup formatter to use (options: :html)
|
35
|
-
:formatter => :html
|
38
|
+
# markup formatter to use (options: :plain (default), :html)
|
39
|
+
:formatter => :html
|
36
40
|
}
|
37
41
|
|
38
42
|
a = Agate::Parser.new(options) # call without arguments to use defaults
|
@@ -55,5 +59,5 @@ It's highly recommended to read the W3C's documentation on the [HTML5
|
|
55
59
|
in all modern browsers, but it's up to you to test all cases where you
|
56
60
|
intend to use the `ruby` element.
|
57
61
|
|
58
|
-
[HTML5 `ruby` element]: http://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element
|
62
|
+
[HTML5 (`ruby` element)]: http://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element
|
59
63
|
[CSS workaround]: http://web.nickshanks.com/stylesheets/ruby.css
|
data/agate.gemspec
CHANGED
@@ -5,11 +5,11 @@ require 'agate/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "agate"
|
8
|
-
spec.version = Agate::VERSION
|
8
|
+
spec.version = Agate::VERSION.join('.')
|
9
9
|
spec.authors = ["Jesse B. Hannah"]
|
10
10
|
spec.email = ["jesse@jbhannah.net"]
|
11
|
-
spec.description = %q{
|
12
|
-
spec.summary = %q{
|
11
|
+
spec.description = %q{Format ruby characters (currently only furigana) in text for display.}
|
12
|
+
spec.summary = %q{Format ruby characters (currently only furigana) in text for display.}
|
13
13
|
spec.homepage = "https://github.com/jbhannah/agate"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -20,6 +20,6 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.2"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "rspec", "~>
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
24
24
|
spec.add_development_dependency "coveralls"
|
25
25
|
end
|
data/bin/agate
CHANGED
data/lib/agate.rb
CHANGED
data/lib/agate/cli.rb
CHANGED
@@ -5,42 +5,40 @@ require 'optparse'
|
|
5
5
|
|
6
6
|
module Agate
|
7
7
|
class CLI
|
8
|
-
include Singleton
|
9
|
-
|
10
8
|
def initialize
|
11
9
|
@options = {}
|
12
10
|
end
|
13
11
|
|
14
|
-
def
|
12
|
+
def parse
|
15
13
|
parse_opts
|
16
14
|
|
17
15
|
agate = Agate::Parser.new(@options)
|
18
|
-
|
16
|
+
agate.parse(ARGV.join)
|
19
17
|
end
|
20
18
|
|
21
19
|
private
|
22
20
|
def parse_opts
|
23
|
-
opts = OptionParser.new do |
|
24
|
-
|
21
|
+
opts = OptionParser.new do |o|
|
22
|
+
o.banner = "Usage: agate [options] text-to-convert"
|
25
23
|
|
26
|
-
|
27
|
-
|
24
|
+
o.separator ""
|
25
|
+
o.separator "Options:"
|
28
26
|
|
29
|
-
|
27
|
+
o.on("-d", "--delimiters DELIMITERS", "Specify custom delimiters for ruby text (default: 【】)") do |delims|
|
30
28
|
@options[:delimiters] = delims
|
31
29
|
end
|
32
30
|
|
33
|
-
|
31
|
+
o.on("-f", "--formatter FORMAT", "Specify a formatter to use (default/fallback: plain text)") do |format|
|
34
32
|
@options[:formatter] = format.to_sym
|
35
33
|
end
|
36
34
|
|
37
|
-
|
38
|
-
puts
|
35
|
+
o.on_tail("-h", "--help", "Show this message") do
|
36
|
+
puts o
|
39
37
|
exit
|
40
38
|
end
|
41
39
|
|
42
|
-
|
43
|
-
puts Agate::VERSION
|
40
|
+
o.on_tail("-v", "--version", "Show version") do
|
41
|
+
puts Agate::VERSION.join('.')
|
44
42
|
exit
|
45
43
|
end
|
46
44
|
end
|
data/lib/agate/formatter/html.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
require 'singleton'
|
3
|
+
|
2
4
|
module Agate
|
3
5
|
module Formatter
|
4
6
|
# Formats text using HTML5 ruby tags, turning
|
@@ -12,8 +14,10 @@ module Agate
|
|
12
14
|
# which can then be rendered by some web browsers or formatted
|
13
15
|
# using CSS.
|
14
16
|
class HTML
|
17
|
+
include Singleton
|
18
|
+
|
15
19
|
# Turns a regexp match object into a formatted string with ruby characters
|
16
|
-
def format(match)
|
20
|
+
def self.format(match)
|
17
21
|
"<ruby>#{match[1]}<rp>#{match[2]}</rp><rt>#{match[3]}</rt><rp>#{match[4]}</rp></ruby>"
|
18
22
|
end
|
19
23
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'singleton'
|
3
|
+
|
4
|
+
module Agate
|
5
|
+
module Formatter
|
6
|
+
# Echoes back the text passed to it.
|
7
|
+
#
|
8
|
+
# > 勉【べん】強【きょう】します
|
9
|
+
class Plain
|
10
|
+
include Singleton
|
11
|
+
|
12
|
+
# Turns a regexp match object into a formatted string with ruby characters
|
13
|
+
def self.format(match)
|
14
|
+
"#{match[1]}#{match[2]}#{match[3]}#{match[4]}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/agate/parser.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
require "agate/formatter/html"
|
3
|
+
require "agate/formatter/plain"
|
4
|
+
|
2
5
|
module Agate
|
3
6
|
class Parser
|
4
7
|
# Default options
|
5
8
|
DEFAULTS = {
|
6
9
|
:delimiters => "【】",
|
7
|
-
:formatter => :
|
10
|
+
:formatter => :plain
|
8
11
|
}
|
9
12
|
|
10
13
|
def initialize(options = {})
|
@@ -12,9 +15,11 @@ module Agate
|
|
12
15
|
|
13
16
|
@formatter = case @options[:formatter]
|
14
17
|
when :html
|
15
|
-
Agate::Formatter::HTML
|
18
|
+
Agate::Formatter::HTML
|
19
|
+
when :plain
|
20
|
+
Agate::Formatter::Plain
|
16
21
|
else
|
17
|
-
Agate::Formatter::
|
22
|
+
Agate::Formatter::Plain
|
18
23
|
end
|
19
24
|
end
|
20
25
|
|
data/lib/agate/version.rb
CHANGED
@@ -0,0 +1,72 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require "spec_helper"
|
3
|
+
require "agate/cli"
|
4
|
+
|
5
|
+
RSpec.describe Agate::CLI do
|
6
|
+
let(:cli) { File.join(File.expand_path(File.dirname(__FILE__)), "..", "..", "bin", "agate") }
|
7
|
+
let(:text) { "勉【べん】強【きょう】します" }
|
8
|
+
|
9
|
+
context "with help option" do
|
10
|
+
it "shows the help message and exits" do
|
11
|
+
stub_const("Agate::CLI::ARGV", ["-h"])
|
12
|
+
|
13
|
+
text = <<-eos
|
14
|
+
Usage: agate [options] text-to-convert
|
15
|
+
|
16
|
+
Options:
|
17
|
+
-d, --delimiters DELIMITERS Specify custom delimiters for ruby text (default: 【】)
|
18
|
+
-f, --formatter FORMAT Specify a formatter to use (default/fallback: plain text)
|
19
|
+
-h, --help Show this message
|
20
|
+
-v, --version Show version
|
21
|
+
eos
|
22
|
+
|
23
|
+
expect do
|
24
|
+
begin
|
25
|
+
load cli
|
26
|
+
rescue SystemExit
|
27
|
+
end
|
28
|
+
end.to output(text).to_stdout
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "with version option" do
|
33
|
+
it "shows the version and exits" do
|
34
|
+
version = ["1", "2", "3"]
|
35
|
+
|
36
|
+
stub_const("Agate::CLI::ARGV", ["-v"])
|
37
|
+
stub_const("Agate::VERSION", version)
|
38
|
+
|
39
|
+
expect do
|
40
|
+
begin
|
41
|
+
load cli
|
42
|
+
rescue SystemExit
|
43
|
+
end
|
44
|
+
end.to output(version.join('.') + "\n").to_stdout
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "with defaults" do
|
49
|
+
it "parses delimited text and echoes it back" do
|
50
|
+
stub_const("Agate::CLI::ARGV", [text])
|
51
|
+
expect { load cli }.to output(text + "\n").to_stdout
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "with custom delimiters" do
|
56
|
+
let(:text) { "勉(べん)強(きょう)します" }
|
57
|
+
|
58
|
+
it "parses delimited text and echoes it back" do
|
59
|
+
stub_const("Agate::CLI::ARGV", ["-d", "\"()\"", text])
|
60
|
+
expect { load cli }.to output(text + "\n").to_stdout
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "with formatter" do
|
65
|
+
let(:formatted_text) { "<ruby>勉<rp>【</rp><rt>べん</rt><rp>】</rp></ruby><ruby>強<rp>【</rp><rt>きょう</rt><rp>】</rp></ruby>します" }
|
66
|
+
|
67
|
+
it "parses delimited text and echoes it back" do
|
68
|
+
stub_const("Agate::CLI::ARGV", ["-f", "html", text])
|
69
|
+
expect { load cli }.to output(formatted_text + "\n").to_stdout
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require "spec_helper"
|
3
|
+
require "agate/formatter/html"
|
4
|
+
|
5
|
+
RSpec.describe Agate::Formatter::HTML do
|
6
|
+
let(:text) { "勉【べん】" }
|
7
|
+
let(:formatted_text) { "<ruby>勉<rp>【</rp><rt>べん</rt><rp>】</rp></ruby>" }
|
8
|
+
let(:expr) { /(\p{Han}+)(【)([\p{Hiragana}\p{Katakana}]+)(】)/u }
|
9
|
+
|
10
|
+
it "returns the string formatted as HTML5 ruby" do
|
11
|
+
expect(text.gsub(expr) { |match| Agate::Formatter::HTML.format($~) }).to eql(formatted_text)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require "spec_helper"
|
3
|
+
require "agate/formatter/plain"
|
4
|
+
|
5
|
+
RSpec.describe Agate::Formatter::Plain do
|
6
|
+
let(:text) { "勉【べん】" }
|
7
|
+
let(:expr) { /(\p{Han}+)(【)([\p{Hiragana}\p{Katakana}]+)(】)/u }
|
8
|
+
|
9
|
+
it "echoes back the original string" do
|
10
|
+
expect(text.gsub(expr) { |match| Agate::Formatter::Plain.format($~) }).to eql(text)
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require "spec_helper"
|
3
|
+
require "agate/parser"
|
4
|
+
|
5
|
+
RSpec.describe Agate::Parser do
|
6
|
+
context "with defaults" do
|
7
|
+
let(:agate) { Agate::Parser.new }
|
8
|
+
let(:text) { "勉【べん】強【きょう】します" }
|
9
|
+
|
10
|
+
it "parses delimited text and echoes it back" do
|
11
|
+
expect(agate.parse(text)).to eql(text)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "with custom delimiters" do
|
16
|
+
context "from regexp-reserved character list" do
|
17
|
+
let(:agate) { Agate::Parser.new(:delimiters => "()") }
|
18
|
+
let(:text) { "勉(べん)強(きょう)します" }
|
19
|
+
|
20
|
+
it "parses delimited text and echoes it back" do
|
21
|
+
expect(agate.parse(text)).to eql(text)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "arbitrary" do
|
26
|
+
let(:agate) { Agate::Parser.new(:delimiters => "@") }
|
27
|
+
let(:text) { "勉@べん@強@きょう@します" }
|
28
|
+
|
29
|
+
it "parses delimited text and echoes it back" do
|
30
|
+
expect(agate.parse(text)).to eql(text)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "with formatter" do
|
36
|
+
context "HTML" do
|
37
|
+
let(:agate) { Agate::Parser.new(:formatter => :html) }
|
38
|
+
let(:text) { "勉【べん】強【きょう】します" }
|
39
|
+
let(:formatted_text) { "<ruby>勉<rp>【</rp><rt>べん</rt><rp>】</rp></ruby><ruby>強<rp>【</rp><rt>きょう</rt><rp>】</rp></ruby>します" }
|
40
|
+
|
41
|
+
it "parses delimited text and formats it with the specified formatter" do
|
42
|
+
expect(agate.parse(text)).to eql(formatted_text)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "not matching an available formatter" do
|
47
|
+
let(:agate) { Agate::Parser.new(:formatter => :foobar) }
|
48
|
+
let(:text) { "勉【べん】強【きょう】します" }
|
49
|
+
|
50
|
+
it "parses delimited text and echoes it back" do
|
51
|
+
expect(agate.parse(text)).to eql(text)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -9,9 +9,7 @@ RSpec.configure do |config|
|
|
9
9
|
require "coveralls"
|
10
10
|
Coveralls.wear!
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
12
|
+
config.raise_errors_for_deprecations!
|
15
13
|
|
16
14
|
# Run specs in random order to surface order dependencies. If you find an
|
17
15
|
# order dependency and want to debug it, you can fix the order by providing
|
metadata
CHANGED
@@ -1,73 +1,72 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jesse B. Hannah
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.2'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '3.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '3.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: coveralls
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description:
|
70
|
-
ruby element.
|
69
|
+
description: Format ruby characters (currently only furigana) in text for display.
|
71
70
|
email:
|
72
71
|
- jesse@jbhannah.net
|
73
72
|
executables:
|
@@ -75,9 +74,9 @@ executables:
|
|
75
74
|
extensions: []
|
76
75
|
extra_rdoc_files: []
|
77
76
|
files:
|
78
|
-
- .gitignore
|
79
|
-
- .rspec
|
80
|
-
- .travis.yml
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".travis.yml"
|
81
80
|
- CHANGELOG.md
|
82
81
|
- Gemfile
|
83
82
|
- LICENSE.txt
|
@@ -88,9 +87,13 @@ files:
|
|
88
87
|
- lib/agate.rb
|
89
88
|
- lib/agate/cli.rb
|
90
89
|
- lib/agate/formatter/html.rb
|
90
|
+
- lib/agate/formatter/plain.rb
|
91
91
|
- lib/agate/parser.rb
|
92
92
|
- lib/agate/version.rb
|
93
|
-
- spec/
|
93
|
+
- spec/agate/cli_spec.rb
|
94
|
+
- spec/agate/formatter/html_spec.rb
|
95
|
+
- spec/agate/formatter/plain_spec.rb
|
96
|
+
- spec/agate/parser_spec.rb
|
94
97
|
- spec/spec_helper.rb
|
95
98
|
homepage: https://github.com/jbhannah/agate
|
96
99
|
licenses:
|
@@ -102,21 +105,23 @@ require_paths:
|
|
102
105
|
- lib
|
103
106
|
required_ruby_version: !ruby/object:Gem::Requirement
|
104
107
|
requirements:
|
105
|
-
- -
|
108
|
+
- - ">="
|
106
109
|
- !ruby/object:Gem::Version
|
107
110
|
version: '0'
|
108
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
112
|
requirements:
|
110
|
-
- -
|
113
|
+
- - ">="
|
111
114
|
- !ruby/object:Gem::Version
|
112
115
|
version: '0'
|
113
116
|
requirements: []
|
114
117
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.
|
118
|
+
rubygems_version: 2.2.2
|
116
119
|
signing_key:
|
117
120
|
specification_version: 4
|
118
|
-
summary:
|
119
|
-
element.
|
121
|
+
summary: Format ruby characters (currently only furigana) in text for display.
|
120
122
|
test_files:
|
121
|
-
- spec/
|
123
|
+
- spec/agate/cli_spec.rb
|
124
|
+
- spec/agate/formatter/html_spec.rb
|
125
|
+
- spec/agate/formatter/plain_spec.rb
|
126
|
+
- spec/agate/parser_spec.rb
|
122
127
|
- spec/spec_helper.rb
|
data/spec/lib/parser_spec.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require "spec_helper"
|
3
|
-
|
4
|
-
describe Agate::Parser do
|
5
|
-
context "with defaults" do
|
6
|
-
let(:agate) { Agate::Parser.new }
|
7
|
-
let(:text) { "勉【べん】強【きょう】します" }
|
8
|
-
let(:parsed_text) { "<ruby>勉<rp>【</rp><rt>べん</rt><rp>】</rp></ruby><ruby>強<rp>【</rp><rt>きょう</rt><rp>】</rp></ruby>します" }
|
9
|
-
|
10
|
-
it "parses delimited text and turns it into HTML" do
|
11
|
-
agate.parse(text).should eql(parsed_text)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context "with custom delimiters" do
|
16
|
-
context "from regexp-reserved character list" do
|
17
|
-
let(:agate) { Agate::Parser.new(:delimiters => "()") }
|
18
|
-
let(:text) { "勉(べん)強(きょう)します" }
|
19
|
-
let(:parsed_text) { "<ruby>勉<rp>(</rp><rt>べん</rt><rp>)</rp></ruby><ruby>強<rp>(</rp><rt>きょう</rt><rp>)</rp></ruby>します" }
|
20
|
-
|
21
|
-
it "parses delimited text and turns it into HTML" do
|
22
|
-
agate.parse(text).should eql(parsed_text)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context "arbitrary" do
|
27
|
-
let(:agate) { Agate::Parser.new(:delimiters => "@") }
|
28
|
-
let(:text) { "勉@べん@強@きょう@します" }
|
29
|
-
let(:parsed_text) { "<ruby>勉<rp>@</rp><rt>べん</rt><rp>@</rp></ruby><ruby>強<rp>@</rp><rt>きょう</rt><rp>@</rp></ruby>します" }
|
30
|
-
|
31
|
-
it "parses delimited text and turns it into HTML" do
|
32
|
-
agate.parse(text).should eql(parsed_text)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context "with formatter" do
|
38
|
-
context "HTML" do
|
39
|
-
let(:agate) { Agate::Parser.new(:formatter => :html) }
|
40
|
-
let(:text) { "勉【べん】強【きょう】します" }
|
41
|
-
let(:parsed_text) { "<ruby>勉<rp>【</rp><rt>べん</rt><rp>】</rp></ruby><ruby>強<rp>【</rp><rt>きょう</rt><rp>】</rp></ruby>します" }
|
42
|
-
|
43
|
-
it "parses delimited text and turns it into HTML" do
|
44
|
-
agate.parse(text).should eql(parsed_text)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context "not matching an available formatter" do
|
49
|
-
let(:agate) { Agate::Parser.new(:formatter => :foobar) }
|
50
|
-
let(:text) { "勉【べん】強【きょう】します" }
|
51
|
-
let(:parsed_text) { "<ruby>勉<rp>【</rp><rt>べん</rt><rp>】</rp></ruby><ruby>強<rp>【</rp><rt>きょう</rt><rp>】</rp></ruby>します" }
|
52
|
-
|
53
|
-
it "parses delimited text and turns it into HTML" do
|
54
|
-
agate.parse(text).should eql(parsed_text)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|