orator 0.6.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MGQ3YzIzN2RmM2EwZWZlMzk2MzAwODY5MTRjYmY3YTc2MjBhODJiNw==
5
+ data.tar.gz: !binary |-
6
+ ZjkxY2VkZTBmMTU1NmIyMDA0ZmFkYzRkZjFmNTBlODNhNWJjZjk2MA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NjFkYWVmMDBkYTM3OTA2NjI2MDQ0YjNlY2RhMGZiZDRhODFhMDI2NjZhODkz
10
+ ZTgzYmE0YzI5OTk3NDBjYzUyNWEwNTQzNzc5ZjIzMWI1MDFkN2Y3ZmNmMmNk
11
+ NWVmMzU4MzcwNTg1ODM2YzQ1Yzc3NGFjMTBjYWEyYzhmYzJkZDQ=
12
+ data.tar.gz: !binary |-
13
+ ZWMyZjE2NTM5N2Q2ZTE2MzE3NDY4NWIwMWMyZmE1ZjdhMGNiMDEyZGJiYWU5
14
+ MjRhYjgxZjJkMWNkZTMxNDRmNTkyMjI5ZWY1ZmFkYjg1ZGFjMjU2NmJmOTQx
15
+ ZTEyOGQ5Y2JlMzdlNGRmZDIwNjY5MmZjMTk5MjM2MTlmYmM3Yzk=
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Orator [![Code Climate](https://codeclimate.com/github/redjazz96/orator.png)](https://codeclimate.com/github/redjazz96/orator) [![Build Status](https://travis-ci.org/redjazz96/orator.png?branch=master)](https://travis-ci.org/redjazz96/orator)
1
+ # Orator [![Code Climate](https://codeclimate.com/github/redjazz96/orator.png)](https://codeclimate.com/github/redjazz96/orator) [![Build Status](https://travis-ci.org/redjazz96/orator.png?branch=master)](https://travis-ci.org/redjazz96/orator) [![Gem Version](https://badge.fury.io/rb/orator.png)](http://badge.fury.io/rb/orator)
2
2
 
3
3
  Orator is a websocket client/server combination that uses events in order to
4
4
  talk to each other. It is still early in its development.
@@ -150,10 +150,15 @@ module Orator
150
150
  # @param event [Symbol] the event to register it to.
151
151
  # @return [void]
152
152
  def on(event, method = nil, &block)
153
+ if event.is_a? Hash
154
+ method = event.values.first
155
+ event = event.keys.first
156
+ end
157
+
153
158
  event_list[event.to_s] ||= []
154
-
159
+
155
160
  if block_given?
156
- event_list[event.to_s] << block
161
+ event_list[event.to_s] << block
157
162
  else
158
163
  event_list[event.to_s] << (method || event).to_sym
159
164
  end
@@ -51,14 +51,18 @@ module Orator
51
51
  # @return [Object, nil]
52
52
  def trigger(event, context, *args)
53
53
  puts "Running event #{event}..." if Orator.debug
54
- if events(event).map do |event|
54
+ matching_events = events(event)
55
+
56
+ if matching_events.length == 0
57
+ puts "Could not find event, running socket.missing..." if Orator.debug
58
+ matching_events = events('socket.missing')
59
+ end
60
+
61
+ matching_events.map do |event|
55
62
  puts "Found responder #{event[:block] || event[:class]}" if Orator.debug
56
63
 
57
64
  run_event(event, context, args)
58
65
  if event[:count] then event[:count] -= 1 end
59
- end.length == 0
60
- puts "could not find event, running socket.missing..." if Orator.debug
61
- events('socket.missing').map { |e| run_event(e, context, args) }
62
66
  end
63
67
 
64
68
  clear_events
@@ -1,5 +1,5 @@
1
1
  module Orator
2
2
 
3
3
  # Version of Orator.
4
- VERSION = '0.6.1'
4
+ VERSION = '0.7.2'
5
5
  end
@@ -106,4 +106,17 @@ describe Orator::Base do
106
106
  subklass.after_list.length.should be 1
107
107
  subklass.after_list.should eql(klass.after_list)
108
108
  end
109
+
110
+ it "should handle hash syntax" do
111
+ klass = Class.new(described_class) do
112
+ orator_name 'test'
113
+
114
+ on('some.event' => :some_thing)
115
+ def some_thing
116
+
117
+ end
118
+ end
119
+
120
+ klass.event_list['some.event'].should eq([:some_thing])
121
+ end
109
122
  end
@@ -59,4 +59,20 @@ describe Orator::EventHandler do
59
59
  subject.events.length.should be 3
60
60
  subject.events(:some_event).length.should be 2
61
61
  end
62
+
63
+ it "should call socket.missing on an empty event" do
64
+ something = double('something')
65
+ something.should_receive(:to_call)
66
+ subject.on('socket.missing') { something.to_call }
67
+ subject.trigger('some.event', self)
68
+ end
69
+
70
+ it "should not call socket.missing on an event" do
71
+ something = double('something')
72
+ something.should_not_receive(:to_call)
73
+ something.should_receive(:should_call)
74
+ subject.on('socket.missing') { something.to_call }
75
+ subject.on('some.event') { something.should_call }
76
+ subject.trigger('some.event', self)
77
+ end
62
78
  end
@@ -0,0 +1,18 @@
1
+ describe Orator::OpenStruct do
2
+ it "should provide a duplicate of the table" do
3
+ subject.table.should_not be subject.instance_variable_get(:@table)
4
+ end
5
+
6
+ it "should provide the value assigned" do
7
+ subject.some_value = 42
8
+ subject[:some_value].should be 42
9
+
10
+ subject[:other_value] = 120
11
+ subject.other_value.should be 120
12
+ end
13
+
14
+ it "should be able to provide a method" do
15
+ subject.some_value = 42
16
+ subject.method(:some_value).should be_kind_of Method
17
+ end
18
+ end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
5
- prerelease:
4
+ version: 0.7.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jeremy Rodi
@@ -14,7 +13,6 @@ dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: em-websocket
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: oj
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: swf_fu
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -84,65 +75,67 @@ executables:
84
75
  extensions: []
85
76
  extra_rdoc_files: []
86
77
  files:
87
- - lib/tasks/orator.rake
88
- - lib/orator.rb
89
- - lib/orator/engine.rb
90
- - lib/orator/server.rb
91
- - lib/orator/base.rb
92
78
  - lib/orator/middle_ground.rb
93
- - lib/orator/event_handler.rb
94
- - lib/orator/open_struct.rb
95
79
  - lib/orator/version.rb
80
+ - lib/orator/server.rb
96
81
  - lib/orator/cli.rb
97
82
  - lib/orator/client.rb
98
- - lib/generators/templates/template_orator.rb
83
+ - lib/orator/open_struct.rb
84
+ - lib/orator/engine.rb
85
+ - lib/orator/base.rb
86
+ - lib/orator/event_handler.rb
87
+ - lib/generators/orator/orator_generator.rb
88
+ - lib/generators/orator/config_generator.rb
99
89
  - lib/generators/templates/config.yml
100
90
  - lib/generators/templates/orators/example_orator.rb
101
91
  - lib/generators/templates/orators/application_orator.rb
102
- - lib/generators/orator/config_generator.rb
103
- - lib/generators/orator/orator_generator.rb
92
+ - lib/generators/templates/template_orator.rb
93
+ - lib/orator.rb
94
+ - lib/tasks/orator.rake
104
95
  - bin/orator
105
- - spec/event_handler_spec.rb
106
- - spec/middle_ground_spec.rb
107
96
  - spec/client_spec.rb
108
- - spec/base_orator_spec.rb
109
97
  - spec/spec_helper.rb
110
- - vendor/assets/swfs/WebSocketMain.swf
111
- - vendor/assets/javascripts/orator.coffee
112
- - vendor/assets/javascripts/orator/web_socket.js
113
- - vendor/assets/javascripts/orator/stringify.jquery.js
114
- - vendor/assets/javascripts/orator/header.coffee
115
- - vendor/assets/javascripts/orator/event_handler.coffee
116
- - vendor/assets/javascripts/orator/chat_logger.coffee
98
+ - spec/middle_ground_spec.rb
99
+ - spec/base_orator_spec.rb
100
+ - spec/open_struct_spec.rb
101
+ - spec/event_handler_spec.rb
102
+ - vendor/assets/javascripts/orator/middle_ground.coffee
117
103
  - vendor/assets/javascripts/orator/swfobject.js
118
104
  - vendor/assets/javascripts/orator/command_handler.coffee
105
+ - vendor/assets/javascripts/orator/event_handler.coffee
106
+ - vendor/assets/javascripts/orator/chat_logger.coffee
107
+ - vendor/assets/javascripts/orator/web_socket.js
119
108
  - vendor/assets/javascripts/orator/strbuf.coffee
120
- - vendor/assets/javascripts/orator/middle_ground.coffee
109
+ - vendor/assets/javascripts/orator/stringify.jquery.js
110
+ - vendor/assets/javascripts/orator/header.coffee
111
+ - vendor/assets/javascripts/orator.coffee
112
+ - vendor/assets/swfs/WebSocketMain.swf
121
113
  - README.md
122
114
  - Rakefile
123
115
  - LICENSE
124
116
  homepage: http://github.com/redjazz96/orator
125
- licenses: []
117
+ licenses:
118
+ - MIT
119
+ metadata: {}
126
120
  post_install_message:
127
121
  rdoc_options: []
128
122
  require_paths:
129
123
  - lib
130
124
  required_ruby_version: !ruby/object:Gem::Requirement
131
- none: false
132
125
  requirements:
133
126
  - - ! '>='
134
127
  - !ruby/object:Gem::Version
135
128
  version: '0'
136
129
  required_rubygems_version: !ruby/object:Gem::Requirement
137
- none: false
138
130
  requirements:
139
131
  - - ! '>='
140
132
  - !ruby/object:Gem::Version
141
133
  version: '0'
142
134
  requirements: []
143
135
  rubyforge_project:
144
- rubygems_version: 1.8.24
136
+ rubygems_version: 2.0.2
145
137
  signing_key:
146
- specification_version: 3
138
+ specification_version: 4
147
139
  summary: Magic for your browser.
148
140
  test_files: []
141
+ has_rdoc: false