protobuf-activerecord 6.1.0 → 7.1.0

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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -27
  3. data/.standard.yml +3 -0
  4. data/CHANGELOG.md +13 -0
  5. data/CODE_OF_CONDUCT.md +132 -0
  6. data/LICENSE.txt +17 -18
  7. data/README.md +8 -4
  8. data/Rakefile +13 -9
  9. data/lib/protobuf/active_record/attribute_methods.rb +2 -2
  10. data/lib/protobuf/active_record/columns.rb +3 -5
  11. data/lib/protobuf/active_record/middleware/connection_management_async.rb +2 -3
  12. data/lib/protobuf/active_record/middleware/query_cache.rb +1 -3
  13. data/lib/protobuf/active_record/nested_attributes.rb +2 -2
  14. data/lib/protobuf/active_record/persistence.rb +6 -6
  15. data/lib/protobuf/active_record/scope.rb +10 -10
  16. data/lib/protobuf/active_record/serialization.rb +29 -34
  17. data/lib/protobuf/active_record/transformation.rb +22 -25
  18. data/lib/protobuf/active_record/transformer.rb +1 -1
  19. data/lib/protobuf/active_record/version.rb +1 -1
  20. metadata +20 -174
  21. data/.gitignore +0 -12
  22. data/.travis.yml +0 -4
  23. data/Gemfile +0 -4
  24. data/protobuf-activerecord.gemspec +0 -43
  25. data/spec/protobuf/active_record/columns_spec.rb +0 -100
  26. data/spec/protobuf/active_record/nested_attributes_spec.rb +0 -28
  27. data/spec/protobuf/active_record/persistence_spec.rb +0 -70
  28. data/spec/protobuf/active_record/scope_spec.rb +0 -201
  29. data/spec/protobuf/active_record/serialization_spec.rb +0 -208
  30. data/spec/protobuf/active_record/transformation_spec.rb +0 -254
  31. data/spec/protobuf/active_record/transformer_spec.rb +0 -42
  32. data/spec/spec_helper.rb +0 -27
  33. data/spec/support/db/setup.rb +0 -29
  34. data/spec/support/db.rb +0 -1
  35. data/spec/support/definitions/messages.proto +0 -23
  36. data/spec/support/models/photo.rb +0 -3
  37. data/spec/support/models/user.rb +0 -53
  38. data/spec/support/models.rb +0 -2
  39. data/spec/support/protobuf/messages.pb.rb +0 -41
data/spec/spec_helper.rb DELETED
@@ -1,27 +0,0 @@
1
- require "rubygems"
2
- require "bundler"
3
-
4
- require "simplecov"
5
- SimpleCov.start do
6
- add_filter "/spec/"
7
- end
8
-
9
- Bundler.require(:default, :development, :test)
10
-
11
- require "support/db"
12
- require "support/models"
13
- require "support/protobuf/messages.pb"
14
-
15
- # Silence protobuf"s logger
16
- Protobuf::Logging.logger.level = ::Logger::FATAL
17
-
18
- RSpec.configure do |config|
19
- # Turn deprecation warnings into errors with full backtrace.
20
- config.raise_errors_for_deprecations!
21
-
22
- # Verifies the existance of any stubbed methods, replaces better_receive and better_stub
23
- # https://www.relishapp.com/rspec/rspec-mocks/v/3-1/docs/verifying-doubles/partial-doubles
24
- config.mock_with :rspec do |mocks|
25
- mocks.verify_partial_doubles = true
26
- end
27
- end
@@ -1,29 +0,0 @@
1
- require "active_record"
2
-
3
- ActiveRecord::Base.establish_connection(
4
- :adapter => "sqlite3",
5
- :database => "spec/test.db"
6
- )
7
-
8
- ActiveRecord::Base.connection.data_sources.each do |table|
9
- ActiveRecord::Base.connection.drop_table(table)
10
- end
11
-
12
- ActiveRecord::Schema.define(:version => 1) do
13
- create_table :photos do |t|
14
- t.string :url
15
- t.integer :user_id
16
-
17
- t.timestamps :null => false
18
- end
19
-
20
- create_table :users do |t|
21
- t.string :guid
22
- t.string :first_name
23
- t.string :last_name
24
- t.string :email
25
- t.integer :account_id
26
-
27
- t.timestamps :null => false
28
- end
29
- end
data/spec/support/db.rb DELETED
@@ -1 +0,0 @@
1
- require "support/db/setup"
@@ -1,23 +0,0 @@
1
- syntax = "proto3";
2
-
3
- message PhotoMessage {
4
- string url = 1;
5
- int64 user_guid = 2;
6
- }
7
-
8
- message UserMessage {
9
- string guid = 1;
10
- string name = 2;
11
- string email = 3;
12
- string email_domain = 4 [deprecated = true];
13
- string password = 5;
14
- repeated string nullify = 6;
15
- repeated PhotoMessage photos = 7;
16
- int64 created_at = 8;
17
- int64 updated_at = 9;
18
- }
19
-
20
- message UserSearchMessage {
21
- repeated string guid = 1;
22
- repeated string email = 2;
23
- }
@@ -1,3 +0,0 @@
1
- class Photo < ActiveRecord::Base
2
- include Protobuf::ActiveRecord::Model
3
- end
@@ -1,53 +0,0 @@
1
- class User < ActiveRecord::Base
2
- include Protobuf::ActiveRecord::Model
3
-
4
- attr_accessor :password
5
-
6
- has_many :photos
7
-
8
- accepts_nested_attributes_for :photos
9
-
10
- scope :by_guid, lambda { |*guids| where(:guid => guids) }
11
- scope :by_email, lambda { |*emails| where(:email => emails) }
12
-
13
- protobuf_fields :except => :photos
14
-
15
- attribute_from_proto :first_name, :extract_first_name
16
- attribute_from_proto :last_name, :extract_last_name
17
- attribute_from_proto :password, lambda { |proto| proto.password! }
18
-
19
- field_from_record :email_domain, lambda { |record| record.email.split("@").last }
20
- field_from_record :password, :password_transformer
21
-
22
- def self.extract_first_name(proto)
23
- if proto.field?(:name)
24
- names = proto.name.split(" ")
25
- first_name = names.first
26
- end
27
-
28
- first_name
29
- end
30
-
31
- def self.extract_last_name(proto)
32
- if proto.field?(:name)
33
- names = proto.name.split(" ")
34
- names.shift # Drop the first name
35
- last_name = names.join(" ")
36
- end
37
-
38
- last_name
39
- end
40
-
41
- def self.password_transformer(user)
42
- # Simple way to test field transformers that call methods
43
- user.password
44
- end
45
-
46
- def token
47
- "key"
48
- end
49
-
50
- def name
51
- "#{first_name} #{last_name}"
52
- end
53
- end
@@ -1,2 +0,0 @@
1
- require "support/models/photo"
2
- require "support/models/user"
@@ -1,41 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ##
4
- # This file is auto-generated. DO NOT EDIT!
5
- #
6
- require 'protobuf'
7
-
8
-
9
- ##
10
- # Message Classes
11
- #
12
- class PhotoMessage < ::Protobuf::Message; end
13
- class UserMessage < ::Protobuf::Message; end
14
- class UserSearchMessage < ::Protobuf::Message; end
15
-
16
-
17
- ##
18
- # Message Fields
19
- #
20
- class PhotoMessage
21
- optional :string, :url, 1
22
- optional :int64, :user_guid, 2
23
- end
24
-
25
- class UserMessage
26
- optional :string, :guid, 1
27
- optional :string, :name, 2
28
- optional :string, :email, 3
29
- optional :string, :email_domain, 4, :deprecated => true
30
- optional :string, :password, 5
31
- repeated :string, :nullify, 6
32
- repeated ::PhotoMessage, :photos, 7
33
- optional :int64, :created_at, 8
34
- optional :int64, :updated_at, 9
35
- end
36
-
37
- class UserSearchMessage
38
- repeated :string, :guid, 1
39
- repeated :string, :email, 2
40
- end
41
-