checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
---
2
2
SHA256:
3
- metadata.gz: c1a6d5d74bee020f790b4ec042f39215edf58006fbbc066f66a360d3e83f9c04
4
- data.tar.gz: 814d8586495d7d17ad59e3d19eb000d9201c24a7887f2076458e636c52060ed4
3
+ metadata.gz: 5d89500c784b448bee79b8f6dcbbdd6d52e690fe28eb6ddb6a4d918bec014f6e
4
+ data.tar.gz: 8243b98b70951510ebdf4556c7861ff7e20a285264a1647339d6bc72bb78ef9a
5
5
SHA512:
6
- metadata.gz: 6f2b16b37178251f2db01a8179bd5667c29f5b343f31065fe528d67ab5b4bc867fca06b6d89365bb0ae576cd2b00637de26489877f79975c55a381470f7936fd
7
- data.tar.gz: 0163403e918a3ea591b19fb80bc1bd933c47fcacbf2177d0973379bdb03c8c2bbc1e920211f60ff2c4149c4defecf87d8dc0ea9bf69a8b217840d418fb26635e
6
+ metadata.gz: cf2051ce415f212e9b86ac84bcddcd76f8968d8511baabac421f2017610e09a803c9a0ad7bc769af75e07931e3085007ee61ab1bd098ba7354fd04dcbd050cca
7
+ data.tar.gz: bbdca385be05e5331742f988154b08953fad7ae1c12ed18886c9e7e12d583f2dd35b538b69057e170afc26cea176caa78703e23d16e0a28b657a3b9eb6c0087e
data/README.md CHANGED
@@ -54,6 +54,11 @@ rake driver:restore
54
54
rake driver:isolate[admin]
55
55
rspec --pattern '{spec,drivers/*/spec}/**{,/*/**}/*_spec.rb'
56
56
rake driver:restore
57
+
58
+ # Short-hand with 'driver' utility!
59
+ bundle exec driver admin do rspec --pattern '{spec,drivers/*/spec}/**{,/*/**}/*_spec.rb'
60
+ # (can run with no drivers as well)
61
+ bundle exec nodriver do rspec --pattern '{spec,drivers/*/spec}/**{,/*/**}/*_spec.rb'
57
62
```
58
63
59
64
This lets you to ensure that the store and admin function properly without each other. Note we're running all of the main app's specs twice. This is good because we also want to make sure the main app is not reaching into drivers.
data/bin/driver CHANGED
@@ -1,15 +1,39 @@
1
1
#!/usr/bin/env ruby
2
2
# frozen_string_literal: true
3
3
4
- APP_PATH = File.expand_path('config/application')
4
+ require 'rails_drivers/files'
5
- require_relative "#{Dir.pwd}/config/boot"
6
5
7
- REPLACE_DEFAULT_PATH_WITH_DRIVER = ARGV.shift
6
+ selected_driver = ARGV.shift
8
7
9
- possible_drivers = Dir['drivers/*'].map { |d| d.split('/').last }
10
- unless possible_drivers.include?(REPLACE_DEFAULT_PATH_WITH_DRIVER)
11
- puts "Unknown driver #{REPLACE_DEFAULT_PATH_WITH_DRIVER}. Must be one of [#{possible_drivers.join(', ')}]"
12
- exit 1
13
- end
8
+ if ARGV[0] == 'do'
9
+ #
10
+ # Run any command with only one driver present
11
+ #
12
+ ARGV.shift
13
+ at_exit { RailsDrivers::Files.restore }
14
+
15
+ if selected_driver == '_clear'
16
+ RailsDrivers::Files.clear
17
+ else
18
+ RailsDrivers::Files.isolate selected_driver
19
+ end
20
+
21
+ Process.wait Process.spawn(*ARGV)
22
+ exit Process.last_status.exitstatus
23
+ else
24
+ #
25
+ # Run 'rails' command as if the driver was the rails app.
26
+ #
27
+ APP_PATH = File.expand_path('config/application')
28
+ REPLACE_DEFAULT_PATH_WITH_DRIVER = selected_driver
14
29
15
- require 'rails/commands'
30
+ require_relative "#{Dir.pwd}/config/boot"
31
+
32
+ possible_drivers = Dir['drivers/*'].map { |d| d.split('/').last }
33
+ unless possible_drivers.include?(REPLACE_DEFAULT_PATH_WITH_DRIVER)
34
+ puts "Unknown driver #{REPLACE_DEFAULT_PATH_WITH_DRIVER}. Must be one of [#{possible_drivers.join(', ')}]"
35
+ exit 1
36
+ end
37
+
38
+ require 'rails/commands'
39
+ end
data/bin/nodriver ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'rails_drivers/files'
5
+
6
+ ARGV.shift if ARGV[0] == 'do'
7
+
8
+ at_exit { RailsDrivers::Files.restore }
9
+ RailsDrivers::Files.clear
10
+ Process.wait Process.spawn(*ARGV)
11
+ exit Process.last_status.exitstatus
data/lib/rails_drivers.rb CHANGED
@@ -5,11 +5,13 @@ require 'rails_drivers/setup'
5
5
require 'rails_drivers/railtie'
6
6
7
7
module RailsDrivers
8
- def self.loaded
9
- @loaded ||= []
10
- end
8
+ class << self
9
+ def loaded
10
+ @loaded ||= []
11
+ end
11
12
12
- def self.freeze!
13
- @loaded = @loaded&.freeze
13
+ def freeze!
14
+ @loaded = @loaded&.freeze
15
+ end
14
16
end
15
17
end
data/lib/rails_drivers/files.rb ADDED
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsDrivers
4
+ module Files
5
+ class Error < StandardError
6
+ end
7
+
8
+ module_function
9
+
10
+ def isolate(driver)
11
+ raise Error, 'No driver specified' if driver.nil? || driver == ''
12
+ raise Error, "Driver #{driver.inspect} not found" unless File.exist?("drivers/#{driver}")
13
+
14
+ FileUtils.mkdir_p 'tmp/drivers'
15
+ Dir['drivers/*'].each do |driver_path|
16
+ next if driver_path.include?("/#{driver}")
17
+
18
+ FileUtils.mv driver_path, "tmp/#{driver_path}"
19
+ end
20
+ end
21
+
22
+ def clear
23
+ FileUtils.mkdir_p 'tmp/drivers'
24
+ Dir['drivers/*'].each do |driver_path|
25
+ FileUtils.mv driver_path, "tmp/#{driver_path}"
26
+ end
27
+ end
28
+
29
+ def restore
30
+ Dir['tmp/drivers/*'].each do |tmp_driver_path|
31
+ driver = tmp_driver_path.split('/').last
32
+ FileUtils.mv tmp_driver_path, "drivers/#{driver}"
33
+ end
34
+ end
35
+ end
36
+ end
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.0'
4
+ VERSION = '0.3.1'
5
5
end
data/lib/tasks/rails_drivers_tasks.rake CHANGED
@@ -1,46 +1,23 @@
1
1
# frozen_string_literal: true
2
2
3
3
namespace :driver do
4
- DriverError = Class.new(StandardError)
5
-
6
4
desc 'Removes every driver but the one specified. Can be undone with driver:restore.'
7
5
task :isolate, [:driver] do |_t, args|
8
- include FileUtils
9
-
10
- raise DriverError, 'No driver specified' if args.driver.blank?
6
+ require 'rails_drivers/files'
7
+ RailsDrivers::Files.isolate(args.driver)
8
+ rescue RailsDrivers::Files::Error => e
11
- raise DriverError, 'Driver not found' unless File.exist?("drivers/#{args.driver}")
12
-
13
- mkdir_p 'tmp/drivers'
14
- Dir['drivers/*'].each do |driver_path|
15
- next if driver_path.include?("/#{args.driver}")
16
-
17
- mv driver_path, "tmp/#{driver_path}"
18
- puts "Moved #{driver_path} to tmp/drivers/"
19
- end
20
-
21
- rescue DriverError => e
22
9
puts e.message
23
10
end
24
11
25
12
desc 'Removes all drivers. Can be undone with driver:restore.'
26
13
task :clear do
27
- include FileUtils
28
-
14
+ require 'rails_drivers/files'
15
+ RailsDrivers::Files.clear
29
- mkdir_p 'tmp/drivers'
30
- Dir['drivers/*'].each do |driver_path|
31
- mv driver_path, "tmp/#{driver_path}"
32
- puts "Moved #{driver_path} to tmp/drivers/"
33
- end
34
16
end
35
17
36
18
desc 'Undoes the effects of driver:isolate and driver:clear.'
37
19
task :restore do
38
- include FileUtils
39
-
20
+ require 'rails_drivers/files'
21
+ RailsDrivers::Files.restore
40
- Dir['tmp/drivers/*'].each do |tmp_driver_path|
41
- driver = tmp_driver_path.split('/').last
42
- mv tmp_driver_path, "drivers/#{driver}"
43
- puts "Moved #{tmp_driver_path} to drivers/"
44
- end
45
22
end
46
23
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.0
4
+ version: 0.3.1
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-18 00:00:00.000000000 Z
11
+ date: 2019-12-20 00:00:00.000000000 Z
12
12
dependencies:
13
13
- !ruby/object:Gem::Dependency
14
14
name: rails
@@ -72,6 +72,7 @@ email:
72
72
- nbaillie@degica.com
73
73
executables:
74
74
- driver
75
+ - nodriver
75
76
extensions: []
76
77
extra_rdoc_files: []
77
78
files:
@@ -79,12 +80,14 @@ files:
79
80
- README.md
80
81
- Rakefile
81
82
- bin/driver
83
+ - bin/nodriver
82
84
- lib/generators/driver/USAGE
83
85
- lib/generators/driver/driver_generator.rb
84
86
- lib/generators/driver/templates/initializer.rb.erb
85
87
- lib/generators/driver/templates/module.rb.erb
86
88
- lib/generators/driver/templates/routes.rb.erb
87
89
- lib/rails_drivers.rb
90
+ - lib/rails_drivers/files.rb
88
91
- lib/rails_drivers/railtie.rb
89
92
- lib/rails_drivers/routes.rb
90
93
- lib/rails_drivers/setup.rb
@@ -109,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
112
- !ruby/object:Gem::Version
110
113
version: '0'
111
114
requirements: []
112
- rubygems_version: 3.0.6
115
+ rubygems_version: 3.0.3
113
116
signing_key:
114
117
specification_version: 4
115
118
summary: De-coupled separation of concerns for Rails