rom-rails 2.2.0 → 2.3.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: 2aa950bd64c7498d660f81d2b6f0f6206d88b81249b6c72103a598ccc4abdeb0
4
- data.tar.gz: '04184007c2c8ec6f3adf047ccb4ab7856c9fdb0bfcf84ca4f59efc91a2cce625'
3
+ metadata.gz: 5fce2e9329194bb83964a04c19899efea1d3f61e2c38a62f5587440a431deb7f
4
+ data.tar.gz: cf7aac16519079bec773b5fa2799199212989c8c8b36c4afd7e2d44eee1032ee
5
5
  SHA512:
6
- metadata.gz: 19289d877377affe80deede5ec1a195252354a6ab2ade3a2ce80b3c0c543295e57ba409e333c4199b38fdec08bea59b027f2eff47cc55af54e18dc5d7ad26884
7
- data.tar.gz: 20199e51ec01cb205650c000bb6f79980c764ce1797634130bf73808e2038cc346aea47d6ef3aadd35ec42a8a9b14103769ac3a558bb084aa2a5f56e95a0388a
6
+ metadata.gz: 846026a514b5aa386cbba31d68e1b643894fb729ef6ee08b3e72dd9b289609b98ca31fe87f431abbfd3cb950c6e42639e89445d96202705c91ed06be14962f4f
7
+ data.tar.gz: 0b3d2dbeaa5c848b52f8d143b79a191fb2ec0a1a08783c7100720abbb74a36ae840c55a41f8ddddc0cf323045f81d10fc5baa638a7bd07325c31edc9cf3a2690
@@ -0,0 +1,10 @@
1
+ ---
2
+ name: "⚠️ Please don't ask for support via issues"
3
+ about: See CONTRIBUTING.md for more information
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+
@@ -0,0 +1,30 @@
1
+ ---
2
+ name: "\U0001F41B Bug report"
3
+ about: See CONTRIBUTING.md for more information
4
+ title: ''
5
+ labels: bug
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Before you submit this: WE ONLY ACCEPT BUG REPORTS AND FEATURE REQUESTS**
11
+
12
+ For more information see [our contribution guidelines](https://github.com/rom-rb/rom/blob/master/CONTRIBUTING.md)
13
+
14
+ **Describe the bug**
15
+
16
+ A clear and concise description of what the bug is.
17
+
18
+ **To Reproduce**
19
+
20
+ Provide detailed steps to reproduce, an executable script would be best.
21
+
22
+ **Expected behavior**
23
+
24
+ A clear and concise description of what you expected to happen.
25
+
26
+ **Your environment**
27
+
28
+ - Affects my production application: **YES/NO**
29
+ - Ruby version: ...
30
+ - OS: ...
@@ -0,0 +1,18 @@
1
+ ---
2
+ name: "\U0001F6E0 Feature request"
3
+ about: See CONTRIBUTING.md for more information
4
+ title: ''
5
+ labels: feature
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ Summary of what the feature is supposed to do.
11
+
12
+ ## Examples
13
+
14
+ Code examples showing how the feature could be used.
15
+
16
+ ## Resources
17
+
18
+ Additional information, like a link to the discussion forum thread where the feature was discussed etc.
@@ -0,0 +1,67 @@
1
+ ---
2
+ name: ci
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ paths:
8
+ - ".github/workflows/ci.yml"
9
+ - lib/**
10
+ - "*.gemspec"
11
+ - spec/**
12
+ - db/migrate/**
13
+ - Rakefile
14
+ - Gemfile
15
+ - ".rubocop.yml"
16
+ pull_request:
17
+ branches:
18
+ - master
19
+ create:
20
+ jobs:
21
+ tests:
22
+ runs-on: ubuntu-latest
23
+ strategy:
24
+ fail-fast: false
25
+ matrix:
26
+ ruby:
27
+ - '2.7'
28
+ - '2.6'
29
+ - '2.5'
30
+ - '2.4'
31
+ - jruby
32
+ rails:
33
+ - "6.1.0"
34
+ - "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
+ env:
47
+ APT_DEPS: libsqlite3-dev
48
+ RAILS_VERSION: "${{matrix.rails}}"
49
+ RAILS_ENV: test
50
+
51
+ steps:
52
+ - name: Checkout
53
+ uses: actions/checkout@v1
54
+ - name: Install package dependencies
55
+ run: "[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS"
56
+ - name: Set up Ruby
57
+ uses: ruby/setup-ruby@v1
58
+ with:
59
+ ruby-version: "${{matrix.ruby}}"
60
+ - name: Install latest bundler
61
+ run: |
62
+ gem install bundler --no-document
63
+ bundle config set without 'tools benchmarks docs'
64
+ - name: Bundle install
65
+ run: bundle install --jobs 4 --retry 3
66
+ - name: Run all tests
67
+ run: bundle exec rake app:db:reset app:spec
@@ -0,0 +1,34 @@
1
+ # this file is managed by rom-rb/devtools project
2
+
3
+ name: docsite
4
+
5
+ on:
6
+ push:
7
+ paths:
8
+ - docsite/**
9
+ - .github/workflows/docsite.yml
10
+ branches:
11
+ - master
12
+ - release-**
13
+ tags:
14
+
15
+ jobs:
16
+ update-docs:
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v1
20
+ - name: Set up Ruby
21
+ uses: actions/setup-ruby@v1
22
+ with:
23
+ ruby-version: "2.6.x"
24
+ - name: Install dependencies
25
+ run: |
26
+ gem install bundler
27
+ bundle install --jobs 4 --retry 3 --without benchmarks sql
28
+ - name: Symlink ossy
29
+ run: mkdir -p bin && ln -sf "$(bundle show ossy)/bin/ossy" bin/ossy
30
+ - name: Trigger rom-rb.org deploy
31
+ env:
32
+ GITHUB_LOGIN: rom-bot
33
+ GITHUB_TOKEN: ${{ secrets.GH_PAT }}
34
+ run: bin/ossy github workflow rom-rb/rom-rb.org ci
@@ -0,0 +1,30 @@
1
+ # this file is managed by rom-rb/devtools project
2
+
3
+ name: sync_configs
4
+
5
+ on:
6
+ repository_dispatch:
7
+
8
+ jobs:
9
+ sync-configs:
10
+ runs-on: ubuntu-latest
11
+ if: github.event.action == 'sync_configs'
12
+ steps:
13
+ - uses: actions/checkout@v1
14
+ - name: Update configuration files from devtools
15
+ env:
16
+ GITHUB_LOGIN: ${{ github.actor }}
17
+ GITHUB_TOKEN: ${{ secrets.GH_PAT }}
18
+ run: |
19
+ git clone https://github.com/rom-rb/devtools.git tmp/devtools
20
+
21
+ rsync -av tmp/devtools/shared/ .
22
+
23
+ git config --local user.email "rom-bot@rom-rb.org"
24
+ git config --local user.name "rom-bot"
25
+ git add -A
26
+ git commit -m "[devtools] config sync" || echo "nothing changed"
27
+ - name: Push changes
28
+ uses: ad-m/github-push-action@master
29
+ with:
30
+ github_token: ${{ secrets.GH_PAT }}
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## v2.3.0 2021-03-20
2
+
3
+ ### Changed
4
+
5
+ * Updated dependencies to allow Rails 6.1 (alex-lairan)
6
+
1
7
  ## v2.2.0 2019-09-12
2
8
 
3
9
  ### Changed
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.0.0').freeze
5
+ RAILS_VERSION = ENV.fetch("RAILS_VERSION", '6.1.1').freeze
6
6
 
7
7
  %w(railties actionview actionpack activerecord).each do |name|
8
8
  gem name, "~> #{RAILS_VERSION}"
@@ -11,13 +11,22 @@ end
11
11
  gem 'byebug', platforms: :mri
12
12
  gem 'sqlite3', platforms: [:mri, :rbx]
13
13
 
14
- gem 'rom', git: 'https://github.com/rom-rb/rom', branch: 'master' do
15
- gem 'rom-core'
16
- gem 'rom-mapper'
17
- gem 'rom-repository', group: :tools
18
- end
19
14
 
20
- gem 'rom-sql', github: 'rom-rb/rom-sql', branch: 'master'
15
+
16
+ if ENV["USE_ROM_MASTER"].eql?("true")
17
+ gem 'rom', git: 'https://github.com/rom-rb/rom', branch: 'master' do
18
+ gem 'rom-core'
19
+ gem 'rom-mapper'
20
+ gem 'rom-repository', group: :tools
21
+ end
22
+
23
+ gem 'rom-sql', github: 'rom-rb/rom-sql', branch: 'master'
24
+ else
25
+ gem "rom"
26
+ gem "rom-sql"
27
+
28
+ gem "sequel", "5.31.0"
29
+ end
21
30
 
22
31
  platforms :jruby do
23
32
  gem 'jdbc-sqlite3'
@@ -26,7 +35,7 @@ end
26
35
  group :test do
27
36
  gem 'capybara'
28
37
  gem 'codeclimate-test-reporter', require: nil
29
- gem 'database_cleaner'
38
+ gem 'database_cleaner', "~> 1.8.1"
30
39
  gem 'generator_spec'
31
40
  gem 'rack-test'
32
41
  gem 'rspec-rails', '~> 3.1'
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [gem]: https://rubygems.org/gems/rom-rails
2
- [travis]: https://travis-ci.org/rom-rb/rom-rails
2
+ [actions]: https://github.com/rom-rb/rom-rails/actions
3
3
  [codeclimate]: https://codeclimate.com/github/rom-rb/rom-rails
4
4
  [coveralls]: https://coveralls.io/r/rom-rb/rom-rails
5
5
  [inchpages]: http://inch-ci.org/github/rom-rb/rom-rails
@@ -7,7 +7,7 @@
7
7
  # rom-rails
8
8
 
9
9
  [![Gem Version](https://badge.fury.io/rb/rom-rails.svg)][gem]
10
- [![Build Status](https://travis-ci.org/rom-rb/rom-rails.svg?branch=master)][travis]
10
+ [![CI Status](https://github.com/rom-rb/rom-rails/workflows/ci/badge.svg)][actions]
11
11
  [![Code Climate](https://codeclimate.com/github/rom-rb/rom-rails/badges/gpa.svg)][codeclimate]
12
12
  [![Test Coverage](https://codeclimate.com/github/rom-rb/rom-rails/badges/coverage.svg)][codeclimate]
13
13
  [![Inline docs](http://inch-ci.org/github/rom-rb/rom-rails.svg?branch=master)][inchpages]
@@ -32,7 +32,7 @@ To run tests:
32
32
  You can read more about ROM and Rails on the official website:
33
33
 
34
34
  * [Introduction to ROM](http://rom-rb.org/learn/)
35
- * [Rails setup](http://rom-rb.org/learn/getting-started/rails-setup/)
35
+ * [Rails setup](http://rom-rb.org/learn/rails/)
36
36
 
37
37
 
38
38
  ## Community
@@ -0,0 +1,165 @@
1
+ ---
2
+ position: 3
3
+ chapter: Rails
4
+ title: Setup
5
+ ---
6
+
7
+ Rails integration is provided by [rom-rails](https://github.com/rom-rb/rom-rails) project. Simply add it to your Gemfile:
8
+
9
+ ``` ruby
10
+ gem 'rom-rails'
11
+ ```
12
+
13
+ ## Configuring Railtie
14
+
15
+ Create a rom initializer:
16
+
17
+ ``` ruby
18
+ # config/initializers/rom.rb
19
+ ROM::Rails::Railtie.configure do |config|
20
+ config.gateways[:default] = [:sql, ENV.fetch('DATABASE_URL')]
21
+ end
22
+ ```
23
+
24
+ You can provide additional adapter-specific options, for example you can enable specific sql plugins for postgres:
25
+
26
+ ``` ruby
27
+ # config/initializers/rom.rb
28
+ ROM::Rails::Railtie.configure do |config|
29
+ config.gateways[:default] = [:sql,
30
+ ENV.fetch('DATABASE_URL'), extensions: [:pg_hstore]
31
+ ]
32
+ end
33
+ ```
34
+
35
+ You can also provide a list of relations that should not be inferred from your schema automatically:
36
+
37
+ ``` ruby
38
+ # config/initializers/rom.rb
39
+ ROM::Rails::Railtie.configure do |config|
40
+ config.gateways[:default] = [:sql,
41
+ ENV.fetch('DATABASE_URL'), not_inferrable_relations: [:schema_migrations]
42
+ ]
43
+ end
44
+ ```
45
+
46
+ ## Migration Tasks
47
+
48
+ The railtie provides rake tasks for managing your database schema. You need to enable them in your `Rakefile`:
49
+
50
+ ``` ruby
51
+ require 'rom/sql/rake_task'
52
+ ```
53
+
54
+ After that, you have access to following tasks:
55
+
56
+ * `rake db:create_migration[migration_name]` - creates a new migration file
57
+ * `rake db:migrate` - runs pending migrations
58
+ * `rake db:clean` - cleans the database
59
+ * `rake db:reset` - drops tables and re-runs migrations
60
+
61
+ ## Accessing Container
62
+
63
+ In Rails environment ROM container is accessible via `ROM.env`:
64
+
65
+ ``` ruby
66
+ ROM.env # returns the container
67
+ ```
68
+
69
+ In your controllers you can access ROM container by `rom` variable:
70
+
71
+ ``` ruby
72
+ class UsersController < ApplicationController
73
+ def show
74
+ @user = rom.relation(:users).by_id(params[:id]).one
75
+ end
76
+ end
77
+ ```
78
+
79
+ ^WARNING
80
+ Accessing the global container directly is considered as a bad practice. The recommended way is to use a DI mechanism to inject specific ROM components as dependencies into your objects.
81
+
82
+ For example you can use [dry-container](https://github.com/dryrb/dry-container) and [dry-auto_inject](https://github.com/dryrb/dry-auto_inject) to define your own application container and specify dependencies there to have them automatically injected.
83
+
84
+ See [rom-rails-skeleton](https://github.com/solnic/rom-rails-skeleton) for an example of such setup.
85
+ ^
86
+
87
+ ## Defining Relations
88
+
89
+ Relation class definitions are automatically loaded from `app/relations`. The following code defines a `users` relation for the `:sql` adapter:
90
+
91
+ ``` ruby
92
+ class Users < ROM::Relation[:sql]
93
+ # some methods
94
+ end
95
+
96
+ # access registered relation via container
97
+ ROM.env.relations[:users]
98
+ ```
99
+
100
+ ## Defining Commands
101
+
102
+ Command class definitions are automatically loaded from `app/commands`. The following code defines a command which inserts data into `users` relation:
103
+
104
+ ``` ruby
105
+ # app/commands/create_user.rb
106
+ class CreateUser < ROM::Commands::Create[:sql]
107
+ relation :users
108
+ register_as :create
109
+ result :one
110
+ end
111
+
112
+ # access registered relation via container
113
+ ROM.env.commands[:users][:create]
114
+ ```
115
+
116
+ ## Defining Custom Mappers
117
+
118
+ If you want to use custom mappers you can place them under `app/mappers`:
119
+
120
+ ``` ruby
121
+ # app/mappers/user_mapper.rb
122
+ class UserMapper < ROM::Mapper
123
+ relation :users
124
+
125
+ # some mapping logic
126
+ end
127
+ ```
128
+
129
+ ## Running alongside ActiveRecord
130
+
131
+ There might be some cases where you will want to run ROM alongside ActiveRecord. Since ROM is designed to work independently, you will need to take few additional steps. ROM creates its own connections and Rails above version 5 won't allow you to drop the database since there are active connections on it.
132
+
133
+ ``` ruby
134
+ # lib/tasks/db.rake
135
+ task :remove_rom_connection => [:environment] do
136
+ ROM.env && ROM.env.disconnect
137
+ end
138
+
139
+ Rake::Task["db:drop"].clear_prerequisites()
140
+ Rake::Task["db:drop"].enhance [:remove_rom_connection, :load_config, :check_protected_environments]
141
+
142
+ Rake::Task["db:reset"].clear_prerequisites()
143
+ Rake::Task["db:reset"].enhance [:remove_rom_connection, "db:drop", "db:setup"]
144
+ ```
145
+
146
+ Since migrations (and other) tasks require environment, ROM will be loaded and will throw an exception, because relations will try to load tables before migrations have actually run. We know this is an ugly solution, but we are working hard to solve this case. This monkey patch will give you reasonable information to act upon if the necessity arises.
147
+
148
+ ``` ruby
149
+ # config/initializers/rom_monkey.rb
150
+ module ROM
151
+ module Rails
152
+ class Railtie < ::Rails::Railtie
153
+ alias_method :create_container!, :create_container
154
+ def create_container
155
+ begin
156
+ create_container!
157
+ rescue => e
158
+ puts "Container failed to initialize because of #{e.inspect}"
159
+ puts "This message comes from the monkey patch in #{__FILE__}, if you are using rake, then this is fine"
160
+ end
161
+ end
162
+ end
163
+ end
164
+ end
165
+ ```
@@ -1,5 +1,5 @@
1
1
  module ROM
2
2
  module Rails
3
- VERSION = '2.2.0'.freeze
3
+ VERSION = '2.3.0'.freeze
4
4
  end
5
5
  end
data/rom-rails.gemspec CHANGED
@@ -17,10 +17,10 @@ Gem::Specification.new do |spec|
17
17
  spec.require_paths = ["lib"]
18
18
 
19
19
  spec.add_runtime_dependency 'addressable', '~> 2.3'
20
- spec.add_runtime_dependency 'dry-core', '~> 0.3'
20
+ spec.add_runtime_dependency 'dry-core', '~> 0.4'
21
21
  spec.add_runtime_dependency 'dry-equalizer', '~> 0.2'
22
- spec.add_runtime_dependency 'railties', '>= 3.0', '< 6.1'
23
- spec.add_runtime_dependency 'rom', '~> 5.0'
22
+ spec.add_runtime_dependency 'railties', '>= 3.0', '< 6.2'
23
+ spec.add_runtime_dependency 'rom', '~> 5.2'
24
24
 
25
25
  spec.add_development_dependency "bundler"
26
26
  spec.add_development_dependency "rake"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rom-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Flipse
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-09-12 00:00:00.000000000 Z
12
+ date: 2021-03-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '0.3'
34
+ version: '0.4'
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.3'
41
+ version: '0.4'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: dry-equalizer
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -62,7 +62,7 @@ dependencies:
62
62
  version: '3.0'
63
63
  - - "<"
64
64
  - !ruby/object:Gem::Version
65
- version: '6.1'
65
+ version: '6.2'
66
66
  type: :runtime
67
67
  prerelease: false
68
68
  version_requirements: !ruby/object:Gem::Requirement
@@ -72,21 +72,21 @@ dependencies:
72
72
  version: '3.0'
73
73
  - - "<"
74
74
  - !ruby/object:Gem::Version
75
- version: '6.1'
75
+ version: '6.2'
76
76
  - !ruby/object:Gem::Dependency
77
77
  name: rom
78
78
  requirement: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '5.0'
82
+ version: '5.2'
83
83
  type: :runtime
84
84
  prerelease: false
85
85
  version_requirements: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '5.0'
89
+ version: '5.2'
90
90
  - !ruby/object:Gem::Dependency
91
91
  name: bundler
92
92
  requirement: !ruby/object:Gem::Requirement
@@ -151,10 +151,15 @@ executables: []
151
151
  extensions: []
152
152
  extra_rdoc_files: []
153
153
  files:
154
+ - ".github/ISSUE_TEMPLATE/----please-don-t-ask-for-support-via-issues.md"
155
+ - ".github/ISSUE_TEMPLATE/---bug-report.md"
156
+ - ".github/ISSUE_TEMPLATE/---feature-request.md"
157
+ - ".github/workflows/ci.yml"
158
+ - ".github/workflows/docsite.yml"
159
+ - ".github/workflows/sync_configs.yml"
154
160
  - ".gitignore"
155
161
  - ".rspec"
156
162
  - ".rubocop.yml"
157
- - ".travis.yml"
158
163
  - CHANGELOG.md
159
164
  - CONTRIBUTING.md
160
165
  - Gemfile
@@ -162,6 +167,7 @@ files:
162
167
  - README.md
163
168
  - Rakefile
164
169
  - db
170
+ - docsite/source/index.html.md
165
171
  - lib/generators/rom.rb
166
172
  - lib/generators/rom/commands/templates/create.rb.erb
167
173
  - lib/generators/rom/commands/templates/delete.rb.erb
data/.travis.yml DELETED
@@ -1,27 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- cache: bundler
4
- bundler_args: --without yard guard benchmarks
5
- script: "RAILS_ENV=test bundle exec rake app:db:reset app:spec"
6
- rvm:
7
- - 2.4.6
8
- - 2.5.5
9
- - 2.6.3
10
- - jruby-9.2.7.0
11
- env:
12
- - RAILS_VERSION=6.0
13
- - RAILS_VERSION=5.2
14
- - RAILS_VERSION=5.1
15
- - RAILS_VERSION=5.0
16
- - RAILS_VERSION=4.2
17
- notifications:
18
- webhooks:
19
- urls:
20
- - https://rom-rb.zulipchat.com/api/v1/external/travis?api_key=S1S2GRkXHlzlaCGyUwm7o4lg50IZrwCH&stream=notifications&topic=ci
21
- on_success: change
22
- on_failure: always
23
- on_start: false
24
- matrix:
25
- exclude:
26
- - rvm: 2.4.6
27
- env: RAILS_VERSION=6.0