ctc 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4f7ac8df2949e083702d174b294f5bc3765f8fd
4
- data.tar.gz: f7ab24c674154cfa8624902a65951e7cd9a583a4
3
+ metadata.gz: 250d5bfb4d0d093804c0e1acbc327325d4d9b99f
4
+ data.tar.gz: 86e395d270bfbb295f145f545da593b5e8d268f5
5
5
  SHA512:
6
- metadata.gz: bd2c70f34bbeadb91dfca832fa4a727e8f2406bd174e9819e6ca094181cb73cc4770dd6eb7dd95302bc13a42169b761fcec6f34e4e1f084c432dbf1dbc7e48ad
7
- data.tar.gz: 1be55beca2b36e1645a07de59010cf0865689ff0f8fa01488f51d7ab8a1f8ec5f1ab2f85e3fe9d2d66d2de01c27dfee079f42074ba726662c3fe3d3f5b76bafa
6
+ metadata.gz: 69e0cb27b8567c4a4d9420d4730544daf51e700a9d561d34dc2adffef2988592f2f04448922318918894f2d848744628aa8eb6a7825faf2f5a527fc6c76b7f81
7
+ data.tar.gz: b9f9ea90ea15d36e1ff03ba934c0cc28f76e553d4e570436f503ba3adc9223e60bf5a9a5a92047a798def03b44f254ba2c82dbcfbd5929658d19e15bbf814c0f
@@ -1,16 +1,18 @@
1
- class Ctc2Kanji
2
- def self.find(kanji)
3
- mappings.fetch(kanji) do
4
- raise Ctc::CtcNotFoundError.new("China Telelgraph Code (CTC) not found.")
1
+ module Ctc
2
+ class Ctc2Kanji
3
+ def self.find(kanji)
4
+ mappings.fetch(kanji) do
5
+ raise Ctc::CtcNotFoundError.new("China Telelgraph Code (CTC) not found.")
6
+ end
5
7
  end
6
- end
7
8
 
8
- private
9
- def self.mappings
10
- return @mappings if @mappings
9
+ private
10
+ def self.mappings
11
+ return @mappings if @mappings
11
12
 
12
- yaml_file = File.expand_path("../../config/ctc_2_kanji.yml", File.dirname(__FILE__))
13
- @mappings = YAML.load_file(yaml_file)
14
- @mappings
13
+ yaml_file = File.expand_path("../../config/ctc_2_kanji.yml", File.dirname(__FILE__))
14
+ @mappings = YAML.load_file(yaml_file)
15
+ @mappings
16
+ end
15
17
  end
16
18
  end
@@ -1,16 +1,18 @@
1
- class Kanji2Ctc
2
- def self.find(kanji)
3
- mappings.fetch(kanji) do
4
- raise Ctc::KanjiNotFoundError.new("Kanji not found.")
1
+ module Ctc
2
+ class Kanji2Ctc
3
+ def self.find(kanji)
4
+ mappings.fetch(kanji) do
5
+ raise Ctc::KanjiNotFoundError.new("Kanji not found.")
6
+ end
5
7
  end
6
- end
7
8
 
8
- private
9
- def self.mappings
10
- return @mappings if @mappings
9
+ private
10
+ def self.mappings
11
+ return @mappings if @mappings
11
12
 
12
- yaml_file = File.expand_path("../../config/kanji_2_ctc.yml", File.dirname(__FILE__))
13
- @mappings = YAML.load_file(yaml_file)
14
- @mappings
13
+ yaml_file = File.expand_path("../../config/kanji_2_ctc.yml", File.dirname(__FILE__))
14
+ @mappings = YAML.load_file(yaml_file)
15
+ @mappings
16
+ end
15
17
  end
16
18
  end
data/lib/ctc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ctc
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,19 +1,19 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Ctc2Kanji do
3
+ describe Ctc::Ctc2Kanji do
4
4
  it "raises error for nil input" do
5
- expect {Ctc2Kanji.find(nil)}.to raise_error(Ctc::CtcNotFoundError)
5
+ expect {Ctc::Ctc2Kanji.find(nil)}.to raise_error(Ctc::CtcNotFoundError)
6
6
  end
7
7
 
8
8
  it "raises error for empty input" do
9
- expect {Ctc2Kanji.find("")}.to raise_error(Ctc::CtcNotFoundError)
9
+ expect {Ctc::Ctc2Kanji.find("")}.to raise_error(Ctc::CtcNotFoundError)
10
10
  end
11
11
 
12
12
  it "raises error for invalid input" do
13
- expect {Ctc2Kanji.find(1)}.to raise_error(Ctc::CtcNotFoundError)
13
+ expect {Ctc::Ctc2Kanji.find(1)}.to raise_error(Ctc::CtcNotFoundError)
14
14
  end
15
15
 
16
16
  it "returns ctc for valid input" do
17
- Ctc2Kanji.find("0491").should == "刘"
17
+ Ctc::Ctc2Kanji.find("0491").should == "刘"
18
18
  end
19
19
  end
@@ -1,19 +1,19 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Kanji2Ctc do
3
+ describe Ctc::Kanji2Ctc do
4
4
  it "raises error for nil input" do
5
- expect {Kanji2Ctc.find(nil)}.to raise_error(Ctc::KanjiNotFoundError)
5
+ expect {Ctc::Kanji2Ctc.find(nil)}.to raise_error(Ctc::KanjiNotFoundError)
6
6
  end
7
7
 
8
8
  it "raises error for empty input" do
9
- expect {Kanji2Ctc.find("")}.to raise_error(Ctc::KanjiNotFoundError)
9
+ expect {Ctc::Kanji2Ctc.find("")}.to raise_error(Ctc::KanjiNotFoundError)
10
10
  end
11
11
 
12
12
  it "raises error for invalid input" do
13
- expect {Kanji2Ctc.find(1)}.to raise_error(Ctc::KanjiNotFoundError)
13
+ expect {Ctc::Kanji2Ctc.find(1)}.to raise_error(Ctc::KanjiNotFoundError)
14
14
  end
15
15
 
16
16
  it "returns ctc for valid input" do
17
- Kanji2Ctc.find("刘").should == "0491"
17
+ Ctc::Kanji2Ctc.find("刘").should == "0491"
18
18
  end
19
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ctc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hao Liu