agate 0.3.4 → 0.4.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.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 0.3.4 / 2013-03-05
2
+
3
+ * Fixed Rubinius compatibility (#10).
4
+
5
+ # 0.3.3 / 2013-03-05
6
+
7
+ * Fixed Ruby 1.9 compatibility (#9).
8
+
1
9
  # 0.3.2 / 2013-03-05
2
10
 
3
11
  * Added CHANGELOG.
data/bin/agate CHANGED
@@ -1,3 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'agate'
3
+ require 'agate/cli'
4
+
5
+ Agate::CLI.instance.start
data/lib/agate/cli.rb ADDED
@@ -0,0 +1,51 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'agate'
3
+ require 'singleton'
4
+ require 'optparse'
5
+
6
+ module Agate
7
+ class CLI
8
+ include Singleton
9
+
10
+ def initialize
11
+ @options = {}
12
+ end
13
+
14
+ def start
15
+ parse_opts
16
+
17
+ agate = Agate::Parser.new(@options)
18
+ puts agate.parse(ARGV.join)
19
+ end
20
+
21
+ private
22
+ def parse_opts
23
+ opts = OptionParser.new do |opts|
24
+ opts.banner = "Usage: agate [options] text-to-convert"
25
+
26
+ opts.separator ""
27
+ opts.separator "Options:"
28
+
29
+ opts.on("-d", "--delimiters DELIMITERS", "Specify custom delimiters for ruby text (default: 【】)") do |delims|
30
+ @options[:delimiters] = delims
31
+ end
32
+
33
+ opts.on("-f", "--formatter FORMAT", "Specify a formatter to use (default/fallback: HTML)") do |format|
34
+ @options[:formatter] = format.to_sym
35
+ end
36
+
37
+ opts.on_tail("-h", "--help", "Show this message") do
38
+ puts opts
39
+ exit
40
+ end
41
+
42
+ opts.on_tail("-v", "--version", "Show version") do
43
+ puts Agate::VERSION
44
+ exit
45
+ end
46
+ end
47
+
48
+ opts.parse!(ARGV)
49
+ end
50
+ end
51
+ end
data/lib/agate/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Agate
2
- VERSION = "0.3.4"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -33,4 +33,26 @@ describe Agate::Parser do
33
33
  end
34
34
  end
35
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
36
58
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: agate
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.4
5
+ version: 0.4.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jesse B. Hannah
@@ -107,6 +107,8 @@ files:
107
107
  YmluL2FnYXRl
108
108
  - !binary |-
109
109
  bGliL2FnYXRlLnJi
110
+ - !binary |-
111
+ bGliL2FnYXRlL2NsaS5yYg==
110
112
  - !binary |-
111
113
  bGliL2FnYXRlL2Zvcm1hdHRlci9odG1sLnJi
112
114
  - !binary |-