rom-rails 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5fce2e9329194bb83964a04c19899efea1d3f61e2c38a62f5587440a431deb7f
4
- data.tar.gz: cf7aac16519079bec773b5fa2799199212989c8c8b36c4afd7e2d44eee1032ee
3
+ metadata.gz: 2b05da5eb835516ae2be2ff5577c763a1a511678e3dc134d6629540c7bc31abe
4
+ data.tar.gz: dc3a893b7392eadbd7c4cd62b0782a3085db09bc376c26da8818d738d5b45ca6
5
5
  SHA512:
6
- metadata.gz: 846026a514b5aa386cbba31d68e1b643894fb729ef6ee08b3e72dd9b289609b98ca31fe87f431abbfd3cb950c6e42639e89445d96202705c91ed06be14962f4f
7
- data.tar.gz: 0b3d2dbeaa5c848b52f8d143b79a191fb2ec0a1a08783c7100720abbb74a36ae840c55a41f8ddddc0cf323045f81d10fc5baa638a7bd07325c31edc9cf3a2690
6
+ metadata.gz: 2db3f6f0e334c2b21ad4a37b94bc7c163765d502e8709069395de7db28ed9a440ab646f64649f37c883d745da5b8cd75aeb1df4d49e266d9aa318a900b241d8e
7
+ data.tar.gz: e92e622115b257e8a6961a883c2454860e44eda32c3cb3636df777ea9fa5d0e34d37d822d3df2c11116faf52cda81806a12a33f5cf8fffcc3c463d61336ace56
@@ -24,25 +24,13 @@ jobs:
24
24
  fail-fast: false
25
25
  matrix:
26
26
  ruby:
27
+ - '3.1'
28
+ - '3.0'
27
29
  - '2.7'
28
- - '2.6'
29
- - '2.5'
30
- - '2.4'
31
- - jruby
32
30
  rails:
31
+ - "7.0.0"
33
32
  - "6.1.0"
34
33
  - "6.0.0"
35
- - "5.2.0"
36
- - "5.1.0"
37
- - "5.0.0"
38
- - "4.2.0"
39
- exclude:
40
- - ruby: "2.4"
41
- rails: "6.0.0"
42
- - ruby: "2.4"
43
- rails: "6.1.0"
44
- - ruby: "2.7"
45
- rails: "4.2.0"
46
34
  env:
47
35
  APT_DEPS: libsqlite3-dev
48
36
  RAILS_VERSION: "${{matrix.rails}}"
data/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## v2.4.0 2023-10-26c
2
+
3
+ ### Changed
4
+
5
+ * Add configuration to allow not trigger reload on each request (alex-lairan)
6
+ * Allow namespace configuration from within an auto_registration path (sasa-b)
7
+
8
+ ### Added
9
+
10
+ * Compatible with Rails 7.0 (nolantait)
11
+ * Compatible with Rails 7.1 (cflipse)
12
+
13
+ ### Removed
14
+
15
+ * Dropped support for Rails < 6.0
16
+ * Dropped support for Ruby < 2.7
17
+
1
18
  ## v2.3.0 2021-03-20
2
19
 
3
20
  ### Changed
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.4.0, available at [https://www.contributor-covenant.org/version/1/4/code-of-conduct](https://www.contributor-covenant.org/version/1/4/code-of-conduct)
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- RAILS_VERSION = ENV.fetch("RAILS_VERSION", '6.1.1').freeze
5
+ RAILS_VERSION = ENV.fetch("RAILS_VERSION", '7.0.4').freeze
6
6
 
7
7
  %w(railties actionview actionpack activerecord).each do |name|
8
8
  gem name, "~> #{RAILS_VERSION}"
@@ -11,8 +11,6 @@ end
11
11
  gem 'byebug', platforms: :mri
12
12
  gem 'sqlite3', platforms: [:mri, :rbx]
13
13
 
14
-
15
-
16
14
  if ENV["USE_ROM_MASTER"].eql?("true")
17
15
  gem 'rom', git: 'https://github.com/rom-rb/rom', branch: 'master' do
18
16
  gem 'rom-core'
@@ -33,6 +31,7 @@ platforms :jruby do
33
31
  end
34
32
 
35
33
  group :test do
34
+ gem 'debug'
36
35
  gem 'capybara'
37
36
  gem 'codeclimate-test-reporter', require: nil
38
37
  gem 'database_cleaner', "~> 1.8.1"
data/README.md CHANGED
@@ -1,14 +1,16 @@
1
1
  [gem]: https://rubygems.org/gems/rom-rails
2
2
  [actions]: https://github.com/rom-rb/rom-rails/actions
3
3
  [codeclimate]: https://codeclimate.com/github/rom-rb/rom-rails
4
+ [codeacy]: https://www.codacy.com/gh/rom-rb/rom-rails
4
5
  [coveralls]: https://coveralls.io/r/rom-rb/rom-rails
5
6
  [inchpages]: http://inch-ci.org/github/rom-rb/rom-rails
6
7
 
7
- # rom-rails
8
+ # rom-rails [![Join the chat at https://rom-rb.zulipchat.com](https://img.shields.io/badge/rom--rb-join%20chat-942283.svg)][chat]
8
9
 
9
10
  [![Gem Version](https://badge.fury.io/rb/rom-rails.svg)][gem]
10
11
  [![CI Status](https://github.com/rom-rb/rom-rails/workflows/ci/badge.svg)][actions]
11
12
  [![Code Climate](https://codeclimate.com/github/rom-rb/rom-rails/badges/gpa.svg)][codeclimate]
13
+ [![Codacy Badge](https://app.codacy.com/project/badge/Grade/81d5362ea6314dd09432fb238d79f481)][codeacy]
12
14
  [![Test Coverage](https://codeclimate.com/github/rom-rb/rom-rails/badges/coverage.svg)][codeclimate]
13
15
  [![Inline docs](http://inch-ci.org/github/rom-rb/rom-rails.svg?branch=master)][inchpages]
14
16
 
@@ -16,9 +18,9 @@ Rails integration for [Ruby Object Mapper](https://github.com/rom-rb/rom) which
16
18
  ships with:
17
19
 
18
20
  * Relation generators
21
+ * Repository generators
19
22
  * Mapper generators
20
23
  * Command generators
21
- * Repository generators
22
24
 
23
25
  ## Tests
24
26
 
@@ -37,8 +39,9 @@ You can read more about ROM and Rails on the official website:
37
39
 
38
40
  ## Community
39
41
 
40
- * [![Gitter chat](https://badges.gitter.im/rom-rb/chat.png)](https://gitter.im/rom-rb/chat)
41
- * [Discussion Forum](https://discuss.rom-rb.org)
42
+ * [Offical ROM blog](https://rom-rb.org/blog)
43
+ * [Discussion Forum](https://discourse.rom-rb.org)
44
+ * [Chat](https://rom-rb.zulipchat.com)
42
45
 
43
46
  ## License
44
47
 
data/db CHANGED
@@ -1 +1 @@
1
- ./spec/dummy/db
1
+ spec/dummy/db
@@ -1,4 +1,5 @@
1
1
  require "types"
2
+ require "dry/core/equalizer"
2
3
 
3
4
  class ApplicationModel < ROM::Struct
4
5
  def self.inherited(base)
@@ -9,7 +10,7 @@ class ApplicationModel < ROM::Struct
9
10
  base.extend ActiveModel::Naming
10
11
  base.include ActiveModel::Conversion
11
12
 
12
- base.include Dry::Equalizer(:id)
13
+ base.include Dry::Core::Equalizer.new(:id)
13
14
 
14
15
  base.attribute :id, Types::ID
15
16
  end
@@ -37,23 +37,20 @@ module ROM
37
37
  #
38
38
  # @api private
39
39
  def call
40
- specs = { default: build(default_configuration.symbolize_keys) }
40
+ specs = {}
41
41
 
42
- if rails6?
43
- configurations.configs_for(env_name: env).each do |config|
44
- specs[config.spec_name.to_sym] = build(config.config.symbolize_keys)
42
+ configurations.configs_for(env_name: env).each do |config|
43
+ if config.respond_to?(:configuration_hash)
44
+ name, hash = [config.name, config.configuration_hash]
45
+ else # Rails 6.0
46
+ name, hash = [config.spec_name, config.config]
45
47
  end
46
- end
47
-
48
- specs
49
- end
50
48
 
51
- def default_configuration
52
- if rails6?
53
- configurations.default_hash(env)
54
- else
55
- configurations.fetch(env)
49
+ specs[:default] ||= hash
50
+ specs[name.to_sym] = hash
56
51
  end
52
+
53
+ specs.transform_values { |hash| build hash.symbolize_keys }
57
54
  end
58
55
 
59
56
  # Builds a configuration hash from a flat database config hash.
@@ -77,12 +74,6 @@ module ROM
77
74
  uri = uri_builder.build(adapter, uri_options)
78
75
  { uri: uri, options: other_options }
79
76
  end
80
-
81
- private
82
-
83
- def rails6?
84
- ::ActiveRecord::VERSION::MAJOR >= 6
85
- end
86
77
  end
87
78
  end
88
79
  end
@@ -13,6 +13,10 @@ module ROM
13
13
  config_accessor :auto_registration_paths do
14
14
  ['app']
15
15
  end
16
+
17
+ config_accessor :reload_on_each_request do
18
+ true
19
+ end
16
20
  end
17
21
  end
18
22
  end
@@ -30,7 +30,7 @@ module ROM
30
30
  initializer 'rom.adjust_eager_load_paths' do |app|
31
31
  paths =
32
32
  auto_registration_paths.inject([]) do |result, root_path|
33
- result.concat(COMPONENT_DIRS.map { |dir| ::Rails.root.join(root_path, dir).to_s })
33
+ result.concat(COMPONENT_DIRS.map { |dir| ::Rails.root.join(root_path.is_a?(Hash) ? root_path[:path] : root_path, dir).to_s })
34
34
  end
35
35
 
36
36
  app.config.eager_load_paths -= paths
@@ -40,9 +40,18 @@ module ROM
40
40
  load "rom/rails/tasks/db.rake" unless active_record?
41
41
  end
42
42
 
43
+ # Load ROM-related application code on startup
44
+ config.after_initialize do
45
+ if !::Rails.application.config.rom.reload_on_each_request
46
+ ROM.env = Railtie.create_container
47
+ end
48
+ end
49
+
43
50
  # Reload ROM-related application code on each request.
44
- config.to_prepare do |_config|
45
- ROM.env = Railtie.create_container
51
+ config.to_prepare do |prepare_conf|
52
+ if ::Rails.application.config.rom.reload_on_each_request
53
+ ROM.env = Railtie.create_container
54
+ end
46
55
  end
47
56
 
48
57
  console do |_app|
@@ -78,7 +87,11 @@ module ROM
78
87
  configuration = create_configuration
79
88
 
80
89
  auto_registration_paths.each do |root_path|
81
- configuration.auto_registration(::Rails.root.join(root_path), namespace: false)
90
+ if root_path.is_a? Hash
91
+ configuration.auto_registration(::Rails.root.join(root_path[:path]), namespace: root_path[:namespace])
92
+ else
93
+ configuration.auto_registration(::Rails.root.join(root_path), namespace: false)
94
+ end
82
95
  end
83
96
 
84
97
  ROM.container(configuration)
@@ -1,5 +1,5 @@
1
1
  module ROM
2
2
  module Rails
3
- VERSION = '2.3.0'.freeze
3
+ VERSION = '2.4.0'.freeze
4
4
  end
5
5
  end
data/log CHANGED
@@ -1 +1 @@
1
- ./spec/dummy/log
1
+ spec/dummy/log
data/rom-rails.gemspec CHANGED
@@ -16,11 +16,16 @@ Gem::Specification.new do |spec|
16
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
17
  spec.require_paths = ["lib"]
18
18
 
19
+ spec.metadata = {
20
+ "bug_tracker_uri" => "https://github.com/rom-rb/rom-rails/issues",
21
+ "changelog_uri" => "https://github.com/rom-rb/rom-rails/blob/master/CHANGELOG.md",
22
+ "source_code_uri" => "https://github.com/rom-rb/rom-rails",
23
+ }
24
+
19
25
  spec.add_runtime_dependency 'addressable', '~> 2.3'
20
- spec.add_runtime_dependency 'dry-core', '~> 0.4'
21
- spec.add_runtime_dependency 'dry-equalizer', '~> 0.2'
22
- spec.add_runtime_dependency 'railties', '>= 3.0', '< 6.2'
23
- spec.add_runtime_dependency 'rom', '~> 5.2'
26
+ spec.add_runtime_dependency 'dry-core', '~> 1.0'
27
+ spec.add_runtime_dependency 'railties', '>= 6.0', '< 8.0.0'
28
+ spec.add_runtime_dependency 'rom', '~> 5.3'
24
29
 
25
30
  spec.add_development_dependency "bundler"
26
31
  spec.add_development_dependency "rake"
@@ -1,5 +1,5 @@
1
1
  class User
2
- include Dry::Equalizer(:id, :name, :email)
2
+ include Dry::Core::Equalizer.new(:id, :name, :email)
3
3
 
4
4
  attr_reader :id, :name, :email
5
5
 
@@ -7,6 +7,7 @@ Bundler.setup(:default, Rails.env)
7
7
  require 'rom-sql'
8
8
  require 'rom-rails'
9
9
  require 'rspec-rails'
10
+ require 'dry/core/equalizer'
10
11
 
11
12
  module Dummy
12
13
  class Application < Rails::Application
@@ -4,4 +4,5 @@ ROM::Rails::Railtie.configure do |config|
4
4
  config.gateways[:sql] = [:sql, "#{scheme}://#{Rails.root}/db/#{Rails.env}.sqlite3"]
5
5
  config.gateways[:default] = [:test_adapter, foo: :bar]
6
6
  config.auto_registration_paths += [Rails.root.join('lib', 'additional_app', 'persistence')]
7
+ config.auto_registration_paths += [{path: Rails.root.join('lib', 'namespaced_app', 'persistence'), namespace: 'NamespacedApp::Persistence'}]
7
8
  end
@@ -0,0 +1,11 @@
1
+ module NamespacedApp
2
+ module Persistence
3
+ module Commands
4
+ class CreateAdditionalTask < ROM::Commands::Create[:sql]
5
+ relation :tasks
6
+ register_as :namespaced_additional
7
+ result :one
8
+ end
9
+ end
10
+ end
11
+ end
@@ -5,7 +5,7 @@ module ROM
5
5
  end
6
6
 
7
7
  class Gateway < ROM::Gateway
8
- include Dry::Equalizer(:args)
8
+ include Dry::Core::Equalizer.new(:args)
9
9
  adapter :test_adapter
10
10
 
11
11
  attr_reader :args, :datasets
@@ -7,7 +7,12 @@ RSpec.describe 'ROM initializer' do
7
7
  expect(rom.relations.dummy).to eql(relation)
8
8
  end
9
9
 
10
- it 'loads commands from additionall auto_registration_paths' do
10
+ it 'loads commands from additional auto_registration_paths' do
11
11
  expect(rom.commands.tasks.create_additional).to be_a(CreateAdditionalTask)
12
12
  end
13
+
14
+ it 'allows namespace configuration on autoload paths' do
15
+ puts rom.commands.tasks.elements
16
+ expect(rom.commands.tasks.namespaced_additional).to be_a(NamespacedApp::Persistence::Commands::CreateAdditionalTask)
17
+ end
13
18
  end
@@ -20,7 +20,9 @@ RSpec.describe ROM::Rails::ActiveRecord::Configuration do
20
20
  URI.parse(uri.gsub(/^jdbc:/, ''))
21
21
  end
22
22
 
23
- it 'raises an error without specifying a database'
23
+ it 'raises an error without specifying a database' do
24
+ expect { read({}) }.to raise_error KeyError
25
+ end
24
26
 
25
27
  context 'with postgresql adapter' do
26
28
  it 'rewrites the scheme' do
@@ -64,6 +64,7 @@ RSpec.describe ROM::Generators::InstallGenerator, type: :generator do
64
64
  file "application_model.rb" do
65
65
  contains <<-CONTENT.strip_heredoc
66
66
  require "types"
67
+ require "dry/core/equalizer"
67
68
 
68
69
  class ApplicationModel < ROM::Struct
69
70
  def self.inherited(base)
@@ -74,7 +75,7 @@ RSpec.describe ROM::Generators::InstallGenerator, type: :generator do
74
75
  base.extend ActiveModel::Naming
75
76
  base.include ActiveModel::Conversion
76
77
 
77
- base.include Dry::Equalizer(:id)
78
+ base.include Dry::Core::Equalizer.new(:id)
78
79
 
79
80
  base.attribute :id, Types::ID
80
81
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rom-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Flipse
8
8
  - Piotr Solnica
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-03-21 00:00:00.000000000 Z
12
+ date: 2023-10-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
@@ -31,62 +31,48 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '0.4'
34
+ version: '1.0'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '0.4'
42
- - !ruby/object:Gem::Dependency
43
- name: dry-equalizer
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - "~>"
47
- - !ruby/object:Gem::Version
48
- version: '0.2'
49
- type: :runtime
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - "~>"
54
- - !ruby/object:Gem::Version
55
- version: '0.2'
41
+ version: '1.0'
56
42
  - !ruby/object:Gem::Dependency
57
43
  name: railties
58
44
  requirement: !ruby/object:Gem::Requirement
59
45
  requirements:
60
46
  - - ">="
61
47
  - !ruby/object:Gem::Version
62
- version: '3.0'
48
+ version: '6.0'
63
49
  - - "<"
64
50
  - !ruby/object:Gem::Version
65
- version: '6.2'
51
+ version: 8.0.0
66
52
  type: :runtime
67
53
  prerelease: false
68
54
  version_requirements: !ruby/object:Gem::Requirement
69
55
  requirements:
70
56
  - - ">="
71
57
  - !ruby/object:Gem::Version
72
- version: '3.0'
58
+ version: '6.0'
73
59
  - - "<"
74
60
  - !ruby/object:Gem::Version
75
- version: '6.2'
61
+ version: 8.0.0
76
62
  - !ruby/object:Gem::Dependency
77
63
  name: rom
78
64
  requirement: !ruby/object:Gem::Requirement
79
65
  requirements:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
- version: '5.2'
68
+ version: '5.3'
83
69
  type: :runtime
84
70
  prerelease: false
85
71
  version_requirements: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: '5.2'
75
+ version: '5.3'
90
76
  - !ruby/object:Gem::Dependency
91
77
  name: bundler
92
78
  requirement: !ruby/object:Gem::Requirement
@@ -143,7 +129,7 @@ dependencies:
143
129
  - - "~>"
144
130
  - !ruby/object:Gem::Version
145
131
  version: '0.50'
146
- description:
132
+ description:
147
133
  email:
148
134
  - cflipse@gmail.com
149
135
  - piotr.solnica@gmail.com
@@ -161,6 +147,7 @@ files:
161
147
  - ".rspec"
162
148
  - ".rubocop.yml"
163
149
  - CHANGELOG.md
150
+ - CODE_OF_CONDUCT.md
164
151
  - CONTRIBUTING.md
165
152
  - Gemfile
166
153
  - LICENSE
@@ -243,6 +230,7 @@ files:
243
230
  - spec/dummy/db/migrate/20150403194906_create_tags.rb
244
231
  - spec/dummy/lib/additional_app/persistence/commands/create_additional_task.rb
245
232
  - spec/dummy/lib/assets/.keep
233
+ - spec/dummy/lib/namespaced_app/persistence/commands/create_additional_task.rb
246
234
  - spec/dummy/lib/rom/test_adapter.rb
247
235
  - spec/dummy/lib/tasks/.keep
248
236
  - spec/dummy/log/.keep
@@ -270,8 +258,11 @@ files:
270
258
  homepage: http://rom-rb.org
271
259
  licenses:
272
260
  - MIT
273
- metadata: {}
274
- post_install_message:
261
+ metadata:
262
+ bug_tracker_uri: https://github.com/rom-rb/rom-rails/issues
263
+ changelog_uri: https://github.com/rom-rb/rom-rails/blob/master/CHANGELOG.md
264
+ source_code_uri: https://github.com/rom-rb/rom-rails
265
+ post_install_message:
275
266
  rdoc_options: []
276
267
  require_paths:
277
268
  - lib
@@ -286,8 +277,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
286
277
  - !ruby/object:Gem::Version
287
278
  version: '0'
288
279
  requirements: []
289
- rubygems_version: 3.0.3
290
- signing_key:
280
+ rubygems_version: 3.2.33
281
+ signing_key:
291
282
  specification_version: 4
292
283
  summary: Integrate Ruby Object Mapper with Rails
293
284
  test_files:
@@ -340,6 +331,7 @@ test_files:
340
331
  - spec/dummy/db/migrate/20150403194906_create_tags.rb
341
332
  - spec/dummy/lib/additional_app/persistence/commands/create_additional_task.rb
342
333
  - spec/dummy/lib/assets/.keep
334
+ - spec/dummy/lib/namespaced_app/persistence/commands/create_additional_task.rb
343
335
  - spec/dummy/lib/rom/test_adapter.rb
344
336
  - spec/dummy/lib/tasks/.keep
345
337
  - spec/dummy/log/.keep