bubot 0.0.3 → 0.0.4
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 +4 -4
- data/lib/bubot.rb +3 -3
- data/lib/bubot/version.rb +1 -1
- data/spec/bubot_spec.rb +28 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2792c17eeb56bb85d6a9ffc698ea25c1acb172c9
|
|
4
|
+
data.tar.gz: dce40cadc2776cc88e1907ff8a820e9a1ef2e18a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a1db04150dfc77b525944a7d7beb2fa07bf0f398faa31a1de58706d77ed91b0a10574b09f2b2bcba06598cda6d5e3d00b3e8ba1ab484e744333681cdf1ee21fb
|
|
7
|
+
data.tar.gz: 9cdb05235e2e6350b873f159150f2301a17f0befae3187a5697cf56b23beb4e44bbca2c5466be95b0a8c49809c970eba6d203660b1c3f46fb1615347c3905565
|
data/lib/bubot.rb
CHANGED
|
@@ -5,11 +5,11 @@ module Bubot
|
|
|
5
5
|
def watch(method_name, timeout=0)
|
|
6
6
|
define_method("#{method_name}_with_feature") do
|
|
7
7
|
start_time = Time.now
|
|
8
|
-
|
|
8
|
+
method_return_value = send("#{method_name}_without_feature".to_sym)
|
|
9
9
|
if (total_time = Time.now - start_time) > timeout
|
|
10
|
-
yield(self, total_time)
|
|
10
|
+
yield(self, total_time, method_return_value)
|
|
11
11
|
end
|
|
12
|
-
|
|
12
|
+
method_return_value
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
alias_method_chain_or_register(method_name)
|
data/lib/bubot/version.rb
CHANGED
data/spec/bubot_spec.rb
CHANGED
|
@@ -129,6 +129,34 @@ describe Bubot do
|
|
|
129
129
|
|
|
130
130
|
bubot_observed.pass_time
|
|
131
131
|
end
|
|
132
|
+
|
|
133
|
+
it "passes the returned value form the watched method" do
|
|
134
|
+
class RecievesReturnValueStrategy
|
|
135
|
+
def self.execute(instance, time, original_value)
|
|
136
|
+
# do stuff
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
class PassesReturnValue
|
|
141
|
+
extend Bubot
|
|
142
|
+
watch(:pass_return_value, 0.001) do |instance, time, return_value|
|
|
143
|
+
RecievesReturnValueStrategy.execute(instance, time, return_value)
|
|
144
|
+
end
|
|
145
|
+
def pass_return_value
|
|
146
|
+
sleep 0.002
|
|
147
|
+
"return_value"
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
bubot_observed = PassesReturnValue.new
|
|
152
|
+
RecievesReturnValueStrategy.should_receive(:execute) do |instance, time, return_value|
|
|
153
|
+
expect(time).to be > 0.002
|
|
154
|
+
expect(instance).to be(bubot_observed)
|
|
155
|
+
expect(return_value).to eq("return_value")
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
bubot_observed.pass_return_value
|
|
159
|
+
end
|
|
132
160
|
end
|
|
133
161
|
end
|
|
134
162
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bubot
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Micah Cooper
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-08-
|
|
12
|
+
date: 2013-08-23 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bundler
|