rom 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +5 -8
  4. data/CHANGELOG.md +28 -1
  5. data/CODE_OF_CONDUCT.md +13 -0
  6. data/Gemfile +2 -2
  7. data/lib/rom.rb +1 -1
  8. data/lib/rom/command.rb +7 -5
  9. data/lib/rom/command_registry.rb +1 -1
  10. data/lib/rom/commands.rb +0 -2
  11. data/lib/rom/commands/abstract.rb +55 -25
  12. data/lib/rom/commands/composite.rb +13 -1
  13. data/lib/rom/commands/delete.rb +0 -8
  14. data/lib/rom/commands/graph.rb +102 -0
  15. data/lib/rom/commands/graph/class_interface.rb +69 -0
  16. data/lib/rom/commands/lazy.rb +87 -0
  17. data/lib/rom/constants.rb +22 -0
  18. data/lib/rom/env.rb +48 -18
  19. data/lib/rom/gateway.rb +132 -0
  20. data/lib/rom/global.rb +19 -19
  21. data/lib/rom/header.rb +42 -16
  22. data/lib/rom/header/attribute.rb +37 -15
  23. data/lib/rom/lint/gateway.rb +94 -0
  24. data/lib/rom/lint/spec.rb +15 -3
  25. data/lib/rom/lint/test.rb +45 -14
  26. data/lib/rom/mapper.rb +23 -10
  27. data/lib/rom/mapper/attribute_dsl.rb +157 -18
  28. data/lib/rom/memory.rb +1 -1
  29. data/lib/rom/memory/commands.rb +10 -8
  30. data/lib/rom/memory/dataset.rb +22 -2
  31. data/lib/rom/memory/{repository.rb → gateway.rb} +10 -10
  32. data/lib/rom/pipeline.rb +2 -1
  33. data/lib/rom/processor/transproc.rb +105 -14
  34. data/lib/rom/relation.rb +4 -4
  35. data/lib/rom/relation/class_interface.rb +19 -13
  36. data/lib/rom/relation/graph.rb +22 -0
  37. data/lib/rom/relation/lazy.rb +5 -3
  38. data/lib/rom/repository.rb +9 -118
  39. data/lib/rom/setup.rb +21 -14
  40. data/lib/rom/setup/finalize.rb +19 -19
  41. data/lib/rom/setup_dsl/relation.rb +10 -1
  42. data/lib/rom/support/deprecations.rb +21 -3
  43. data/lib/rom/support/enumerable_dataset.rb +1 -1
  44. data/lib/rom/version.rb +1 -1
  45. data/rom.gemspec +2 -4
  46. data/spec/integration/commands/delete_spec.rb +6 -0
  47. data/spec/integration/commands/graph_spec.rb +235 -0
  48. data/spec/integration/mappers/combine_spec.rb +14 -5
  49. data/spec/integration/mappers/definition_dsl_spec.rb +6 -1
  50. data/spec/integration/mappers/exclude_spec.rb +28 -0
  51. data/spec/integration/mappers/fold_spec.rb +16 -0
  52. data/spec/integration/mappers/group_spec.rb +0 -22
  53. data/spec/integration/mappers/prefix_separator_spec.rb +54 -0
  54. data/spec/integration/mappers/prefix_spec.rb +50 -0
  55. data/spec/integration/mappers/reusing_mappers_spec.rb +21 -0
  56. data/spec/integration/mappers/step_spec.rb +120 -0
  57. data/spec/integration/mappers/unfold_spec.rb +93 -0
  58. data/spec/integration/mappers/ungroup_spec.rb +127 -0
  59. data/spec/integration/mappers/unwrap_spec.rb +2 -2
  60. data/spec/integration/multi_repo_spec.rb +11 -11
  61. data/spec/integration/repositories/setting_logger_spec.rb +2 -2
  62. data/spec/integration/setup_spec.rb +11 -1
  63. data/spec/shared/command_behavior.rb +18 -0
  64. data/spec/shared/materializable.rb +4 -2
  65. data/spec/shared/users_and_tasks.rb +3 -3
  66. data/spec/test/memory_repository_lint_test.rb +4 -4
  67. data/spec/unit/rom/commands/graph_spec.rb +198 -0
  68. data/spec/unit/rom/commands/lazy_spec.rb +88 -0
  69. data/spec/unit/rom/commands_spec.rb +2 -2
  70. data/spec/unit/rom/env_spec.rb +26 -0
  71. data/spec/unit/rom/gateway_spec.rb +90 -0
  72. data/spec/unit/rom/global_spec.rb +4 -3
  73. data/spec/unit/rom/mapper/dsl_spec.rb +42 -1
  74. data/spec/unit/rom/mapper_spec.rb +4 -1
  75. data/spec/unit/rom/memory/commands/create_spec.rb +21 -0
  76. data/spec/unit/rom/memory/commands/delete_spec.rb +21 -0
  77. data/spec/unit/rom/memory/commands/update_spec.rb +21 -0
  78. data/spec/unit/rom/memory/relation_spec.rb +42 -10
  79. data/spec/unit/rom/memory/repository_spec.rb +3 -3
  80. data/spec/unit/rom/processor/transproc_spec.rb +75 -0
  81. data/spec/unit/rom/relation/lazy/combine_spec.rb +33 -4
  82. data/spec/unit/rom/relation/lazy_spec.rb +9 -1
  83. data/spec/unit/rom/repository_spec.rb +4 -63
  84. data/spec/unit/rom/setup_spec.rb +19 -5
  85. metadata +28 -38
  86. data/.ruby-version +0 -1
  87. data/lib/rom/lint/repository.rb +0 -94
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.1.5
@@ -1,94 +0,0 @@
1
- require 'rom/lint/linter'
2
-
3
- module ROM
4
- module Lint
5
- # Ensures that a [ROM::Repository] extension provides datasets through the
6
- # expected methods
7
- #
8
- # @api public
9
- class Repository < ROM::Lint::Linter
10
- # The repository identifier e.g. +:memory+
11
- #
12
- # @api public
13
- attr_reader :identifier
14
-
15
- # The repository class
16
- #
17
- # @api public
18
- attr_reader :repository
19
-
20
- # The optional URI
21
- #
22
- # @api public
23
- attr_reader :uri
24
-
25
- # Repository instance used in lint tests
26
- #
27
- # @api private
28
- attr_reader :repository_instance
29
-
30
- # Create a repository linter
31
- #
32
- # @param [Symbol] identifier
33
- # @param [Class] repository
34
- # @param [String] uri optional
35
- def initialize(identifier, repository, uri = nil)
36
- @identifier = identifier
37
- @repository = repository
38
- @uri = uri
39
- @repository_instance = setup_repository_instance
40
- end
41
-
42
- # Lint: Ensure that +repository+ setups up its instance
43
- #
44
- # @api public
45
- def lint_repository_setup
46
- return if repository_instance.instance_of? repository
47
-
48
- complain <<-STRING
49
- #{repository}.setup must return a repository instance but
50
- returned #{repository_instance.inspect}
51
- STRING
52
- end
53
-
54
- # Lint: Ensure that +repository_instance+ responds to +[]+
55
- #
56
- # @api public
57
- def lint_dataset_reader
58
- return if repository_instance.respond_to? :[]
59
-
60
- complain "#{repository_instance} must respond to []"
61
- end
62
-
63
- # Lint: Ensure that +repository_instance+ responds to +dataset?+
64
- #
65
- # @api public
66
- def lint_dataset_predicate
67
- return if repository_instance.respond_to? :dataset?
68
-
69
- complain "#{repository_instance} must respond to dataset?"
70
- end
71
-
72
- private
73
-
74
- # Setup repository instance
75
- #
76
- # @api private
77
- def setup_repository_instance
78
- if uri
79
- ROM::Repository.setup(identifier, uri)
80
- else
81
- ROM::Repository.setup(identifier)
82
- end
83
- end
84
-
85
- # Run Repository#disconnect
86
- #
87
- # @api private
88
- def after_lint
89
- super
90
- repository_instance.disconnect
91
- end
92
- end
93
- end
94
- end