checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
2
SHA256:
3
- metadata.gz: e3bd5b772c813ca055bb157f001f938e037c6751164289ffaad33a816094c984
4
- data.tar.gz: e587870e976b82236d791cfb103f3e2e215b680296bac881ac573fc2f22e3f66
3
+ metadata.gz: b0d06c45078456d085945c12374a78a6e8cd8c5ae83ad7abc7fd55cda175e8c4
4
+ data.tar.gz: 18d5755774da8c851c0a39a25bcfa061445ac1acc06a98e27b22acb896443ab2
5
5
SHA512:
6
- metadata.gz: e453df4ddad4bec91db240d267ecf10df8a49efe65b9ce9f7610fd1370f830b0b525b8f7d47060405b1c00a7db7946acc0f03ad90c97599ccd07bd641a6dd7c4
7
- data.tar.gz: d46bd906c8c0759c9a66e5cd94aa943ff33297f27d5de1c017a305c021c6b79a9f5febe9ad620ac06e91abfed713dc7fd4229d4109469540e6586386651aedc4
6
+ metadata.gz: '09235347fa19b0da2ea6f20bebdfc4f2048c51760df3889575d7d6cd376a658ccac01a1053b03feaa7f6f89a329ca60db323aa2eb365b62977e29bd05e20a20c'
7
+ data.tar.gz: cff5ba12b81d820189e145f8b15535ec8ab42942963cb31eb501c359f4f2561171326d1cf93adab12df6d1a540f2f2465f4cb18c304316049561237409005656
data/README.md CHANGED
@@ -34,6 +34,21 @@ Just run `rails g driver my_new_driver_name`.
34
34
The `driver` utility technically works with other generators and rake tasks, but is only guaranteed to work with migrations.
35
35
The reason is that some generators assume a particular path, rather than using the Rails path methods.
36
36
37
+ ### Creating a rake task in a driver
38
+
39
+ Every driver includes a `lib/tasks` directory where you can define rake tasks. Rake tasks defined in drivers are automatically loaded and namespaced.
40
+ For example,
41
+
42
+ ```ruby
43
+ # drivers/my_driver/lib/tasks/my_namespace.rake
44
+ namespace :my_namespace do
45
+ task :task_name do
46
+ end
47
+ end
48
+ ```
49
+
50
+ Can be executed using `rake driver:my_driver:my_namespace:task_name`.
51
+
37
52
### Testing for coupling
38
53
39
54
Since drivers are merged into your main application just like engines, there's nothing stopping them from accessing other drivers, and there's nothing stopping your main application from accessing drivers. In order to ensure those things don't happen, we have a handful of rake tasks:
data/lib/generators/driver/driver_generator.rb CHANGED
@@ -9,7 +9,7 @@ class DriverGenerator < Rails::Generators::NamedBase
9
9
create_file "drivers/#{file_name}/app/views/#{file_name}/.keep", ''
10
10
create_file "drivers/#{file_name}/spec/.keep", ''
11
11
create_file "drivers/#{file_name}/db/migrate/.keep", ''
12
- create_file "drivers/#{file_name}/lib/.keep", ''
12
+ create_file "drivers/#{file_name}/lib/tasks/.keep", ''
13
13
14
14
template 'routes.rb.erb', "drivers/#{file_name}/config/routes.rb"
15
15
template 'initializer.rb.erb', "drivers/#{file_name}/config/initializers/#{file_name}_feature.rb"
data/lib/rails_drivers/railtie.rb CHANGED
@@ -6,6 +6,17 @@ module RailsDrivers
6
6
7
7
rake_tasks do
8
8
load File.expand_path("#{__dir__}/../tasks/rails_drivers_tasks.rake")
9
+
10
+ # load drivers rake tasks
11
+ Dir['drivers/*/lib/tasks/**/*.rake'].each do |driver_rake_file|
12
+ %r{^drivers/(?<driver_name>\w+)/} =~ driver_rake_file
13
+
14
+ namespace(:driver) do
15
+ namespace(driver_name) do
16
+ load driver_rake_file
17
+ end
18
+ end
19
+ end
9
20
end
10
21
11
22
config.before_configuration { setup_paths }
data/lib/rails_drivers/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
# frozen_string_literal: true
2
2
3
3
module RailsDrivers
4
- VERSION = '0.3.2'
4
+ VERSION = '0.4.0'
5
5
end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
--- !ruby/object:Gem::Specification
2
2
name: rails_drivers
3
3
version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.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: 2019-12-23 00:00:00.000000000 Z
11
+ date: 2020-01-14 00:00:00.000000000 Z
12
12
dependencies:
13
13
- !ruby/object:Gem::Dependency
14
14
name: rails