File tree Expand file tree Collapse file tree 3 files changed +30
-11
lines changed Expand file tree Collapse file tree 3 files changed +30
-11
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ module Bootstrap
31
31
#
32
32
# rubocop:disable Metrics/MethodLength
33
33
def self . apply ( world , config )
34
+ # TOOD: Have this behind a conditional.
34
35
config = Rails . call ( world , config )
35
36
36
37
env = Env
Original file line number Diff line number Diff line change 1
1
module Mutant
2
2
module Bootstrap
3
- module Rails
4
- def self . call ( world , config )
3
+ class Rails
4
+ include Procto . call , Concord . new ( :world , :config )
5
+
6
+ def call
5
7
world . stdout . puts ( 'Loading mutant config from rails environment' )
6
8
7
- # TODO move to world.
9
+ # TODO add env to world.
10
+ #
11
+ # Make actual env configurable
8
12
ENV [ 'RAILS_ENV' ] = 'test'
9
13
10
14
world . kernel . require ( './config/environment.rb' )
11
15
12
16
::Rails . application . eager_load!
13
17
18
+ # TODO: preload engines, these *love* to pack things
19
+ # in the main project
20
+ #
21
+ # TODO: allow custom preload hooks.
22
+
23
+ add_rails_matchers
24
+ end
25
+
26
+ private
27
+
28
+ def add_rails_matchers
29
+ # This logic sucks, instead rails should be come a match expression
30
+ # possibly allow match expressions like: `ActionController.subclasses`
31
+ return config if config . matcher . match_expressions . any?
32
+
33
+ config . with (
34
+ matcher : config . matcher . with ( match_expressions : rails_expressions )
35
+ )
36
+ end
37
+
38
+ def rails_expressions
14
39
expressions = [
15
40
ApplicationController ,
16
41
*ApplicationController . subclasses ,
17
42
ApplicationRecord ,
18
43
*ApplicationRecord . subclasses
19
44
] . map { |klass | config . expression_parser . apply ( klass . name ) . from_right }
20
-
21
- config . with (
22
- matcher : config . matcher . with (
23
- match_expressions : config . matcher . match_expressions | expressions
24
- )
25
- )
26
45
end
46
+
27
47
end # Rails
28
48
end # Bootstrap
29
49
end # Mutant
Original file line number Diff line number Diff line change @@ -13,8 +13,6 @@ module License
13
13
#
14
14
# @api private
15
15
def self . apply ( world )
16
- return Either ::Right . new ( nil )
17
-
18
16
load_mutant_license ( world )
19
17
. fmap { license_path ( world ) }
20
18
. bind { |path | Subscription . load ( world , world . json . load ( path ) ) }
You can’t perform that action at this time.
0 commit comments