CallBaecker 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23c469821da170447107aafac44d805d9d3557ba
4
- data.tar.gz: 53ea3cff2b492a7f37003a757f16aad3d7d6e6f6
3
+ metadata.gz: d412a814b599236b6d93ef668dda1bcd94f44f19
4
+ data.tar.gz: 4ae56bd1805a25100cc6538984f2588ec76b7fa1
5
5
  SHA512:
6
- metadata.gz: 2532a5bfe9f972c5a1736b762466de7ff5e4899cab27d5150c9a33774c524228d88281d490557edb79317c8a5632031427ca9ea1327a52e5d7a64fbb5fd01fb3
7
- data.tar.gz: 5452eba4fee00c98e5a08a775b29eff812d6fc3aafc87671283fb0cbc8efd7db7b68d92afe6f4453e6c388471eefa9954a04a2ed8c8f37aaaa45bfe7f0f9d90c
6
+ metadata.gz: 8a1d555040dcb2a6a08a7f8eb2b1c28cefcee1a6ded030a054c26216a79f9986c626c295d8774f4dfc4202086aeb9ff5fe0b5ce3bbe2a62af4c683c99a0f84b1
7
+ data.tar.gz: 415db5b62eb411ca589864243fa3f8cfbec9a75b2131f5f171bf55dc747240eb43956f77a517a8d836421824217e8bcc102717629552ac5076c6fd7b4eff42b1
data/.gitignore CHANGED
@@ -12,4 +12,5 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
- .gem
15
+ *.gem
16
+ *.DS_store
data/CallBaecker.gemspec CHANGED
@@ -17,6 +17,6 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_development_dependency "bundler", "~> 1.7"
20
+ spec.add_development_dependency "bundler", "~> 1.6"
21
21
  spec.add_development_dependency "rake", "~> 10.0"
22
22
  end
data/lib/CallBaecker.rb CHANGED
@@ -8,35 +8,69 @@ module CallBaecker
8
8
  module ClassMethods
9
9
  def method_added(name)
10
10
  return if @__last_methods_added && @__last_methods_added.include?(name)
11
+
12
+ # setup
13
+ # TODO make it pluggable
14
+ # it shouldnt be limited to rubisierung
15
+ has_before_hook = instance_variables.include? :@__setup_instance_method
16
+ if has_before_hook
17
+ params = @__setup_instance_method.call(self, name)
18
+ end
19
+
11
20
  with = :"#{name}_with_before_each_method"
12
21
  without = :"#{name}_without_before_each_method"
13
22
  @__last_methods_added = [name, with, without]
23
+ _self = self
14
24
  define_method with do |*args, &block|
15
25
  @__last_args = *args
16
26
  catch :CallBaeckerDone do
27
+ # before hook
28
+ # TODO make it pluggable
29
+ # it shouldnt be limited to rubisierung
30
+ if has_before_hook
31
+ *args = _self.instance_variable_get(:@__before_hook).call(params, args[0])
32
+ end
17
33
  send without, *args, &block
18
34
  end
19
35
  end
36
+ # teardow
20
37
  alias_method without, name
21
38
  alias_method name, with
22
39
  @__last_methods_added = nil
23
40
  end
24
41
 
42
+
25
43
  def singleton_method_added(name)
26
44
  return if @__last_methods_added && @__last_methods_added.include?(name)
45
+
46
+ # setup
47
+ # TODO make it pluggable
48
+ # it shouldnt be limited to rubisierung
49
+ has_before_hook = instance_variables.include? :@__setup_class_method
50
+ if has_before_hook
51
+ params = @__setup_class_method.call(self, name)
52
+ end
53
+
27
54
  with = :"#{name}_with_before_each_method"
28
55
  without = :"#{name}_without_before_each_method"
29
56
  @__last_methods_added = [name, with, without]
30
-
31
57
  define_singleton_method with do |*args, &block|
32
58
  @__last_args = *args
33
59
  catch :CallBaeckerDone do
60
+ # before hook
61
+ # TODO make it pluggable
62
+ # it shouldnt be limited to rubisierung
63
+ if has_before_hook
64
+ *args = @__before_hook.call(params, args[0])
65
+ end
34
66
  send without, *args, &block
35
67
  end
36
68
  end
69
+ # TODO teardown
37
70
  singleton_class.send(:alias_method, without, name.to_sym)
38
71
  singleton_class.send(:alias_method, name.to_sym, with)
39
72
  @__last_methods_added = nil
40
73
  end
41
74
  end
42
75
  end
76
+
@@ -1,3 +1,3 @@
1
1
  module CallBaecker
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: CallBaecker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - doodzik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-25 00:00:00.000000000 Z
11
+ date: 2014-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.7'
19
+ version: '1.6'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.7'
26
+ version: '1.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement