tataki 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2ee32cd3111b09f4e62781debac62e4b5685017
4
- data.tar.gz: 90a9ae1f2b96841d50ec13cefc9740fb43f7557c
3
+ metadata.gz: aa8fec9bc8527b014ade8528d1cd9cefa2223c59
4
+ data.tar.gz: 39f9543bbcdf66bb83fc3062a019c126064cbde2
5
5
  SHA512:
6
- metadata.gz: ba6ba513abcfbd2b1b31250cc592a094a39ab9c5dc995741dcbfa864091f7e96f1f73119ea3965f5b49ec4329589731219c62fca4c6df8096ec10b3001bfe6c1
7
- data.tar.gz: 94070b7ba996462447f5e942c6193829ab8c01cb10687e5812d7d97954710168fcf6fe2443a6b736f79595bc7b21af29830ea4cbfec74842165a68060ea00832
6
+ metadata.gz: d1b330894a4b2bd8d159b6ebabb3be71486ba820f87feee4a744682a83e3a93936acbeacd48bfd44cf80ecec99f197b2da6d354e97e2048e067fe1bfe73492e0
7
+ data.tar.gz: ff9e1b5643bb7d748bfe0fadfcd191ebf270103198662d5e2f6c2d4aa3171d8c29bc4bebbe8a58ce4cbf67853ea9a8d87a5f2a43d4c1c5de2cbdff158627c4a5
@@ -7,30 +7,30 @@ require "trie"
7
7
  module Tataki
8
8
  module Converter
9
9
  class SkkJisyo < Base
10
+ DEFAULT_CONFIG_PATH = "../../../../data/skk-jisyo.yml"
10
11
  DEFAULT_JISYO_SUFFIXES = %w[M]
11
12
 
12
- def initialize(options = {})
13
- options = {
14
- :jisyo_paths => DEFAULT_JISYO_SUFFIXES.map{|suffix| Skk::Jisyo.path(suffix) },
15
- :trie_cache_path => trie_cache_path(DEFAULT_JISYO_SUFFIXES.join("_")),
16
- }.merge(options)
17
- config_file = File.expand_path("../../../../data/skk-jisyo.yml", __FILE__)
13
+ def initialize(jisyo_types = DEFAULT_JISYO_SUFFIXES)
14
+ @jisyo_paths = jisyo_types.map{|suffix| Skk::Jisyo.path(suffix) }
15
+ @trie_cache_path = trie_cache_path(jisyo_types.join("_"))
16
+
17
+ config_file = File.expand_path(DEFAULT_CONFIG_PATH, __FILE__)
18
18
  config_data = YAML.load_file(config_file)
19
19
  @roman_data = config_data["roman_table"]
20
20
  @ignore_kana = config_data["ignore_kana"]
21
- @trie = setup_jisyo(options).freeze
21
+ @trie = setup_jisyo.freeze
22
22
  end
23
23
 
24
- def setup_jisyo(options)
25
- if File.exist?(options[:trie_cache_path])
26
- trie = Marshal.load(File.read(options[:trie_cache_path]))
24
+ def setup_jisyo
25
+ if File.exist?(@trie_cache_path)
26
+ trie = Marshal.load(File.read(@trie_cache_path))
27
27
  else
28
28
  trie = Trie.new
29
- options[:jisyo_paths].each do |jisyo_path|
29
+ @jisyo_paths.each do |jisyo_path|
30
30
  add_jisyo(trie, jisyo_path)
31
31
  end
32
- File.binwrite(options[:trie_cache_path], Marshal.dump(trie))
33
- File.write("#{options[:trie_cache_path]}.timestamp", Time.now.to_s)
32
+ File.binwrite(@trie_cache_path, Marshal.dump(trie))
33
+ File.write("#{@trie_cache_path}.timestamp", Time.now.to_s)
34
34
  end
35
35
  trie
36
36
  end
@@ -1,3 +1,3 @@
1
1
  module Tataki
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -2,7 +2,6 @@
2
2
  require "spec_helper"
3
3
 
4
4
  describe Tataki::Converter::SkkJisyo do
5
- let(:converter) { Tataki::Converter::SkkJisyo.new }
6
5
 
7
6
  describe ".to_kana" do
8
7
  shared_examples "converts_kana" do |sentence, kana|
@@ -11,12 +10,24 @@ describe Tataki::Converter::SkkJisyo do
11
10
  end
12
11
  end
13
12
 
14
- include_examples "converts_kana", "", ""
15
- include_examples "converts_kana", "漢字", "かんじ"
16
- include_examples "converts_kana", "漢字変換する", "かんじへんかんする"
17
- include_examples "converts_kana", "隣りの", "となりの"
18
- include_examples "converts_kana", "隣りはよく柿食う", "となりはよくかきくう"
19
- include_examples "converts_kana", "安心安全", "あんしんあんぜん"
20
- include_examples "converts_kana", "毎朝新聞配達をしています", "まいあさしんぶんはいたつをしています"
13
+ context "with default config" do
14
+ let(:converter) { Tataki::Converter::SkkJisyo.new }
15
+
16
+ include_examples "converts_kana", "", ""
17
+ include_examples "converts_kana", "漢字", "かんじ"
18
+ include_examples "converts_kana", "漢字変換する", "かんじへんかんする"
19
+ include_examples "converts_kana", "隣りの", "となりの"
20
+ include_examples "converts_kana", "隣りはよく柿食う", "となりはよくかきくう"
21
+ include_examples "converts_kana", "安心安全", "あんしんあんぜん"
22
+ include_examples "converts_kana", "毎朝新聞配達をしています", "まいあさしんぶんはいたつをしています"
23
+ end
24
+
25
+ context "with jinmei jisyo" do
26
+ let(:converter) { Tataki::Converter::SkkJisyo.new(%w[jinmei]) }
27
+
28
+ include_examples "converts_kana", "", ""
29
+ include_examples "converts_kana", "漢字", "漢字"
30
+ include_examples "converts_kana", "半澤直樹", "はんざわなおき"
31
+ end
21
32
  end
22
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tataki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - hogelog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-17 00:00:00.000000000 Z
11
+ date: 2013-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: skk-jisyo