droonga-message-pack-packer 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/text/news.md +4 -0
- data/lib/droonga/message-pack-packer.rb +7 -1
- data/lib/droonga/message-pack-packer/geo-point-formatter.rb +35 -0
- data/lib/droonga/message-pack-packer/version.rb +1 -1
- data/test/test-geo-point-formatter.rb +41 -0
- data/test/test-packer.rb +48 -0
- metadata +19 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd0c2ea3bfe7003cddef67677e1799b60532c292
|
4
|
+
data.tar.gz: c5822a0aa546e579bcb4ce1097c968c328194a9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a17a757f7d24e53b60a8dbccf7fadc91a15d77a65bb3ca8d18948bd6ea57dd2c83f4162596dbb19e82b90528d420bf1480658881bc1e3668772bfa01c2fe0226
|
7
|
+
data.tar.gz: 95f15321681b559ac975a8017e9d638aa6606ef894d84d28e46a9e48028f2f003e6d454d41adaa5ae5706a3705f4a49719971a5c94546090ebdc01e00b1617ec
|
data/doc/text/news.md
CHANGED
@@ -16,6 +16,7 @@
|
|
16
16
|
require "msgpack"
|
17
17
|
|
18
18
|
require "droonga/message-pack-packer/time-formatter"
|
19
|
+
require "droonga/message-pack-packer/geo-point-formatter"
|
19
20
|
|
20
21
|
module Droonga
|
21
22
|
class MessagePackPacker
|
@@ -49,7 +50,12 @@ module Droonga
|
|
49
50
|
when Time
|
50
51
|
@packer.write(TimeFormatter.format(object))
|
51
52
|
else
|
52
|
-
|
53
|
+
case object.class.name
|
54
|
+
when "Groonga::WGS84GeoPoint", "Groonga::TokyoGeoPoint"
|
55
|
+
@packer.write(GeoPointFormatter.format(object))
|
56
|
+
else
|
57
|
+
@packer.write(object)
|
58
|
+
end
|
53
59
|
end
|
54
60
|
end
|
55
61
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Copyright (C) 2013-2014 Droonga Project
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License version 2.1 as published by the Free Software Foundation.
|
6
|
+
#
|
7
|
+
# This library is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
10
|
+
# Lesser General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU Lesser General Public
|
13
|
+
# License along with this library; if not, write to the Free Software
|
14
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
15
|
+
|
16
|
+
module Droonga
|
17
|
+
class MessagePackPacker
|
18
|
+
class GeoPointFormatter
|
19
|
+
class << self
|
20
|
+
def format(object)
|
21
|
+
formatter = new(object)
|
22
|
+
formatter.format
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(geo_point)
|
27
|
+
@geo_point = geo_point
|
28
|
+
end
|
29
|
+
|
30
|
+
def format
|
31
|
+
@geo_point.to_s
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# Copyright (C) 2014 Droonga Project
|
2
|
+
#
|
3
|
+
# This library is free software; you can redistribute it and/or
|
4
|
+
# modify it under the terms of the GNU Lesser General Public
|
5
|
+
# License version 2.1 as published by the Free Software Foundation.
|
6
|
+
#
|
7
|
+
# This library is distributed in the hope that it will be useful,
|
8
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
9
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
10
|
+
# Lesser General Public License for more details.
|
11
|
+
#
|
12
|
+
# You should have received a copy of the GNU Lesser General Public
|
13
|
+
# License along with this library; if not, write to the Free Software
|
14
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
15
|
+
|
16
|
+
require "droonga/message-pack-packer/geo-point-formatter"
|
17
|
+
|
18
|
+
class GeoPointFormatterTest < Test::Unit::TestCase
|
19
|
+
def test_format
|
20
|
+
geo_point_class = Class.new do
|
21
|
+
def initialize(latitude, longitude)
|
22
|
+
@latitude = latitude
|
23
|
+
@longitude = longitude
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_s
|
27
|
+
"<#{@latitude}x#{@longitude}>"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
latitude = 35.681382
|
32
|
+
longitude = 139.766084
|
33
|
+
tokyo = geo_point_class.new(latitude, longitude)
|
34
|
+
assert_equal("<#{latitude}x#{longitude}>", format(tokyo))
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
def format(geo_point)
|
39
|
+
Droonga::MessagePackPacker::GeoPointFormatter.format(geo_point)
|
40
|
+
end
|
41
|
+
end
|
data/test/test-packer.rb
CHANGED
@@ -40,6 +40,54 @@ class PackerTest < Test::Unit::TestCase
|
|
40
40
|
assert_equal(array, unpack(pack(array)))
|
41
41
|
end
|
42
42
|
|
43
|
+
def test_wgs84_geo_point
|
44
|
+
wgs84_geo_point_class = Class.new do
|
45
|
+
class << self
|
46
|
+
def name
|
47
|
+
"Groonga::WGS84GeoPoint"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def initialize(latitude, longitude)
|
52
|
+
@latitude = latitude
|
53
|
+
@longitude = longitude
|
54
|
+
end
|
55
|
+
|
56
|
+
def to_s
|
57
|
+
"<#{@latitude}x#{@longitude}>"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
latitude = 35.681382
|
62
|
+
longitude = 139.766084
|
63
|
+
tokyo = wgs84_geo_point_class.new(latitude, longitude)
|
64
|
+
assert_equal("<#{latitude}x#{longitude}>", unpack(pack(tokyo)))
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_tokyo_geo_point
|
68
|
+
tokyo_geo_point_class = Class.new do
|
69
|
+
class << self
|
70
|
+
def name
|
71
|
+
"Groonga::TokyoGeoPoint"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def initialize(latitude, longitude)
|
76
|
+
@latitude = latitude
|
77
|
+
@longitude = longitude
|
78
|
+
end
|
79
|
+
|
80
|
+
def to_s
|
81
|
+
"<#{@latitude}x#{@longitude}>"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
latitude = 35.681382
|
86
|
+
longitude = 139.766084
|
87
|
+
tokyo = tokyo_geo_point_class.new(latitude, longitude)
|
88
|
+
assert_equal("<#{latitude}x#{longitude}>", unpack(pack(tokyo)))
|
89
|
+
end
|
90
|
+
|
43
91
|
private
|
44
92
|
def pack(object)
|
45
93
|
Droonga::MessagePackPacker.pack(object)
|
metadata
CHANGED
@@ -1,83 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: droonga-message-pack-packer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Droonga Project
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: packnga
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: test-unit
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: This MessagePack packer packs time values into W3C-TDF format string
|
@@ -88,7 +88,7 @@ executables: []
|
|
88
88
|
extensions: []
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
|
-
- .gitignore
|
91
|
+
- ".gitignore"
|
92
92
|
- Gemfile
|
93
93
|
- LICENSE.txt
|
94
94
|
- README.md
|
@@ -96,9 +96,11 @@ files:
|
|
96
96
|
- doc/text/news.md
|
97
97
|
- droonga-message-pack-packer.gemspec
|
98
98
|
- lib/droonga/message-pack-packer.rb
|
99
|
+
- lib/droonga/message-pack-packer/geo-point-formatter.rb
|
99
100
|
- lib/droonga/message-pack-packer/time-formatter.rb
|
100
101
|
- lib/droonga/message-pack-packer/version.rb
|
101
102
|
- test/run-test.rb
|
103
|
+
- test/test-geo-point-formatter.rb
|
102
104
|
- test/test-packer.rb
|
103
105
|
- test/test-time-formatter.rb
|
104
106
|
homepage: https://github.com/droonga/droonga-message-pack-packer-ruby
|
@@ -111,22 +113,23 @@ require_paths:
|
|
111
113
|
- lib
|
112
114
|
required_ruby_version: !ruby/object:Gem::Requirement
|
113
115
|
requirements:
|
114
|
-
- -
|
116
|
+
- - ">="
|
115
117
|
- !ruby/object:Gem::Version
|
116
118
|
version: 1.9.3
|
117
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
120
|
requirements:
|
119
|
-
- -
|
121
|
+
- - ">="
|
120
122
|
- !ruby/object:Gem::Version
|
121
123
|
version: '0'
|
122
124
|
requirements: []
|
123
125
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.
|
126
|
+
rubygems_version: 2.2.2
|
125
127
|
signing_key:
|
126
128
|
specification_version: 4
|
127
129
|
summary: A MessagePack packer for Droonga message
|
128
130
|
test_files:
|
129
131
|
- test/run-test.rb
|
132
|
+
- test/test-geo-point-formatter.rb
|
130
133
|
- test/test-packer.rb
|
131
134
|
- test/test-time-formatter.rb
|
132
135
|
has_rdoc:
|