cuprum-collections 0.3.0.rc.0 → 0.4.0.rc.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +56 -4
  3. data/DEVELOPMENT.md +2 -2
  4. data/README.md +13 -11
  5. data/lib/cuprum/collections/association.rb +256 -0
  6. data/lib/cuprum/collections/associations/belongs_to.rb +32 -0
  7. data/lib/cuprum/collections/associations/has_many.rb +23 -0
  8. data/lib/cuprum/collections/associations/has_one.rb +23 -0
  9. data/lib/cuprum/collections/associations.rb +10 -0
  10. data/lib/cuprum/collections/basic/collection.rb +39 -74
  11. data/lib/cuprum/collections/basic/commands/find_many.rb +1 -1
  12. data/lib/cuprum/collections/basic/commands/find_matching.rb +1 -1
  13. data/lib/cuprum/collections/basic/repository.rb +9 -33
  14. data/lib/cuprum/collections/basic.rb +1 -0
  15. data/lib/cuprum/collections/collection.rb +154 -0
  16. data/lib/cuprum/collections/commands/associations/find_many.rb +161 -0
  17. data/lib/cuprum/collections/commands/associations/require_many.rb +48 -0
  18. data/lib/cuprum/collections/commands/associations.rb +13 -0
  19. data/lib/cuprum/collections/commands/find_one_matching.rb +1 -1
  20. data/lib/cuprum/collections/commands.rb +1 -0
  21. data/lib/cuprum/collections/errors/abstract_find_error.rb +1 -1
  22. data/lib/cuprum/collections/relation.rb +401 -0
  23. data/lib/cuprum/collections/repository.rb +71 -4
  24. data/lib/cuprum/collections/resource.rb +65 -0
  25. data/lib/cuprum/collections/rspec/contracts/association_contracts.rb +2137 -0
  26. data/lib/cuprum/collections/rspec/contracts/basic/command_contracts.rb +484 -0
  27. data/lib/cuprum/collections/rspec/contracts/basic.rb +11 -0
  28. data/lib/cuprum/collections/rspec/contracts/collection_contracts.rb +429 -0
  29. data/lib/cuprum/collections/rspec/contracts/command_contracts.rb +1462 -0
  30. data/lib/cuprum/collections/rspec/contracts/query_contracts.rb +1093 -0
  31. data/lib/cuprum/collections/rspec/contracts/relation_contracts.rb +1381 -0
  32. data/lib/cuprum/collections/rspec/contracts/repository_contracts.rb +605 -0
  33. data/lib/cuprum/collections/rspec/contracts.rb +23 -0
  34. data/lib/cuprum/collections/rspec/fixtures.rb +85 -82
  35. data/lib/cuprum/collections/rspec.rb +4 -1
  36. data/lib/cuprum/collections/version.rb +2 -2
  37. data/lib/cuprum/collections.rb +9 -4
  38. metadata +23 -19
  39. data/lib/cuprum/collections/base.rb +0 -11
  40. data/lib/cuprum/collections/basic/rspec/command_contract.rb +0 -392
  41. data/lib/cuprum/collections/rspec/assign_one_command_contract.rb +0 -168
  42. data/lib/cuprum/collections/rspec/build_one_command_contract.rb +0 -93
  43. data/lib/cuprum/collections/rspec/collection_contract.rb +0 -190
  44. data/lib/cuprum/collections/rspec/destroy_one_command_contract.rb +0 -108
  45. data/lib/cuprum/collections/rspec/find_many_command_contract.rb +0 -407
  46. data/lib/cuprum/collections/rspec/find_matching_command_contract.rb +0 -194
  47. data/lib/cuprum/collections/rspec/find_one_command_contract.rb +0 -157
  48. data/lib/cuprum/collections/rspec/insert_one_command_contract.rb +0 -84
  49. data/lib/cuprum/collections/rspec/query_builder_contract.rb +0 -92
  50. data/lib/cuprum/collections/rspec/query_contract.rb +0 -650
  51. data/lib/cuprum/collections/rspec/querying_contract.rb +0 -298
  52. data/lib/cuprum/collections/rspec/repository_contract.rb +0 -235
  53. data/lib/cuprum/collections/rspec/update_one_command_contract.rb +0 -80
  54. data/lib/cuprum/collections/rspec/validate_one_command_contract.rb +0 -96
@@ -4,86 +4,89 @@ require 'cuprum/collections/rspec'
4
4
 
5
5
  module Cuprum::Collections::RSpec
6
6
  # Sample data for validating collection implementations.
7
- BOOKS_FIXTURES = [
8
- {
9
- 'id' => 0,
10
- 'title' => 'The Hobbit',
11
- 'author' => 'J.R.R. Tolkien',
12
- 'series' => nil,
13
- 'category' => 'Science Fiction and Fantasy',
14
- 'published_at' => '1937-09-21'
15
- },
16
- {
17
- 'id' => 1,
18
- 'title' => 'The Silmarillion',
19
- 'author' => 'J.R.R. Tolkien',
20
- 'series' => nil,
21
- 'category' => 'Science Fiction and Fantasy',
22
- 'published_at' => '1977-09-15'
23
- },
24
- {
25
- 'id' => 2,
26
- 'title' => 'The Fellowship of the Ring',
27
- 'author' => 'J.R.R. Tolkien',
28
- 'series' => 'The Lord of the Rings',
29
- 'category' => 'Science Fiction and Fantasy',
30
- 'published_at' => '1954-07-29'
31
- },
32
- {
33
- 'id' => 3,
34
- 'title' => 'The Two Towers',
35
- 'author' => 'J.R.R. Tolkien',
36
- 'series' => 'The Lord of the Rings',
37
- 'category' => 'Science Fiction and Fantasy',
38
- 'published_at' => '1954-11-11'
39
- },
40
- {
41
- 'id' => 4,
42
- 'title' => 'The Return of the King',
43
- 'author' => 'J.R.R. Tolkien',
44
- 'series' => 'The Lord of the Rings',
45
- 'category' => 'Science Fiction and Fantasy',
46
- 'published_at' => '1955-10-20'
47
- },
48
- {
49
- 'id' => 5,
50
- 'title' => 'The Word for World is Forest',
51
- 'author' => 'Ursula K. LeGuin',
52
- 'series' => nil,
53
- 'category' => 'Science Fiction and Fantasy',
54
- 'published_at' => '1972-03-13'
55
- },
56
- {
57
- 'id' => 6,
58
- 'title' => 'The Ones Who Walk Away From Omelas',
59
- 'author' => 'Ursula K. LeGuin',
60
- 'series' => nil,
61
- 'category' => 'Science Fiction and Fantasy',
62
- 'published_at' => '1973-10-01'
63
- },
64
- {
65
- 'id' => 7,
66
- 'title' => 'A Wizard of Earthsea',
67
- 'author' => 'Ursula K. LeGuin',
68
- 'series' => 'Earthsea',
69
- 'category' => 'Science Fiction and Fantasy',
70
- 'published_at' => '1968-11-01'
71
- },
72
- {
73
- 'id' => 8,
74
- 'title' => 'The Tombs of Atuan',
75
- 'author' => 'Ursula K. LeGuin',
76
- 'series' => 'Earthsea',
77
- 'category' => 'Science Fiction and Fantasy',
78
- 'published_at' => '1970-12-01'
79
- },
80
- {
81
- 'id' => 9,
82
- 'title' => 'The Farthest Shore',
83
- 'author' => 'Ursula K. LeGuin',
84
- 'series' => 'Earthsea',
85
- 'category' => 'Science Fiction and Fantasy',
86
- 'published_at' => '1972-09-01'
87
- }
88
- ].map(&:freeze).freeze
7
+ module Fixtures
8
+ # Sample data for Book objects.
9
+ BOOKS_FIXTURES = [
10
+ {
11
+ 'id' => 0,
12
+ 'title' => 'The Hobbit',
13
+ 'author' => 'J.R.R. Tolkien',
14
+ 'series' => nil,
15
+ 'category' => 'Science Fiction and Fantasy',
16
+ 'published_at' => '1937-09-21'
17
+ },
18
+ {
19
+ 'id' => 1,
20
+ 'title' => 'The Silmarillion',
21
+ 'author' => 'J.R.R. Tolkien',
22
+ 'series' => nil,
23
+ 'category' => 'Science Fiction and Fantasy',
24
+ 'published_at' => '1977-09-15'
25
+ },
26
+ {
27
+ 'id' => 2,
28
+ 'title' => 'The Fellowship of the Ring',
29
+ 'author' => 'J.R.R. Tolkien',
30
+ 'series' => 'The Lord of the Rings',
31
+ 'category' => 'Science Fiction and Fantasy',
32
+ 'published_at' => '1954-07-29'
33
+ },
34
+ {
35
+ 'id' => 3,
36
+ 'title' => 'The Two Towers',
37
+ 'author' => 'J.R.R. Tolkien',
38
+ 'series' => 'The Lord of the Rings',
39
+ 'category' => 'Science Fiction and Fantasy',
40
+ 'published_at' => '1954-11-11'
41
+ },
42
+ {
43
+ 'id' => 4,
44
+ 'title' => 'The Return of the King',
45
+ 'author' => 'J.R.R. Tolkien',
46
+ 'series' => 'The Lord of the Rings',
47
+ 'category' => 'Science Fiction and Fantasy',
48
+ 'published_at' => '1955-10-20'
49
+ },
50
+ {
51
+ 'id' => 5,
52
+ 'title' => 'The Word for World is Forest',
53
+ 'author' => 'Ursula K. LeGuin',
54
+ 'series' => nil,
55
+ 'category' => 'Science Fiction and Fantasy',
56
+ 'published_at' => '1972-03-13'
57
+ },
58
+ {
59
+ 'id' => 6,
60
+ 'title' => 'The Ones Who Walk Away From Omelas',
61
+ 'author' => 'Ursula K. LeGuin',
62
+ 'series' => nil,
63
+ 'category' => 'Science Fiction and Fantasy',
64
+ 'published_at' => '1973-10-01'
65
+ },
66
+ {
67
+ 'id' => 7,
68
+ 'title' => 'A Wizard of Earthsea',
69
+ 'author' => 'Ursula K. LeGuin',
70
+ 'series' => 'Earthsea',
71
+ 'category' => 'Science Fiction and Fantasy',
72
+ 'published_at' => '1968-11-01'
73
+ },
74
+ {
75
+ 'id' => 8,
76
+ 'title' => 'The Tombs of Atuan',
77
+ 'author' => 'Ursula K. LeGuin',
78
+ 'series' => 'Earthsea',
79
+ 'category' => 'Science Fiction and Fantasy',
80
+ 'published_at' => '1970-12-01'
81
+ },
82
+ {
83
+ 'id' => 9,
84
+ 'title' => 'The Farthest Shore',
85
+ 'author' => 'Ursula K. LeGuin',
86
+ 'series' => 'Earthsea',
87
+ 'category' => 'Science Fiction and Fantasy',
88
+ 'published_at' => '1972-09-01'
89
+ }
90
+ ].map(&:freeze).freeze
91
+ end
89
92
  end
@@ -4,5 +4,8 @@ require 'cuprum/collections'
4
4
 
5
5
  module Cuprum::Collections
6
6
  # Namespace for RSpec contracts, which validate collection implementations.
7
- module RSpec; end
7
+ module RSpec
8
+ autoload :Contracts, 'cuprum/collections/rspec/contracts'
9
+ autoload :Fixtures, 'cuprum/collections/rspec/fixtures'
10
+ end
8
11
  end
@@ -11,11 +11,11 @@ module Cuprum
11
11
  # Major version.
12
12
  MAJOR = 0
13
13
  # Minor version.
14
- MINOR = 3
14
+ MINOR = 4
15
15
  # Patch version.
16
16
  PATCH = 0
17
17
  # Prerelease version.
18
- PRERELEASE = :rc
18
+ PRERELEASE = 'rc'
19
19
  # Build metadata.
20
20
  BUILD = 0
21
21
 
@@ -6,10 +6,15 @@ require 'cuprum'
6
6
  module Cuprum
7
7
  # A data abstraction layer based on the Cuprum library.
8
8
  module Collections
9
- autoload :Base, 'cuprum/collections/base'
10
- autoload :Basic, 'cuprum/collections/basic'
11
- autoload :Command, 'cuprum/collections/command'
12
- autoload :Errors, 'cuprum/collections/errors'
9
+ autoload :Association, 'cuprum/collections/association'
10
+ autoload :Associations, 'cuprum/collections/associations'
11
+ autoload :Basic, 'cuprum/collections/basic'
12
+ autoload :Collection, 'cuprum/collections/collection'
13
+ autoload :Command, 'cuprum/collections/command'
14
+ autoload :Errors, 'cuprum/collections/errors'
15
+ autoload :Relation, 'cuprum/collections/relation'
16
+ autoload :Repository, 'cuprum/collections/repository'
17
+ autoload :Resource, 'cuprum/collections/resource'
13
18
 
14
19
  # @return [String] the absolute path to the gem directory.
15
20
  def self.gem_path
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuprum-collections
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.rc.0
4
+ version: 0.4.0.rc.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob "Merlin" Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-26 00:00:00.000000000 Z
11
+ date: 2023-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cuprum
@@ -51,7 +51,11 @@ files:
51
51
  - LICENSE
52
52
  - README.md
53
53
  - lib/cuprum/collections.rb
54
- - lib/cuprum/collections/base.rb
54
+ - lib/cuprum/collections/association.rb
55
+ - lib/cuprum/collections/associations.rb
56
+ - lib/cuprum/collections/associations/belongs_to.rb
57
+ - lib/cuprum/collections/associations/has_many.rb
58
+ - lib/cuprum/collections/associations/has_one.rb
55
59
  - lib/cuprum/collections/basic.rb
56
60
  - lib/cuprum/collections/basic/collection.rb
57
61
  - lib/cuprum/collections/basic/command.rb
@@ -69,12 +73,15 @@ files:
69
73
  - lib/cuprum/collections/basic/query_builder.rb
70
74
  - lib/cuprum/collections/basic/repository.rb
71
75
  - lib/cuprum/collections/basic/rspec.rb
72
- - lib/cuprum/collections/basic/rspec/command_contract.rb
76
+ - lib/cuprum/collections/collection.rb
73
77
  - lib/cuprum/collections/command.rb
74
78
  - lib/cuprum/collections/commands.rb
75
79
  - lib/cuprum/collections/commands/abstract_find_many.rb
76
80
  - lib/cuprum/collections/commands/abstract_find_matching.rb
77
81
  - lib/cuprum/collections/commands/abstract_find_one.rb
82
+ - lib/cuprum/collections/commands/associations.rb
83
+ - lib/cuprum/collections/commands/associations/find_many.rb
84
+ - lib/cuprum/collections/commands/associations/require_many.rb
78
85
  - lib/cuprum/collections/commands/create.rb
79
86
  - lib/cuprum/collections/commands/find_one_matching.rb
80
87
  - lib/cuprum/collections/commands/update.rb
@@ -106,23 +113,20 @@ files:
106
113
  - lib/cuprum/collections/queries/parse_strategy.rb
107
114
  - lib/cuprum/collections/query.rb
108
115
  - lib/cuprum/collections/query_builder.rb
116
+ - lib/cuprum/collections/relation.rb
109
117
  - lib/cuprum/collections/repository.rb
118
+ - lib/cuprum/collections/resource.rb
110
119
  - lib/cuprum/collections/rspec.rb
111
- - lib/cuprum/collections/rspec/assign_one_command_contract.rb
112
- - lib/cuprum/collections/rspec/build_one_command_contract.rb
113
- - lib/cuprum/collections/rspec/collection_contract.rb
114
- - lib/cuprum/collections/rspec/destroy_one_command_contract.rb
115
- - lib/cuprum/collections/rspec/find_many_command_contract.rb
116
- - lib/cuprum/collections/rspec/find_matching_command_contract.rb
117
- - lib/cuprum/collections/rspec/find_one_command_contract.rb
120
+ - lib/cuprum/collections/rspec/contracts.rb
121
+ - lib/cuprum/collections/rspec/contracts/association_contracts.rb
122
+ - lib/cuprum/collections/rspec/contracts/basic.rb
123
+ - lib/cuprum/collections/rspec/contracts/basic/command_contracts.rb
124
+ - lib/cuprum/collections/rspec/contracts/collection_contracts.rb
125
+ - lib/cuprum/collections/rspec/contracts/command_contracts.rb
126
+ - lib/cuprum/collections/rspec/contracts/query_contracts.rb
127
+ - lib/cuprum/collections/rspec/contracts/relation_contracts.rb
128
+ - lib/cuprum/collections/rspec/contracts/repository_contracts.rb
118
129
  - lib/cuprum/collections/rspec/fixtures.rb
119
- - lib/cuprum/collections/rspec/insert_one_command_contract.rb
120
- - lib/cuprum/collections/rspec/query_builder_contract.rb
121
- - lib/cuprum/collections/rspec/query_contract.rb
122
- - lib/cuprum/collections/rspec/querying_contract.rb
123
- - lib/cuprum/collections/rspec/repository_contract.rb
124
- - lib/cuprum/collections/rspec/update_one_command_contract.rb
125
- - lib/cuprum/collections/rspec/validate_one_command_contract.rb
126
130
  - lib/cuprum/collections/version.rb
127
131
  homepage: http://sleepingkingstudios.com
128
132
  licenses:
@@ -146,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
150
  - !ruby/object:Gem::Version
147
151
  version: 1.3.1
148
152
  requirements: []
149
- rubygems_version: 3.4.13
153
+ rubygems_version: 3.4.21
150
154
  signing_key:
151
155
  specification_version: 4
152
156
  summary: A data abstraction layer based on the Cuprum library.
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'cuprum/command_factory'
4
-
5
- require 'cuprum/collections'
6
-
7
- module Cuprum::Collections
8
- # Abstract base class for Collection factories.
9
- class Base < Cuprum::CommandFactory
10
- end
11
- end