msgpack_rails 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Gemfile +0 -4
- data/README.md +6 -6
- data/lib/msgpack_rails.rb +18 -1
- data/lib/msgpack_rails/version.rb +1 -1
- data/msgpack_rails.gemspec +4 -0
- data/test/msgpack_rails/core_ext_test.rb +1 -1
- data/test/msgpack_rails/decoding_test.rb +1 -1
- data/test/msgpack_rails/encoding_test.rb +1 -1
- data/test/msgpack_rails/serializer_test.rb +1 -1
- data/test/test_helper.rb +1 -1
- metadata +53 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa953ad7bf6c8b84380f987b05e4314b4262157d
|
4
|
+
data.tar.gz: a9fb9126633b10bd5b772a554d03180e3178e037
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5279ae7c6457130feb4cfe62debe47be00a2bff2ebff84f227351474edb2e3e73ffc5d598f9a27144cc7b971189592735aebb55bb22dd165fd3aed0c2c40c78
|
7
|
+
data.tar.gz: 1d2ed627a79283a094d1d5fa83f9f78a6c5240e126c038c9e38ad96a466318ae8d4e363d237379b85e39d893e1d6c7a90b79e10670ea3bbee7056140ea9b0a50
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
# msgpack_rails
|
1
|
+
# MessagePack for Rails [![Build Status](https://travis-ci.org/jingweno/msgpack_rails.png?branch=master)](https://travis-ci.org/jingweno/msgpack_rails)
|
2
2
|
|
3
|
-
The Rails way to serialize/deserialize with [Message Pack](http://msgpack.org).
|
4
|
-
It implements
|
3
|
+
The Rails way to serialize/deserialize objects with [Message Pack](http://msgpack.org).
|
4
|
+
It implements the [ActiveSupport](http://rubygems.org/gems/activesupport) [encoder](https://github.com/jingweno/msgpack_rails/blob/master/lib/msgpack_rails/activesupport/message_pack/encoding.rb) & [decoder](https://github.com/jingweno/msgpack_rails/blob/master/lib/msgpack_rails/activesupport/message_pack/decoding.rb) and the [ActiveModel](http://rubygems.org/gems/activemodel) [serializer](https://github.com/jingweno/msgpack_rails/blob/master/lib/msgpack_rails/activemodel/serializers/message_pack.rb) for Message Pack.
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
|
@@ -41,7 +41,7 @@ Here are a few examples:
|
|
41
41
|
$ ActiveSupport::MessagePack.decode Time.now.to_msgpack
|
42
42
|
=> Wed, 11 Sep 2013 11:25:18 -0700
|
43
43
|
|
44
|
-
You can also use it as part of `ActiveModel`:
|
44
|
+
You can also use it as part of `ActiveModel`, similar to `to_json`:
|
45
45
|
|
46
46
|
```ruby
|
47
47
|
class Contact
|
@@ -51,8 +51,8 @@ class Contact
|
|
51
51
|
end
|
52
52
|
|
53
53
|
@contact = Contact.new
|
54
|
-
@contact.name = '
|
55
|
-
@contact.age =
|
54
|
+
@contact.name = 'Owen Ou'
|
55
|
+
@contact.age = 28
|
56
56
|
@contact.created_at = Time.utc(2006, 8, 1)
|
57
57
|
@contact.awesome = true
|
58
58
|
@contact.preferences = { 'shows' => 'anime' }
|
data/lib/msgpack_rails.rb
CHANGED
@@ -24,7 +24,24 @@ if defined?(::Rails)
|
|
24
24
|
module MsgpackRails
|
25
25
|
class Rails < ::Rails::Engine
|
26
26
|
initializer "msgpack_rails" do
|
27
|
-
::ActiveRecord::Base
|
27
|
+
if defined?(::ActiveRecord::Base)
|
28
|
+
::ActiveSupport.on_load(:active_record) do
|
29
|
+
::ActiveRecord::Base.send(:include, ActiveModel::Serializers::MessagePack)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
if defined?(::Mongoid::Document)
|
34
|
+
::ActiveSupport.on_load(:mongoid) do
|
35
|
+
::Mongoid::Document.send(:include, ActiveModel::Serializers::MessagePack)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
::Mime::Type.register "application/msgpack", :msgpack
|
40
|
+
|
41
|
+
::ActionController.add_renderer :msgpack do |data, options|
|
42
|
+
self.content_type = Mime::MSGPACK
|
43
|
+
self.response_body = data.as_msgpack(options)
|
44
|
+
end
|
28
45
|
end
|
29
46
|
end
|
30
47
|
end
|
data/msgpack_rails.gemspec
CHANGED
@@ -24,4 +24,8 @@ Gem::Specification.new do |spec|
|
|
24
24
|
else
|
25
25
|
spec.add_runtime_dependency "msgpack"
|
26
26
|
end
|
27
|
+
|
28
|
+
spec.add_development_dependency "rake", "~> 10.3.1"
|
29
|
+
spec.add_development_dependency "minitest", "~> 5.3.3"
|
30
|
+
spec.add_development_dependency "activemodel", "~> 4.1.0"
|
27
31
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative "../test_helper"
|
2
2
|
|
3
|
-
class TestMessagePackCoreExt < Test
|
3
|
+
class TestMessagePackCoreExt < Minitest::Test
|
4
4
|
def test_to_msgpack
|
5
5
|
[nil, true, false, 10, 123456789 ** 2, 1.0, "foo", [:foo, :bar], {:a => :b}, :a, Time.now, /foo/, Date.new, DateTime.new].each do |data|
|
6
6
|
assert_equal MessagePack.pack(data.as_json), data.to_msgpack
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative "../test_helper"
|
2
2
|
|
3
|
-
class TestMessagePackEncoding < Test
|
3
|
+
class TestMessagePackEncoding < Minitest::Test
|
4
4
|
def test_decoding
|
5
5
|
[Time.now, [Date.new], {:foo => DateTime.new}].each do |data|
|
6
6
|
assert_equal data.as_json, ActiveSupport::MessagePack.decode(ActiveSupport::MessagePack.encode(data))
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative "../test_helper"
|
2
2
|
|
3
|
-
class TestMessagePackEncoding < Test
|
3
|
+
class TestMessagePackEncoding < Minitest::Test
|
4
4
|
def test_default_encoding
|
5
5
|
[nil, true, false, 10, 123456789 ** 2, 1.0, "foo", [:foo, :bar], {:a => :b}, :a].each do |data|
|
6
6
|
assert_equal MessagePack.pack(data), ActiveSupport::MessagePack.encode(data)
|
data/test/test_helper.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require "
|
1
|
+
require "minitest/autorun"
|
2
2
|
require_relative "../lib/msgpack_rails"
|
metadata
CHANGED
@@ -1,43 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: msgpack_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jingwen Owen Ou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.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: '3.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: msgpack
|
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: :runtime
|
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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 10.3.1
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 10.3.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 5.3.3
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 5.3.3
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activemodel
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 4.1.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 4.1.0
|
41
83
|
description: Message Pack for Rails.
|
42
84
|
email:
|
43
85
|
- jingweno@gmail.com
|
@@ -45,8 +87,8 @@ executables: []
|
|
45
87
|
extensions: []
|
46
88
|
extra_rdoc_files: []
|
47
89
|
files:
|
48
|
-
- .gitignore
|
49
|
-
- .travis.yml
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
50
92
|
- Gemfile
|
51
93
|
- LICENSE.txt
|
52
94
|
- README.md
|
@@ -75,17 +117,17 @@ require_paths:
|
|
75
117
|
- lib
|
76
118
|
required_ruby_version: !ruby/object:Gem::Requirement
|
77
119
|
requirements:
|
78
|
-
- -
|
120
|
+
- - ">="
|
79
121
|
- !ruby/object:Gem::Version
|
80
122
|
version: '0'
|
81
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
124
|
requirements:
|
83
|
-
- -
|
125
|
+
- - ">="
|
84
126
|
- !ruby/object:Gem::Version
|
85
127
|
version: '0'
|
86
128
|
requirements: []
|
87
129
|
rubyforge_project:
|
88
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.2.2
|
89
131
|
signing_key:
|
90
132
|
specification_version: 4
|
91
133
|
summary: The Rails way to serialize/deserialize with Message Pack.
|