tsundere 0.2.0 → 0.2.1
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/VERSION +1 -1
- data/lib/tsundere/imouto.rb +2 -0
- data/lib/tsundere/instance_methods.rb +8 -5
- data/spec/integration_spec.rb +72 -0
- data/tsundere.gemspec +2 -1
- metadata +3 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/lib/tsundere/imouto.rb
CHANGED
@@ -8,6 +8,7 @@ module Tsundere
|
|
8
8
|
end # initialize
|
9
9
|
|
10
10
|
def method_missing meth, *args, &block
|
11
|
+
|
11
12
|
conditions = []
|
12
13
|
conditions << lambda do
|
13
14
|
:[] == meth and @parent.dere_for? @level, process_args( *args )
|
@@ -33,6 +34,7 @@ module Tsundere
|
|
33
34
|
@parent.send(meth, *args) if block.nil?
|
34
35
|
end # meth
|
35
36
|
else
|
37
|
+
|
36
38
|
return @parent.tsun_for @level
|
37
39
|
end # if conditions inject
|
38
40
|
else
|
@@ -3,6 +3,7 @@ module Tsundere
|
|
3
3
|
|
4
4
|
def tsundere_for(duck)
|
5
5
|
level = p_retrieve_level_or_rank duck
|
6
|
+
|
6
7
|
Imouto.new self, level
|
7
8
|
end # tsundere_for
|
8
9
|
|
@@ -31,15 +32,17 @@ module Tsundere
|
|
31
32
|
private
|
32
33
|
|
33
34
|
def p_retrieve_level_or_rank duck
|
35
|
+
level = nil
|
34
36
|
case duck.class.to_s
|
35
37
|
when String.to_s, Fixnum.to_s, Float.to_s, Integer.to_s, Symbol.to_s
|
36
|
-
duck
|
38
|
+
level = duck
|
37
39
|
when Hash.to_s
|
38
|
-
duck[:level] if duck.has_key? :level
|
39
|
-
duck[:rank] if duck.has_key? :rank
|
40
|
+
level = duck[:level] if duck.has_key? :level
|
41
|
+
level = duck[:rank] if duck.has_key? :rank
|
40
42
|
else
|
41
|
-
duck.level if duck.respond_to? :level
|
42
|
-
duck.rank if duck.respond_to? :rank
|
43
|
+
level = duck.level if duck.respond_to? :level
|
44
|
+
level = duck.rank if duck.respond_to? :rank
|
43
45
|
end # duck class
|
46
|
+
level
|
44
47
|
end # level or rank
|
45
48
|
end # Tsundere
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Person
|
4
|
+
def self.ranks
|
5
|
+
[:stranger, :classmate, :senpai, :osanajimi, :oniichan, :trevor]
|
6
|
+
end # ranks
|
7
|
+
attr_accessor :level, :rank
|
8
|
+
@@ranks = {
|
9
|
+
:stranger => 1,
|
10
|
+
:classmate => 2,
|
11
|
+
:senpai => 3,
|
12
|
+
:osanajimi => 4,
|
13
|
+
:oniichan => 5,
|
14
|
+
:trevor => 6
|
15
|
+
}
|
16
|
+
def initialize rank
|
17
|
+
@level = @@ranks[rank]
|
18
|
+
@rank = rank
|
19
|
+
end # initialize
|
20
|
+
end # Person
|
21
|
+
|
22
|
+
class HighSchooler
|
23
|
+
def self.actions
|
24
|
+
[:speak_with, :eat_with, :go_on_date_with, :hold_hands_with, :bathe_with, :pomf_on_bed_with]
|
25
|
+
end # actions
|
26
|
+
include Tsundere
|
27
|
+
attr_tsundere :speak_with, :fail => "damare!", :as => { :stranger => 1 }
|
28
|
+
attr_tsundere :eat_with, :fail => "itadakimasu!", :as => { :classmate => 2 }
|
29
|
+
attr_tsundere :go_on_date_with, :fail => "furareta", :as => { :senpai => 3 }
|
30
|
+
attr_tsundere :hold_hands_with, :fail => "kyaa!", :as => { :osanajimi => 4 }
|
31
|
+
attr_tsundere :bathe_with, :fail => "oniichan no ecchi!", :as => { :oniichan => 5 }
|
32
|
+
attr_tsundere :pomf_on_bed_with, :as => { :trevor => 6 }
|
33
|
+
|
34
|
+
def initialize unused
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
def speak_with
|
39
|
+
true
|
40
|
+
end # speak
|
41
|
+
def eat_with
|
42
|
+
true
|
43
|
+
end # eat
|
44
|
+
def go_on_date_with
|
45
|
+
true
|
46
|
+
end # go_on_date
|
47
|
+
def hold_hands_with
|
48
|
+
true
|
49
|
+
end # hold_hands
|
50
|
+
def bathe_with
|
51
|
+
true
|
52
|
+
end # bathe
|
53
|
+
def pomf_on_bed_with
|
54
|
+
true
|
55
|
+
end # pomf_on_bed
|
56
|
+
end # SchoolGirl
|
57
|
+
|
58
|
+
describe "HighSchooler-Person relationships" do
|
59
|
+
context "passing in user" do
|
60
|
+
before :each do
|
61
|
+
@oniichan = Person.new :oniichan
|
62
|
+
@dekomori = HighSchooler.new :death
|
63
|
+
end # each
|
64
|
+
|
65
|
+
it "should permit oniichan to bathe with dekomori" do
|
66
|
+
@dekomori.tsundere_for(@oniichan).bathe_with.should be_true
|
67
|
+
end # it
|
68
|
+
it "should not let oniichan pomf" do
|
69
|
+
@dekomori.tsundere_for(@oniichan).pomf_on_bed_with.should =~ /ecchi/i
|
70
|
+
end # it
|
71
|
+
end # context
|
72
|
+
end # relationships
|
data/tsundere.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "tsundere"
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Thomas Chen", "Trevor Umeda"]
|
@@ -43,6 +43,7 @@ Gem::Specification.new do |s|
|
|
43
43
|
"spec/class_methods_spec.rb",
|
44
44
|
"spec/imouto_spec.rb",
|
45
45
|
"spec/instance_methods_spec.rb",
|
46
|
+
"spec/integration_spec.rb",
|
46
47
|
"spec/spec_helper.rb",
|
47
48
|
"spec/tsundere_spec.rb",
|
48
49
|
"test/helper.rb",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tsundere
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -145,6 +145,7 @@ files:
|
|
145
145
|
- spec/class_methods_spec.rb
|
146
146
|
- spec/imouto_spec.rb
|
147
147
|
- spec/instance_methods_spec.rb
|
148
|
+
- spec/integration_spec.rb
|
148
149
|
- spec/spec_helper.rb
|
149
150
|
- spec/tsundere_spec.rb
|
150
151
|
- test/helper.rb
|
@@ -165,7 +166,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
165
166
|
version: '0'
|
166
167
|
segments:
|
167
168
|
- 0
|
168
|
-
hash:
|
169
|
+
hash: 1709556245775294920
|
169
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
171
|
none: false
|
171
172
|
requirements:
|