katsuyoujin 0.0.1.2 → 0.0.2

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: 44cfd3f22767c75014b9a50f281789113f6f260a
4
- data.tar.gz: 2bbf9e0d4c05170863d8d71a0db24860904071ee
3
+ metadata.gz: 1d2d86774f80cd186b0600fac3406b429630482e
4
+ data.tar.gz: 234cfd1fa512c20603731af88c225a2836d2f735
5
5
  SHA512:
6
- metadata.gz: bf84e89a694d05cc354a0f88583cbd3090e296ea13ae029f54694b0bb836ce6d7cfa67ad9666c5a2b9d00e7982346c3d2d621d8a7cb67db37a3703dcc8e18a61
7
- data.tar.gz: 47592697ea54f010016b63f252d5e89fe312e446152dc8f6929faf98ff29d15032b77a7ac04315e64ddc0c0c3465ddc41b2e863824499c20410d261b2ed08e27
6
+ metadata.gz: 04955ced89c6f018e526c54c5c3ab4eeaaf053406eb158960e30d98ce490a3b04cb32eb7fd7bd7ceeaecd19efef24d6e77b22324b8352dd109a4e677b7040137
7
+ data.tar.gz: 3f7b4ebd7506c3abde0330345663418fa003f68b8bca7e7f0699a86cc206d90084cb2efbf98b03091b961fb5918289dcd0fbaafe7cb8f2ab729281622842f4da
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ AlignParameters:
2
+ Enabled: false
3
+ LineLength:
4
+ Max: 100
5
+ Style/WordArray:
6
+ Enabled: false
7
+ Style/Documentation:
8
+ Enabled: false
data/Gemfile CHANGED
@@ -2,5 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'kuromoji-ruby', github: 'toyama0919/kuromoji-ruby'
4
4
 
5
+ gem 'codeclimate-test-reporter', group: :test, require: nil
6
+
5
7
  # Specify your gem's dependencies in katsuyoujin.gemspec
6
8
  gemspec
data/README.md CHANGED
@@ -1,3 +1,12 @@
1
1
  # Katsuyoujin (活用人)
2
2
 
3
- Japanese verb conjugator
3
+ ## Japanese verb conjugator
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/katsuyoujin.svg)](http://badge.fury.io/rb/katsuyoujin)
6
+
7
+ [![Dependency Status](https://gemnasium.com/LuckyThirteen/katsuyoujin.svg)](https://gemnasium.com/LuckyThirteen/katsuyoujin)
8
+
9
+ [![Codeship Status for LuckyThirteen/katsuyoujin](https://codeship.com/projects/a45769b0-fb17-0132-8717-56a30f6b7674/status)](https://codeship.com/projects/87068)
10
+
11
+ [![Code Climate](https://codeclimate.com/github/LuckyThirteen/katsuyoujin/badges/gpa.svg)](https://codeclimate.com/github/LuckyThirteen/katsuyoujin)
12
+ [![Test Coverage](https://codeclimate.com/github/LuckyThirteen/katsuyoujin/badges/coverage.svg)](https://codeclimate.com/github/LuckyThirteen/katsuyoujin/coverage)
data/Rakefile CHANGED
@@ -1,4 +1,59 @@
1
1
  require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
2
 
4
- RSpec::Core::RakeTask.new
3
+ if ENV['RACK_ENV'] == 'test'
4
+ require 'rainbow'
5
+ require 'rspec/core/rake_task'
6
+ require 'rubocop/rake_task'
7
+ require 'rubycritic'
8
+ require 'rubycritic/source_control_systems/base'
9
+ require 'rubycritic/analysers_runner'
10
+
11
+ namespace :ci do
12
+ desc 'Run specs'
13
+ RSpec::Core::RakeTask.new(:specs) do |t|
14
+ t.verbose = false
15
+ t.rspec_opts = ['--format documentation',
16
+ '-t ~@skip-ci',
17
+ '--failure-exit-code 1']
18
+ end
19
+
20
+ desc 'Run rubocop'
21
+ RuboCop::RakeTask.new(:rubocop) do |t|
22
+ t.fail_on_error = true
23
+ t.verbose = false
24
+ t.formatters = ['RuboCop::Formatter::SimpleTextFormatter']
25
+ t.options = ['-D']
26
+ end
27
+
28
+ desc 'Run rubycritic'
29
+ task :rubycritic do
30
+ Rubycritic::Config.source_control_system = Rubycritic::SourceControlSystem::Base.create
31
+ analysed_files = Rubycritic::AnalysersRunner.new(['lib']).run
32
+ analysed_files.each do |file|
33
+ color = case file.rating.to_s
34
+ when 'A' then :green
35
+ when 'B' then :yellow
36
+ else :red
37
+ end
38
+ puts Rainbow("\s\s#{file.rating} | #{file.path}").send(color)
39
+ end
40
+ fail 'something smells' if analysed_files.map { |file| file.rating.to_s }.max > 'B'
41
+ end
42
+
43
+ desc 'Run things for ci'
44
+ task :build do
45
+ puts Rainbow('Running rubocop').blue
46
+ Rake::Task['ci:rubocop'].invoke
47
+
48
+ puts
49
+
50
+ puts Rainbow('Running rspec').blue
51
+ Rake::Task['ci:specs'].invoke
52
+
53
+ puts
54
+
55
+ puts Rainbow('Running rubycritic').blue
56
+ Rake::Task['ci:rubycritic'].invoke
57
+ end
58
+ end
59
+ end
data/katsuyoujin.gemspec CHANGED
@@ -23,4 +23,8 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency 'bundler'
24
24
  spec.add_development_dependency 'rake'
25
25
  spec.add_development_dependency 'rspec'
26
+ spec.add_development_dependency 'rainbow'
27
+ spec.add_development_dependency 'rubocop'
28
+ spec.add_development_dependency 'simplecov-gem-profile'
29
+ spec.add_development_dependency 'rubycritic'
26
30
  end
data/lib/katsuyoujin.rb CHANGED
@@ -14,17 +14,26 @@ module Katsuyoujin
14
14
  File.join root, 'rules'
15
15
  end
16
16
 
17
- ICHIDAN_BASE_TABLE = YAML.load_file File.join(Katsuyoujin.rules, 'ichidan/base.yml').freeze
18
- GODAN_BASE_TABLE = YAML.load_file File.join(Katsuyoujin.rules, 'godan/base.yml').freeze
17
+ GODAN_IRU_ERU = YAML.load_file(File.join(Katsuyoujin.rules, 'godan/iru_eru.yml')).freeze
18
+ GODAN_KURU_SURU = YAML.load_file(File.join(Katsuyoujin.rules, 'godan/kuru_suru.yml')).freeze
19
19
 
20
- CONJUGATIONS = { 'ichidan' => YAML.load_file(File.join(rules, 'ichidan/conjugations.yml')).freeze,
21
- 'godan' => YAML.load_file(File.join(rules, 'godan/conjugations.yml')).freeze }
20
+ ICHIDAN_BASE_TABLE = YAML.load_file File.join(Katsuyoujin.rules, 'ichidan/base.yml').freeze
21
+ GODAN_BASE_TABLE = YAML.load_file File.join(Katsuyoujin.rules, 'godan/base.yml').freeze
22
+ IRREGULAR_BASE_TABLE = YAML.load_file File.join(Katsuyoujin.rules, 'irregular/base.yml').freeze
23
+
24
+ CONJUGATIONS = {
25
+ 'ichidan' => YAML.load_file(File.join(rules, 'ichidan/conjugations.yml')).freeze,
26
+ 'godan' => YAML.load_file(File.join(rules, 'godan/conjugations.yml')).freeze,
27
+ 'irregular' => YAML.load_file(File.join(rules, 'irregular/conjugations.yml')).freeze
28
+ }
22
29
 
23
30
  def self.conjugate(word, *args, category: nil, hiragana: true)
24
31
  verb = Verb.new word
25
32
 
26
33
  vcat = category || verb.category
27
- rules = args.inject(CONJUGATIONS[vcat]) { |conjugations, rule| conjugations[rule] || {} }
34
+ vcat = 'irregular' if ['kuru', 'suru'].include?(vcat)
35
+
36
+ rules = args.inject(CONJUGATIONS[vcat]) { |a, e| a[e] || {} }
28
37
  return unless rules['base']
29
38
 
30
39
  base = Base.new(verb, rules['base']).conjugate category: category, hiragana: hiragana
@@ -24,19 +24,43 @@ module Katsuyoujin
24
24
  end
25
25
 
26
26
  def verb_category
27
- return nil unless base_form
27
+ fail ArgumentError('not a verb') unless base_form
28
28
 
29
29
  case
30
- when ['する'].include?(base_form_hiragana.chars.last(2).join) then 'irregular'
31
- when 'くる' == base_form_hiragana then 'irregular'
32
- when YAML.load_file(File.join(Katsuyoujin.rules, 'godan/iru_eru.yml')).include?(base_form_hiragana) then 'godan'
33
- when ['iru', 'eru'].include?(base_form_hiragana.romaji.chars.last(3).join) then 'ichidan'
30
+ when irregular_godan? then 'godan'
31
+ when suru? then 'suru'
32
+ when kuru? then 'kuru'
33
+ when ichidan? then 'ichidan'
34
34
  else 'godan'
35
35
  end
36
36
  end
37
37
 
38
38
  private
39
39
 
40
+ def suru?
41
+ 'する' == base_form_hiragana
42
+ end
43
+
44
+ def kuru?
45
+ 'くる' == base_form_hiragana
46
+ end
47
+
48
+ def godan_iru_eru?
49
+ GODAN_IRU_ERU.include?(base_form_hiragana)
50
+ end
51
+
52
+ def godan_kuru_suru?
53
+ GODAN_KURU_SURU.include?(base_form)
54
+ end
55
+
56
+ def irregular_godan?
57
+ godan_iru_eru? || godan_kuru_suru?
58
+ end
59
+
60
+ def ichidan?
61
+ ['iru', 'eru'].include? base_form_hiragana.romaji.chars.last(3).join
62
+ end
63
+
40
64
  def analysis
41
65
  @analysis ||= Kuromoji::Core.new.tokenize_with_hash word
42
66
  end
@@ -9,22 +9,24 @@ module Katsuyoujin
9
9
 
10
10
  def conjugate(category: nil, hiragana: true)
11
11
  case category || verb.category
12
- when 'ichidan' then ichidan_base(verb, base_letter, hiragana: hiragana)
13
- when 'godan' then godan_base(verb, base_letter, hiragana: hiragana)
14
- when 'irregular' then irregular_base(verb, base_letter, hiragana: hiragana)
12
+ when 'ichidan' then ichidan_base(base_letter, hiragana: hiragana)
13
+ when 'godan' then godan_base(base_letter, hiragana: hiragana)
14
+ when 'suru', 'kuru' then irregular_base(base_letter, hiragana: hiragana)
15
15
  end
16
16
  end
17
17
 
18
- def ichidan_base(verb, base_letter, hiragana: true)
18
+ private
19
+
20
+ def ichidan_base(base_letter, hiragana: true)
19
21
  verb_root(hiragana) + ICHIDAN_BASE_TABLE[base_letter]
20
22
  end
21
23
 
22
- def godan_base(verb, base_letter, hiragana: true)
24
+ def godan_base(base_letter, hiragana: true)
23
25
  verb_root(hiragana) + GODAN_BASE_TABLE[base_letter][verb.ending]
24
26
  end
25
27
 
26
- def irregular_base(verb, base_letter, hiragana: true)
27
- fail NotImplementedError
28
+ def irregular_base(base_letter, hiragana: true)
29
+ IRREGULAR_BASE_TABLE[base_letter][verb.hiragana_ending][hiragana ? 'hiragana' : 'kanji']
28
30
  end
29
31
 
30
32
  def verb_root(hiragana = true)
@@ -16,8 +16,20 @@ module Katsuyoujin
16
16
  @analyzer.verb_category
17
17
  end
18
18
 
19
+ def irregular?
20
+ ['kuru', 'suru'].include? category
21
+ end
22
+
19
23
  def ending
20
- dictionary_form[-1]
24
+ irregular? ? dictionary_form[-2..-1] : dictionary_form[-1]
25
+ end
26
+
27
+ def hiragana_ending
28
+ case category
29
+ when 'suru' then 'する'
30
+ when 'kuru' then 'くる'
31
+ else ending
32
+ end
21
33
  end
22
34
 
23
35
  def root
@@ -25,7 +37,7 @@ module Katsuyoujin
25
37
  end
26
38
 
27
39
  def hiragana_root
28
- dictionary_form_hiragana.chomp ending
40
+ dictionary_form_hiragana.chomp hiragana_ending
29
41
  end
30
42
  end
31
43
  end
@@ -1,3 +1,3 @@
1
1
  module Katsuyoujin
2
- VERSION = '0.0.1.2'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -0,0 +1,8 @@
1
+ - "刷る"
2
+ - "摺る"
3
+ - "擦る"
4
+ - "摩る"
5
+ - "磨る"
6
+ - "擂る"
7
+ - "掏る"
8
+ - "繰る"
@@ -0,0 +1,49 @@
1
+ "あ":
2
+ "する":
3
+ "hiragana": "し"
4
+ "kanji": "為"
5
+ "くる":
6
+ "hiragana": "こ"
7
+ "kanji": "来"
8
+ "い":
9
+ "する":
10
+ "hiragana": "し"
11
+ "kanji": "為"
12
+ "くる":
13
+ "hiragana": "き"
14
+ "kanji": "来"
15
+ "う":
16
+ "する":
17
+ "hiragana": "する"
18
+ "kanji": "為る"
19
+ "くる":
20
+ "hiragana": "くる"
21
+ "kanji": "来る"
22
+ "え":
23
+ "する":
24
+ "hiragana": "すれ"
25
+ "kanji": "為れ"
26
+ "くる":
27
+ "hiragana": "くれ"
28
+ "kanji": "来れ"
29
+ "お":
30
+ "する":
31
+ "hiragana": "しよう"
32
+ "kanji": "為よう"
33
+ "くる":
34
+ "hiragana": "こよう"
35
+ "kanji": "来よう"
36
+ "て":
37
+ "する":
38
+ "hiragana": "して"
39
+ "kanji": "為て"
40
+ "くる":
41
+ "hiragana": "きて"
42
+ "kanji": "来て"
43
+ "た":
44
+ "する":
45
+ "hiragana": "した"
46
+ "kanji": "為た"
47
+ "くる":
48
+ "hiragana": "きた"
49
+ "kanji": "来た"
@@ -0,0 +1,30 @@
1
+ "casual":
2
+ "nonpast_indicative":
3
+ "affirmative":
4
+ "base": "う"
5
+ "attachment": ""
6
+ "negative":
7
+ "base": "あ"
8
+ "attachment": "ない"
9
+ "past_indicative":
10
+ "affirmative":
11
+ "base": "た"
12
+ "attachment": ""
13
+ "negative":
14
+ "base": "あ"
15
+ "attachment": "なかった"
16
+ "polite":
17
+ "nonpast_indicative":
18
+ "affirmative":
19
+ "base": "い"
20
+ "attachment": "ます"
21
+ "negative":
22
+ "base": "い"
23
+ "attachment": "ません"
24
+ "past_indicative":
25
+ "affirmative":
26
+ "base": "い"
27
+ "attachment": "ました"
28
+ "negative":
29
+ "base": "い"
30
+ "attachment": "ませんでした"
@@ -1,3 +1,33 @@
1
+ "する":
2
+ "casual":
3
+ "nonpast_indicative":
4
+ "affirmative": "する"
5
+ "negative": "しない"
6
+ "past_indicative":
7
+ "affirmative": "した"
8
+ "negative": "しなかった"
9
+ "polite":
10
+ "nonpast_indicative":
11
+ "affirmative": "します"
12
+ "negative": "しません"
13
+ "past_indicative":
14
+ "affirmative": "しました"
15
+ "negative": "しませんでした"
16
+ "来る":
17
+ "casual":
18
+ "nonpast_indicative":
19
+ "affirmative": "くる"
20
+ "negative": "こない"
21
+ "past_indicative":
22
+ "affirmative": "きた"
23
+ "negative": "こなかった"
24
+ "polite":
25
+ "nonpast_indicative":
26
+ "affirmative": "きます"
27
+ "negative": "きません"
28
+ "past_indicative":
29
+ "affirmative": "きました"
30
+ "negative": "きませんでした"
1
31
  "食べる":
2
32
  "casual":
3
33
  "nonpast_indicative":
@@ -0,0 +1,15 @@
1
+ "呼ぶ":
2
+ "casual":
3
+ "nonpast_indicative":
4
+ "affirmative": "よぶ"
5
+ "negative": "よばない"
6
+ "past_indicative":
7
+ "affirmative": "よんだ"
8
+ "negative": "よばなかった"
9
+ "polite":
10
+ "nonpast_indicative":
11
+ "affirmative": "よびます"
12
+ "negative": "よびません"
13
+ "past_indicative":
14
+ "affirmative": "よびました"
15
+ "negative": "よびませんでした"
@@ -0,0 +1,15 @@
1
+ "泳ぐ":
2
+ "casual":
3
+ "nonpast_indicative":
4
+ "affirmative": "およぐ"
5
+ "negative": "およがない"
6
+ "past_indicative":
7
+ "affirmative": "およいだ"
8
+ "negative": "およがなかった"
9
+ "polite":
10
+ "nonpast_indicative":
11
+ "affirmative": "およぎます"
12
+ "negative": "およぎません"
13
+ "past_indicative":
14
+ "affirmative": "およぎました"
15
+ "negative": "およぎませんでした"
@@ -0,0 +1,15 @@
1
+ "歩く":
2
+ "casual":
3
+ "nonpast_indicative":
4
+ "affirmative": "あるく"
5
+ "negative": "あるかない"
6
+ "past_indicative":
7
+ "affirmative": "あるいた"
8
+ "negative": "あるかなかった"
9
+ "polite":
10
+ "nonpast_indicative":
11
+ "affirmative": "あるきます"
12
+ "negative": "あるきません"
13
+ "past_indicative":
14
+ "affirmative": "あるきました"
15
+ "negative": "あるきませんでした"
@@ -0,0 +1,15 @@
1
+ "飲む":
2
+ "casual":
3
+ "nonpast_indicative":
4
+ "affirmative": "のむ"
5
+ "negative": "のまない"
6
+ "past_indicative":
7
+ "affirmative": "のんだ"
8
+ "negative": "のまなかった"
9
+ "polite":
10
+ "nonpast_indicative":
11
+ "affirmative": "のみます"
12
+ "negative": "のみません"
13
+ "past_indicative":
14
+ "affirmative": "のみました"
15
+ "negative": "のみませんでした"
@@ -0,0 +1,15 @@
1
+ "死ぬ":
2
+ "casual":
3
+ "nonpast_indicative":
4
+ "affirmative": "しぬ"
5
+ "negative": "しなない"
6
+ "past_indicative":
7
+ "affirmative": "しんだ"
8
+ "negative": "しななかった"
9
+ "polite":
10
+ "nonpast_indicative":
11
+ "affirmative": "しにます"
12
+ "negative": "しにません"
13
+ "past_indicative":
14
+ "affirmative": "しにました"
15
+ "negative": "しにませんでした"
@@ -0,0 +1,15 @@
1
+ "作る":
2
+ "casual":
3
+ "nonpast_indicative":
4
+ "affirmative": "つくる"
5
+ "negative": "つくらない"
6
+ "past_indicative":
7
+ "affirmative": "つくった"
8
+ "negative": "つくらなかった"
9
+ "polite":
10
+ "nonpast_indicative":
11
+ "affirmative": "つくります"
12
+ "negative": "つくりません"
13
+ "past_indicative":
14
+ "affirmative": "つくりました"
15
+ "negative": "つくりませんでした"
@@ -0,0 +1,15 @@
1
+ "話す":
2
+ "casual":
3
+ "nonpast_indicative":
4
+ "affirmative": "はなす"
5
+ "negative": "はなさない"
6
+ "past_indicative":
7
+ "affirmative": "はなした"
8
+ "negative": "はなさなかった"
9
+ "polite":
10
+ "nonpast_indicative":
11
+ "affirmative": "はなします"
12
+ "negative": "はなしません"
13
+ "past_indicative":
14
+ "affirmative": "はなしました"
15
+ "negative": "はなしませんでした"
@@ -0,0 +1,15 @@
1
+ "待つ":
2
+ "casual":
3
+ "nonpast_indicative":
4
+ "affirmative": "まつ"
5
+ "negative": "またない"
6
+ "past_indicative":
7
+ "affirmative": "まった"
8
+ "negative": "またなかった"
9
+ "polite":
10
+ "nonpast_indicative":
11
+ "affirmative": "まちます"
12
+ "negative": "まちません"
13
+ "past_indicative":
14
+ "affirmative": "まちました"
15
+ "negative": "まちませんでした"
@@ -0,0 +1,15 @@
1
+ "洗う":
2
+ "casual":
3
+ "nonpast_indicative":
4
+ "affirmative": "あらう"
5
+ "negative": "あらわない"
6
+ "past_indicative":
7
+ "affirmative": "あらった"
8
+ "negative": "あらわなかった"
9
+ "polite":
10
+ "nonpast_indicative":
11
+ "affirmative": "あらいます"
12
+ "negative": "あらいません"
13
+ "past_indicative":
14
+ "affirmative": "あらいました"
15
+ "negative": "あらいませんでした"
@@ -0,0 +1,15 @@
1
+ "食べる":
2
+ "casual":
3
+ "nonpast_indicative":
4
+ "affirmative": "たべる"
5
+ "negative": "たべない"
6
+ "past_indicative":
7
+ "affirmative": "たべた"
8
+ "negative": "たべなかった"
9
+ "polite":
10
+ "nonpast_indicative":
11
+ "affirmative": "たべます"
12
+ "negative": "たべません"
13
+ "past_indicative":
14
+ "affirmative": "たべました"
15
+ "negative": "たべませんでした"
@@ -0,0 +1,16 @@
1
+ "する":
2
+ "あ": "し"
3
+ "い": "し"
4
+ "う": "する"
5
+ "え": "すれ"
6
+ "お": "しよう"
7
+ "て": "して"
8
+ "た": "した"
9
+ "くる":
10
+ "あ": "こ"
11
+ "い": "き"
12
+ "う": "くる"
13
+ "え": "くれ"
14
+ "お": "こよう"
15
+ "て": "きて"
16
+ "た": "きた"
@@ -0,0 +1,30 @@
1
+ "する":
2
+ "casual":
3
+ "nonpast_indicative":
4
+ "affirmative": "する"
5
+ "negative": "しない"
6
+ "past_indicative":
7
+ "affirmative": "した"
8
+ "negative": "しなかった"
9
+ "polite":
10
+ "nonpast_indicative":
11
+ "affirmative": "します"
12
+ "negative": "しません"
13
+ "past_indicative":
14
+ "affirmative": "しました"
15
+ "negative": "しませんでした"
16
+ "来る":
17
+ "casual":
18
+ "nonpast_indicative":
19
+ "affirmative": "くる"
20
+ "negative": "こない"
21
+ "past_indicative":
22
+ "affirmative": "きた"
23
+ "negative": "こなかった"
24
+ "polite":
25
+ "nonpast_indicative":
26
+ "affirmative": "きます"
27
+ "negative": "きません"
28
+ "past_indicative":
29
+ "affirmative": "きました"
30
+ "negative": "きませんでした"
@@ -1,11 +1,11 @@
1
1
  describe 'base' do
2
2
  BASE_CATEGORIES.each do |base_category|
3
3
  context "#{base_category} base" do
4
- ['ichidan', 'godan'].each do |verb_category|
4
+ ['ichidan', 'godan', 'irregular'].each do |verb_category|
5
5
  BASES[verb_category].each do |word, bases|
6
6
  it "knows the #{base_category} base of #{word} (#{verb_category})" do
7
7
  verb = Katsuyoujin::Verb.new word
8
- base = Katsuyoujin::Base.new(verb, base_category).conjugate(category: verb_category)
8
+ base = Katsuyoujin::Base.new(verb, base_category).conjugate
9
9
  expect(bases[base_category]).to eq(base)
10
10
  end
11
11
  end
@@ -0,0 +1,5 @@
1
+ GODAN_CONJUGATIONS.each do |ending, conjugations|
2
+ describe "godan conjugations (#{ending} ending)" do
3
+ it_should_behave_like 'conjugations', conjugations
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ describe 'ichidan conjugations' do
2
+ it_should_behave_like 'conjugations', ICHIDAN_CONJUGATIONS
3
+ end
@@ -0,0 +1,3 @@
1
+ describe 'irregular conjugations' do
2
+ it_should_behave_like 'conjugations', IRREGULAR_CONJUGATIONS
3
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,36 @@
1
+ require 'simplecov-gem-profile'
2
+ require 'codeclimate-test-reporter'
3
+ SimpleCov.start 'gem' if ENV['COVERAGE']
4
+ CodeClimate::TestReporter.start if ENV['CODECLIMATE_REPO_TOKEN']
5
+
1
6
  require 'katsuyoujin'
7
+ require_relative 'support/shared_examples_for_conjugations'
2
8
 
3
- BASE_CATEGORIES = ['あ', 'い', 'う', 'え', 'お', 'て', 'た']
4
- ICHIDAN_BASES = YAML.load_file('spec/fixtures/ichidan/base.yml')
9
+ BASE_CATEGORIES = ['あ', 'い', 'う', 'え', 'お', 'て', 'た'].freeze
10
+ ICHIDAN_BASES = YAML.load_file('spec/fixtures/ichidan/base.yml').freeze
5
11
 
6
12
  BASES = { 'ichidan' => YAML.load_file('spec/fixtures/ichidan/base.yml'),
7
- 'godan' => YAML.load_file('spec/fixtures/godan/base.yml') }
13
+ 'godan' => YAML.load_file('spec/fixtures/godan/base.yml'),
14
+ 'irregular' => YAML.load_file('spec/fixtures/irregular/base.yml') }.freeze
15
+
16
+ ICHIDAN_CONJUGATIONS = YAML.load_file('spec/fixtures/ichidan/conjugations.yml').freeze
17
+
18
+ GODAN_ENDINGS = ['す', 'く', 'ぐ', 'ぶ', 'む', 'ぬ', 'る', 'つ', 'う']
19
+
20
+ GODAN_CONJUGATIONS = GODAN_ENDINGS.each_with_object({}) do |ending, hsh|
21
+ hsh[ending] = YAML.load_file("spec/fixtures/godan/#{ending.romaji}_conjugations.yml")
22
+ end.freeze
23
+
24
+ IRREGULAR_CONJUGATIONS = YAML.load_file('spec/fixtures/irregular/conjugations.yml').freeze
25
+
26
+ CONJUGATION_TYPES = ['nonpast_indicative',
27
+ 'past_indicative'].freeze
28
+
29
+ RSpec.configure do |config|
30
+ config.run_all_when_everything_filtered = true
31
+ config.filter_run :focus
32
+
33
+ config.mock_with :rspec
8
34
 
9
- CONJUGATIONS = YAML.load_file('spec/fixtures/conjugations.yml')
35
+ config.order = 'random'
36
+ end
@@ -0,0 +1,43 @@
1
+ RSpec.shared_examples 'conjugations' do |collection|
2
+ CONJUGATION_TYPES.each do |category|
3
+ context category do
4
+ context 'casual' do
5
+ context 'affirmative' do
6
+ collection.each do |verb, conjugations|
7
+ it "knows the #{category} casual affirmative conjugation of #{verb}" do
8
+ conj = Katsuyoujin.conjugate(verb, 'casual', category, 'affirmative')
9
+ expect(conj).to eq conjugations['casual'][category]['affirmative']
10
+ end
11
+ end
12
+ end
13
+ context 'negative' do
14
+ collection.each do |verb, conjugations|
15
+ it "knows the #{category} casual negative conjugation of #{verb}" do
16
+ conj = Katsuyoujin.conjugate(verb, 'casual', category, 'negative')
17
+ expect(conj).to eq conjugations['casual'][category]['negative']
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ context 'polite' do
24
+ context 'affirmative' do
25
+ collection.each do |verb, conjugations|
26
+ it "knows the #{category} polite affirmative conjugation of #{verb}" do
27
+ conj = Katsuyoujin.conjugate(verb, 'polite', category, 'affirmative')
28
+ expect(conj).to eq conjugations['polite'][category]['affirmative']
29
+ end
30
+ end
31
+ end
32
+ context 'negative' do
33
+ collection.each do |verb, conjugations|
34
+ it "knows the #{category} polite negative conjugation of #{verb}" do
35
+ conj = Katsuyoujin.conjugate(verb, 'polite', category, 'negative')
36
+ expect(conj).to eq conjugations['polite'][category]['negative']
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katsuyoujin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.2
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - LuckyThirteen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-21 00:00:00.000000000 Z
11
+ date: 2015-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mojinizer
@@ -66,6 +66,62 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rainbow
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov-gem-profile
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubycritic
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
69
125
  description: ''
70
126
  email:
71
127
  - baloghzsof@gmail.com
@@ -75,6 +131,7 @@ extra_rdoc_files: []
75
131
  files:
76
132
  - ".gitignore"
77
133
  - ".rspec"
134
+ - ".rubocop.yml"
78
135
  - ".ruby-gemset"
79
136
  - ".ruby-version"
80
137
  - Gemfile
@@ -90,14 +147,32 @@ files:
90
147
  - rules/godan/base.yml
91
148
  - rules/godan/conjugations.yml
92
149
  - rules/godan/iru_eru.yml
150
+ - rules/godan/kuru_suru.yml
93
151
  - rules/ichidan/base.yml
94
152
  - rules/ichidan/conjugations.yml
153
+ - rules/irregular/base.yml
154
+ - rules/irregular/conjugations.yml
95
155
  - spec/fixtures/conjugations.yml
96
156
  - spec/fixtures/godan/base.yml
157
+ - spec/fixtures/godan/bu_conjugations.yml
158
+ - spec/fixtures/godan/gu_conjugations.yml
159
+ - spec/fixtures/godan/ku_conjugations.yml
160
+ - spec/fixtures/godan/mu_conjugations.yml
161
+ - spec/fixtures/godan/nu_conjugations.yml
162
+ - spec/fixtures/godan/ru_conjugations.yml
163
+ - spec/fixtures/godan/su_conjugations.yml
164
+ - spec/fixtures/godan/tsu_conjugations.yml
165
+ - spec/fixtures/godan/u_conjugations.yml
97
166
  - spec/fixtures/ichidan/base.yml
167
+ - spec/fixtures/ichidan/conjugations.yml
168
+ - spec/fixtures/irregular/base.yml
169
+ - spec/fixtures/irregular/conjugations.yml
98
170
  - spec/lib/base_spec.rb
99
- - spec/lib/conjugations_spec.rb
171
+ - spec/lib/godan_conjugations_spec.rb
172
+ - spec/lib/ichidan_conjugations_spec.rb
173
+ - spec/lib/irregular_conjugations_spec.rb
100
174
  - spec/spec_helper.rb
175
+ - spec/support/shared_examples_for_conjugations.rb
101
176
  homepage: https://github.com/LuckyThirteen/katsuyoujin
102
177
  licenses:
103
178
  - GPLv3
@@ -125,7 +200,22 @@ summary: Japanese verb conjugator.
125
200
  test_files:
126
201
  - spec/fixtures/conjugations.yml
127
202
  - spec/fixtures/godan/base.yml
203
+ - spec/fixtures/godan/bu_conjugations.yml
204
+ - spec/fixtures/godan/gu_conjugations.yml
205
+ - spec/fixtures/godan/ku_conjugations.yml
206
+ - spec/fixtures/godan/mu_conjugations.yml
207
+ - spec/fixtures/godan/nu_conjugations.yml
208
+ - spec/fixtures/godan/ru_conjugations.yml
209
+ - spec/fixtures/godan/su_conjugations.yml
210
+ - spec/fixtures/godan/tsu_conjugations.yml
211
+ - spec/fixtures/godan/u_conjugations.yml
128
212
  - spec/fixtures/ichidan/base.yml
213
+ - spec/fixtures/ichidan/conjugations.yml
214
+ - spec/fixtures/irregular/base.yml
215
+ - spec/fixtures/irregular/conjugations.yml
129
216
  - spec/lib/base_spec.rb
130
- - spec/lib/conjugations_spec.rb
217
+ - spec/lib/godan_conjugations_spec.rb
218
+ - spec/lib/ichidan_conjugations_spec.rb
219
+ - spec/lib/irregular_conjugations_spec.rb
131
220
  - spec/spec_helper.rb
221
+ - spec/support/shared_examples_for_conjugations.rb
@@ -1,40 +0,0 @@
1
- describe 'conjugations' do
2
- ['nonpast_indicative', 'past_indicative'].each do |category|
3
- context category do
4
- context 'casual' do
5
- context 'affirmative' do
6
- CONJUGATIONS.each do |verb, conjugations|
7
- it "knows the #{category} casual affirmative conjugation of #{verb}" do
8
- expect(Katsuyoujin.conjugate(verb, 'casual', category, 'affirmative')).to eq conjugations['casual'][category]['affirmative']
9
- end
10
- end
11
- end
12
- context 'negative' do
13
- CONJUGATIONS.each do |verb, conjugations|
14
- it "knows the #{category} casual negative conjugation of #{verb}" do
15
- expect(Katsuyoujin.conjugate(verb, 'casual', category, 'negative')).to eq conjugations['casual'][category]['negative']
16
- end
17
- end
18
- end
19
- end
20
-
21
- context 'polite' do
22
- context 'affirmative' do
23
- CONJUGATIONS.each do |verb, conjugations|
24
- it "knows the #{category} polite affirmative conjugation of #{verb}" do
25
- expect(Katsuyoujin.conjugate(verb, 'polite', category, 'affirmative')).to eq conjugations['polite'][category]['affirmative']
26
- end
27
- end
28
- end
29
- context 'negative' do
30
- CONJUGATIONS.each do |verb, conjugations|
31
- it "knows the #{category} polite negative conjugation of #{verb}" do
32
- expect(Katsuyoujin.conjugate(verb, 'polite', category, 'negative')).to eq conjugations['polite'][category]['negative']
33
- end
34
- end
35
- end
36
- end
37
- end
38
-
39
- end
40
- end