granite-form 0.2.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CODEOWNERS +1 -2
  3. data/.github/workflows/{ci.yml → ruby.yml} +22 -4
  4. data/.rubocop.yml +1 -1
  5. data/.rubocop_todo.yml +3 -3
  6. data/Appraisals +1 -2
  7. data/CHANGELOG.md +15 -0
  8. data/README.md +6 -15
  9. data/docker-compose.yml +14 -0
  10. data/gemfiles/rails.5.0.gemfile +0 -1
  11. data/gemfiles/rails.5.1.gemfile +0 -1
  12. data/gemfiles/rails.5.2.gemfile +0 -1
  13. data/granite-form.gemspec +15 -15
  14. data/lib/granite/form/active_record/associations.rb +1 -1
  15. data/lib/granite/form/base.rb +1 -2
  16. data/lib/granite/form/errors.rb +0 -15
  17. data/lib/granite/form/model/associations/base.rb +0 -4
  18. data/lib/granite/form/model/associations/collection/embedded.rb +2 -1
  19. data/lib/granite/form/model/associations/collection/proxy.rb +1 -1
  20. data/lib/granite/form/model/associations/embeds_any.rb +7 -0
  21. data/lib/granite/form/model/associations/embeds_many.rb +9 -58
  22. data/lib/granite/form/model/associations/embeds_one.rb +7 -36
  23. data/lib/granite/form/model/associations/nested_attributes.rb +7 -7
  24. data/lib/granite/form/model/associations/persistence_adapters/active_record.rb +0 -4
  25. data/lib/granite/form/model/associations/persistence_adapters/base.rb +0 -4
  26. data/lib/granite/form/model/associations/references_many.rb +0 -32
  27. data/lib/granite/form/model/associations/references_one.rb +0 -28
  28. data/lib/granite/form/model/associations/reflections/embeds_any.rb +1 -1
  29. data/lib/granite/form/model/associations/reflections/embeds_many.rb +1 -1
  30. data/lib/granite/form/model/associations/reflections/embeds_one.rb +11 -1
  31. data/lib/granite/form/model/associations/reflections/references_any.rb +0 -4
  32. data/lib/granite/form/model/associations/reflections/singular.rb +0 -22
  33. data/lib/granite/form/model/associations.rb +0 -6
  34. data/lib/granite/form/model/attributes/attribute.rb +3 -21
  35. data/lib/granite/form/model/attributes/base.rb +5 -23
  36. data/lib/granite/form/model/attributes/reference_many.rb +1 -1
  37. data/lib/granite/form/model/attributes/reference_one.rb +1 -1
  38. data/lib/granite/form/model/attributes/reflections/attribute.rb +2 -8
  39. data/lib/granite/form/model/attributes/reflections/base/build_type_definition.rb +38 -0
  40. data/lib/granite/form/model/attributes/reflections/base.rb +20 -17
  41. data/lib/granite/form/model/attributes/reflections/collection/build_type_definition.rb +19 -0
  42. data/lib/granite/form/model/attributes/reflections/dictionary/build_type_definition.rb +19 -0
  43. data/lib/granite/form/model/attributes/reflections/dictionary.rb +0 -3
  44. data/lib/granite/form/model/attributes/reflections/reference_one.rb +0 -6
  45. data/lib/granite/form/model/attributes/reflections/represents/build_type_definition.rb +73 -0
  46. data/lib/granite/form/model/attributes/reflections/represents.rb +10 -2
  47. data/lib/granite/form/model/attributes/represents.rb +22 -37
  48. data/lib/granite/form/model/attributes.rb +10 -2
  49. data/lib/granite/form/model/persistence.rb +1 -19
  50. data/lib/granite/form/model/representation.rb +1 -0
  51. data/lib/granite/form/model/validations.rb +6 -0
  52. data/lib/granite/form/model.rb +1 -3
  53. data/lib/granite/form/types/active_support/time_zone.rb +2 -0
  54. data/lib/granite/form/types/array.rb +2 -0
  55. data/lib/granite/form/types/big_decimal.rb +2 -0
  56. data/lib/granite/form/types/boolean.rb +2 -0
  57. data/lib/granite/form/types/collection.rb +11 -0
  58. data/lib/granite/form/types/date.rb +2 -0
  59. data/lib/granite/form/types/date_time.rb +2 -0
  60. data/lib/granite/form/types/dictionary.rb +23 -0
  61. data/lib/granite/form/types/float.rb +2 -0
  62. data/lib/granite/form/types/has_subtype.rb +18 -0
  63. data/lib/granite/form/types/hash_with_action_controller_parameters.rb +2 -0
  64. data/lib/granite/form/types/integer.rb +2 -0
  65. data/lib/granite/form/types/object.rb +28 -0
  66. data/lib/granite/form/types/string.rb +2 -0
  67. data/lib/granite/form/types/time.rb +2 -0
  68. data/lib/granite/form/types/uuid.rb +2 -0
  69. data/lib/granite/form/types.rb +3 -0
  70. data/lib/granite/form/util.rb +55 -0
  71. data/lib/granite/form/version.rb +1 -1
  72. data/lib/granite/form.rb +1 -0
  73. data/spec/granite/form/active_record/associations_spec.rb +16 -18
  74. data/spec/granite/form/model/associations/embeds_many_spec.rb +29 -305
  75. data/spec/granite/form/model/associations/embeds_one_spec.rb +27 -212
  76. data/spec/granite/form/model/associations/nested_attributes_spec.rb +0 -95
  77. data/spec/granite/form/model/associations/references_many_spec.rb +5 -326
  78. data/spec/granite/form/model/associations/references_one_spec.rb +7 -279
  79. data/spec/granite/form/model/associations/reflections/embeds_any_spec.rb +1 -2
  80. data/spec/granite/form/model/associations/reflections/embeds_many_spec.rb +18 -26
  81. data/spec/granite/form/model/associations/reflections/embeds_one_spec.rb +16 -23
  82. data/spec/granite/form/model/associations/reflections/references_many_spec.rb +1 -1
  83. data/spec/granite/form/model/associations/reflections/references_one_spec.rb +1 -22
  84. data/spec/granite/form/model/associations/validations_spec.rb +0 -3
  85. data/spec/granite/form/model/associations_spec.rb +3 -24
  86. data/spec/granite/form/model/attributes/attribute_spec.rb +0 -29
  87. data/spec/granite/form/model/attributes/reflections/attribute_spec.rb +0 -9
  88. data/spec/granite/form/model/attributes/reflections/base/build_type_definition_spec.rb +27 -0
  89. data/spec/granite/form/model/attributes/reflections/base_spec.rb +16 -10
  90. data/spec/granite/form/model/attributes/reflections/collection/build_type_definition_spec.rb +24 -0
  91. data/spec/granite/form/model/attributes/reflections/dictionary/build_type_definition_spec.rb +24 -0
  92. data/spec/granite/form/model/attributes/reflections/dictionary_spec.rb +0 -6
  93. data/spec/granite/form/model/attributes/reflections/represents/build_type_definition_spec.rb +129 -0
  94. data/spec/granite/form/model/attributes/reflections/represents_spec.rb +43 -20
  95. data/spec/granite/form/model/attributes/represents_spec.rb +78 -55
  96. data/spec/granite/form/model/attributes_spec.rb +84 -23
  97. data/spec/granite/form/model/dirty_spec.rb +1 -7
  98. data/spec/granite/form/model/persistence_spec.rb +0 -2
  99. data/spec/granite/form/model/representation_spec.rb +4 -7
  100. data/spec/granite/form/model/validations/associated_spec.rb +2 -4
  101. data/spec/granite/form/model/validations/nested_spec.rb +2 -4
  102. data/spec/granite/form/model/validations_spec.rb +28 -1
  103. data/spec/granite/form/types/collection_spec.rb +22 -0
  104. data/spec/granite/form/types/dictionary_spec.rb +32 -0
  105. data/spec/granite/form/types/has_subtype_spec.rb +20 -0
  106. data/spec/granite/form/types/object_spec.rb +50 -4
  107. data/spec/granite/form/util_spec.rb +108 -0
  108. data/spec/spec_helper.rb +0 -15
  109. data/spec/support/active_record.rb +23 -0
  110. data/spec/support/shared/nested_attribute_examples.rb +3 -21
  111. metadata +56 -51
  112. data/.github/workflows/main.yml +0 -29
  113. data/gemfiles/rails.4.2.gemfile +0 -15
  114. data/lib/granite/form/model/attributes/collection.rb +0 -19
  115. data/lib/granite/form/model/attributes/dictionary.rb +0 -28
  116. data/lib/granite/form/model/attributes/localized.rb +0 -44
  117. data/lib/granite/form/model/attributes/reflections/localized.rb +0 -45
  118. data/lib/granite/form/model/callbacks.rb +0 -72
  119. data/lib/granite/form/model/lifecycle.rb +0 -309
  120. data/lib/granite/form/model/localization.rb +0 -26
  121. data/spec/granite/form/model/attributes/collection_spec.rb +0 -72
  122. data/spec/granite/form/model/attributes/dictionary_spec.rb +0 -100
  123. data/spec/granite/form/model/attributes/localized_spec.rb +0 -103
  124. data/spec/granite/form/model/attributes/reflections/localized_spec.rb +0 -37
  125. data/spec/granite/form/model/callbacks_spec.rb +0 -337
  126. data/spec/granite/form/model/lifecycle_spec.rb +0 -356
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Granite::Form::Types::HasSubtype do
6
+ subject(:type) { described_class.new(subtype_definition) }
7
+ let(:subtype_definition) { Granite::Form::Types::Object.new(Dummy, reflection, nil) }
8
+ let(:reflection) { Granite::Form::Model::Attributes::Reflections::Base.new(:field) }
9
+ let(:dummy_object) { Dummy.new }
10
+
11
+ before { stub_class :dummy }
12
+
13
+ describe '#build_duplicate' do
14
+ subject { type.build_duplicate(new_reflection, new_model) }
15
+ let(:new_model) { double('new_model') }
16
+ let(:new_reflection) { double('new_reflection') }
17
+
18
+ it { is_expected.to have_attributes(subtype_definition: have_attributes(type: Dummy, reflection: new_reflection, owner: new_model)) }
19
+ end
20
+ end
@@ -3,12 +3,32 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe Granite::Form::Types::Object do
6
- subject(:type) { described_class.new(String, reflection, model.new) }
7
- let(:model) { stub_model }
8
- let(:reflection) { Granite::Form::Model::Attributes::Reflections::Base.new(:field) }
6
+ subject(:type) { build_type(reflection: reflection) }
7
+ let(:model) { Model.new }
8
+ let(:reflection) { build_reflection }
9
+
10
+ before do
11
+ stub_model :model
12
+ end
13
+
14
+ def build_reflection(name: :field, **options)
15
+ Granite::Form::Model::Attributes::Reflections::Base.new(name, options)
16
+ end
17
+
18
+ def build_type(type: String, reflection: nil, **options)
19
+ described_class.new(type, reflection || build_reflection(**options), model)
20
+ end
9
21
 
10
22
  describe '#initialize' do
11
- it { is_expected.to have_attributes(type: String, reflection: reflection, owner: an_instance_of(model)) }
23
+ it { is_expected.to have_attributes(type: String, reflection: reflection, owner: model) }
24
+ end
25
+
26
+ describe '#build_duplicate' do
27
+ subject { type.build_duplicate(new_reflection, new_model) }
28
+ let(:new_model) { double('new_model') }
29
+ let(:new_reflection) { Granite::Form::Model::Attributes::Reflections::Base.new(:new_field) }
30
+
31
+ it { is_expected.to have_attributes(type: String, reflection: new_reflection, owner: new_model) }
12
32
  end
13
33
 
14
34
  describe 'typecasting' do
@@ -37,4 +57,30 @@ RSpec.describe Granite::Form::Types::Object do
37
57
  specify { expect(typecast(nil)).to be_nil }
38
58
  end
39
59
  end
60
+
61
+ describe '#enum' do
62
+ before { allow(model).to receive_messages(value: 1..5) }
63
+
64
+ specify { expect(build_type.enum).to eq([].to_set) }
65
+ specify { expect(build_type(enum: []).enum).to eq([].to_set) }
66
+ specify { expect(build_type(enum: 'hello').enum).to eq(['hello'].to_set) }
67
+ specify { expect(build_type(enum: %w[hello world]).enum).to eq(%w[hello world].to_set) }
68
+ specify { expect(build_type(enum: [1..5]).enum).to eq([1..5].to_set) }
69
+ specify { expect(build_type(enum: 1..5).enum).to eq((1..5).to_a.to_set) }
70
+ specify { expect(build_type(enum: -> { 1..5 }).enum).to eq((1..5).to_a.to_set) }
71
+ specify { expect(build_type(enum: -> { 'hello' }).enum).to eq(['hello'].to_set) }
72
+ specify { expect(build_type(enum: -> { ['hello', 42] }).enum).to eq(['hello', 42].to_set) }
73
+ specify { expect(build_type(enum: -> { value }).enum).to eq((1..5).to_a.to_set) }
74
+ end
75
+
76
+ describe '#prepare' do
77
+ specify { expect(build_type.prepare('anything')).to eq('anything') }
78
+ specify { expect(build_type(enum: %w[hello 42]).prepare('hello')).to eq('hello') }
79
+ specify { expect(build_type(enum: %w[hello 42]).prepare('world')).to eq(nil) }
80
+ specify { expect(build_type(enum: %w[hello 42]).prepare('42')).to eq('42') }
81
+ specify { expect(build_type(enum: %w[hello 42]).prepare(42)).to eq(nil) }
82
+ specify { expect(build_type(enum: -> { 'hello' }).prepare('hello')).to eq('hello') }
83
+ specify { expect(build_type(type: Integer, enum: -> { 1..5 }).prepare(2)).to eq(2) }
84
+ specify { expect(build_type(type: Integer, enum: -> { 1..5 }).prepare(42)).to eq(nil) }
85
+ end
40
86
  end
@@ -0,0 +1,108 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Granite::Form::Util do
4
+ subject(:dummy) { Dummy.new('John') }
5
+
6
+ before do
7
+ stub_class(:dummy, Object) do
8
+ attr_accessor :name
9
+
10
+ def initialize(name)
11
+ @name = name
12
+ end
13
+
14
+ def full_name(last_name)
15
+ [name, last_name].join(' ')
16
+ end
17
+ end
18
+
19
+ Dummy.include described_class
20
+ end
21
+
22
+ describe '#evaluate' do
23
+ subject { dummy.evaluate(target) }
24
+ let(:target) { 'Peter' }
25
+
26
+ it { is_expected.to eq('Peter') }
27
+
28
+ context 'when symbol is passed' do
29
+ let(:target) { :name }
30
+
31
+ it { is_expected.to eq('John') }
32
+ end
33
+
34
+ context 'when lambda is passed' do
35
+ let(:target) { -> { name } }
36
+
37
+ it { is_expected.to eq('John') }
38
+ end
39
+
40
+ context 'with extra arguments' do
41
+ subject { dummy.evaluate(target, 'Doe') }
42
+
43
+ context 'when symbol is passed' do
44
+ let(:target) { :full_name }
45
+
46
+ it { is_expected.to eq('John Doe') }
47
+ end
48
+
49
+ context 'when lambda is passed' do
50
+ let(:target) { ->(last_name) { ['John', last_name].join(' ') } }
51
+
52
+ it { is_expected.to eq('John Doe') }
53
+ end
54
+ end
55
+ end
56
+
57
+ describe '#evaluate_if_proc' do
58
+ subject { dummy.evaluate(target) }
59
+ let(:target) { 'Peter' }
60
+
61
+ it { is_expected.to eq('Peter') }
62
+
63
+ context 'when lambda is passed' do
64
+ let(:target) { -> { name } }
65
+
66
+ it { is_expected.to eq('John') }
67
+ end
68
+
69
+ context 'with extra arguments' do
70
+ subject { dummy.evaluate(target, 'Doe') }
71
+
72
+ let(:target) { ->(last_name) { ['John', last_name].join(' ') } }
73
+
74
+ it { is_expected.to eq('John Doe') }
75
+ end
76
+ end
77
+
78
+ describe '#conditions_satisfied?' do
79
+ subject { dummy.conditions_satisfied?(**conditions) }
80
+ let(:conditions) { {if: -> { name == 'John' }} }
81
+
82
+ it { is_expected.to be_truthy }
83
+
84
+ context 'when if condition is satisfied' do
85
+ before { dummy.name = 'Peter' }
86
+
87
+ it { is_expected.to be_falsey }
88
+ end
89
+
90
+ context 'when unless condition is passed' do
91
+ let(:conditions) { {unless: :name} }
92
+
93
+ it { is_expected.to be_falsey }
94
+ end
95
+
96
+ context 'when no condition is passed' do
97
+ let(:conditions) { {} }
98
+
99
+ it { is_expected.to be_truthy }
100
+ end
101
+
102
+ context 'when both if & unless are passed' do
103
+ let(:conditions) { {if: :name, unless: :name} }
104
+
105
+ it { expect { subject }.to raise_error(ArgumentError) }
106
+ end
107
+ end
108
+ end
data/spec/spec_helper.rb CHANGED
@@ -10,21 +10,6 @@ require 'database_cleaner'
10
10
 
11
11
  Dir[File.join(__dir__, 'support', '**', '*.rb')].sort.each { |f| require f }
12
12
 
13
- ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
14
- ActiveRecord::Base.logger = Logger.new('/dev/null')
15
-
16
- ActiveRecord::Schema.define do
17
- create_table :users do |t|
18
- t.column :email, :string
19
- t.column :projects, :text
20
- t.column :profile, :text
21
- end
22
-
23
- create_table :authors do |t|
24
- t.column :name, :string
25
- end
26
- end
27
-
28
13
  RSpec.configure do |config|
29
14
  config.mock_with :rspec
30
15
  config.order = :random
@@ -0,0 +1,23 @@
1
+ ActiveRecord::Base.establish_connection(
2
+ adapter: 'postgresql',
3
+ database: 'granite',
4
+ username: 'granite',
5
+ password: 'granite',
6
+ host: 'localhost'
7
+ )
8
+ ActiveRecord::Base.logger = Logger.new('/dev/null')
9
+
10
+ ActiveRecord::Schema.define do
11
+ create_table :users, force: :cascade do |t|
12
+ t.column :email, :string
13
+ t.column :projects, :text
14
+ t.column :profile, :text
15
+ end
16
+
17
+ create_table :authors, force: :cascade do |t|
18
+ t.column :name, :string
19
+ t.column :status, :integer
20
+ t.column :related_ids, :integer, array: true
21
+ t.column :data, :text
22
+ end
23
+ end
@@ -4,7 +4,7 @@ shared_examples 'nested attributes' do
4
4
  before do
5
5
  stub_model :project do
6
6
  include Granite::Form::Model::Primary
7
- include Granite::Form::Model::Lifecycle
7
+ include Granite::Form::Model::Associations
8
8
 
9
9
  primary :slug, String
10
10
  attribute :title, String
@@ -12,7 +12,7 @@ shared_examples 'nested attributes' do
12
12
 
13
13
  stub_model :profile do
14
14
  include Granite::Form::Model::Primary
15
- include Granite::Form::Model::Lifecycle
15
+ include Granite::Form::Model::Associations
16
16
 
17
17
  primary :identifier
18
18
  attribute :first_name, String
@@ -49,14 +49,12 @@ shared_examples 'nested attributes' do
49
49
  specify do
50
50
  expect do
51
51
  user.profile_attributes = {first_name: 'User 1', _destroy: '1'}
52
- user.save { true }
53
52
  end.not_to change { user.profile.first_name }
54
53
  end
55
54
  specify { expect { user.profile_attributes = {identifier: profile.identifier.to_s, first_name: 'User 1', _destroy: '1'} }.to change { user.profile.first_name }.to('User 1') }
56
55
  specify do
57
56
  expect do
58
57
  user.profile_attributes = {identifier: profile.identifier.to_s, first_name: 'User 1', _destroy: '1'}
59
- user.save { true }
60
58
  end.to change { user.profile.first_name }.to('User 1')
61
59
  end
62
60
 
@@ -67,14 +65,12 @@ shared_examples 'nested attributes' do
67
65
  specify do
68
66
  expect do
69
67
  user.profile_attributes = {first_name: 'User 1', _destroy: '1'}
70
- user.save { true }
71
68
  end.not_to change { user.profile.first_name }
72
69
  end
73
- specify { expect { user.profile_attributes = {identifier: profile.identifier.to_s, first_name: 'User 1', _destroy: '1'} }.to change { user.profile.first_name }.to('User 1') }
70
+ specify { expect { user.profile_attributes = {identifier: profile.identifier.to_s, first_name: 'User 1', _destroy: '1'} }.to change { user.profile }.to(nil) }
74
71
  specify do
75
72
  expect do
76
73
  user.profile_attributes = {identifier: profile.identifier.to_s, first_name: 'User 1', _destroy: '1'}
77
- user.save { true }
78
74
  end.to change { user.profile }.to(nil)
79
75
  end
80
76
  end
@@ -92,8 +88,6 @@ shared_examples 'nested attributes' do
92
88
  context 'not primary' do
93
89
  before do
94
90
  stub_model :profile do
95
- include Granite::Form::Model::Lifecycle
96
-
97
91
  attribute :identifier, Integer
98
92
  attribute :first_name, String
99
93
  end
@@ -245,7 +239,6 @@ shared_examples 'nested attributes' do
245
239
  {slug: projects.first.slug.to_i, title: 'Project 3', _destroy: '1'},
246
240
  {title: 'Project 4', _destroy: '1'}
247
241
  ]
248
- user.save { true }
249
242
  end
250
243
  .to change { user.projects.map(&:title) }.to(['Project 3', 'Project 2'])
251
244
  end
@@ -259,16 +252,6 @@ shared_examples 'nested attributes' do
259
252
  {slug: projects.first.slug.to_i, title: 'Project 3', _destroy: '1'},
260
253
  {title: 'Project 4', _destroy: '1'}
261
254
  ]
262
- end
263
- .to change { user.projects.map(&:title) }.to(['Project 3', 'Project 2'])
264
- end
265
- specify do
266
- expect do
267
- user.projects_attributes = [
268
- {slug: projects.first.slug.to_i, title: 'Project 3', _destroy: '1'},
269
- {title: 'Project 4', _destroy: '1'}
270
- ]
271
- user.save { true }
272
255
  end
273
256
  .to change { user.projects.map(&:title) }.to(['Project 2'])
274
257
  end
@@ -303,7 +286,6 @@ shared_examples 'nested attributes' do
303
286
  before do
304
287
  stub_model :project do
305
288
  include Granite::Form::Model::Primary
306
- include Granite::Form::Model::Lifecycle
307
289
 
308
290
  attribute :slug, String
309
291
  attribute :title, String
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: granite-form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
- - pyromaniac
7
+ - Toptal Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-12 00:00:00.000000000 Z
11
+ date: 2023-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '5.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.0'
26
+ version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '4.0'
33
+ version: '5.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '4.0'
40
+ version: '5.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: appraisal
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pg
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rake
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -136,20 +150,6 @@ dependencies:
136
150
  - - '='
137
151
  - !ruby/object:Gem::Version
138
152
  version: 0.52.1
139
- - !ruby/object:Gem::Dependency
140
- name: sqlite3
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: uuidtools
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -170,28 +170,28 @@ dependencies:
170
170
  requirements:
171
171
  - - ">="
172
172
  - !ruby/object:Gem::Version
173
- version: '4.0'
173
+ version: '5.0'
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
- version: '4.0'
180
+ version: '5.0'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: activesupport
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
185
  - - ">="
186
186
  - !ruby/object:Gem::Version
187
- version: '4.0'
187
+ version: '5.0'
188
188
  type: :runtime
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - ">="
193
193
  - !ruby/object:Gem::Version
194
- version: '4.0'
194
+ version: '5.0'
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: tzinfo
197
197
  requirement: !ruby/object:Gem::Requirement
@@ -207,16 +207,14 @@ dependencies:
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
209
  description: Making object from any hash or hash array
210
- email:
211
- - kinwizard@gmail.com
210
+ email:
212
211
  executables: []
213
212
  extensions: []
214
213
  extra_rdoc_files: []
215
214
  files:
216
215
  - ".codeclimate.yml"
217
216
  - ".github/CODEOWNERS"
218
- - ".github/workflows/ci.yml"
219
- - ".github/workflows/main.yml"
217
+ - ".github/workflows/ruby.yml"
220
218
  - ".gitignore"
221
219
  - ".rspec"
222
220
  - ".rubocop.yml"
@@ -228,7 +226,7 @@ files:
228
226
  - LICENSE
229
227
  - README.md
230
228
  - Rakefile
231
- - gemfiles/rails.4.2.gemfile
229
+ - docker-compose.yml
232
230
  - gemfiles/rails.5.0.gemfile
233
231
  - gemfiles/rails.5.1.gemfile
234
232
  - gemfiles/rails.5.2.gemfile
@@ -270,25 +268,22 @@ files:
270
268
  - lib/granite/form/model/attributes.rb
271
269
  - lib/granite/form/model/attributes/attribute.rb
272
270
  - lib/granite/form/model/attributes/base.rb
273
- - lib/granite/form/model/attributes/collection.rb
274
- - lib/granite/form/model/attributes/dictionary.rb
275
- - lib/granite/form/model/attributes/localized.rb
276
271
  - lib/granite/form/model/attributes/reference_many.rb
277
272
  - lib/granite/form/model/attributes/reference_one.rb
278
273
  - lib/granite/form/model/attributes/reflections/attribute.rb
279
274
  - lib/granite/form/model/attributes/reflections/base.rb
275
+ - lib/granite/form/model/attributes/reflections/base/build_type_definition.rb
280
276
  - lib/granite/form/model/attributes/reflections/collection.rb
277
+ - lib/granite/form/model/attributes/reflections/collection/build_type_definition.rb
281
278
  - lib/granite/form/model/attributes/reflections/dictionary.rb
282
- - lib/granite/form/model/attributes/reflections/localized.rb
279
+ - lib/granite/form/model/attributes/reflections/dictionary/build_type_definition.rb
283
280
  - lib/granite/form/model/attributes/reflections/reference_many.rb
284
281
  - lib/granite/form/model/attributes/reflections/reference_one.rb
285
282
  - lib/granite/form/model/attributes/reflections/represents.rb
283
+ - lib/granite/form/model/attributes/reflections/represents/build_type_definition.rb
286
284
  - lib/granite/form/model/attributes/represents.rb
287
- - lib/granite/form/model/callbacks.rb
288
285
  - lib/granite/form/model/conventions.rb
289
286
  - lib/granite/form/model/dirty.rb
290
- - lib/granite/form/model/lifecycle.rb
291
- - lib/granite/form/model/localization.rb
292
287
  - lib/granite/form/model/persistence.rb
293
288
  - lib/granite/form/model/primary.rb
294
289
  - lib/granite/form/model/representation.rb
@@ -302,9 +297,12 @@ files:
302
297
  - lib/granite/form/types/array.rb
303
298
  - lib/granite/form/types/big_decimal.rb
304
299
  - lib/granite/form/types/boolean.rb
300
+ - lib/granite/form/types/collection.rb
305
301
  - lib/granite/form/types/date.rb
306
302
  - lib/granite/form/types/date_time.rb
303
+ - lib/granite/form/types/dictionary.rb
307
304
  - lib/granite/form/types/float.rb
305
+ - lib/granite/form/types/has_subtype.rb
308
306
  - lib/granite/form/types/hash_with_action_controller_parameters.rb
309
307
  - lib/granite/form/types/integer.rb
310
308
  - lib/granite/form/types/object.rb
@@ -312,6 +310,7 @@ files:
312
310
  - lib/granite/form/types/time.rb
313
311
  - lib/granite/form/types/uuid.rb
314
312
  - lib/granite/form/undefined_class.rb
313
+ - lib/granite/form/util.rb
315
314
  - lib/granite/form/version.rb
316
315
  - spec/granite/form/active_record/associations_spec.rb
317
316
  - spec/granite/form/active_record/nested_attributes_spec.rb
@@ -332,21 +331,19 @@ files:
332
331
  - spec/granite/form/model/associations_spec.rb
333
332
  - spec/granite/form/model/attributes/attribute_spec.rb
334
333
  - spec/granite/form/model/attributes/base_spec.rb
335
- - spec/granite/form/model/attributes/collection_spec.rb
336
- - spec/granite/form/model/attributes/dictionary_spec.rb
337
- - spec/granite/form/model/attributes/localized_spec.rb
338
334
  - spec/granite/form/model/attributes/reflections/attribute_spec.rb
335
+ - spec/granite/form/model/attributes/reflections/base/build_type_definition_spec.rb
339
336
  - spec/granite/form/model/attributes/reflections/base_spec.rb
337
+ - spec/granite/form/model/attributes/reflections/collection/build_type_definition_spec.rb
340
338
  - spec/granite/form/model/attributes/reflections/collection_spec.rb
339
+ - spec/granite/form/model/attributes/reflections/dictionary/build_type_definition_spec.rb
341
340
  - spec/granite/form/model/attributes/reflections/dictionary_spec.rb
342
- - spec/granite/form/model/attributes/reflections/localized_spec.rb
341
+ - spec/granite/form/model/attributes/reflections/represents/build_type_definition_spec.rb
343
342
  - spec/granite/form/model/attributes/reflections/represents_spec.rb
344
343
  - spec/granite/form/model/attributes/represents_spec.rb
345
344
  - spec/granite/form/model/attributes_spec.rb
346
- - spec/granite/form/model/callbacks_spec.rb
347
345
  - spec/granite/form/model/conventions_spec.rb
348
346
  - spec/granite/form/model/dirty_spec.rb
349
- - spec/granite/form/model/lifecycle_spec.rb
350
347
  - spec/granite/form/model/persistence_spec.rb
351
348
  - spec/granite/form/model/primary_spec.rb
352
349
  - spec/granite/form/model/representation_spec.rb
@@ -359,23 +356,28 @@ files:
359
356
  - spec/granite/form/types/array_spec.rb
360
357
  - spec/granite/form/types/big_decimal_spec.rb
361
358
  - spec/granite/form/types/boolean_spec.rb
359
+ - spec/granite/form/types/collection_spec.rb
362
360
  - spec/granite/form/types/date_spec.rb
363
361
  - spec/granite/form/types/date_time_spec.rb
362
+ - spec/granite/form/types/dictionary_spec.rb
364
363
  - spec/granite/form/types/float_spec.rb
364
+ - spec/granite/form/types/has_subtype_spec.rb
365
365
  - spec/granite/form/types/hash_with_action_controller_parameters_spec.rb
366
366
  - spec/granite/form/types/integer_spec.rb
367
367
  - spec/granite/form/types/object_spec.rb
368
368
  - spec/granite/form/types/string_spec.rb
369
369
  - spec/granite/form/types/time_spec.rb
370
370
  - spec/granite/form/types/uuid_spec.rb
371
+ - spec/granite/form/util_spec.rb
371
372
  - spec/granite/form_spec.rb
372
373
  - spec/spec_helper.rb
374
+ - spec/support/active_record.rb
373
375
  - spec/support/model_helpers.rb
374
376
  - spec/support/muffle_helper.rb
375
377
  - spec/support/shared/nested_attribute_examples.rb
376
378
  - spec/support/shared/type_examples.rb
377
379
  - spec/support/translations.rb
378
- homepage: ''
380
+ homepage: https://github.com/toptal/granite-form
379
381
  licenses: []
380
382
  metadata: {}
381
383
  post_install_message:
@@ -386,7 +388,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
386
388
  requirements:
387
389
  - - ">="
388
390
  - !ruby/object:Gem::Version
389
- version: '0'
391
+ version: 2.4.0
390
392
  required_rubygems_version: !ruby/object:Gem::Requirement
391
393
  requirements:
392
394
  - - ">="
@@ -417,21 +419,19 @@ test_files:
417
419
  - spec/granite/form/model/associations_spec.rb
418
420
  - spec/granite/form/model/attributes/attribute_spec.rb
419
421
  - spec/granite/form/model/attributes/base_spec.rb
420
- - spec/granite/form/model/attributes/collection_spec.rb
421
- - spec/granite/form/model/attributes/dictionary_spec.rb
422
- - spec/granite/form/model/attributes/localized_spec.rb
423
422
  - spec/granite/form/model/attributes/reflections/attribute_spec.rb
423
+ - spec/granite/form/model/attributes/reflections/base/build_type_definition_spec.rb
424
424
  - spec/granite/form/model/attributes/reflections/base_spec.rb
425
+ - spec/granite/form/model/attributes/reflections/collection/build_type_definition_spec.rb
425
426
  - spec/granite/form/model/attributes/reflections/collection_spec.rb
427
+ - spec/granite/form/model/attributes/reflections/dictionary/build_type_definition_spec.rb
426
428
  - spec/granite/form/model/attributes/reflections/dictionary_spec.rb
427
- - spec/granite/form/model/attributes/reflections/localized_spec.rb
429
+ - spec/granite/form/model/attributes/reflections/represents/build_type_definition_spec.rb
428
430
  - spec/granite/form/model/attributes/reflections/represents_spec.rb
429
431
  - spec/granite/form/model/attributes/represents_spec.rb
430
432
  - spec/granite/form/model/attributes_spec.rb
431
- - spec/granite/form/model/callbacks_spec.rb
432
433
  - spec/granite/form/model/conventions_spec.rb
433
434
  - spec/granite/form/model/dirty_spec.rb
434
- - spec/granite/form/model/lifecycle_spec.rb
435
435
  - spec/granite/form/model/persistence_spec.rb
436
436
  - spec/granite/form/model/primary_spec.rb
437
437
  - spec/granite/form/model/representation_spec.rb
@@ -444,17 +444,22 @@ test_files:
444
444
  - spec/granite/form/types/array_spec.rb
445
445
  - spec/granite/form/types/big_decimal_spec.rb
446
446
  - spec/granite/form/types/boolean_spec.rb
447
+ - spec/granite/form/types/collection_spec.rb
447
448
  - spec/granite/form/types/date_spec.rb
448
449
  - spec/granite/form/types/date_time_spec.rb
450
+ - spec/granite/form/types/dictionary_spec.rb
449
451
  - spec/granite/form/types/float_spec.rb
452
+ - spec/granite/form/types/has_subtype_spec.rb
450
453
  - spec/granite/form/types/hash_with_action_controller_parameters_spec.rb
451
454
  - spec/granite/form/types/integer_spec.rb
452
455
  - spec/granite/form/types/object_spec.rb
453
456
  - spec/granite/form/types/string_spec.rb
454
457
  - spec/granite/form/types/time_spec.rb
455
458
  - spec/granite/form/types/uuid_spec.rb
459
+ - spec/granite/form/util_spec.rb
456
460
  - spec/granite/form_spec.rb
457
461
  - spec/spec_helper.rb
462
+ - spec/support/active_record.rb
458
463
  - spec/support/model_helpers.rb
459
464
  - spec/support/muffle_helper.rb
460
465
  - spec/support/shared/nested_attribute_examples.rb
@@ -1,29 +0,0 @@
1
- name: Ruby
2
-
3
- on: [push]
4
-
5
- jobs:
6
- spec:
7
- runs-on: ubuntu-latest
8
- name: Run specs in ruby v${{ matrix.ruby }} rails v${{ matrix.rails }}
9
- strategy:
10
- matrix:
11
- ruby: [ '2.6', '2.7', '3.0' ]
12
- rails: [ '6.0', '6.1' ]
13
- steps:
14
- - uses: actions/checkout@v2
15
-
16
- - name: Set up Ruby
17
- uses: ruby/setup-ruby@v1
18
- with:
19
- ruby-version: ${{ matrix.ruby }}
20
-
21
- - name: Install dependencies
22
- env:
23
- BUNDLE_GEMFILE: gemfiles/rails.${{ matrix.rails }}.gemfile
24
- run: bundle install
25
-
26
- - name: Run specs
27
- env:
28
- BUNDLE_GEMFILE: gemfiles/rails.${{ matrix.rails }}.gemfile
29
- run: bundle exec rake spec