active_model_serializers_binary 0.2.1 → 0.3.1

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.
Files changed (60) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +10 -8
  3. data/Gemfile +5 -20
  4. data/Gemfile.lock +33 -140
  5. data/MIT-LICENSE +1 -1
  6. data/Rakefile +2 -31
  7. data/active_model_serializers_binary.gemspec +2 -17
  8. data/bin/test +5 -0
  9. data/lib/active_model_serializers_binary/active_model_serializers_binary.rb +41 -14
  10. data/lib/active_model_serializers_binary/base_type.rb +0 -0
  11. data/lib/active_model_serializers_binary/data_types.rb +17 -6
  12. data/lib/active_model_serializers_binary/railtie.rb +4 -0
  13. data/lib/active_model_serializers_binary/version.rb +1 -1
  14. data/test/active_model_serializers_binary_test.rb +3 -3
  15. data/test/dummy/Rakefile +1 -1
  16. data/test/dummy/app/assets/stylesheets/application.css +1 -15
  17. data/test/dummy/app/channels/application_cable/channel.rb +4 -0
  18. data/test/dummy/app/channels/application_cable/connection.rb +4 -0
  19. data/test/dummy/app/controllers/application_controller.rb +0 -3
  20. data/test/dummy/app/jobs/application_job.rb +7 -0
  21. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  22. data/test/dummy/app/models/application_record.rb +3 -0
  23. data/test/dummy/app/models/product.rb +2 -1
  24. data/test/dummy/app/models/silo.rb +6 -0
  25. data/test/dummy/app/models/type.rb +0 -0
  26. data/test/dummy/app/views/layouts/application.html.erb +10 -9
  27. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  28. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  29. data/test/dummy/bin/rails +3 -3
  30. data/test/dummy/bin/rake +2 -2
  31. data/test/dummy/bin/setup +33 -0
  32. data/test/dummy/config/application.rb +12 -13
  33. data/test/dummy/config/boot.rb +3 -3
  34. data/test/dummy/config/cable.yml +10 -0
  35. data/test/dummy/config/database.yml +3 -3
  36. data/test/dummy/config/environment.rb +1 -1
  37. data/test/dummy/config/environments/development.rb +46 -15
  38. data/test/dummy/config/environments/production.rb +38 -33
  39. data/test/dummy/config/environments/test.rb +34 -13
  40. data/test/dummy/config/initializers/content_security_policy.rb +25 -0
  41. data/test/dummy/config/initializers/filter_parameter_logging.rb +6 -2
  42. data/test/dummy/config/initializers/inflections.rb +4 -4
  43. data/test/dummy/config/initializers/permissions_policy.rb +11 -0
  44. data/test/dummy/config/locales/en.yml +13 -3
  45. data/test/dummy/config/puma.rb +43 -0
  46. data/test/dummy/config/routes.rb +3 -53
  47. data/test/dummy/config/storage.yml +34 -0
  48. data/test/dummy/config.ru +3 -1
  49. data/test/dummy/db/migrate/20170830125642_create_silos.rb +10 -0
  50. data/test/dummy/db/schema.rb +35 -0
  51. data/test/dummy/lib/test_parser.rb +2 -2
  52. data/test/dummy/public/404.html +6 -6
  53. data/test/dummy/public/422.html +6 -6
  54. data/test/dummy/public/500.html +6 -6
  55. data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
  56. data/test/dummy/public/apple-touch-icon.png +0 -0
  57. data/test/dummy/test/fixtures/silos.yml +9 -0
  58. data/test/dummy/test/models/silo_test.rb +7 -0
  59. data/test/test_helper.rb +7 -8
  60. metadata +50 -64
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 596d98d9d3ebdccccb17e210ba65d1c21f3402a1
4
- data.tar.gz: c8b0dfdb53e10abb64d79185687d6530a440e0fb
2
+ SHA256:
3
+ metadata.gz: c3bc7e78d3a4a01bdea3e551b39e05cdfc096b529a218a4dc5bb926c1a579b9d
4
+ data.tar.gz: d2c020e620d5f0b887dce84a315917658f775ffaaa14518bdeff9882f9a41cee
5
5
  SHA512:
6
- metadata.gz: 524d45fbc3dc9b1208cf49a5efe72a3beac8860b0ddc98e6897999f4f60f532e37512db7f2fa76cdbbf15681d250e0c899386933ab02ff39124949209521b7ad
7
- data.tar.gz: c6b4b8d0e2a58b39d111fad53e10ef3ea40d2b540bcc6ad00b0661c4ed2174864a0e57465e997c4802d0d58f642d1d4a58e06cf7c59f33ea79272a238b2fd5fd
6
+ metadata.gz: c36e1ecfda5c4348b6fc986c9cac58250e632f7c73839c6cee145591d3be07bbe29f0116e91a2405bc8e23d8aa8657f7725f18f3807dc907c7c7b341d48c0a85
7
+ data.tar.gz: a633a65ee4d69e0ccd37555553aff02d44141800d43234ffed5e6f5f69b27145287d54638cd5386c902d966183214b3e2608b8e23bcb7847d8850f3ff1e8e845
data/.gitignore CHANGED
@@ -1,9 +1,11 @@
1
- .bundle/
2
- log/*.log
3
- pkg/
4
- test/dummy/db/*.sqlite3
5
- test/dummy/db/*.sqlite3-journal
6
- test/dummy/log/*.log
7
- test/dummy/tmp/
8
- test/dummy/.sass-cache
1
+ /.bundle/
2
+ /doc/
3
+ /log/*.log
4
+ /pkg/
5
+ /tmp/
6
+ /test/dummy/db/*.sqlite3
7
+ /test/dummy/db/*.sqlite3-*
8
+ /test/dummy/log/*.log
9
+ /test/dummy/storage/
10
+ /test/dummy/tmp/
9
11
  *.gem
data/Gemfile CHANGED
@@ -1,25 +1,10 @@
1
1
  source "https://rubygems.org"
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
2
3
 
3
- # Declare your gem's dependencies in active_model_serializers_binary.gemspec.
4
- # Bundler will treat runtime dependencies like base dependencies, and
5
- # development dependencies will be added by default to the :development group.
4
+ # Specify your gem's dependencies in active_model_serializers_binary.gemspec.
6
5
  gemspec
7
6
 
8
- # Declare any dependencies that are still in development here instead of in
9
- # your gemspec. These might include edge Rails or gems from your path or
10
- # Git. Remember to move these dependencies to your gemspec before releasing
11
- # your gem to rubygems.org.
7
+ gem "sqlite3"
12
8
 
13
- # To use debugger
14
- # gem 'debugger'
15
-
16
- group :development do
17
- gem 'pry'
18
- gem 'pry-rescue'
19
- gem 'pry-doc'
20
- gem 'pry-rails'
21
-
22
- #debuggers
23
- gem 'pry-byebug'
24
- gem 'annotate'
25
- end
9
+ # Start debugger with binding.b [https://github.com/ruby/debug]
10
+ # gem "debug", ">= 1.0.0"
data/Gemfile.lock CHANGED
@@ -1,156 +1,49 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_model_serializers_binary (0.2.0)
5
- activemodel (~> 5.0)
4
+ active_model_serializers_binary (0.3.1)
5
+ activemodel (>= 5.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (5.0.0.1)
11
- actionpack (= 5.0.0.1)
12
- nio4r (~> 1.2)
13
- websocket-driver (~> 0.6.1)
14
- actionmailer (5.0.0.1)
15
- actionpack (= 5.0.0.1)
16
- actionview (= 5.0.0.1)
17
- activejob (= 5.0.0.1)
18
- mail (~> 2.5, >= 2.5.4)
19
- rails-dom-testing (~> 2.0)
20
- actionpack (5.0.0.1)
21
- actionview (= 5.0.0.1)
22
- activesupport (= 5.0.0.1)
23
- rack (~> 2.0)
24
- rack-test (~> 0.6.3)
25
- rails-dom-testing (~> 2.0)
26
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
- actionview (5.0.0.1)
28
- activesupport (= 5.0.0.1)
29
- builder (~> 3.1)
30
- erubis (~> 2.7.0)
31
- rails-dom-testing (~> 2.0)
32
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
33
- activejob (5.0.0.1)
34
- activesupport (= 5.0.0.1)
35
- globalid (>= 0.3.6)
36
- activemodel (5.0.0.1)
37
- activesupport (= 5.0.0.1)
38
- activerecord (5.0.0.1)
39
- activemodel (= 5.0.0.1)
40
- activesupport (= 5.0.0.1)
41
- arel (~> 7.0)
42
- activesupport (5.0.0.1)
43
- concurrent-ruby (~> 1.0, >= 1.0.2)
44
- i18n (~> 0.7)
45
- minitest (~> 5.1)
46
- tzinfo (~> 1.1)
47
- annotate (2.7.1)
48
- activerecord (>= 3.2, < 6.0)
49
- rake (>= 10.4, < 12.0)
50
- arel (7.1.1)
51
- builder (3.2.2)
52
- byebug (4.0.5)
53
- columnize (= 0.9.0)
54
- coderay (1.1.0)
55
- colorize (0.7.3)
56
- columnize (0.9.0)
57
- concurrent-ruby (1.0.2)
58
- erubis (2.7.0)
59
- globalid (0.3.7)
60
- activesupport (>= 4.1.0)
61
- i18n (0.7.0)
62
- interception (0.5)
63
- loofah (2.0.3)
64
- nokogiri (>= 1.5.9)
65
- mail (2.6.4)
66
- mime-types (>= 1.16, < 4)
67
- method_source (0.8.2)
68
- mime-types (3.1)
69
- mime-types-data (~> 3.2015)
70
- mime-types-data (3.2016.0521)
71
- mini_portile2 (2.1.0)
72
- minitest (5.9.0)
73
- nio4r (1.2.1)
74
- nokogiri (1.6.8)
75
- mini_portile2 (~> 2.1.0)
76
- pkg-config (~> 1.1.7)
77
- pkg-config (1.1.7)
78
- pry (0.10.1)
79
- coderay (~> 1.1.0)
80
- method_source (~> 0.8.1)
81
- slop (~> 3.4)
82
- pry-byebug (3.1.0)
83
- byebug (~> 4.0)
84
- pry (~> 0.10)
85
- pry-doc (0.6.0)
86
- pry (~> 0.9)
87
- yard (~> 0.8)
88
- pry-rails (0.3.4)
89
- pry (>= 0.9.10)
90
- pry-rescue (1.4.2)
91
- interception (>= 0.5)
92
- pry
93
- rack (2.0.1)
94
- rack-test (0.6.3)
95
- rack (>= 1.0)
96
- rails (5.0.0.1)
97
- actioncable (= 5.0.0.1)
98
- actionmailer (= 5.0.0.1)
99
- actionpack (= 5.0.0.1)
100
- actionview (= 5.0.0.1)
101
- activejob (= 5.0.0.1)
102
- activemodel (= 5.0.0.1)
103
- activerecord (= 5.0.0.1)
104
- activesupport (= 5.0.0.1)
105
- bundler (>= 1.3.0, < 2.0)
106
- railties (= 5.0.0.1)
107
- sprockets-rails (>= 2.0.0)
108
- rails-dom-testing (2.0.1)
109
- activesupport (>= 4.2.0, < 6.0)
110
- nokogiri (~> 1.6.0)
111
- rails-html-sanitizer (1.0.3)
112
- loofah (~> 2.0)
113
- railties (5.0.0.1)
114
- actionpack (= 5.0.0.1)
115
- activesupport (= 5.0.0.1)
116
- method_source
117
- rake (>= 0.8.7)
118
- thor (>= 0.18.1, < 2.0)
119
- rake (10.5.0)
120
- slop (3.6.0)
121
- sprockets (3.7.0)
10
+ activemodel (7.2.2.1)
11
+ activesupport (= 7.2.2.1)
12
+ activesupport (7.2.2.1)
13
+ base64
14
+ benchmark (>= 0.3)
15
+ bigdecimal
16
+ concurrent-ruby (~> 1.0, >= 1.3.1)
17
+ connection_pool (>= 2.2.5)
18
+ drb
19
+ i18n (>= 1.6, < 2)
20
+ logger (>= 1.4.2)
21
+ minitest (>= 5.1)
22
+ securerandom (>= 0.3)
23
+ tzinfo (~> 2.0, >= 2.0.5)
24
+ base64 (0.2.0)
25
+ benchmark (0.4.0)
26
+ bigdecimal (3.1.9)
27
+ colorize (0.8.1)
28
+ concurrent-ruby (1.3.5)
29
+ connection_pool (2.5.0)
30
+ drb (2.2.1)
31
+ i18n (1.14.7)
32
+ concurrent-ruby (~> 1.0)
33
+ logger (1.6.6)
34
+ minitest (5.25.4)
35
+ securerandom (0.4.1)
36
+ sqlite3 (1.5.2-x86_64-linux)
37
+ tzinfo (2.0.6)
122
38
  concurrent-ruby (~> 1.0)
123
- rack (> 1, < 3)
124
- sprockets-rails (3.2.0)
125
- actionpack (>= 4.0)
126
- activesupport (>= 4.0)
127
- sprockets (>= 3.0.0)
128
- sqlite3 (1.3.11)
129
- thor (0.19.1)
130
- thread_safe (0.3.5)
131
- tzinfo (1.2.2)
132
- thread_safe (~> 0.1)
133
- websocket-driver (0.6.4)
134
- websocket-extensions (>= 0.1.0)
135
- websocket-extensions (0.1.2)
136
- yard (0.8.7.6)
137
39
 
138
40
  PLATFORMS
139
- ruby
41
+ x86_64-linux
140
42
 
141
43
  DEPENDENCIES
142
44
  active_model_serializers_binary!
143
- annotate
144
- bundler (~> 1.6)
145
- colorize (~> 0.7)
146
- pry
147
- pry-byebug
148
- pry-doc
149
- pry-rails
150
- pry-rescue
151
- rails (~> 5.0)
152
- rake (~> 10.3)
45
+ colorize
153
46
  sqlite3
154
47
 
155
48
  BUNDLED WITH
156
- 1.15.3
49
+ 2.3.14
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2014 YOURNAME
1
+ Copyright 2022 Guillermo Bisheimer
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -1,32 +1,3 @@
1
- begin
2
- require 'bundler/setup'
3
- rescue LoadError
4
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
- end
1
+ require "bundler/setup"
6
2
 
7
- require 'rdoc/task'
8
-
9
- RDoc::Task.new(:rdoc) do |rdoc|
10
- rdoc.rdoc_dir = 'rdoc'
11
- rdoc.title = 'ActiveModelSerializersBinary'
12
- rdoc.options << '--line-numbers'
13
- rdoc.rdoc_files.include('README.rdoc')
14
- rdoc.rdoc_files.include('lib/**/*.rb')
15
- end
16
-
17
-
18
-
19
-
20
- Bundler::GemHelper.install_tasks
21
-
22
- require 'rake/testtask'
23
-
24
- Rake::TestTask.new(:test) do |t|
25
- t.libs << 'lib'
26
- t.libs << 'test'
27
- t.pattern = 'test/**/*_test.rb'
28
- t.verbose = false
29
- end
30
-
31
-
32
- task default: :test
3
+ require "bundler/gem_tasks"
@@ -19,21 +19,6 @@ Gem::Specification.new do |s|
19
19
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_development_dependency "bundler", "~> 1.6"
23
- s.add_development_dependency "rake", "~> 10.3"
24
- s.add_development_dependency "sqlite3"
25
- s.add_development_dependency "rails", "~> 5.0"
26
-
27
- #s.add_development_dependency 'devise', '~> 3.2'
28
- #s.add_development_dependency 'jquery-ui-rails', '~> 4.2'
29
- #s.add_development_dependency 'sass-rails', '~> 4.0'
30
- #s.add_development_dependency 'uglifier', '~> 1.3'
31
- #s.add_development_dependency 'coffee-rails', '~> 4.0'
32
- #s.add_development_dependency 'turbolinks', "~> 2.2"
33
- #s.add_development_dependency 'jbuilder', '~> 1.2'
34
- #s.add_development_dependency 'jquery-validation-rails', '~> 1.12'
35
- #s.add_development_dependency 'therubyracer', '~> 0.12'
36
- s.add_development_dependency "colorize", '~> 0.7'
37
-
38
- s.add_dependency "activemodel", "~> 5.0"
22
+ s.add_development_dependency "colorize"
23
+ s.add_dependency "activemodel", ">= 5.0"
39
24
  end
data/bin/test ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.expand_path("../test", __dir__)
3
+
4
+ require "bundler/setup"
5
+ require "rails/plugin/test"
@@ -7,7 +7,6 @@ module ActiveModel
7
7
  # == Active Model Binary serializer
8
8
  module Binary
9
9
  extend ActiveSupport::Concern
10
- include ActiveModel::Model
11
10
  include ActiveModel::Serialization
12
11
  include DataTypes
13
12
 
@@ -26,8 +25,8 @@ module ActiveModel
26
25
  end
27
26
 
28
27
  def initialize( *args )
29
- initialize_serializer
30
28
  super rescue super()
29
+ initialize_serializer
31
30
  end
32
31
 
33
32
  def initialize_serializer
@@ -37,7 +36,7 @@ module ActiveModel
37
36
  after_initialize :initialize_serializer rescue nil
38
37
 
39
38
  endianess :little
40
- align false
39
+ align :dword
41
40
  end
42
41
 
43
42
  module ClassMethods
@@ -50,7 +49,11 @@ module ActiveModel
50
49
  true
51
50
  else
52
51
  attr_name = attr[:name].to_s
53
- if !instance.respond_to? attr_name
52
+ if (instance.class.respond_to? :column_names) && (!instance.class.column_names.include? attr_name)
53
+ attr[:virtual] = true
54
+ attr_accessor attr_name
55
+ true
56
+ elsif !instance.respond_to? attr_name
54
57
  attr[:virtual] = true
55
58
  attr_accessor attr_name
56
59
  true
@@ -139,11 +142,27 @@ module ActiveModel
139
142
  serialize_attribute_options attr_name, options.merge({coder: DataTypes::Float32}), &block
140
143
  end
141
144
 
145
+ def float32le( attr_name, options = {}, &block )
146
+ float32( attr_name, options.merge({endianess: :little}), &block )
147
+ end
148
+
149
+ def float32be( attr_name, options = {}, &block )
150
+ float32( attr_name, options.merge({endianess: :big}), &block )
151
+ end
152
+
142
153
  def float64( attr_name, options = {}, &block )
143
154
  options = self.serialize_options_global.merge(options)
144
155
  serialize_attribute_options attr_name, options.merge({coder: DataTypes::Float64}), &block
145
156
  end
146
157
 
158
+ def float64le( attr_name, options = {}, &block )
159
+ float64( attr_name, options.merge({endianess: :little}), &block )
160
+ end
161
+
162
+ def float64be( attr_name, options = {}, &block )
163
+ float64( attr_name, options.merge({endianess: :big}), &block )
164
+ end
165
+
147
166
  def char( attr_name, options = {}, &block )
148
167
  options = self.serialize_options_global.merge(options)
149
168
  serialize_attribute_options attr_name, options.merge({coder: DataTypes::Char}), &block
@@ -234,7 +253,7 @@ module ActiveModel
234
253
  end
235
254
 
236
255
  def dump
237
- serializable_values = @serializable.serializable_hash(@options)
256
+ serializable_values = @serializable.attributes
238
257
  self.start_address = @options[:start_address] || 0
239
258
 
240
259
  buffer = [] # Data Buffer
@@ -316,7 +335,7 @@ module ActiveModel
316
335
 
317
336
  # Return size of object in bytes
318
337
  def size
319
- serializable_values = @serializable.serializable_hash(@options)
338
+ serializable_values = @serializable.attributes
320
339
  self.start_address = @options[:start_address] || 0
321
340
 
322
341
  current_address = 0.0 # Dirección en bytes
@@ -342,9 +361,9 @@ module ActiveModel
342
361
  # => [98, 111, 98, 0, 0, 0, 0, 0, 0, 0, 22, 0, 1]
343
362
  #
344
363
  def to_bytes(options = {}, &block)
345
- options = self.serialize_options_global.deep_merge(options)
364
+ options = self.serialize_options_global.merge(options)
346
365
  if block_given?
347
- yield self
366
+ yield self, options
348
367
  end
349
368
  Serializer.new(self, options).dump
350
369
  end
@@ -353,8 +372,12 @@ module ActiveModel
353
372
 
354
373
  def to_words(options = {}, &block)
355
374
  data = to_bytes(options, &block)
356
- byte_count = (data.count/2.0).ceil*2
357
- data.fill(0, data.count...byte_count).pack('C*').unpack('v*')
375
+ data.push(0) if data.count.odd?
376
+ if self.serialize_options_global[:endianess]==:big
377
+ data.pack('C*').unpack('S>*')
378
+ else
379
+ data.pack('C*').unpack('S<*')
380
+ end
358
381
  end
359
382
 
360
383
  # Sets the model +attributes+ from an Binary string. Returns +self+.
@@ -394,11 +417,11 @@ module ActiveModel
394
417
  # @yield code block to execute after deserialization
395
418
  #
396
419
  def from_bytes(buffer, options = {}, &block)
397
- options = self.serialize_options_global.deep_merge(options)
420
+ options = self.serialize_options_global.merge(options)
398
421
  retVal = Serializer.new(self, options).load buffer
399
422
 
400
423
  if block_given?
401
- yield self
424
+ yield self, options
402
425
  end
403
426
  retVal
404
427
  end
@@ -406,12 +429,16 @@ module ActiveModel
406
429
  alias_method :load, :from_bytes
407
430
 
408
431
  def from_words(buffer = [], options = {}, &block)
409
- data = buffer.pack('v*').unpack('C*')
432
+ if self.serialize_options_global[:endianess]==:big
433
+ data = buffer.pack('S>*').unpack('C*')
434
+ else
435
+ data = buffer.pack('S<*').unpack('C*')
436
+ end
410
437
  from_bytes(data, options, &block)
411
438
  end
412
439
 
413
440
  def size(options = {})
414
- options = self.serialize_options_global.deep_merge(options)
441
+ options = self.serialize_options_global.merge(options)
415
442
  Serializer.new(self, options).size
416
443
  end
417
444
 
File without changes
@@ -174,13 +174,24 @@ module DataTypes
174
174
  super options.merge :bit_length => 8, :sign => nil, :default_value => "\x0"
175
175
  end
176
176
 
177
- def dump(value=nil)
178
- before_dump( value )
179
- @raw_value = @value.map{|v| v.ljust(@length, @default_value).slice(0,@length).unpack('C*')}
180
- end
177
+ EXTENDED_CHARACTERS = ["Ç","ü","é","â","ä","à","å","ç","ê","ë","è","ï","î","ì","Ä","Å","É","æ","Æ","ô","ö","ò","û","ù","ÿ","Ö","Ü","ø","£","Ø","×","ƒ","á","í","ó","ú","ñ","Ñ","ª","º","¿","®","¬","½","¼","¡","«","»","░","▒","▓","│","┤","Á","Â","À","©","╣","║","╗","╝","¢","¥","┐","└","┴","┬","├","─","┼","ã","Ã","╚","╔","╩","╦","╠","═","╬","¤","ð","Ð","Ê","Ë","È","ı","Í","Î","Ï","┘","┌","█","▄","¦","Ì","▀","Ó","ß","Ô","Ò","õ","Õ","µ","þ","Þ","Ú","Û","Ù","ý","Ý","¯","´","≡","±","‗","¾","¶","§","÷","¸","°","¨","·","¹","³","²","■"," "]
178
+ ASCII_TO_UTF8=["",('?'*31).split(''),(32..126).to_a.pack("U*").split(''),"?", EXTENDED_CHARACTERS].flatten
181
179
 
182
- def load(raw_value)
183
- self.value = check_raw_value(raw_value).pack('C*').unpack("Z#{@length}") if !value.nil?
180
+ def dump(value=nil) # to bytes
181
+ before_dump( value )
182
+ @raw_value = @value.map{|v| v.ljust(@length, @default_value).slice(0,@length)}.first.split("").map{|x| x=="\u0000" ? 0 : ASCII_TO_UTF8.index(x)}
183
+ @raw_value
184
+ end
185
+
186
+ def load(raw_value) # from bytes
187
+ if !value.nil?
188
+ characters = []
189
+ check_raw_value(raw_value).each do |x|
190
+ break if x == 0
191
+ characters << ASCII_TO_UTF8[x]
192
+ end
193
+ self.value = characters.empty? ? "" : characters.join[0...@length]
194
+ end
184
195
  after_load
185
196
  end
186
197
  end
@@ -0,0 +1,4 @@
1
+ module ActiveModelSerializersBinary
2
+ class Railtie < ::Rails::Railtie
3
+ end
4
+ end
@@ -1,3 +1,3 @@
1
1
  module ActiveModelSerializersBinary
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -1,7 +1,7 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  class ActiveModelSerializersBinaryTest < ActiveSupport::TestCase
4
- test "truth" do
5
- assert_kind_of Module, ActiveModelSerializersBinary
4
+ test "it has a version number" do
5
+ assert ActiveModelSerializersBinary::VERSION
6
6
  end
7
7
  end
data/test/dummy/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  # Add your own tasks in files placed in lib/tasks ending in .rake,
2
2
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
3
 
4
- require File.expand_path('../config/application', __FILE__)
4
+ require_relative "config/application"
5
5
 
6
6
  Rails.application.load_tasks
@@ -1,15 +1 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any styles
10
- * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
- * file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */
1
+ /* Application styles */
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Channel < ActionCable::Channel::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Connection < ActionCable::Connection::Base
3
+ end
4
+ end
@@ -1,5 +1,2 @@
1
1
  class ApplicationController < ActionController::Base
2
- # Prevent CSRF attacks by raising an exception.
3
- # For APIs, you may want to use :null_session instead.
4
- protect_from_forgery with: :exception
5
2
  end
@@ -0,0 +1,7 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ # Automatically retry jobs that encountered a deadlock
3
+ # retry_on ActiveRecord::Deadlocked
4
+
5
+ # Most jobs are safe to ignore if the underlying records are no longer available
6
+ # discard_on ActiveJob::DeserializationError
7
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: "from@example.com"
3
+ layout "mailer"
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ primary_abstract_class
3
+ end
@@ -1,5 +1,6 @@
1
1
  class Product
2
2
  include ActiveModel::Serializers::Binary
3
+ include ActiveModel::Model # This must not be included when serializing ActiveRecord classes
3
4
 
4
5
  endianess :big
5
6
  align :dword
@@ -23,5 +24,5 @@ class Product
23
24
  float64 :float64
24
25
  char :char
25
26
  bool :bool
26
- nest :type, coder: Type
27
+ #nest :type, coder: Type
27
28
  end
@@ -0,0 +1,6 @@
1
+ class Silo < ApplicationRecord
2
+ include ActiveModel::Serializers::Binary
3
+
4
+ int16 :test
5
+ int32 :test1
6
+ end
File without changes
@@ -1,14 +1,15 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
6
- <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <%= csrf_meta_tags %>
7
+ <%= csp_meta_tag %>
10
8
 
11
- <%= yield %>
9
+ <%= stylesheet_link_tag "application" %>
10
+ </head>
12
11
 
13
- </body>
12
+ <body>
13
+ <%= yield %>
14
+ </body>
14
15
  </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>