rails_drivers 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -3
- data/lib/rails_drivers/extensions.rb +1 -0
- data/lib/rails_drivers/railtie.rb +13 -0
- data/lib/rails_drivers/setup.rb +11 -3
- data/lib/rails_drivers/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c7d656ab0c27596f48e919c471b2ccfa30859bc808ae8942e24d8924fbbe7e7
|
4
|
+
data.tar.gz: 65275e5544bb6b1a76c82c106fd2f8cd7df6a346422a8accf655fb5026df06d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c03812aa671e2305a5dd04a373a4bb2fe06bb37f307ade5bf3a74398b8d0722c97b94a8cb71f372eb53699bc5101260804da1b9d3f98ac34f13c3fe4740485b5
|
7
|
+
data.tar.gz: c43ef0a47625c66942ef8c841b917047bf6b63945d9ac483fe202d5630b0da8b07088ba586acaceab1606de128e749422ed547f3498be191864e4478ee49ae48
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ Technically speaking, "driver" is just a fancy name for code that live in a diff
|
|
11
11
|
|
12
12
|
The "main app" refers to the files inside your `<project root>/app` directory.
|
13
13
|
|
14
|
-
If your test suite is good enough (see [Testing for coupling](#testing-for-coupling), you can test that these rules are adhered to by selectively adding and removing drivers before running your tests.
|
14
|
+
If your test suite is good enough (see [Testing for coupling](#testing-for-coupling)), you can test that these rules are adhered to by selectively adding and removing drivers before running your tests.
|
15
15
|
|
16
16
|
## Aren't these just engines?
|
17
17
|
|
@@ -44,7 +44,7 @@ Run `rails g driver my_new_driver_name` to get a scaffold driver.
|
|
44
44
|
`bundle exec driver my_driver_name generate migration blah etc_etc:string`
|
45
45
|
|
46
46
|
The `driver` utility technically works with other generators and rake tasks, but is only guaranteed to work with migrations.
|
47
|
-
The reason is that some generators have hard-coded path
|
47
|
+
The reason is that some generators have hard-coded path strings, rather than using the Rails path methods.
|
48
48
|
|
49
49
|
### Creating a rake task in a driver
|
50
50
|
|
@@ -132,6 +132,8 @@ Of course there's nothing stopping you from using if-statements to detect whethe
|
|
132
132
|
## Installation
|
133
133
|
Add this line to your application's Gemfile:
|
134
134
|
|
135
|
+
### Install the gem
|
136
|
+
|
135
137
|
```ruby
|
136
138
|
gem 'rails_drivers'
|
137
139
|
```
|
@@ -141,15 +143,21 @@ And then execute:
|
|
141
143
|
$ bundle install
|
142
144
|
```
|
143
145
|
|
144
|
-
|
146
|
+
### Update routes file
|
147
|
+
|
148
|
+
Add these lines to your routes.rb:
|
145
149
|
|
146
150
|
```ruby
|
151
|
+
# config/routes.rb in your main Rails app
|
152
|
+
|
147
153
|
require 'rails_drivers/routes'
|
148
154
|
|
149
155
|
# This can go before or after your application's route definitions
|
150
156
|
RailsDrivers::Routes.load_driver_routes
|
151
157
|
```
|
152
158
|
|
159
|
+
This will tell your main Rails app to load the `routes.rb` files generated in each of your drivers.
|
160
|
+
|
153
161
|
### RSpec
|
154
162
|
|
155
163
|
If you use RSpec with FactoryBot, add these lines to your `spec/rails_helper.rb` or `spec/spec_helper.rb`:
|
@@ -19,6 +19,19 @@ module RailsDrivers
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
# Since the extensions directory exists for organizational
|
23
|
+
# purposes and does not define modules with namespace `Extention`
|
24
|
+
# we need to use Zeitwerk collapse function.
|
25
|
+
#
|
26
|
+
# see https://github.com/fxn/zeitwerk#collapsing-directories
|
27
|
+
if Rails::VERSION::MAJOR >= 6
|
28
|
+
initializer 'rails_drivers.autoloader.collapse' do
|
29
|
+
Rails.autoloaders.each do |loader|
|
30
|
+
loader.collapse('drivers/*/extensions')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
22
35
|
config.before_configuration { setup_paths }
|
23
36
|
config.after_initialize { RailsDrivers.freeze! }
|
24
37
|
end
|
data/lib/rails_drivers/setup.rb
CHANGED
@@ -34,20 +34,28 @@ module RailsDrivers
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def replace_rails_paths_with_driver(driver_name)
|
37
|
+
rails_config.autoload_paths << "#{rails_config.root}/drivers"
|
38
|
+
|
37
39
|
DRIVER_PATHS.each do |path|
|
38
40
|
rails_config.paths[path] = "drivers/#{driver_name}/#{path}"
|
39
|
-
rails_config.autoload_paths
|
41
|
+
rails_config.autoload_paths += [
|
42
|
+
"#{rails_config.root}/drivers/#{driver_name}/lib"
|
43
|
+
]
|
40
44
|
end
|
41
45
|
end
|
42
46
|
|
43
|
-
def add_every_driver_to_rails_paths
|
47
|
+
def add_every_driver_to_rails_paths # rubocop:disable Metrics/AbcSize
|
48
|
+
rails_config.autoload_paths << "#{rails_config.root}/drivers"
|
49
|
+
|
44
50
|
Dir['drivers/*'].each do |driver|
|
45
51
|
DRIVER_PATHS.each do |path|
|
46
52
|
rails_config.paths[path] << "#{driver}/#{path}"
|
47
53
|
end
|
48
54
|
|
49
55
|
# We want to autoload driver/*/lib folders
|
50
|
-
rails_config.autoload_paths += [
|
56
|
+
rails_config.autoload_paths += [
|
57
|
+
"#{rails_config.root}/#{driver}/lib"
|
58
|
+
]
|
51
59
|
end
|
52
60
|
end
|
53
61
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_drivers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nigel Baillie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '5.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '5.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: webpacker
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '0'
|
83
83
|
description: Like Rails Engines, but without the friction. Your Rails app can't access
|
84
84
|
them, and they can't access each other.
|
85
85
|
email:
|