super-poller 0.3.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/lib/super_poller/starling_queue.rb +14 -5
- data/test/starling_queue_test.rb +11 -0
- metadata +9 -4
data/Rakefile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require "rubygems"
|
2
|
-
require "
|
2
|
+
require "rubygems/package_task"
|
3
3
|
|
4
4
|
task :default => :test
|
5
5
|
|
@@ -10,4 +10,4 @@ Rake::TestTask.new do |t|
|
|
10
10
|
t.verbose = true
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
Gem::PackageTask.new(eval(File.read('super-poller.gemspec'))){ }
|
@@ -42,12 +42,21 @@ class SuperPoller::StarlingQueue
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
|
45
|
+
if "".respond_to? :force_encoding
|
46
|
+
def fix_encoding(v)
|
47
|
+
v.force_encoding('UTF-8')
|
48
|
+
end
|
49
|
+
else
|
50
|
+
def fix_encoding(v)
|
51
|
+
v
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
46
55
|
def coerce(message)
|
47
|
-
|
48
|
-
MultiJson.
|
49
|
-
else
|
50
|
-
Marshal.load(message)
|
56
|
+
unless message.start_with?('{')
|
57
|
+
message = MultiJson.dump(Marshal.load(message))
|
51
58
|
end
|
59
|
+
message = fix_encoding(message)
|
60
|
+
MultiJson.decode(message)
|
52
61
|
end
|
53
62
|
end
|
data/test/starling_queue_test.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: UTF-8
|
1
2
|
require File.join(File.dirname(__FILE__), "test_helper")
|
2
3
|
|
3
4
|
class StarlingQueueTest < Test::Unit::TestCase
|
@@ -41,6 +42,16 @@ class StarlingQueueTest < Test::Unit::TestCase
|
|
41
42
|
assert queue.empty?
|
42
43
|
end
|
43
44
|
|
45
|
+
if ''.respond_to? :encoding
|
46
|
+
should 'force encoding to UTF8' do
|
47
|
+
instance = StarlingQueue.allocate
|
48
|
+
ascii_string = Marshal.dump({"a" => "\xC3\xA3".force_encoding('ascii')})
|
49
|
+
object = instance.coerce(ascii_string)
|
50
|
+
|
51
|
+
assert_equal "ã", object["a"]
|
52
|
+
assert_equal Encoding.find('utf-8'), object["a"].encoding
|
53
|
+
end
|
54
|
+
end
|
44
55
|
end
|
45
56
|
|
46
57
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: super-poller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ date: 2012-05-23 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|
17
|
-
requirement:
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,7 +22,12 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements:
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
26
31
|
description: Small modular library for dealing with queues and pollers.
|
27
32
|
email: contrib@tomlea.co.uk
|
28
33
|
executables:
|
@@ -82,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
87
|
version: '0'
|
83
88
|
requirements: []
|
84
89
|
rubyforge_project:
|
85
|
-
rubygems_version: 1.8.
|
90
|
+
rubygems_version: 1.8.23
|
86
91
|
signing_key:
|
87
92
|
specification_version: 3
|
88
93
|
summary: Tools for dealing with queues.
|