agate 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eda63f3e809d3e097848a34b3fc9cec35cbe6ac8
4
+ data.tar.gz: e2548f805540a40a648ea918d7d94cba84ce965b
5
+ SHA512:
6
+ metadata.gz: 1661c4901e2cf8c4f929dd7560a7da24f91284ce7647cdde9e3f1fb8c9955e2cb94d84c7c19be2c10900044216bc983a9ae6abe415e34048288b70403f502b20
7
+ data.tar.gz: 68ccb1be9b3b9847b087d05c2afa3f0242eb8b1a80715f4f0d6902f90c1661ffee16e648b0a695bf63c5ae80c950f4b1cda937680c769242c50beeaf671e07b4
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
6
+ - 2.0.0
7
+ - jruby-18mode
8
+ - jruby-19mode
9
+ - rbx-18mode
10
+ - rbx-19mode
11
+ - ruby-head
12
+ - jruby-head
13
+ - ree
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in agate.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Jesse B. Hannah
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # [Agate](http://en.wikipedia.org/w/index.php?title=Ruby_character&oldid=540994629#History)
2
+
3
+ [![Build Status](https://travis-ci.org/jbhannah/agate.png?branch=master)](https://travis-ci.org/jbhannah/agate)
4
+ [![Dependency Status](https://gemnasium.com/jbhannah/agate.png)](https://gemnasium.com/jbhannah/agate)
5
+ [![Code Climate](https://codeclimate.com/github/jbhannah/agate.png)](https://codeclimate.com/github/jbhannah/agate)
6
+ [![Coverage Status](https://coveralls.io/repos/jbhannah/agate/badge.png?branch=master)](https://coveralls.io/r/jbhannah/agate)
7
+
8
+ Wrap ruby characters (e.g. furigana, Pinyin, Zhuyin) in text with the
9
+ [HTML `ruby` element][].
10
+
11
+ ## Usage
12
+
13
+ ```ruby
14
+ a = Agate::Parser.new("勉【べん】強【きょう】します")
15
+ a.parse
16
+ ```
17
+
18
+ results in
19
+
20
+ ```html
21
+ <ruby>勉<rt>べん</rt></ruby><ruby>強<rt>きょう</rt></ruby>します
22
+ ```
23
+
24
+ It's highly recommended to read the W3C's documentation on the [HTML
25
+ `ruby` element][] to understand the usage of this element. There is a
26
+ [CSS workaround][] available that enables the display of ruby characters
27
+ in all modern browsers, but it's up to you to test all cases where you
28
+ intend to use the `ruby` element.
29
+
30
+ [HTML `ruby` element]: http://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element
31
+ [CSS workaround]: http://web.nickshanks.com/stylesheets/ruby.css
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/agate.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'agate/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "agate"
8
+ spec.version = Agate::VERSION
9
+ spec.authors = ["Jesse B. Hannah"]
10
+ spec.email = ["jesse@jbhannah.net"]
11
+ spec.description = %q{Wrap ruby characters (e.g. furigana, Pinyin, Zhuyin) in text with the HTML ruby element.}
12
+ spec.summary = %q{Wrap ruby characters (e.g. furigana, Pinyin, Zhuyin) in text with the HTML ruby element.}
13
+ spec.homepage = "https://github.com/jbhannah/agate"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.2"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec", "~> 2.13.0"
24
+ spec.add_development_dependency "coveralls"
25
+ end
data/bin/agate ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'agate'
data/lib/agate.rb ADDED
@@ -0,0 +1,2 @@
1
+ require "agate/parser"
2
+ require "agate/version"
@@ -0,0 +1,16 @@
1
+ # -*- coding: utf-8 -*-
2
+ module Agate
3
+ class Parser
4
+ def initialize(text)
5
+ @text = text
6
+ end
7
+
8
+ def text
9
+ @text
10
+ end
11
+
12
+ def parse
13
+ @parsed_text ||= @text.gsub(/(\p{Han}+)(【)([\p{Hiragana}\p{Katakana}]+)(】)/, '<ruby>\1<rp>\2</rp><rt>\3</rt><rp>\4</rp></ruby>')
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module Agate
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,16 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "spec_helper"
3
+
4
+ describe Agate::Parser do
5
+ let!(:text) { "勉【べん】強【きょう】します" }
6
+ let!(:agate) { Agate::Parser.new(text) }
7
+ let!(:parsed_text) { "<ruby>勉<rp>【</rp><rt>べん</rt><rp>】</rp></ruby><ruby>強<rp>【</rp><rt>きょう</rt><rp>】</rp></ruby>します" }
8
+
9
+ it "saves text to an instance variable" do
10
+ agate.text.should eql(text)
11
+ end
12
+
13
+ it "parses demarcated text and turns it into HTML" do
14
+ agate.parse.should eql(parsed_text)
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+
8
+ RSpec.configure do |config|
9
+ require "coveralls"
10
+ Coveralls.wear!
11
+
12
+ require "agate"
13
+
14
+ config.treat_symbols_as_metadata_keys_with_true_values = true
15
+
16
+ # Run specs in random order to surface order dependencies. If you find an
17
+ # order dependency and want to debug it, you can fix the order by providing
18
+ # the seed, which is printed after each run.
19
+ # --seed 1234
20
+ config.order = "random"
21
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: agate
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jesse B. Hannah
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-03-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 2.13.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 2.13.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Wrap ruby characters (e.g. furigana, Pinyin, Zhuyin) in text with the
70
+ HTML ruby element.
71
+ email:
72
+ - jesse@jbhannah.net
73
+ executables:
74
+ - agate
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - .gitignore
79
+ - .rspec
80
+ - .travis.yml
81
+ - Gemfile
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - agate.gemspec
86
+ - bin/agate
87
+ - lib/agate.rb
88
+ - lib/agate/parser.rb
89
+ - lib/agate/version.rb
90
+ - spec/lib/parser_spec.rb
91
+ - spec/spec_helper.rb
92
+ homepage: https://github.com/jbhannah/agate
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.0.0
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Wrap ruby characters (e.g. furigana, Pinyin, Zhuyin) in text with the HTML
116
+ ruby element.
117
+ test_files:
118
+ - spec/lib/parser_spec.rb
119
+ - spec/spec_helper.rb