cry 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/cry.rb +33 -0
- data/lib/cry/version.rb +3 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 708082c5a6628625229155561845b2008f316a7c
|
4
|
+
data.tar.gz: 65572d7265e5dfdfcde27399888993bee3fb5deb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 81f6d9849ae7ec577eb15ccec1e46fac3ab210c6aaba678fefcd281c65fd7f06c846bbd346ba44a18c8d640f0c66c8ece11943f741d874884eb04da602826c22
|
7
|
+
data.tar.gz: ed4efd1bad536e1bcd809ead5b391d8bc78a59a311fea9290698c92791f6ed3d085e316ad4336bd61f15f80c9696e95aed183e513ff9bc329d0a7eba1060f057
|
data/lib/cry.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require "cry/version"
|
2
|
+
|
3
|
+
module Cry
|
4
|
+
def on(*events, &block)
|
5
|
+
raise ArgumentError, "must specify at least one event" unless events.any?
|
6
|
+
events.each { |event| listeners_for(event) << block }
|
7
|
+
self
|
8
|
+
end
|
9
|
+
|
10
|
+
class NoListenersError < StandardError; end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def publish(event, *args)
|
15
|
+
listeners_for(event).each do |listener|
|
16
|
+
listener.call(*args)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def publish!(event, *args)
|
21
|
+
raise NoListenersError, "nothing listening for #{event}" \
|
22
|
+
unless listeners_for(event).any?
|
23
|
+
publish(event, *args)
|
24
|
+
end
|
25
|
+
|
26
|
+
def listeners
|
27
|
+
@listeners ||= {}
|
28
|
+
end
|
29
|
+
|
30
|
+
def listeners_for(event)
|
31
|
+
listeners[event.to_sym] ||= []
|
32
|
+
end
|
33
|
+
end
|
data/lib/cry/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cry
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Powell
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Ridiculously simple interface for subscribing to arbitrary events on
|
56
|
+
your objects and executing callbacks.
|
57
|
+
email:
|
58
|
+
- fauxparse@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- lib/cry.rb
|
64
|
+
- lib/cry/version.rb
|
65
|
+
homepage: https://github.com/fauxparse/cry
|
66
|
+
licenses:
|
67
|
+
- MIT
|
68
|
+
metadata: {}
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 2.5.1
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: Publish arbitrary events from inside any Ruby object
|
89
|
+
test_files: []
|
90
|
+
has_rdoc:
|