keigo 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec CHANGED
@@ -1 +1,2 @@
1
1
  --color
2
+ --format documentation
data/Gemfile CHANGED
@@ -10,4 +10,5 @@ group :development do
10
10
  gem "bundler", "~> 1.0.0"
11
11
  gem "jeweler", "~> 1.6.4"
12
12
  gem "rcov", ">= 0"
13
+ gem 'autotest'
13
14
  end
@@ -1,6 +1,9 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ ZenTest (4.6.0)
5
+ autotest (4.4.6)
6
+ ZenTest (>= 4.4.1)
4
7
  diff-lcs (1.1.2)
5
8
  git (1.2.5)
6
9
  jeweler (1.6.4)
@@ -22,6 +25,7 @@ PLATFORMS
22
25
  ruby
23
26
 
24
27
  DEPENDENCIES
28
+ autotest
25
29
  bundler (~> 1.0.0)
26
30
  jeweler (~> 1.6.4)
27
31
  rcov
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{keigo}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{kano4}]
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
26
26
  "Rakefile",
27
27
  "VERSION",
28
28
  "keigo.gemspec",
29
+ "keigo.yml",
29
30
  "lib/keigo.rb",
30
31
  "spec/keigo_spec.rb",
31
32
  "spec/spec_helper.rb"
@@ -44,17 +45,20 @@ Gem::Specification.new do |s|
44
45
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
45
46
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
46
47
  s.add_development_dependency(%q<rcov>, [">= 0"])
48
+ s.add_development_dependency(%q<autotest>, [">= 0"])
47
49
  else
48
50
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
49
51
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
50
52
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
51
53
  s.add_dependency(%q<rcov>, [">= 0"])
54
+ s.add_dependency(%q<autotest>, [">= 0"])
52
55
  end
53
56
  else
54
57
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
55
58
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
56
59
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
57
60
  s.add_dependency(%q<rcov>, [">= 0"])
61
+ s.add_dependency(%q<autotest>, [">= 0"])
58
62
  end
59
63
  end
60
64
 
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+ '今日' : '本日'
3
+ 'わたしたち': 'わたくしども'
4
+ 'わたし' : 'わたくし'
5
+ '俺' : 'わたくし'
@@ -1,6 +1,26 @@
1
1
  # encoding: utf-8
2
+ require 'yaml'
3
+ $keigo_henkan = YAML.load_file(File.dirname(__FILE__) + '/../keigo.yml')
4
+
5
+ def sama name
6
+ Keigo.new.sama name
7
+ end
8
+
9
+ def k text
10
+ Keigo.new.k text
11
+ end
12
+
2
13
  class Keigo
3
- def sama(name)
14
+ def initialize
15
+ @keigo_henkan = $keigo_henkan
16
+ end
17
+
18
+ def sama name
4
19
  "#{name}様"
5
20
  end
21
+
22
+ def k text
23
+ @keigo_henkan.each_key {|key| text = text.sub(key, @keigo_henkan[key])}
24
+ text
25
+ end
6
26
  end
@@ -1,10 +1,27 @@
1
1
  # encoding: utf-8
2
2
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
 
4
- describe "Keigo" do
5
- it "は、samaを使うと'様'が付加される" do
6
- keigo = Keigo.new
7
- name = keigo.sama('Keigo')
4
+ describe 'Keigo' do
5
+ before(:each) do
6
+ @keigo = Keigo.new
7
+ end
8
+ it 'は、keigo.samaを使うと最後に"様"が付加される' do
9
+ name = @keigo.sama('Keigo')
8
10
  name.should == 'Keigo様'
9
11
  end
12
+
13
+ it 'は、sama関数を使うと最後に"様"が付加される' do
14
+ sama('Keigo').should be_eql 'Keigo様'
15
+ end
16
+
17
+ it { @keigo.k('こんにちわ').should be_eql 'こんにちわ' }
18
+ it { @keigo.k('わたくし').should be_eql 'わたくし' }
19
+
20
+ it { @keigo.k('わたしたち').should be_eql 'わたくしども' }
21
+ it { @keigo.k('わたし').should be_eql 'わたくし' }
22
+ it { @keigo.k('今日').should be_eql '本日' }
23
+
24
+ it { @keigo.k('わたしは今日は外出いたします。').should be_eql 'わたくしは本日は外出いたします。' }
25
+
26
+ it { k('わたし').should be_eql 'わたくし' }
10
27
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: keigo
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - kano4
@@ -56,6 +56,17 @@ dependencies:
56
56
  type: :development
57
57
  prerelease: false
58
58
  version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: autotest
61
+ requirement: &id005 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: *id005
59
70
  description: This is a polite expression gem.
60
71
  email: shinji@kano4.com
61
72
  executables: []
@@ -75,6 +86,7 @@ files:
75
86
  - Rakefile
76
87
  - VERSION
77
88
  - keigo.gemspec
89
+ - keigo.yml
78
90
  - lib/keigo.rb
79
91
  - spec/keigo_spec.rb
80
92
  - spec/spec_helper.rb
@@ -91,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
103
  requirements:
92
104
  - - ">="
93
105
  - !ruby/object:Gem::Version
94
- hash: -1390406890285455638
106
+ hash: -2381433747295631490
95
107
  segments:
96
108
  - 0
97
109
  version: "0"