smack 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/smack.rb +1 -1
- data/smack.gemspec +1 -1
- data/test/smack_test.rb +5 -5
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.0
|
data/lib/smack.rb
CHANGED
@@ -3,7 +3,7 @@ module Smack
|
|
3
3
|
def smack_inject(substitutions)
|
4
4
|
(class << self; self; end).instance_eval { @smack_subs = (@smack_subs || {}).merge!(substitutions) }
|
5
5
|
end
|
6
|
-
def
|
6
|
+
def smack_score(klass_or_mod)
|
7
7
|
[self, *(class << self; self; end).ancestors].any? { |mod| (found_mod = mod.smack_fetch(klass_or_mod)) ? (break(found_mod)) : nil } || klass_or_mod
|
8
8
|
end
|
9
9
|
def smack_fetch(klass_or_mod)
|
data/smack.gemspec
CHANGED
data/test/smack_test.rb
CHANGED
@@ -3,7 +3,7 @@ Smack.up
|
|
3
3
|
|
4
4
|
class Useless
|
5
5
|
def write_a_song
|
6
|
-
|
6
|
+
smack_score(Junkie).new.write_a_song
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
@@ -49,7 +49,7 @@ module BandManager
|
|
49
49
|
smack_inject Junkie => LayneStaley
|
50
50
|
|
51
51
|
def get_a_song
|
52
|
-
|
52
|
+
smack_score(Junkie).new.write_a_song
|
53
53
|
end
|
54
54
|
|
55
55
|
end
|
@@ -64,11 +64,11 @@ module CreativeConglomerate
|
|
64
64
|
smack_inject Band => AliceInChains
|
65
65
|
|
66
66
|
def get_a_band
|
67
|
-
|
67
|
+
smack_score(Band).new
|
68
68
|
end
|
69
69
|
|
70
70
|
def sell_a_song
|
71
|
-
"BUY BUY BUY " +
|
71
|
+
"BUY BUY BUY " + smack_score(Junkie).new.write_a_song
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -181,7 +181,7 @@ context "Smack" do
|
|
181
181
|
Useless.new
|
182
182
|
end
|
183
183
|
|
184
|
-
should "just return the value given to
|
184
|
+
should "just return the value given to smack_score" do
|
185
185
|
topic.write_a_song
|
186
186
|
end.equals("i'm a regular junkie, not a talented one")
|
187
187
|
end # a class with no substitutions
|