bushido_stub 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/bushido.rb +29 -1
  2. metadata +21 -6
@@ -3,7 +3,7 @@ require 'ostruct'
3
3
 
4
4
  module Bushido
5
5
 
6
- mattr_accessor :domains, :subdomain, :last_command_successful, :claimed, :last_event
6
+ mattr_accessor :domains, :subdomain, :last_command_successful, :claimed, :last_event, :events
7
7
 
8
8
  def self.set_env(options = {})
9
9
  options = {
@@ -15,6 +15,13 @@ module Bushido
15
15
  :category => 'user',
16
16
  :name => 'create',
17
17
  :data => { 'email' => 'san_francisco@bushi.do', 'id' => 4242 }
18
+ },
19
+ :events => {
20
+ 'app.claimed' => {
21
+ 'data' => {
22
+ 'email' => 'san_francisco@bushi.do'
23
+ }
24
+ }
18
25
  }
19
26
  }.merge(options)
20
27
 
@@ -27,6 +34,8 @@ module Bushido
27
34
 
28
35
  @@last_event = OpenStruct.new(options.delete(:last_event))
29
36
 
37
+ @@events = options.delete(:events)
38
+
30
39
  options.each { |k, v| ENV[k] = v }
31
40
  end
32
41
 
@@ -70,4 +79,23 @@ module Bushido
70
79
 
71
80
  end
72
81
 
82
+ module Data
83
+
84
+ attr_accessor :registered_events
85
+
86
+ def self.listen(name, &block)
87
+ @@registered_events ||= {}
88
+ @@registered_events[name] = block
89
+ end
90
+
91
+ def self.call(name)
92
+ event = @@registered_events[name]
93
+
94
+ raise "Unregistered event: #{name}" if event.nil?
95
+
96
+ event.call(::Bushido.events[name])
97
+ end
98
+
99
+ end
100
+
73
101
  end
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bushido_stub
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 25
4
5
  prerelease:
5
- version: 0.0.2
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 3
10
+ version: 0.0.3
6
11
  platform: ruby
7
12
  authors:
8
13
  - Didier Lafforgue
@@ -14,15 +19,20 @@ date: 2011-05-26 00:00:00 Z
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: activesupport
17
- requirement: &id001 !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ type: :runtime
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
18
25
  none: false
19
26
  requirements:
20
27
  - - ">="
21
28
  - !ruby/object:Gem::Version
29
+ hash: 9
30
+ segments:
31
+ - 3
32
+ - 0
33
+ - 7
22
34
  version: 3.0.7
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: *id001
35
+ requirement: *id001
26
36
  description: Best tool ever for Bushido developers
27
37
  email: didier@nocoffee.fr
28
38
  executables: []
@@ -50,7 +60,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
50
60
  requirements:
51
61
  - - ">="
52
62
  - !ruby/object:Gem::Version
53
- hash: -3874642435453488185
63
+ hash: 3
54
64
  segments:
55
65
  - 0
56
66
  version: "0"
@@ -59,6 +69,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
69
  requirements:
60
70
  - - ">="
61
71
  - !ruby/object:Gem::Version
72
+ hash: 23
73
+ segments:
74
+ - 1
75
+ - 3
76
+ - 6
62
77
  version: 1.3.6
63
78
  requirements: []
64
79