eventbus 0.0.22 → 0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,4 @@
1
1
  require 'rubygems'
2
- require 'bunny'
3
2
  require 'yaml'
4
3
  require 'uuid'
5
4
  require 'eventbus/queue'
@@ -15,21 +14,21 @@ class Message
15
14
  raise "No application ID specified!" if application_id.nil?
16
15
 
17
16
  @data = {
18
- :HEADER => {
19
- :message_id => UUID.new.generate.to_s,
20
- :message_type => self.default_section_name,
21
- :status => "BEGIN",
22
- :application_id => application_id
17
+ 'HEADER' => {
18
+ 'message_id' => UUID.new.generate.to_s,
19
+ 'message_type' => self.default_section_name,
20
+ 'status' => "BEGIN",
21
+ 'application_id' => application_id
23
22
  },
24
- :ERROR_INFO => {
25
- :is_error => false,
26
- :backtrace => nil,
27
- :message => nil
23
+ 'ERROR_INFO' => {
24
+ 'is_error' => false,
25
+ 'backtrace' => nil,
26
+ 'message' => nil
28
27
  },
29
- :PAYLOAD => {}
28
+ 'PAYLOAD' => {}
30
29
  }
31
30
 
32
- @connection_driver = ENV["EVENTBUS_CONNECTOR"] || "Bunny"
31
+ @connection_driver = ENV["EVENTBUS_CONNECTOR"] || "Stomp"
33
32
 
34
33
  driver_module = "#{@connection_driver}ConnectionDriver"
35
34
 
@@ -47,18 +46,33 @@ class Message
47
46
 
48
47
  def set(key, val, opts = {})
49
48
 
49
+ # This is for convenience and to make messages more
50
+ # human-readable by eliminating the !Binary encoding
51
+ # in YAML messages. I'm not willing to make this method
52
+ # more expensive by walking deep structures to do the
53
+ # same legwork, because this isn't a functionality issue.
54
+ # The message deserializes just fine without this.
55
+ # If your YAML is popping up with random !binary segments
56
+ # in the YAML *and this bothers you*, just do
57
+ # a force_encoding("UTF-8") on the members of the structure
58
+ # as needed.
59
+ if val.is_a?(String)
60
+ val = val.dup if val.frozen? # Copy to non-frozen string.
61
+ val.force_encoding("UTF-8")
62
+ end
63
+
50
64
  raise "You must specify a key name!" if key.nil?
51
65
  section = opts.delete(:section) || self.default_section_name
52
66
 
53
- @data[:PAYLOAD][section] = {} if @data[:PAYLOAD][section].nil?
54
- @data[:PAYLOAD][section][key] = val
67
+ @data['PAYLOAD'][section.to_s] = {} if @data['PAYLOAD'][section.to_s].nil?
68
+ @data['PAYLOAD'][section.to_s][key.to_s] = val
55
69
  end
56
70
 
57
71
  def get(key, opts = {})
58
72
  raise "You must specify a key name!" if key.nil?
59
73
  section = opts.delete(:section) || self.default_section_name
60
74
 
61
- return @data[:PAYLOAD][section].nil? ? nil : @data[:PAYLOAD][section][key]
75
+ return @data['PAYLOAD'][section.to_s].nil? ? nil : @data['PAYLOAD'][section.to_s][key.to_s]
62
76
  end
63
77
 
64
78
  # opts:
@@ -89,8 +103,12 @@ class Message
89
103
  end
90
104
 
91
105
  def set_error(exception)
92
- @data[:ERROR_INFO][:backtrace] = exception.backtrace
93
- @data[:ERROR_INFO][:message] = exception.to_s
106
+
107
+ exception.backtrace.map { |frame| frame.force_encoding("UTF-8") }
108
+ exception.message.force_encoding("UTF-8")
109
+
110
+ @data['ERROR_INFO']['backtrace'] = exception.backtrace
111
+ @data['ERROR_INFO']['message'] = exception.message
94
112
  self.is_error = true
95
113
  self.status = exception.class.name
96
114
  end
@@ -163,14 +181,16 @@ class Message
163
181
 
164
182
  private
165
183
 
166
-
167
-
168
184
  def set_special(block, key, val)
169
- @data[block][key] = val
185
+ if val.is_a?(String)
186
+ val = val.dup if val.frozen? # Copy to non-frozen string.
187
+ val.force_encoding("UTF-8")
188
+ end
189
+ @data[block.to_s][key.to_s] = val
170
190
  end
171
191
 
172
192
  def get_special(block, key)
173
- return @data[block][key]
193
+ return @data[block.to_s][key.to_s]
174
194
  end
175
195
 
176
196
  end
@@ -1,4 +1,3 @@
1
- require 'bunny'
2
1
  require 'logger'
3
2
  require 'eventbus/queue'
4
3
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventbus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: '0.24'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-30 00:00:00.000000000 Z
12
+ date: 2013-03-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bunny
16
- requirement: &13397500 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *13397500
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: amqp
27
- requirement: &13396960 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *13396960
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: stomp
38
- requirement: &13396440 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0'
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *13396440
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: uuid
49
- requirement: &13396000 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,19 +69,24 @@ dependencies:
54
69
  version: '0'
55
70
  type: :runtime
56
71
  prerelease: false
57
- version_requirements: *13396000
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  description: Distributed application framework for developing event-driven automations.
59
79
  email: dev.incognito@spadea.net
60
80
  executables: []
61
81
  extensions: []
62
82
  extra_rdoc_files: []
63
83
  files:
64
- - lib/eventbus/message.rb
65
- - lib/eventbus/service.rb
66
84
  - lib/eventbus/queue.rb
67
- - lib/eventbus/connectors/stomp.rb
68
85
  - lib/eventbus/connectors/bunny.rb
86
+ - lib/eventbus/connectors/stomp.rb
69
87
  - lib/eventbus/connectors/amqp.rb
88
+ - lib/eventbus/message.rb
89
+ - lib/eventbus/service.rb
70
90
  homepage: http://spadea.net/?page_id=8
71
91
  licenses: []
72
92
  post_install_message:
@@ -87,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
107
  version: '0'
88
108
  requirements: []
89
109
  rubyforge_project:
90
- rubygems_version: 1.8.11
110
+ rubygems_version: 1.8.23
91
111
  signing_key:
92
112
  specification_version: 3
93
113
  summary: Libraries for creating EventBus services