msgpack_rails 0.4.2 → 0.4.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f2f1d29060724de7628414010d1ae64726a42031
4
- data.tar.gz: 9af97cd66af6a9ac3b066cfe8a7de5f0cf0dd1d1
2
+ SHA256:
3
+ metadata.gz: 00efa0feb39b9beea82cbace5192b43bb070f84e90507ed35b4bf36babcd6ef0
4
+ data.tar.gz: c25775d97ea9901a21ade994fe080b564ab9198d5b6c85570b5e0d705300aad4
5
5
  SHA512:
6
- metadata.gz: 9a915f09a781a4148b62a79b3082006a8171accb70e95e449c907acea061e59472000fcffaf2297accd4f0622c92a6444e5b164d9e840b18372830ce909a71ea
7
- data.tar.gz: 55241e38fe2ecf105a6dfdb4148542d64575bb9f74262dcae03f274c1e237bcc8b774eaf553b19ceebdd79fba2674caa43859876e05d81a21a8127007c8a94ee
6
+ metadata.gz: e790c4b03853ee64aae3496efbe93b1974cabcbd866747ee7a6df498e72743eba0ce5512edbf67dba2e0ce7594fa2738521e01ce0c1c725cd0e31e1fad9aeac8
7
+ data.tar.gz: 4d280dd65409fec590baae67e0561d7688d844b20cba9c3b7075dc29d309a23dad37280a61aee7bc53f85e8a4cec8c4d888246484ef12f59da1b0c8d63063c57
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ gemfiles/*.lock
@@ -3,3 +3,51 @@ rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
5
  - 2.1.0
6
+ - 2.2.2
7
+ - 2.3.0
8
+ - 2.4.1
9
+ - 2.5.0
10
+ gemfile:
11
+ - gemfiles/rails_41.gemfile
12
+ - gemfiles/rails_42.gemfile
13
+ - gemfiles/rails_50.gemfile
14
+ - gemfiles/rails_51.gemfile
15
+ - gemfiles/rails_52.gemfile
16
+ - gemfiles/rails_edge.gemfile
17
+ matrix:
18
+ exclude:
19
+ # Rails 5.0+ requires CRuby 2.2.2+
20
+ - rvm: 1.9.3
21
+ gemfile: gemfiles/rails_50.gemfile
22
+ - rvm: 1.9.3
23
+ gemfile: gemfiles/rails_51.gemfile
24
+ - rvm: 1.9.3
25
+ gemfile: gemfiles/rails_52.gemfile
26
+ - rvm: 1.9.3
27
+ gemfile: gemfiles/rails_edge.gemfile
28
+ - rvm: 2.0.0
29
+ gemfile: gemfiles/rails_50.gemfile
30
+ - rvm: 2.0.0
31
+ gemfile: gemfiles/rails_51.gemfile
32
+ - rvm: 2.0.0
33
+ gemfile: gemfiles/rails_52.gemfile
34
+ - rvm: 2.0.0
35
+ gemfile: gemfiles/rails_edge.gemfile
36
+ - rvm: 2.1.0
37
+ gemfile: gemfiles/rails_50.gemfile
38
+ - rvm: 2.1.0
39
+ gemfile: gemfiles/rails_51.gemfile
40
+ - rvm: 2.1.0
41
+ gemfile: gemfiles/rails_52.gemfile
42
+ - rvm: 2.1.0
43
+ gemfile: gemfiles/rails_edge.gemfile
44
+ # Rails 6.0+ requires CRuby 2.4.1+
45
+ - rvm: 2.2.2
46
+ gemfile: gemfiles/rails_edge.gemfile
47
+ - rvm: 2.3.0
48
+ gemfile: gemfiles/rails_edge.gemfile
49
+ # CRuby 2.4+ requires Rails 4.2.8+
50
+ - rvm: 2.4.1
51
+ gemfile: gemfiles/rails_41.gemfile
52
+ - rvm: 2.5.0
53
+ gemfile: gemfiles/rails_41.gemfile
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem "rails", "~> 4.1.0"
4
+
5
+ gemspec :path => "../"
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem "rails", "~> 4.2.8"
4
+
5
+ gemspec :path => "../"
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem "rails", "~> 5.0.0"
4
+
5
+ gemspec :path => "../"
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem "rails", "~> 5.1.0"
4
+
5
+ gemspec :path => "../"
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem "rails", "~> 5.2.0"
4
+
5
+ gemspec :path => "../"
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
4
+
5
+ gem "rails", :github => "rails/rails"
6
+
7
+ gemspec :path => "../"
@@ -35,9 +35,16 @@ if defined?(::Rails)
35
35
 
36
36
  ::Mime::Type.register "application/msgpack", :msgpack
37
37
 
38
- ::ActionController::Renderers.add :msgpack do |data, options|
39
- self.content_type = Mime::MSGPACK
40
- self.response_body = data.as_msgpack(options)
38
+ if ::Rails::VERSION::MAJOR > 3 || ::Rails::VERSION::MINOR > 0
39
+ ::ActionController::Renderers.add :msgpack do |data, options|
40
+ self.content_type = Mime[:msgpack]
41
+ data.is_a?(String) ? data : data.to_msgpack(options)
42
+ end
43
+ else
44
+ ::ActionController::Renderers.add :msgpack do |data, options|
45
+ self.content_type = Mime[:msgpack]
46
+ self.response_body = data.is_a?(String) ? data : data.to_msgpack(options)
47
+ end
41
48
  end
42
49
  end
43
50
  end
@@ -8,7 +8,13 @@ end
8
8
  # The msgpack gem adds a few modules to Ruby core classes containing :to_msgpack definition, overwriting
9
9
  # their default behavior. That said, we need to define the basic to_msgpack method in all of them,
10
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|
11
+ klasses = [Object, NilClass, TrueClass, FalseClass, Float, String, Array, Hash, Symbol]
12
+ if 1.class.name == "Integer"
13
+ klasses.push(Integer)
14
+ else
15
+ klasses.push(Fixnum, Bignum)
16
+ end
17
+ klasses.each do |klass|
12
18
  klass.class_eval do
13
19
  alias_method :msgpack_to_msgpack, :to_msgpack if respond_to?(:to_msgpack)
14
20
  # Dumps object in msgpack. See http://msgpack.org for more infoa
@@ -1,3 +1,3 @@
1
1
  module MsgpackRails
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
3
3
  end
@@ -27,5 +27,5 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.add_development_dependency "rake", "~> 10.3.1"
29
29
  spec.add_development_dependency "minitest", "~> 5.3.3"
30
- spec.add_development_dependency "activemodel", "~> 4.1.0"
30
+ spec.add_development_dependency "rails", ">= 4.1.0"
31
31
  end
@@ -0,0 +1,15 @@
1
+ require "action_controller/railtie"
2
+ require "active_model/railtie"
3
+
4
+ class FakeApp < Rails::Application
5
+ config.secret_token = config.secret_key_base = "1234567890"
6
+ config.session_store :cookie_store, key: '_myapp_session'
7
+ config.active_support.deprecation = :log
8
+ config.eager_load = false
9
+ config.root = File.dirname(__FILE__)
10
+ end
11
+ Rails.backtrace_cleaner.remove_silencers!
12
+ Rails.application.initialize!
13
+
14
+ class ApplicationController < ActionController::Base
15
+ end
@@ -0,0 +1,58 @@
1
+ require_relative "../test_helper"
2
+
3
+ class ContactsController < ApplicationController
4
+ def raw
5
+ @contact = new_contact
6
+ render msgpack: @contact
7
+ end
8
+ def serialized
9
+ @contact = new_contact
10
+ render msgpack: @contact.to_msgpack
11
+ end
12
+ private
13
+ def new_contact
14
+ contact = Contact.new
15
+ contact.name = 'Konata Izumi'
16
+ contact.age = 16
17
+ contact.created_at = Time.utc(2006, 8, 1)
18
+ contact.awesome = true
19
+ contact.preferences = { 'shows' => 'anime' }
20
+ contact
21
+ end
22
+ end
23
+
24
+ class RenderingTest < ActionController::TestCase
25
+ tests ContactsController
26
+
27
+ def setup
28
+ r = ActionDispatch::Routing::RouteSet.new
29
+ r.draw do
30
+ get ":controller/:action"
31
+ end
32
+ r.finalize!
33
+ @routes = r
34
+ end
35
+
36
+ def test_raw
37
+ get :raw, :format => :msgpack
38
+ verify_response
39
+ end
40
+
41
+ def test_serialized
42
+ get :serialized, :format => :msgpack
43
+ verify_response
44
+ end
45
+
46
+ private
47
+
48
+ def verify_response
49
+ assert_response :success
50
+
51
+ contact = MessagePack.unpack(response.body)
52
+ assert_equal 'Konata Izumi', contact['name']
53
+ assert_equal 16, contact['age']
54
+ assert_equal Time.utc(2006, 8, 1), contact['created_at']
55
+ assert_equal true, contact['awesome']
56
+ assert_equal({ 'shows' => 'anime' }, contact['preferences'])
57
+ end
58
+ end
@@ -1,2 +1,4 @@
1
1
  require "minitest/autorun"
2
+ require "rails"
2
3
  require_relative "../lib/msgpack_rails"
4
+ require_relative "msgpack_rails/fake_app"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msgpack_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
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: 2014-07-03 00:00:00.000000000 Z
11
+ date: 2018-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -67,17 +67,17 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: 5.3.3
69
69
  - !ruby/object:Gem::Dependency
70
- name: activemodel
70
+ name: rails
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: 4.1.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: 4.1.0
83
83
  description: Message Pack for Rails.
@@ -93,6 +93,12 @@ files:
93
93
  - LICENSE.txt
94
94
  - README.md
95
95
  - Rakefile
96
+ - gemfiles/rails_41.gemfile
97
+ - gemfiles/rails_42.gemfile
98
+ - gemfiles/rails_50.gemfile
99
+ - gemfiles/rails_51.gemfile
100
+ - gemfiles/rails_52.gemfile
101
+ - gemfiles/rails_edge.gemfile
96
102
  - lib/msgpack_rails.rb
97
103
  - lib/msgpack_rails/activemodel/serializers/message_pack.rb
98
104
  - lib/msgpack_rails/activesupport/core_ext/object/to_msgpack.rb
@@ -104,7 +110,9 @@ files:
104
110
  - test/msgpack_rails/core_ext_test.rb
105
111
  - test/msgpack_rails/decoding_test.rb
106
112
  - test/msgpack_rails/encoding_test.rb
113
+ - test/msgpack_rails/fake_app.rb
107
114
  - test/msgpack_rails/models/contact.rb
115
+ - test/msgpack_rails/rendering_test.rb
108
116
  - test/msgpack_rails/serializer_test.rb
109
117
  - test/test_helper.rb
110
118
  homepage: https://github.com/jingweno/msgpack_rails
@@ -127,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
135
  version: '0'
128
136
  requirements: []
129
137
  rubyforge_project:
130
- rubygems_version: 2.2.2
138
+ rubygems_version: 2.7.6
131
139
  signing_key:
132
140
  specification_version: 4
133
141
  summary: The Rails way to serialize/deserialize with Message Pack.
@@ -135,6 +143,8 @@ test_files:
135
143
  - test/msgpack_rails/core_ext_test.rb
136
144
  - test/msgpack_rails/decoding_test.rb
137
145
  - test/msgpack_rails/encoding_test.rb
146
+ - test/msgpack_rails/fake_app.rb
138
147
  - test/msgpack_rails/models/contact.rb
148
+ - test/msgpack_rails/rendering_test.rb
139
149
  - test/msgpack_rails/serializer_test.rb
140
150
  - test/test_helper.rb