rom 2.0.2 → 4.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +35 -430
  3. data/LICENSE +1 -1
  4. data/README.md +83 -11
  5. data/lib/rom/version.rb +1 -1
  6. data/lib/rom.rb +3 -46
  7. metadata +30 -236
  8. data/.gitignore +0 -24
  9. data/.rspec +0 -3
  10. data/.rubocop.yml +0 -87
  11. data/.rubocop_todo.yml +0 -46
  12. data/.travis.yml +0 -28
  13. data/CODE_OF_CONDUCT.md +0 -13
  14. data/CONTRIBUTING.md +0 -1
  15. data/Gemfile +0 -41
  16. data/Guardfile +0 -24
  17. data/Rakefile +0 -22
  18. data/lib/rom/association_set.rb +0 -26
  19. data/lib/rom/command.rb +0 -173
  20. data/lib/rom/command_registry.rb +0 -153
  21. data/lib/rom/commands/class_interface.rb +0 -148
  22. data/lib/rom/commands/composite.rb +0 -54
  23. data/lib/rom/commands/create.rb +0 -13
  24. data/lib/rom/commands/delete.rb +0 -14
  25. data/lib/rom/commands/graph/builder.rb +0 -176
  26. data/lib/rom/commands/graph/class_interface.rb +0 -62
  27. data/lib/rom/commands/graph/input_evaluator.rb +0 -62
  28. data/lib/rom/commands/graph.rb +0 -103
  29. data/lib/rom/commands/lazy/create.rb +0 -23
  30. data/lib/rom/commands/lazy/delete.rb +0 -27
  31. data/lib/rom/commands/lazy/update.rb +0 -34
  32. data/lib/rom/commands/lazy.rb +0 -99
  33. data/lib/rom/commands/result.rb +0 -96
  34. data/lib/rom/commands/update.rb +0 -14
  35. data/lib/rom/commands.rb +0 -3
  36. data/lib/rom/configuration.rb +0 -88
  37. data/lib/rom/configuration_dsl/command.rb +0 -43
  38. data/lib/rom/configuration_dsl/command_dsl.rb +0 -35
  39. data/lib/rom/configuration_dsl/mapper.rb +0 -37
  40. data/lib/rom/configuration_dsl/mapper_dsl.rb +0 -44
  41. data/lib/rom/configuration_dsl/relation.rb +0 -26
  42. data/lib/rom/configuration_dsl.rb +0 -78
  43. data/lib/rom/configuration_plugin.rb +0 -17
  44. data/lib/rom/constants.rb +0 -30
  45. data/lib/rom/container.rb +0 -231
  46. data/lib/rom/create_container.rb +0 -61
  47. data/lib/rom/environment.rb +0 -70
  48. data/lib/rom/gateway.rb +0 -154
  49. data/lib/rom/global/plugin_dsl.rb +0 -49
  50. data/lib/rom/global.rb +0 -60
  51. data/lib/rom/lint/enumerable_dataset.rb +0 -54
  52. data/lib/rom/lint/gateway.rb +0 -94
  53. data/lib/rom/lint/linter.rb +0 -78
  54. data/lib/rom/lint/spec.rb +0 -20
  55. data/lib/rom/lint/test.rb +0 -98
  56. data/lib/rom/mapper_registry.rb +0 -35
  57. data/lib/rom/memory/commands.rb +0 -58
  58. data/lib/rom/memory/dataset.rb +0 -98
  59. data/lib/rom/memory/gateway.rb +0 -64
  60. data/lib/rom/memory/relation.rb +0 -49
  61. data/lib/rom/memory/storage.rb +0 -59
  62. data/lib/rom/memory/types.rb +0 -9
  63. data/lib/rom/memory.rb +0 -4
  64. data/lib/rom/pipeline.rb +0 -106
  65. data/lib/rom/plugin.rb +0 -17
  66. data/lib/rom/plugin_base.rb +0 -31
  67. data/lib/rom/plugin_registry.rb +0 -173
  68. data/lib/rom/plugins/command/schema.rb +0 -37
  69. data/lib/rom/plugins/configuration/configuration_dsl.rb +0 -17
  70. data/lib/rom/plugins/relation/key_inference.rb +0 -46
  71. data/lib/rom/plugins/relation/registry_reader.rb +0 -32
  72. data/lib/rom/plugins/relation/view/dsl.rb +0 -32
  73. data/lib/rom/plugins/relation/view.rb +0 -95
  74. data/lib/rom/relation/class_interface.rb +0 -230
  75. data/lib/rom/relation/composite.rb +0 -46
  76. data/lib/rom/relation/curried.rb +0 -104
  77. data/lib/rom/relation/graph.rb +0 -115
  78. data/lib/rom/relation/loaded.rb +0 -118
  79. data/lib/rom/relation/materializable.rb +0 -66
  80. data/lib/rom/relation/name.rb +0 -102
  81. data/lib/rom/relation.rb +0 -172
  82. data/lib/rom/relation_registry.rb +0 -9
  83. data/lib/rom/schema/dsl.rb +0 -58
  84. data/lib/rom/schema.rb +0 -89
  85. data/lib/rom/setup/auto_registration.rb +0 -69
  86. data/lib/rom/setup/auto_registration_strategies/base.rb +0 -11
  87. data/lib/rom/setup/auto_registration_strategies/custom_namespace.rb +0 -22
  88. data/lib/rom/setup/auto_registration_strategies/no_namespace.rb +0 -19
  89. data/lib/rom/setup/auto_registration_strategies/with_namespace.rb +0 -18
  90. data/lib/rom/setup/finalize/finalize_commands.rb +0 -47
  91. data/lib/rom/setup/finalize/finalize_mappers.rb +0 -36
  92. data/lib/rom/setup/finalize/finalize_relations.rb +0 -60
  93. data/lib/rom/setup/finalize.rb +0 -146
  94. data/lib/rom/setup.rb +0 -55
  95. data/lib/rom/support/configurable.rb +0 -80
  96. data/lib/rom/types.rb +0 -18
  97. data/log/.gitkeep +0 -0
  98. data/rakelib/benchmark.rake +0 -15
  99. data/rakelib/mutant.rake +0 -19
  100. data/rakelib/rubocop.rake +0 -18
  101. data/rom.gemspec +0 -26
  102. data/spec/fixtures/app/commands/create_user.rb +0 -2
  103. data/spec/fixtures/app/mappers/user_list.rb +0 -2
  104. data/spec/fixtures/app/my_commands/create_user.rb +0 -2
  105. data/spec/fixtures/app/my_mappers/user_list.rb +0 -2
  106. data/spec/fixtures/app/my_relations/users.rb +0 -2
  107. data/spec/fixtures/app/relations/users.rb +0 -2
  108. data/spec/fixtures/custom/commands/create_user.rb +0 -6
  109. data/spec/fixtures/custom/mappers/user_list.rb +0 -6
  110. data/spec/fixtures/custom/relations/users.rb +0 -6
  111. data/spec/fixtures/lib/persistence/commands/create_user.rb +0 -6
  112. data/spec/fixtures/lib/persistence/mappers/user_list.rb +0 -6
  113. data/spec/fixtures/lib/persistence/my_commands/create_user.rb +0 -6
  114. data/spec/fixtures/lib/persistence/my_mappers/user_list.rb +0 -6
  115. data/spec/fixtures/lib/persistence/my_relations/users.rb +0 -6
  116. data/spec/fixtures/lib/persistence/relations/users.rb +0 -6
  117. data/spec/integration/command_registry_spec.rb +0 -60
  118. data/spec/integration/commands/create_spec.rb +0 -177
  119. data/spec/integration/commands/delete_spec.rb +0 -67
  120. data/spec/integration/commands/error_handling_spec.rb +0 -25
  121. data/spec/integration/commands/graph_builder_spec.rb +0 -213
  122. data/spec/integration/commands/graph_spec.rb +0 -288
  123. data/spec/integration/commands/update_spec.rb +0 -109
  124. data/spec/integration/commands_spec.rb +0 -67
  125. data/spec/integration/mappers/combine_spec.rb +0 -117
  126. data/spec/integration/mappers/deep_embedded_spec.rb +0 -44
  127. data/spec/integration/mappers/definition_dsl_spec.rb +0 -206
  128. data/spec/integration/mappers/embedded_spec.rb +0 -62
  129. data/spec/integration/mappers/exclude_spec.rb +0 -27
  130. data/spec/integration/mappers/fold_spec.rb +0 -71
  131. data/spec/integration/mappers/group_spec.rb +0 -163
  132. data/spec/integration/mappers/overwrite_attributes_value_spec.rb +0 -51
  133. data/spec/integration/mappers/prefix_separator_spec.rb +0 -52
  134. data/spec/integration/mappers/prefix_spec.rb +0 -48
  135. data/spec/integration/mappers/prefixing_attributes_spec.rb +0 -37
  136. data/spec/integration/mappers/registering_custom_mappers_spec.rb +0 -28
  137. data/spec/integration/mappers/renaming_attributes_spec.rb +0 -125
  138. data/spec/integration/mappers/reusing_mappers_spec.rb +0 -43
  139. data/spec/integration/mappers/step_spec.rb +0 -119
  140. data/spec/integration/mappers/symbolizing_attributes_spec.rb +0 -77
  141. data/spec/integration/mappers/unfold_spec.rb +0 -92
  142. data/spec/integration/mappers/ungroup_spec.rb +0 -126
  143. data/spec/integration/mappers/unwrap_spec.rb +0 -93
  144. data/spec/integration/mappers/wrap_spec.rb +0 -155
  145. data/spec/integration/memory/commands/create_spec.rb +0 -23
  146. data/spec/integration/memory/commands/delete_spec.rb +0 -23
  147. data/spec/integration/memory/commands/update_spec.rb +0 -23
  148. data/spec/integration/multi_env_spec.rb +0 -69
  149. data/spec/integration/multi_repo_spec.rb +0 -46
  150. data/spec/integration/relations/default_dataset_spec.rb +0 -38
  151. data/spec/integration/relations/inheritance_spec.rb +0 -37
  152. data/spec/integration/relations/reading_spec.rb +0 -169
  153. data/spec/integration/relations/registry_dsl_spec.rb +0 -45
  154. data/spec/integration/repositories/extending_relations_spec.rb +0 -58
  155. data/spec/integration/repositories/setting_logger_spec.rb +0 -34
  156. data/spec/integration/setup_spec.rb +0 -160
  157. data/spec/shared/command_behavior.rb +0 -28
  158. data/spec/shared/command_graph.rb +0 -50
  159. data/spec/shared/container.rb +0 -9
  160. data/spec/shared/enumerable_dataset.rb +0 -52
  161. data/spec/shared/gateway_only.rb +0 -6
  162. data/spec/shared/materializable.rb +0 -36
  163. data/spec/shared/no_container.rb +0 -16
  164. data/spec/shared/one_behavior.rb +0 -26
  165. data/spec/shared/proxy.rb +0 -0
  166. data/spec/shared/users_and_tasks.rb +0 -10
  167. data/spec/spec_helper.rb +0 -52
  168. data/spec/support/constant_leak_finder.rb +0 -14
  169. data/spec/support/mutant.rb +0 -10
  170. data/spec/support/types.rb +0 -5
  171. data/spec/test/memory_repository_lint_test.rb +0 -27
  172. data/spec/unit/rom/association_set_spec.rb +0 -23
  173. data/spec/unit/rom/commands/graph_spec.rb +0 -191
  174. data/spec/unit/rom/commands/lazy_spec.rb +0 -307
  175. data/spec/unit/rom/commands/result_spec.rb +0 -70
  176. data/spec/unit/rom/commands_spec.rb +0 -165
  177. data/spec/unit/rom/configurable_spec.rb +0 -49
  178. data/spec/unit/rom/configuration_spec.rb +0 -61
  179. data/spec/unit/rom/container_spec.rb +0 -99
  180. data/spec/unit/rom/create_container_spec.rb +0 -151
  181. data/spec/unit/rom/environment_spec.rb +0 -123
  182. data/spec/unit/rom/gateway_spec.rb +0 -146
  183. data/spec/unit/rom/mapper_registry_spec.rb +0 -25
  184. data/spec/unit/rom/memory/commands_spec.rb +0 -43
  185. data/spec/unit/rom/memory/dataset_spec.rb +0 -31
  186. data/spec/unit/rom/memory/relation_spec.rb +0 -109
  187. data/spec/unit/rom/memory/repository_spec.rb +0 -12
  188. data/spec/unit/rom/memory/storage_spec.rb +0 -45
  189. data/spec/unit/rom/plugin_spec.rb +0 -150
  190. data/spec/unit/rom/plugins/command/schema_spec.rb +0 -66
  191. data/spec/unit/rom/plugins/relation/key_inference_spec.rb +0 -85
  192. data/spec/unit/rom/plugins/relation/view_spec.rb +0 -51
  193. data/spec/unit/rom/relation/composite_spec.rb +0 -89
  194. data/spec/unit/rom/relation/curried_spec.rb +0 -52
  195. data/spec/unit/rom/relation/graph_spec.rb +0 -92
  196. data/spec/unit/rom/relation/lazy/combine_spec.rb +0 -165
  197. data/spec/unit/rom/relation/lazy_spec.rb +0 -214
  198. data/spec/unit/rom/relation/loaded_spec.rb +0 -53
  199. data/spec/unit/rom/relation/name_spec.rb +0 -58
  200. data/spec/unit/rom/relation/schema_spec.rb +0 -117
  201. data/spec/unit/rom/relation_spec.rb +0 -237
  202. data/spec/unit/rom/schema_spec.rb +0 -10
  203. data/spec/unit/rom/setup/auto_registration_spec.rb +0 -152
@@ -1,60 +0,0 @@
1
- require 'rom/relation_registry'
2
-
3
- module ROM
4
- class Finalize
5
- class FinalizeRelations
6
- # Build relation registry of specified descendant classes
7
- #
8
- # This is used by the setup
9
- #
10
- # @param [Hash] gateways
11
- # @param [Array] relation_classes a list of relation descendants
12
- #
13
- # @api private
14
- def initialize(gateways, relation_classes)
15
- @gateways = gateways
16
- @relation_classes = relation_classes
17
- end
18
-
19
- # @return [Hash]
20
- #
21
- # @api private
22
- def run!
23
- RelationRegistry.new do |registry, relations|
24
- @relation_classes.each do |klass|
25
- relation = build_relation(klass, registry)
26
-
27
- key = relation.name.to_sym
28
-
29
- if registry.key?(key)
30
- raise RelationAlreadyDefinedError,
31
- "Relation with `register_as #{key.inspect}` registered more " \
32
- "than once"
33
- end
34
-
35
- relations[key] = relation
36
- end
37
-
38
- relations.each_value do |relation|
39
- relation.class.finalize(registry, relation)
40
- end
41
- end
42
- end
43
-
44
- # @return [ROM::Relation]
45
- #
46
- # @api private
47
- def build_relation(klass, registry)
48
- # TODO: raise a meaningful error here and add spec covering the case
49
- # where klass' gateway points to non-existant repo
50
- gateway = @gateways.fetch(klass.gateway)
51
- ds_proc = klass.dataset_proc || -> _ { self }
52
-
53
- klass.schema.finalize!(gateway) if klass.schema
54
- dataset = gateway.dataset(klass.dataset).instance_exec(klass, &ds_proc)
55
-
56
- klass.new(dataset, __registry__: registry)
57
- end
58
- end
59
- end
60
- end
@@ -1,146 +0,0 @@
1
- require 'rom/relation'
2
- require 'rom/command'
3
-
4
- require 'rom/support/registry'
5
- require 'rom/command_registry'
6
- require 'rom/mapper_registry'
7
-
8
- require 'rom/container'
9
- require 'rom/setup/finalize/finalize_commands'
10
- require 'rom/setup/finalize/finalize_relations'
11
- require 'rom/setup/finalize/finalize_mappers'
12
-
13
- # temporary
14
- require 'rom/configuration_dsl/relation'
15
-
16
- module ROM
17
- # This giant builds an container using defined classes for core parts of ROM
18
- #
19
- # It is used by the setup object after it's done gathering class definitions
20
- #
21
- # @private
22
- class Finalize
23
- attr_reader :gateways, :repo_adapter, :datasets, :gateway_map,
24
- :relation_classes, :mapper_classes, :mapper_objects, :command_classes, :config
25
-
26
- # @api private
27
- def initialize(options)
28
- @gateways = options.fetch(:gateways)
29
- @gateway_map = options.fetch(:gateway_map)
30
-
31
- @relation_classes = options.fetch(:relation_classes)
32
- @command_classes = options.fetch(:command_classes)
33
-
34
- mappers = options.fetch(:mappers, [])
35
- @mapper_classes = mappers.select { |mapper| mapper.is_a?(Class) }
36
- @mapper_objects = (mappers - @mapper_classes).reduce(:merge) || {}
37
-
38
- @config = options.fetch(:config)
39
-
40
- initialize_datasets
41
- end
42
-
43
- # Return adapter identifier for a given gateway object
44
- #
45
- # @return [Symbol]
46
- #
47
- # @api private
48
- def adapter_for(gateway)
49
- @gateway_map.fetch(gateways[gateway])
50
- end
51
-
52
- # Run the finalization process
53
- #
54
- # This creates relations, mappers and commands
55
- #
56
- # @return [Container]
57
- #
58
- # @api private
59
- def run!
60
- infer_relations
61
-
62
- relations = load_relations
63
- mappers = load_mappers
64
- commands = load_commands(relations)
65
-
66
- container = Container.new(gateways, relations, mappers, commands)
67
- container.freeze
68
- container
69
- end
70
-
71
- private
72
-
73
- # Infer all datasets using configured gateways
74
- #
75
- # Not all gateways can do that, by default an empty array is returned
76
- #
77
- # @return [Hash] gateway name => array with datasets map
78
- #
79
- # @api private
80
- def initialize_datasets
81
- @datasets = gateways.each_with_object({}) do |(key, gateway), h|
82
- infer_relations = config.gateways && config.gateways[key] && config.gateways[key][:infer_relations]
83
- h[key] = gateway.schema if infer_relations
84
- end
85
- end
86
-
87
- # Build entire relation registry from all known relation subclasses
88
- #
89
- # This includes both classes created via DSL and explicit definitions
90
- #
91
- # @api private
92
- def load_relations
93
- FinalizeRelations.new(gateways, relation_classes).run!
94
- end
95
-
96
- # @api private
97
- def load_mappers
98
- FinalizeMappers.new(mapper_classes, mapper_objects).run!
99
- end
100
-
101
- # Build entire command registries
102
- #
103
- # This includes both classes created via DSL and explicit definitions
104
- #
105
- # @api private
106
- def load_commands(relations)
107
- FinalizeCommands.new(relations, gateways, command_classes).run!
108
- end
109
-
110
- # For every dataset infered from gateways we infer a relation
111
- #
112
- # Relations explicitly defined are being skipped
113
- #
114
- # @api private
115
- def infer_relations
116
- datasets.each do |gateway, schema|
117
- schema.each do |name|
118
- if infer_relation?(gateway, name)
119
- klass = ROM::ConfigurationDSL::Relation.build_class(name, adapter: adapter_for(gateway))
120
- klass.gateway(gateway)
121
- klass.dataset(name)
122
- @relation_classes << klass
123
- else
124
- next
125
- end
126
- end
127
- end
128
- end
129
-
130
- def infer_relation?(gateway, name)
131
- inferrable_relations(gateway).include?(name) && relation_classes.none? { |klass|
132
- klass.dataset == name
133
- }
134
- end
135
-
136
- def inferrable_relations(gateway)
137
- gateway_config = config.gateways[gateway]
138
- schema = gateways[gateway].schema
139
-
140
- allowed = gateway_config[:inferrable_relations] || schema
141
- skipped = gateway_config[:not_inferrable_relations] || []
142
-
143
- schema & allowed - skipped
144
- end
145
- end
146
- end
data/lib/rom/setup.rb DELETED
@@ -1,55 +0,0 @@
1
- require 'rom/setup/auto_registration'
2
-
3
- module ROM
4
- class Setup
5
- # @return [Array] registered relation subclasses
6
- #
7
- # @api private
8
- attr_reader :relation_classes
9
-
10
- # @return [Array] registered mapper subclasses
11
- #
12
- # @api private
13
- attr_reader :mapper_classes
14
-
15
- # @return [Array] registered command subclasses
16
- #
17
- # @api private
18
- attr_reader :command_classes
19
-
20
- # @api private
21
- def initialize
22
- @relation_classes = []
23
- @command_classes = []
24
- @mapper_classes = []
25
- end
26
-
27
- # Relation sub-classes are being registered with this method during setup
28
- #
29
- # @api private
30
- def register_relation(*klasses)
31
- klasses.reduce(@relation_classes, :<<)
32
- end
33
-
34
- # Mapper sub-classes are being registered with this method during setup
35
- #
36
- # @api private
37
- def register_mapper(*klasses)
38
- klasses.reduce(@mapper_classes, :<<)
39
- end
40
-
41
- # Command sub-classes are being registered with this method during setup
42
- #
43
- # @api private
44
- def register_command(*klasses)
45
- klasses.reduce(@command_classes, :<<)
46
- end
47
-
48
- def auto_registration(directory, options = {})
49
- auto_registration = AutoRegistration.new(directory, options)
50
- auto_registration.relations.map { |r| register_relation(r) }
51
- auto_registration.commands.map { |r| register_command(r) }
52
- auto_registration.mappers.map { |r| register_mapper(r) }
53
- end
54
- end
55
- end
@@ -1,80 +0,0 @@
1
- module ROM
2
- # @api private
3
- module Configurable
4
- class Config
5
- WRITER_REGEXP = /=$/.freeze
6
-
7
- attr_reader :settings
8
-
9
- # @api private
10
- def initialize(settings = {})
11
- @settings = settings
12
- end
13
-
14
- # @api public
15
- def [](name)
16
- public_send(name)
17
- end
18
-
19
- # @api private
20
- def key?(name)
21
- settings.key?(name)
22
- end
23
-
24
- # @api private
25
- def freeze
26
- settings.each_value(&:freeze)
27
- super
28
- end
29
-
30
- # @api private
31
- def respond_to_missing?(_name, _include_private = false)
32
- true
33
- end
34
-
35
- def dup
36
- self.class.new(dup_settings(settings))
37
- end
38
-
39
- private
40
-
41
- def dup_settings(settings)
42
- settings.each_with_object({}) do |(key, value), new_settings|
43
- if value.is_a?(self.class)
44
- new_settings[key] = value.dup
45
- else
46
- new_settings[key] = value
47
- end
48
- end
49
- end
50
-
51
- # @api private
52
- def method_missing(meth, *args, &_block)
53
- return settings.fetch(meth, nil) if frozen?
54
-
55
- name = meth.to_s
56
- key = name.gsub(WRITER_REGEXP, '').to_sym
57
-
58
- if writer?(name)
59
- settings[key] = args.first
60
- else
61
- settings.fetch(key) { settings[key] = self.class.new }
62
- end
63
- end
64
-
65
- # @api private
66
- def writer?(name)
67
- !WRITER_REGEXP.match(name).nil?
68
- end
69
- end
70
-
71
- def config
72
- @config ||= Config.new
73
- end
74
-
75
- # @api public
76
- def configure
77
- yield(config)
78
- end
79
- end
80
- end
data/lib/rom/types.rb DELETED
@@ -1,18 +0,0 @@
1
- require 'dry-types'
2
-
3
- module ROM
4
- module Types
5
- include Dry::Types.module
6
-
7
- def self.included(other)
8
- other.extend(Methods)
9
- super
10
- end
11
-
12
- module Methods
13
- def ForeignKey(relation, type = Types::Int)
14
- type.meta(foreign_key: true, relation: relation)
15
- end
16
- end
17
- end
18
- end
data/log/.gitkeep DELETED
File without changes
@@ -1,15 +0,0 @@
1
- desc "Run benchmarks (tweak count via COUNT envvar)"
2
- task :benchmark do
3
- FileList["benchmarks/**/*_bench.rb"].each do |bench|
4
- sh "ruby #{bench}"
5
- end
6
- end
7
-
8
- namespace :benchmark do
9
- desc "Verify benchmarks"
10
- task :verify do
11
- ENV['VERIFY'] = "true"
12
- ENV['COUNT'] = "1"
13
- Rake::Task[:benchmark].invoke
14
- end
15
- end
data/rakelib/mutant.rake DELETED
@@ -1,19 +0,0 @@
1
- desc "Run mutant against a specific subject"
2
- task :mutant do
3
- subject = ARGV.last
4
- if subject == 'mutant'
5
- abort "usage: rake mutant SUBJECT\nexample: rake mutant ROM::Header"
6
- else
7
- sep = subject.include?('#') ? '#' : '.'
8
- ns = subject.split(sep).first
9
-
10
- opts = {
11
- 'include' => 'lib',
12
- 'require' => 'rom',
13
- 'use' => 'rspec',
14
- 'ignore-subject' => "#{ns}#respond_to_missing?"
15
- }.to_a.map { |k, v| "--#{k} #{v}" }.join(' ')
16
-
17
- exec("bundle exec mutant #{opts} #{subject}")
18
- end
19
- end
data/rakelib/rubocop.rake DELETED
@@ -1,18 +0,0 @@
1
- begin
2
- require "rubocop/rake_task"
3
-
4
- Rake::Task[:default].enhance [:rubocop]
5
-
6
- RuboCop::RakeTask.new do |task|
7
- task.options << "--display-cop-names"
8
- end
9
-
10
- namespace :rubocop do
11
- desc 'Generate a configuration file acting as a TODO list.'
12
- task :auto_gen_config do
13
- exec "bundle exec rubocop --auto-gen-config"
14
- end
15
- end
16
-
17
- rescue LoadError
18
- end
data/rom.gemspec DELETED
@@ -1,26 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.expand_path('../lib/rom/version', __FILE__)
4
-
5
- Gem::Specification.new do |gem|
6
- gem.name = 'rom'
7
- gem.summary = 'Ruby Object Mapper'
8
- gem.description = 'Persistence and mapping toolkit for Ruby'
9
- gem.author = 'Piotr Solnica'
10
- gem.email = 'piotr.solnica@gmail.com'
11
- gem.homepage = 'http://rom-rb.org'
12
- gem.require_paths = ['lib']
13
- gem.version = ROM::VERSION.dup
14
- gem.files = `git ls-files`.split("\n").reject { |name| name.include?('benchmarks') }
15
- gem.test_files = `git ls-files -- {spec}/*`.split("\n")
16
- gem.license = 'MIT'
17
-
18
- gem.add_runtime_dependency 'concurrent-ruby', '~> 1.0'
19
- gem.add_runtime_dependency 'dry-equalizer', '~> 0.2'
20
- gem.add_runtime_dependency 'dry-types', '~> 0.8'
21
- gem.add_runtime_dependency 'rom-support', '~> 2.0'
22
- gem.add_runtime_dependency 'rom-mapper', '~> 0.4.0'
23
-
24
- gem.add_development_dependency 'rake', '~> 10.3'
25
- gem.add_development_dependency 'rspec', '~> 3.3'
26
- end
@@ -1,2 +0,0 @@
1
- class CreateUser
2
- end
@@ -1,2 +0,0 @@
1
- class UserList
2
- end
@@ -1,2 +0,0 @@
1
- class CreateUser
2
- end
@@ -1,2 +0,0 @@
1
- class UserList
2
- end
@@ -1,2 +0,0 @@
1
- class Users
2
- end
@@ -1,2 +0,0 @@
1
- class Users
2
- end
@@ -1,6 +0,0 @@
1
- module My
2
- module Namespace
3
- class CreateUser
4
- end
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- module My
2
- module Namespace
3
- class UserList
4
- end
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- module My
2
- module Namespace
3
- class Users
4
- end
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- module Persistence
2
- module Commands
3
- class CreateUser
4
- end
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- module Persistence
2
- module Mappers
3
- class UserList
4
- end
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- module Persistence
2
- module MyCommands
3
- class CreateUser
4
- end
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- module Persistence
2
- module MyMappers
3
- class UserList
4
- end
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- module Persistence
2
- module MyRelations
3
- class Users
4
- end
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- module Persistence
2
- module Relations
3
- class Users
4
- end
5
- end
6
- end
@@ -1,60 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'ROM::CommandRegistry' do
4
- include_context 'container'
5
-
6
- let(:users) { container.command(:users) }
7
-
8
- before do
9
- configuration.relation(:users)
10
-
11
- configuration.register_command(Class.new(ROM::Commands::Create[:memory]) do
12
- register_as :create
13
- relation :users
14
- validator proc { |input| raise(ROM::CommandError) unless input[:name] }
15
- end)
16
- end
17
-
18
- describe '#[]' do
19
- it 'fetches a command from the registry' do
20
- expect(users[:create]).to be_a(ROM::Commands::Create[:memory])
21
- end
22
-
23
- it 'throws an error when the command is not found' do
24
- expect { users[:not_found] }.to raise_error(
25
- ROM::CommandRegistry::CommandNotFoundError,
26
- 'There is no :not_found command for :users relation'
27
- )
28
- end
29
- end
30
-
31
- describe '#try' do
32
- it 'returns a success result object on successful execution' do
33
- result = users.try { users.create.call(name: 'Jane') }
34
-
35
- expect(result).to match_array([{ name: 'Jane' }])
36
- end
37
-
38
- it 'returns a success result on successful curried-command execution' do
39
- result = users.try { users.create.curry(name: 'Jane') }
40
-
41
- expect(result).to match_array([{ name: 'Jane' }])
42
- end
43
-
44
- it 'returns a failure result object on failed execution' do
45
- result = users.try { users.create.call({}) }
46
-
47
- expect(result.value).to be(nil)
48
- end
49
-
50
- it 'returns a failure result on unsuccessful curried-command execution' do
51
- result = users.try { users.create.curry({}) }
52
-
53
- expect(result.value).to be(nil)
54
- end
55
-
56
- it 'allows checking if a command is available using respond_to?' do
57
- expect(users).to respond_to(:create)
58
- end
59
- end
60
- end