msgpack_rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +37 -0
- data/lib/msgpack_rails.rb +9 -0
- data/lib/msgpack_rails/activesupport/core_ext/object/to_msgpack.rb +18 -0
- data/lib/msgpack_rails/activesupport/message_pack.rb +1 -0
- data/lib/msgpack_rails/activesupport/message_pack/encoding.rb +17 -0
- data/lib/msgpack_rails/version.rb +3 -0
- data/msgpack_rails.gemspec +23 -0
- data/test/msgpack/core_ext_test.rb +9 -0
- data/test/msgpack/encoding_test.rb +15 -0
- data/test/test_helper.rb +2 -0
- metadata +89 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0c6eaa9d8b98123a292747cbc66404b247220f28
|
4
|
+
data.tar.gz: ec4579fd1e49c004dab3b5e58c3958b2cecbb5ae
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 83276939225377e02cb0d7d0829fcddadca35138c830f0f6c3244da214d550d3a20a210790110c062f54c8d1900fd91e8ce0064f0b55efde29bb18c83c4a3768
|
7
|
+
data.tar.gz: 715965446491d1b3ec94b1ec4d7d96cb141b384d003a67dde4b1533b3a247fca07d6c50a9d1daff7c4f1ca27786f7d670abf81fa1ac814ce9d973aa25bd76635
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Jingwen Owen Ou
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# MsgpackRails
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'msgpack_rails'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install msgpack_rails
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
#############################################################################
|
4
|
+
#
|
5
|
+
# Helper functions
|
6
|
+
#
|
7
|
+
#############################################################################
|
8
|
+
|
9
|
+
def name
|
10
|
+
@name ||= Dir['*.gemspec'].first.split('.').first
|
11
|
+
end
|
12
|
+
|
13
|
+
#############################################################################
|
14
|
+
#
|
15
|
+
# Standard tasks
|
16
|
+
#
|
17
|
+
#############################################################################
|
18
|
+
|
19
|
+
task :default => :test
|
20
|
+
|
21
|
+
require 'rake/testtask'
|
22
|
+
Rake::TestTask.new(:test) do |test|
|
23
|
+
test.libs << 'lib' << 'test'
|
24
|
+
test.pattern = 'test/**/*_test.rb'
|
25
|
+
test.verbose = true
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "Open an irb session preloaded with this library"
|
29
|
+
task :console do
|
30
|
+
sh "irb -rubygems -r ./lib/#{name}.rb"
|
31
|
+
end
|
32
|
+
|
33
|
+
#############################################################################
|
34
|
+
#
|
35
|
+
# Custom tasks (add your own tasks here)
|
36
|
+
#
|
37
|
+
#############################################################################
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Hack to load msgpack gem first so we can overwrite its to_msgpack.
|
2
|
+
|
3
|
+
begin
|
4
|
+
require "msgpack"
|
5
|
+
rescue LoadError
|
6
|
+
end
|
7
|
+
|
8
|
+
# The msgpack gem adds a few modules to Ruby core classes containing :to_msgpack definition, overwriting
|
9
|
+
# their default behavior. That said, we need to define the basic to_msgpack method in all of them,
|
10
|
+
# otherwise they will always use to_msgpack gem implementation.
|
11
|
+
[Object, NilClass, TrueClass, FalseClass, Fixnum, Bignum, Float, String, Array, Hash, Symbol].each do |klass|
|
12
|
+
klass.class_eval do
|
13
|
+
# Dumps object in msgpack. See http://msgpack.org for more info.
|
14
|
+
def to_msgpack(options = {})
|
15
|
+
ActiveSupport::MessagePack.encode(self, options)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "msgpack_rails/activesupport/message_pack/encoding"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "active_support/json"
|
2
|
+
require "msgpack_rails/activesupport/core_ext/object/to_msgpack"
|
3
|
+
|
4
|
+
module ActiveSupport
|
5
|
+
module MessagePack
|
6
|
+
def self.encode(value, options = {})
|
7
|
+
out = options.fetch(:out, nil)
|
8
|
+
::MessagePack.pack(value.as_msgpack(options), out)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Object
|
14
|
+
def as_msgpack(options = {})
|
15
|
+
as_json(options)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'msgpack_rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "msgpack_rails"
|
8
|
+
spec.version = MsgpackRails::VERSION
|
9
|
+
spec.authors = ["Jingwen Owen Ou"]
|
10
|
+
spec.email = ["jingweno@gmail.com"]
|
11
|
+
spec.description = %q{Message Pack for Rails.}
|
12
|
+
spec.summary = %q{Run Message Pack with Rails.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "activesupport", ">= 3.0"
|
22
|
+
spec.add_runtime_dependency "msgpack"
|
23
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require_relative "../test_helper"
|
2
|
+
|
3
|
+
class TestMessagePackCoreExt < Test::Unit::TestCase
|
4
|
+
def test_to_msgpack
|
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
|
+
assert_equal MessagePack.pack(data.as_json), data.to_msgpack
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative "../test_helper"
|
2
|
+
|
3
|
+
class TestMessagePackEncoding < Test::Unit::TestCase
|
4
|
+
def test_default_encoding
|
5
|
+
[nil, true, false, 10, 123456789 ** 2, 1.0, "foo", [:foo, :bar], {:a => :b}, :a].each do |data|
|
6
|
+
assert_equal MessagePack.pack(data), ActiveSupport::MessagePack.encode(data)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_extension_encoding
|
11
|
+
[Time.now, /foo/, Date.new, DateTime.new].each do |data|
|
12
|
+
assert_equal MessagePack.pack(data.as_json), ActiveSupport::MessagePack.encode(data)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: msgpack_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jingwen Owen Ou
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: msgpack
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Message Pack for Rails.
|
42
|
+
email:
|
43
|
+
- jingweno@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/msgpack_rails.rb
|
54
|
+
- lib/msgpack_rails/activesupport/core_ext/object/to_msgpack.rb
|
55
|
+
- lib/msgpack_rails/activesupport/message_pack.rb
|
56
|
+
- lib/msgpack_rails/activesupport/message_pack/encoding.rb
|
57
|
+
- lib/msgpack_rails/version.rb
|
58
|
+
- msgpack_rails.gemspec
|
59
|
+
- test/msgpack/core_ext_test.rb
|
60
|
+
- test/msgpack/encoding_test.rb
|
61
|
+
- test/test_helper.rb
|
62
|
+
homepage: ''
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.0.3
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: Run Message Pack with Rails.
|
86
|
+
test_files:
|
87
|
+
- test/msgpack/core_ext_test.rb
|
88
|
+
- test/msgpack/encoding_test.rb
|
89
|
+
- test/test_helper.rb
|