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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 61b8714f36f8ffd5ce16f726b8e825e87fce1675
4
- data.tar.gz: 971c067f88323df3644029a93403d29ee4fcaade
3
+ metadata.gz: 082fa68e924d6ca49504cc5b5add126064803671
4
+ data.tar.gz: 5c19845e152f54b321f964f5f0d44dcea4f18250
5
5
  SHA512:
6
- metadata.gz: 5f68ea896b142d190f95e801487fc0986ed39a9f07b10be2491a17e3868b6c4bb55856fcfbf419a4883fed0971230a31de911beaee596267ece5d7c999651534
7
- data.tar.gz: 681afdb738799121773ff70375a20b07d481c78bf86fbe0bec7a4df8416e639dd3ac540eb5bfcf1bf90f6e19d33cb5818faf1b5d5956faccc8d19b743b77e0be
6
+ metadata.gz: abedee9fda0c7d0d3fa0c3d1547fcf86fceb29fedacc11cbc312a920d43c44477277b278d05391935a68f1f4e1a47d7ae9bcc953ef0a7d7448f7342211407d28
7
+ data.tar.gz: a6a2e3352ae201ab8ac4eb8104f52fed3e52cbf195e1fdde4d8ca8cd0b1000e7c78ae69449dd7795359bf7d89395eaa088f91fe9e5ac072174631ae6ba789a5c
@@ -3,7 +3,6 @@ rvm:
3
3
  - 1.9.2
4
4
  - 1.9.3
5
5
  - 2.0.0
6
+ - 2.1.2
6
7
  - jruby-19mode
7
- - rbx-19mode
8
- - ruby-head
9
- - jruby-head
8
+ - rbx-2
@@ -1,3 +1,8 @@
1
+ # 0.5.0 / 2014-08-30
2
+
3
+ * Plaintext parser.
4
+ * Structural cleanup.
5
+
1
6
  # 0.4.1 / 2013-03-06
2
7
 
3
8
  * Documentation fixes.
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.png)](http://badge.fury.io/rb/agate)
4
- [![Build Status](https://travis-ci.org/jbhannah/agate.png?branch=master)](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.png)](https://codeclimate.com/github/jbhannah/agate)
7
- [![Coverage Status](https://coveralls.io/repos/jbhannah/agate/badge.png?branch=master)](https://coveralls.io/r/jbhannah/agate)
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
- Wrap ruby characters (currently only furigana) in text with the
10
- [HTML5 `ruby` element][]. **Requires Ruby 1.9 or later (or compabible
11
- engine).**
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 # default (and currently only) formatter
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
@@ -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{Wrap ruby characters (currently only furigana) in text with the HTML5 ruby element.}
12
- spec.summary = %q{Wrap ruby characters (currently only furigana) in text with the HTML5 ruby element.}
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", "~> 2.13.0"
23
+ spec.add_development_dependency "rspec", "~> 3.0"
24
24
  spec.add_development_dependency "coveralls"
25
25
  end
data/bin/agate CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require 'agate/cli'
4
4
 
5
- Agate::CLI.instance.start
5
+ puts Agate::CLI.new.parse
@@ -1,3 +1,2 @@
1
- require "agate/formatter/html"
2
1
  require "agate/parser"
3
2
  require "agate/version"
@@ -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 start
12
+ def parse
15
13
  parse_opts
16
14
 
17
15
  agate = Agate::Parser.new(@options)
18
- puts agate.parse(ARGV.join)
16
+ agate.parse(ARGV.join)
19
17
  end
20
18
 
21
19
  private
22
20
  def parse_opts
23
- opts = OptionParser.new do |opts|
24
- opts.banner = "Usage: agate [options] text-to-convert"
21
+ opts = OptionParser.new do |o|
22
+ o.banner = "Usage: agate [options] text-to-convert"
25
23
 
26
- opts.separator ""
27
- opts.separator "Options:"
24
+ o.separator ""
25
+ o.separator "Options:"
28
26
 
29
- opts.on("-d", "--delimiters DELIMITERS", "Specify custom delimiters for ruby text (default: 【】)") do |delims|
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
- opts.on("-f", "--formatter FORMAT", "Specify a formatter to use (default/fallback: HTML)") do |format|
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
- opts.on_tail("-h", "--help", "Show this message") do
38
- puts opts
35
+ o.on_tail("-h", "--help", "Show this message") do
36
+ puts o
39
37
  exit
40
38
  end
41
39
 
42
- opts.on_tail("-v", "--version", "Show version") do
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
@@ -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
@@ -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 => :html
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.new
18
+ Agate::Formatter::HTML
19
+ when :plain
20
+ Agate::Formatter::Plain
16
21
  else
17
- Agate::Formatter::HTML.new
22
+ Agate::Formatter::Plain
18
23
  end
19
24
  end
20
25
 
@@ -1,3 +1,3 @@
1
1
  module Agate
2
- VERSION = "0.4.1"
2
+ VERSION = ["0", "5", "0"]
3
3
  end
@@ -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
@@ -9,9 +9,7 @@ RSpec.configure do |config|
9
9
  require "coveralls"
10
10
  Coveralls.wear!
11
11
 
12
- require "agate"
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.1
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: 2013-03-06 00:00:00.000000000 Z
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: 2.13.0
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: 2.13.0
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: Wrap ruby characters (currently only furigana) in text with the HTML5
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/lib/parser_spec.rb
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.0.0
118
+ rubygems_version: 2.2.2
116
119
  signing_key:
117
120
  specification_version: 4
118
- summary: Wrap ruby characters (currently only furigana) in text with the HTML5 ruby
119
- element.
121
+ summary: Format ruby characters (currently only furigana) in text for display.
120
122
  test_files:
121
- - spec/lib/parser_spec.rb
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
@@ -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