ruby-hooks 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/{ruby/hooks.rb → ruby-hooks.rb} +2 -2
- data/lib/{ruby/hooks → ruby-hooks}/extensible.rb +5 -5
- data/lib/{ruby/hooks → ruby-hooks}/hook.rb +3 -3
- data/lib/{ruby/hooks → ruby-hooks}/instance_hooks.rb +3 -3
- data/lib/ruby-hooks/version.rb +12 -0
- data/test/example1_test.rb +3 -3
- data/test/example2_test.rb +3 -3
- data/test/{ruby/hooks → ruby-hooks}/extensible_test.rb +3 -3
- data/test/{ruby/hooks → ruby-hooks}/hook_test.rb +3 -3
- data/test/{ruby/hooks → ruby-hooks}/instance_hooks_test.rb +3 -3
- metadata +29 -15
- data/lib/ruby/hooks/version.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34102235069c4f0a18da548ae0a791374c78c048
|
4
|
+
data.tar.gz: e6ce9521271058c79eb8f1c60457eda4d730780c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01df655d5584bc2c1a1319051d0ddbe990de8ff5f2f8cf975d7417c89b81e3fd480dc038b77466eadaa159faad9981d2e517568426609bc6df35032b5854f531
|
7
|
+
data.tar.gz: 56901eaa67e91ec0d39f4a81784ecd62596476f2e797068c6b759c87d91a9fbffc0fe05801aeac6866d9ae83512ac76d4a70b621e1681e40bbf51b03844efa6c
|
@@ -4,14 +4,14 @@ Copyright 2014 Michal Papis <mpapis@gmail.com>
|
|
4
4
|
See the file LICENSE for copying permission.
|
5
5
|
=end
|
6
6
|
|
7
|
+
require "ruby-hooks/version"
|
8
|
+
|
7
9
|
# Allow extending object with plugins(modules)
|
8
|
-
module
|
10
|
+
module RubyHooks::Extensible
|
9
11
|
|
10
12
|
# handle single parameters as well as arrays of params
|
11
|
-
# @param method [Symbol]
|
12
|
-
# @param plugins [Array] call method for every element of array
|
13
|
-
# @param plugins [Object] call method for the object
|
14
|
-
# @returns :nodoc: - unperdictable
|
13
|
+
# @param method [Symbol] name of the method to call
|
14
|
+
# @param plugins [Object|Array] call method for object or every element of array
|
15
15
|
def add_plugins(method, plugins = nil)
|
16
16
|
case plugins
|
17
17
|
when Array then plugins.each { |plugin| send(method, plugin) }
|
@@ -5,12 +5,12 @@ See the file LICENSE for copying permission.
|
|
5
5
|
=end
|
6
6
|
|
7
7
|
require "observer"
|
8
|
-
require "ruby
|
8
|
+
require "ruby-hooks/extensible"
|
9
9
|
|
10
10
|
# Wrapper for Observable module
|
11
|
-
class
|
11
|
+
class RubyHooks::Hook
|
12
12
|
include Observable
|
13
|
-
include ::
|
13
|
+
include ::RubyHooks::Extensible
|
14
14
|
|
15
15
|
# automatically extends Hook instance with given modules
|
16
16
|
#
|
@@ -4,10 +4,10 @@ Copyright 2014 Michal Papis <mpapis@gmail.com>
|
|
4
4
|
See the file LICENSE for copying permission.
|
5
5
|
=end
|
6
6
|
|
7
|
-
require "ruby
|
7
|
+
require "ruby-hooks/hook"
|
8
8
|
|
9
9
|
# Helper to add multiple instance hooks
|
10
|
-
module
|
10
|
+
module RubyHooks::InstanceHooks
|
11
11
|
|
12
12
|
# define instance hook method, it gives easy acces to Hook and
|
13
13
|
# it's methods
|
@@ -21,7 +21,7 @@ module Ruby::Hooks::InstanceHooks
|
|
21
21
|
if hook = instance_variable_get(:"@#{name}")
|
22
22
|
then return hook
|
23
23
|
end
|
24
|
-
hook =
|
24
|
+
hook = RubyHooks::Hook.new(options)
|
25
25
|
instance_variable_set(:"@#{name}", hook)
|
26
26
|
hook
|
27
27
|
end
|
data/test/example1_test.rb
CHANGED
@@ -5,10 +5,10 @@ See the file LICENSE for copying permission.
|
|
5
5
|
=end
|
6
6
|
|
7
7
|
require "test_helper"
|
8
|
-
require "ruby
|
8
|
+
require "ruby-hooks"
|
9
9
|
|
10
10
|
class Test1
|
11
|
-
extend
|
11
|
+
extend RubyHooks::InstanceHooks
|
12
12
|
define_hook(:my_event_one)
|
13
13
|
end
|
14
14
|
|
@@ -26,7 +26,7 @@ class Observer2
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
describe
|
29
|
+
describe RubyHooks::Extensible do
|
30
30
|
subject do
|
31
31
|
Test1.new
|
32
32
|
end
|
data/test/example2_test.rb
CHANGED
@@ -5,7 +5,7 @@ See the file LICENSE for copying permission.
|
|
5
5
|
=end
|
6
6
|
|
7
7
|
require "test_helper"
|
8
|
-
require "ruby
|
8
|
+
require "ruby-hooks"
|
9
9
|
|
10
10
|
module FindObserver
|
11
11
|
def find_observer(*arg)
|
@@ -24,7 +24,7 @@ module FindObserver
|
|
24
24
|
end
|
25
25
|
|
26
26
|
class Test2
|
27
|
-
extend
|
27
|
+
extend RubyHooks::InstanceHooks
|
28
28
|
define_hook(:my_event_two, :extends => FindObserver)
|
29
29
|
end
|
30
30
|
|
@@ -40,7 +40,7 @@ class Observer4
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
describe
|
43
|
+
describe RubyHooks::Extensible do
|
44
44
|
subject do
|
45
45
|
Test2.new
|
46
46
|
end
|
@@ -5,10 +5,10 @@ See the file LICENSE for copying permission.
|
|
5
5
|
=end
|
6
6
|
|
7
7
|
require "test_helper"
|
8
|
-
require "ruby
|
8
|
+
require "ruby-hooks/extensible"
|
9
9
|
|
10
10
|
class ExtensibleTestClass
|
11
|
-
include
|
11
|
+
include RubyHooks::Extensible
|
12
12
|
attr_reader :calls
|
13
13
|
def initialize
|
14
14
|
@calls = []
|
@@ -28,7 +28,7 @@ class ExtensibleTestClass
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
describe
|
31
|
+
describe RubyHooks::Extensible do
|
32
32
|
subject do
|
33
33
|
ExtensibleTestClass.new
|
34
34
|
end
|
@@ -5,7 +5,7 @@ See the file LICENSE for copying permission.
|
|
5
5
|
=end
|
6
6
|
|
7
7
|
require "test_helper"
|
8
|
-
require "ruby
|
8
|
+
require "ruby-hooks/hook"
|
9
9
|
|
10
10
|
class HookTestClass
|
11
11
|
module Extra
|
@@ -20,9 +20,9 @@ class HookTestClass
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
describe
|
23
|
+
describe RubyHooks::Hook do
|
24
24
|
subject do
|
25
|
-
|
25
|
+
RubyHooks::Hook.allocate
|
26
26
|
end
|
27
27
|
|
28
28
|
it "is based on Observable" do
|
@@ -5,19 +5,19 @@ See the file LICENSE for copying permission.
|
|
5
5
|
=end
|
6
6
|
|
7
7
|
require "test_helper"
|
8
|
-
require "ruby
|
8
|
+
require "ruby-hooks/instance_hooks"
|
9
9
|
|
10
10
|
class InstanceHooksTestClass
|
11
11
|
module Extra
|
12
12
|
def method3
|
13
13
|
end
|
14
14
|
end
|
15
|
-
extend
|
15
|
+
extend RubyHooks::InstanceHooks
|
16
16
|
define_hook(:test1)
|
17
17
|
define_hook(:test2, :extends => Extra)
|
18
18
|
end
|
19
19
|
|
20
|
-
describe
|
20
|
+
describe RubyHooks::Extensible do
|
21
21
|
subject do
|
22
22
|
InstanceHooksTestClass.new
|
23
23
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-hooks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michal Papis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: yard-ruby-hooks
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rake
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,16 +59,16 @@ executables: []
|
|
45
59
|
extensions: []
|
46
60
|
extra_rdoc_files: []
|
47
61
|
files:
|
48
|
-
- lib/ruby
|
49
|
-
- lib/ruby
|
50
|
-
- lib/ruby
|
51
|
-
- lib/ruby
|
52
|
-
- lib/ruby
|
62
|
+
- lib/ruby-hooks.rb
|
63
|
+
- lib/ruby-hooks/extensible.rb
|
64
|
+
- lib/ruby-hooks/hook.rb
|
65
|
+
- lib/ruby-hooks/instance_hooks.rb
|
66
|
+
- lib/ruby-hooks/version.rb
|
53
67
|
- test/example1_test.rb
|
54
68
|
- test/example2_test.rb
|
55
|
-
- test/ruby
|
56
|
-
- test/ruby
|
57
|
-
- test/ruby
|
69
|
+
- test/ruby-hooks/extensible_test.rb
|
70
|
+
- test/ruby-hooks/hook_test.rb
|
71
|
+
- test/ruby-hooks/instance_hooks_test.rb
|
58
72
|
- test/test_helper.rb
|
59
73
|
homepage: https://github.com/remote-exec/ruby-hooks
|
60
74
|
licenses:
|
@@ -76,15 +90,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
90
|
version: '0'
|
77
91
|
requirements: []
|
78
92
|
rubyforge_project:
|
79
|
-
rubygems_version: 2.
|
93
|
+
rubygems_version: 2.2.2
|
80
94
|
signing_key:
|
81
95
|
specification_version: 4
|
82
96
|
summary: Helpers for multiple publish/subscribe hooks
|
83
97
|
test_files:
|
84
|
-
- test/ruby/hooks/extensible_test.rb
|
85
|
-
- test/ruby/hooks/instance_hooks_test.rb
|
86
|
-
- test/ruby/hooks/hook_test.rb
|
87
98
|
- test/test_helper.rb
|
88
|
-
- test/example2_test.rb
|
89
99
|
- test/example1_test.rb
|
100
|
+
- test/example2_test.rb
|
101
|
+
- test/ruby-hooks/extensible_test.rb
|
102
|
+
- test/ruby-hooks/hook_test.rb
|
103
|
+
- test/ruby-hooks/instance_hooks_test.rb
|
90
104
|
has_rdoc:
|
data/lib/ruby/hooks/version.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
Copyright 2014 Michal Papis <mpapis@gmail.com>
|
3
|
-
|
4
|
-
See the file LICENSE for copying permission.
|
5
|
-
=end
|
6
|
-
|
7
|
-
module Ruby
|
8
|
-
# Helpers for multiple publish/subscribe hooks
|
9
|
-
module Hooks
|
10
|
-
# Rubygems version of Ruby::Hooks
|
11
|
-
VERSION = "1.1.0"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|