maximus 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/LICENSE.txt +1 -1
- data/README.md +23 -5
- data/lib/maximus/cli.rb +8 -4
- data/lib/maximus/config.rb +161 -149
- data/lib/maximus/config/maximus.yml +60 -2
- data/lib/maximus/config/wraith/nojs.js +3 -1
- data/lib/maximus/config/wraith/snap.js +3 -1
- data/lib/maximus/git_control.rb +224 -119
- data/lib/maximus/helper.rb +7 -25
- data/lib/maximus/lint.rb +64 -88
- data/lib/maximus/lints/brakeman.rb +2 -9
- data/lib/maximus/lints/jshint.rb +1 -5
- data/lib/maximus/lints/railsbp.rb +12 -21
- data/lib/maximus/lints/rubocop.rb +1 -5
- data/lib/maximus/lints/scsslint.rb +1 -4
- data/lib/maximus/reporter/git-lines.sh +8 -22
- data/lib/maximus/statistic.rb +2 -2
- data/lib/maximus/statistics/phantomas.rb +0 -1
- data/lib/maximus/statistics/stylestats.rb +91 -56
- data/lib/maximus/statistics/wraith.rb +79 -21
- data/lib/maximus/version.rb +1 -1
- data/maximus.gemspec +8 -8
- data/roadmap.md +4 -0
- data/spec/maximus/config_spec.rb +98 -5
- data/spec/maximus/git_control_spec.rb +172 -0
- data/spec/maximus/helper_spec.rb +97 -0
- data/spec/maximus/lint_spec.rb +51 -0
- data/spec/spec_helper.rb +5 -0
- data/spec/support/rubocop.yml +1 -0
- metadata +40 -33
- data/lib/maximus/config/rubocop.yml +0 -1007
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b23428dccc821b0c760a0e9e700dae8a98590824
|
4
|
+
data.tar.gz: 584a217684704ba5e28be0362805de0dff016d4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d6782b673a666075f0e8fef4dbbe885a25f5eba717522a6adf3eeb0e89089abaac67a1bea31c6b07a25e6bb8fa188f02ca1b23ad97f301be7e5b3242bdbeaed
|
7
|
+
data.tar.gz: 7b8fe7dfbf4401ba3c12ce4249d790e1b9c6e59c18688c1c75fda55cc998ad3ad1964f6e2ea6e4aa9bb2c9f3a1c431cb9f4f05ead59c5a50884c5258cbf66f8e
|
data/.travis.yml
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -77,18 +77,18 @@ lints: true # all lints including brakeman will run
|
|
77
77
|
|
78
78
|
Flag | Accepts | Description
|
79
79
|
--------------------|----------------------------------|--------------------
|
80
|
-
`-
|
81
|
-
`-u`/`--urls` | String/Array | Statistics only - Space-separated path(s) to relative URLs
|
82
|
-
`-d`/`--domain` | String | Statistics only - Web address (prepended to paths)
|
83
|
-
`-po`/`--port` | String/Numeric | Statistics only - Port to use if required (appended to domain)
|
80
|
+
`-g`/`--sha` | String | Run maximus based on a git commit. See [below](#git-examples)
|
84
81
|
`-f`/`--frontend` | Boolean/Blank | Run all front-end lints
|
85
82
|
`-b`/`--backend` | Boolean/Blank | Run all back-end lints
|
86
83
|
`-s`/`--statistics` | Boolean/Blank | Run all statistics
|
87
84
|
`-a`/`--all` | Boolean/Blank | Run everything
|
88
85
|
`-i`/`--include` | String/Array | Include specific lints or statistics
|
89
86
|
`-i`/`--exclude` | String/Array | Exclude specific lints or statistics
|
90
|
-
`-git`/`--sha` | String | Run maximus based on a git commit. See [below](#git-examples)
|
91
87
|
`-c`/`--config` | String | Path to config file
|
88
|
+
`-fp`/`--filepaths` | String/Array | Space-separated path(s) to files
|
89
|
+
`-u`/`--urls` | String/Array | Statistics only - Space-separated path(s) to relative URLs
|
90
|
+
`-d`/`--domain` | String | Statistics only - Web address (prepended to paths)
|
91
|
+
`-po`/`--port` | String/Numeric | Statistics only - Port to use if required (appended to domain)
|
92
92
|
|
93
93
|
|
94
94
|
* Lint tasks can accept glob notation, i.e. `**/*.scss`
|
@@ -135,8 +135,26 @@ When adding new lints, the JSON output should obey the following format:
|
|
135
135
|
} ]
|
136
136
|
```
|
137
137
|
|
138
|
+
## Notes
|
139
|
+
|
140
|
+
If calling Maximus::Wraith from a script, please see the note in lib/statistics/wraith.rb#result
|
141
|
+
|
138
142
|
## Changelog
|
139
143
|
|
144
|
+
### 0.1.5 (February 1, 2015)
|
145
|
+
|
146
|
+
Bugfixes:
|
147
|
+
|
148
|
+
* Wraith outputs percentages properly
|
149
|
+
* Diff data for initial commits
|
150
|
+
* More intuitive config path discovery
|
151
|
+
* Flip GitControl#diff around for old to new comparison
|
152
|
+
* More stability/defensive programming in Config, Wraith, and GitControl
|
153
|
+
|
154
|
+
Features:
|
155
|
+
|
156
|
+
* Wraith includes images in output
|
157
|
+
|
140
158
|
### 0.1.4 (January 3, 2015)
|
141
159
|
|
142
160
|
Bugfixes:
|
data/lib/maximus/cli.rb
CHANGED
@@ -14,14 +14,14 @@ class Maximus::CLI < Thor
|
|
14
14
|
class_option :filepath, aliases: ['-fp'], type: :array, default: [], desc: "Space-separated path(s) to files"
|
15
15
|
class_option :urls, aliases: ['-u'], type: :array, default: ['/'], desc: "Statistics only - Space-separated path(s) to relative URL paths"
|
16
16
|
class_option :domain, aliases: ['-d'], type: :string, default: 'http://localhost', desc: "Statistics only - Web address (prepended to paths)"
|
17
|
-
class_option :port, aliases: ['-po'], type: :numeric, default:
|
17
|
+
class_option :port, aliases: ['-po'], type: :numeric, default: 3000, desc: 'Statistics only - Port to use if required (appended to domain)'
|
18
18
|
|
19
19
|
class_option :include, aliases: ['-i'], type: :array, default: [], desc: "Include only specific lints or statistics"
|
20
20
|
class_option :exclude, aliases: ['-e'], type: :array, default: [], desc: "Exlude specific lints or statistics"
|
21
21
|
|
22
|
-
class_option :config, aliases: ['-c'], type: :string, default:
|
22
|
+
class_option :config, aliases: ['-c'], type: :string, default: nil, desc: 'Path to config file'
|
23
23
|
|
24
|
-
class_option :git, aliases: ['-g', '--sha'], type: :string, default: 'working', banner: "working, last, master, or sha", desc: "Lint by commit or working copy"
|
24
|
+
class_option :git, aliases: ['-g', '--git', '--sha'], type: :string, default: 'working', banner: "working, last, master, or sha", desc: "Lint by commit or working copy"
|
25
25
|
|
26
26
|
def initialize(*args)
|
27
27
|
super
|
@@ -31,16 +31,19 @@ class Maximus::CLI < Thor
|
|
31
31
|
desc "frontend", "Execute all front-end tasks"
|
32
32
|
def frontend
|
33
33
|
['scsslint', 'jshint'].each { |e| check_exclude(e) }
|
34
|
+
@config.destroy_temp
|
34
35
|
end
|
35
36
|
|
36
37
|
desc "backend", "Lint with all backend lints"
|
37
38
|
def backend
|
38
39
|
['rubocop', 'railsbp', 'brakeman'].each { |e| check_exclude(e) }
|
40
|
+
@config.destroy_temp
|
39
41
|
end
|
40
42
|
|
41
43
|
desc "statistics", "Run all statistics"
|
42
44
|
def statistics
|
43
45
|
['stylestats', 'phantomas', 'wraith'].each { |e| check_exclude(e) }
|
46
|
+
@config.destroy_temp
|
44
47
|
end
|
45
48
|
|
46
49
|
# Alias ruby to backend
|
@@ -61,7 +64,8 @@ class Maximus::CLI < Thor
|
|
61
64
|
return options[:include].each { |i| send(i) } unless options[:include].blank?
|
62
65
|
# If all flag is not enabled, lint working copy as it's supposed to be
|
63
66
|
@config.settings[:commit] = options[:git]
|
64
|
-
|
67
|
+
Maximus::GitControl.new({config: @config}).lints_and_stats(true)
|
68
|
+
@config.destroy_temp
|
65
69
|
end
|
66
70
|
|
67
71
|
# @todo something better than just installing in the global npm file
|
data/lib/maximus/config.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/core_ext/hash/keys'
|
3
|
+
|
1
4
|
module Maximus
|
2
5
|
|
3
6
|
# Global options and configuration
|
@@ -27,127 +30,99 @@ module Maximus
|
|
27
30
|
# @option opts [Hash] :paths ({home: '/'}) labeled relative path to URLs. Statistics only
|
28
31
|
# @option opts [String] :commit accepts sha, "working", "last", or "master".
|
29
32
|
# @option opts [String] :config_file ('maximus.yml') path to config file
|
30
|
-
# @
|
33
|
+
# @option opts [Boolean] :compile_assets (true) compile and destroy assets automagically
|
34
|
+
# @return [#load_config_file #group_families #evaluate_settings] this method is used to set up instance variables
|
31
35
|
def initialize(opts = {})
|
32
|
-
|
36
|
+
|
37
|
+
default_options = {
|
38
|
+
root_dir: root_dir,
|
39
|
+
domain: 'http://localhost',
|
40
|
+
port: is_rails? ? 3000 : '',
|
41
|
+
paths: { 'home' => '/' },
|
42
|
+
is_dev: false,
|
43
|
+
phantomas: false,
|
44
|
+
stylestats: false,
|
45
|
+
wraith: false
|
46
|
+
}
|
47
|
+
|
48
|
+
yaml = default_options.merge load_config_file(opts[:config_file])
|
49
|
+
@settings = yaml.merge opts
|
33
50
|
|
34
51
|
# Only set log file if it's set to true.
|
35
52
|
# Otherwise, allow it to be nil or a path
|
36
|
-
|
53
|
+
@settings[:log] = false if @settings[:log].nil?
|
54
|
+
@settings[:log] ||= 'log/maximus.log' if @settings[:log].is_a?(TrueClass)
|
37
55
|
|
38
|
-
|
39
|
-
|
56
|
+
@settings[:git_log] = false if @settings[:git_log].nil?
|
57
|
+
@settings[:git_log] ||= 'log/maximus_git.log' if @settings[:git_log].is_a?(TrueClass)
|
40
58
|
|
41
|
-
|
42
|
-
opts[:root_dir] ||= root_dir
|
43
|
-
opts[:domain] ||= 'http://localhost'
|
44
|
-
opts[:port] ||= is_rails? ? 3000 : ''
|
45
|
-
opts[:paths] ||= { 'home' => '/' }
|
59
|
+
@settings[:compile_assets] = true if @settings[:compile_assets].nil?
|
46
60
|
|
47
|
-
|
61
|
+
@settings[:paths] = split_paths(@settings[:paths]) if @settings[:paths].is_a?(Array)
|
48
62
|
|
49
|
-
|
50
|
-
@settings = opts
|
63
|
+
group_families
|
51
64
|
|
52
65
|
# Instance variables for Config class only
|
53
66
|
@temp_files = {}
|
54
|
-
|
55
|
-
load_config_file(opts[:config_file])
|
56
|
-
|
57
|
-
group_families
|
58
|
-
|
59
67
|
# Override options with any defined in a discovered config file
|
60
|
-
|
68
|
+
evaluate_settings
|
61
69
|
end
|
62
70
|
|
63
71
|
# Set global options or generate appropriate config files for lints or statistics
|
64
|
-
#
|
65
|
-
# @param yaml_data [Hash] (@yaml) loaded data from the discovered maximus config file
|
72
|
+
# @param settings_data [Hash] (@settings) loaded data from the discovered maximus config file
|
66
73
|
# @return [Hash] paths to temp config files and static options
|
67
74
|
# These should be deleted with destroy_temp after read and loaded
|
68
|
-
def
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
new_data = {}
|
120
|
-
new_data['browser'] = []
|
121
|
-
new_data['browser'] << { browser.to_s => browser.to_s }
|
122
|
-
|
123
|
-
# Regardless of what's in the config, override with maximus,
|
124
|
-
# predictable namespacing
|
125
|
-
new_data['directory'] = "maximus_wraith_#{browser}"
|
126
|
-
new_data['history_dir'] = "maximus_wraith_history_#{browser}"
|
127
|
-
|
128
|
-
# @todo a snap file cannot be set in the config
|
129
|
-
snap_file = case browser
|
130
|
-
when 'casperjs' then 'casper'
|
131
|
-
when 'nojs' then 'nojs'
|
132
|
-
else 'snap'
|
133
|
-
end
|
134
|
-
new_data['snap_file'] = File.join(File.dirname(__FILE__), "config/wraith/#{snap_file}.js")
|
135
|
-
|
136
|
-
@settings[:wraith][browser.to_sym] = wraith_setup(new_data, "wraith_#{browser}")
|
137
|
-
end
|
138
|
-
end
|
139
|
-
else
|
140
|
-
value['browser'] = { 'phantomjs' => 'phantomjs' }
|
141
|
-
value['directory'] = 'maximus_wraith_phantomjs'
|
142
|
-
value['history_dir'] = 'maximus_wraith_history_phantomjs'
|
143
|
-
value['snap_file'] = File.join(File.dirname(__FILE__), "config/wraith/snap.js")
|
144
|
-
@settings[:wraith][:phantomjs] = wraith_setup(value)
|
145
|
-
end
|
146
|
-
|
147
|
-
# Configuration important to all of maximus
|
148
|
-
when 'is_dev', 'log', 'root_dir', 'domain', 'port', 'paths', 'commit'
|
149
|
-
@settings[key.to_sym] = yaml_data[key]
|
150
|
-
end
|
75
|
+
def evaluate_settings(settings_data = @settings)
|
76
|
+
settings_data.each do |key, value|
|
77
|
+
next if value.is_a?(FalseClass)
|
78
|
+
value = {} if value.is_a?(TrueClass)
|
79
|
+
|
80
|
+
case key
|
81
|
+
|
82
|
+
when :jshint, :JSHint, :JShint
|
83
|
+
|
84
|
+
# @todo DRY this load_config up, but can't call it at the start because of the
|
85
|
+
# global config variables (last when statement in this switch)
|
86
|
+
value = load_config(value)
|
87
|
+
|
88
|
+
if settings_data[key].is_a?(Hash) && settings_data[key].has_key?('jshintignore')
|
89
|
+
jshintignore_file = []
|
90
|
+
settings_data[key]['jshintignore'].each { |i| jshintignore_file << "#{i}\n" }
|
91
|
+
@settings[:jshintignore] = temp_it('jshintignore.json', jshintignore_file)
|
92
|
+
end
|
93
|
+
@settings[:jshint] = temp_it('jshint.json', value.to_json)
|
94
|
+
|
95
|
+
when :scsslint, :SCSSlint
|
96
|
+
value = load_config(value)
|
97
|
+
|
98
|
+
@settings[:scsslint] = temp_it('scsslint.yml', value.to_yaml)
|
99
|
+
|
100
|
+
when :rubocop, :Rubocop, :RuboCop
|
101
|
+
value = load_config(value)
|
102
|
+
|
103
|
+
@settings[:rubocop] = temp_it('rubocop.yml', value.to_yaml)
|
104
|
+
|
105
|
+
when :brakeman
|
106
|
+
@settings[:brakeman] = settings_data[key]
|
107
|
+
|
108
|
+
when :rails_best_practice, :railsbp
|
109
|
+
@settings[:railsbp] = settings_data[key]
|
110
|
+
|
111
|
+
when :stylestats, :Stylestats
|
112
|
+
value = load_config(value)
|
113
|
+
@settings[:stylestats] = temp_it('stylestats.json', value.to_json)
|
114
|
+
|
115
|
+
when :phantomas, :Phantomas
|
116
|
+
value = load_config(value)
|
117
|
+
@settings[:phantomas] = temp_it('phantomas.json', value.to_json)
|
118
|
+
|
119
|
+
when :wraith, :Wraith
|
120
|
+
value = load_config(value)
|
121
|
+
evaluate_for_wraith(value)
|
122
|
+
|
123
|
+
# Configuration important to all of maximus
|
124
|
+
when :is_dev, :log, :root_dir, :domain, :port, :paths, :commit
|
125
|
+
@settings[key] = settings_data[key]
|
151
126
|
end
|
152
127
|
end
|
153
128
|
|
@@ -175,17 +150,23 @@ module Maximus
|
|
175
150
|
|
176
151
|
# Remove all or one created temporary config file
|
177
152
|
# @see temp_it
|
178
|
-
# @param filename [String] file to destroy
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
153
|
+
# @param filename [String] (nil) file to destroy
|
154
|
+
# If nil, destroy all temp files
|
155
|
+
def destroy_temp(filename = nil)
|
156
|
+
if filename.nil?
|
157
|
+
@temp_files.each { |filename, file| file.unlink }
|
158
|
+
@temp_files = {}
|
159
|
+
else
|
160
|
+
return if @temp_files[filename.to_sym].blank?
|
161
|
+
@temp_files[filename.to_sym].unlink
|
162
|
+
@temp_files.delete(filename.to_sym)
|
163
|
+
end
|
183
164
|
end
|
184
165
|
|
185
166
|
# Combine domain with port if necessary
|
186
167
|
# @return [String] complete domain/host address
|
187
168
|
def domain
|
188
|
-
(!@settings[:port].blank?
|
169
|
+
(!@settings[:port].blank?) ? "#{@settings[:domain]}:#{@settings[:port]}" : @settings[:domain]
|
189
170
|
end
|
190
171
|
|
191
172
|
|
@@ -193,44 +174,41 @@ module Maximus
|
|
193
174
|
|
194
175
|
# Look for a maximus config file
|
195
176
|
#
|
196
|
-
# Checks ./maximus.yml,
|
177
|
+
# Checks ./maximus.yml, ./.maximus.yml, ./config/maximus.yml in order.
|
197
178
|
# If there hasn't been a file discovered yet, checks ./config/maximus.yml
|
198
179
|
# and if there still isn't a file, load the default one included with the
|
199
180
|
# maximus gem.
|
200
181
|
#
|
201
182
|
# @since 0.1.4
|
202
183
|
# @param file_path [String]
|
203
|
-
# @return @
|
184
|
+
# @return @settings [Hash]
|
204
185
|
def load_config_file(file_path)
|
205
186
|
|
206
187
|
conf_location = if !file_path.nil? && File.exist?(file_path)
|
207
188
|
file_path
|
208
189
|
else
|
209
|
-
config_exists('maximus.yml') || config_exists('maximus.
|
190
|
+
config_exists('.maximus.yml') || config_exists('maximus.yml') || check_default_config_path('config/maximus.yml')
|
210
191
|
end
|
211
192
|
|
212
|
-
|
193
|
+
yaml = YAML.load_file(conf_location)
|
213
194
|
|
214
|
-
|
215
|
-
@yaml['domain'] ||= @settings[:domain]
|
216
|
-
@yaml['paths'] ||= @settings[:paths]
|
217
|
-
@yaml['port'] ||= @settings[:port]
|
195
|
+
yaml.symbolize_keys
|
218
196
|
|
219
197
|
end
|
220
198
|
|
221
199
|
# Allow shorthand to be declared for groups Maximus executions
|
222
200
|
#
|
223
201
|
# @example disable statistics
|
224
|
-
# @
|
202
|
+
# @settings[:statistics] = false
|
225
203
|
# set_families('statistics', ['phantomas', 'stylestats', 'wraith'])
|
226
204
|
#
|
227
205
|
# Sets as Boolean based on whether or not the queried label is `true`
|
228
|
-
# @param head_of_house [String] @
|
229
|
-
# @param family [Array] group of other @
|
230
|
-
# @return [void] modified @
|
206
|
+
# @param head_of_house [String] @settings key and group label
|
207
|
+
# @param family [Array] group of other @settings keys to be disabled
|
208
|
+
# @return [void] modified @settings
|
231
209
|
def set_families(head_of_house, family)
|
232
|
-
if @
|
233
|
-
family.each { |f| @
|
210
|
+
if @settings.has_key?(head_of_house)
|
211
|
+
family.each { |f| @settings[f] ||= @settings[head_of_house].is_a?(TrueClass) }
|
234
212
|
end
|
235
213
|
end
|
236
214
|
|
@@ -259,9 +237,11 @@ module Maximus
|
|
259
237
|
# @return [String] absolute path to new config file
|
260
238
|
def temp_it(filename, data)
|
261
239
|
ext = filename.split('.')
|
262
|
-
file = Tempfile.new([filename, ".#{ext[1]}"])
|
263
|
-
|
264
|
-
|
240
|
+
file = Tempfile.new([filename, ".#{ext[1]}"]).tap do |f|
|
241
|
+
f.rewind
|
242
|
+
f.write(data)
|
243
|
+
f.close
|
244
|
+
end
|
265
245
|
@temp_files[ext[0].to_sym] = file
|
266
246
|
file.path
|
267
247
|
end
|
@@ -282,7 +262,7 @@ module Maximus
|
|
282
262
|
# @since 0.1.4
|
283
263
|
# @param paths [Array]
|
284
264
|
# @return [Hash]
|
285
|
-
def
|
265
|
+
def split_paths(paths)
|
286
266
|
new_paths = {}
|
287
267
|
paths.each do |p|
|
288
268
|
if p.split('/').length > 1
|
@@ -298,44 +278,76 @@ module Maximus
|
|
298
278
|
# @since 0.1.4
|
299
279
|
# @todo the command line options are overriden here and it should be the other way around
|
300
280
|
def group_families
|
301
|
-
set_families(
|
302
|
-
set_families(
|
303
|
-
set_families(
|
304
|
-
set_families(
|
305
|
-
set_families(
|
306
|
-
set_families(
|
281
|
+
set_families(:lints, [:jshint, :scsslint, :rubocop, :brakeman, :railsbp])
|
282
|
+
set_families(:frontend, [:jshint, :scsslint, :phantomas, :stylestats, :wraith])
|
283
|
+
set_families(:backend, [:rubocop, :brakeman, :railsbp])
|
284
|
+
set_families(:ruby, [:rubocop, :brakeman, :railsbp])
|
285
|
+
set_families(:statistics, [:phantomas, :stylestats, :wraith])
|
286
|
+
set_families(:all, [:lints, :statistics])
|
307
287
|
end
|
308
288
|
|
309
289
|
# Wraith is a complicated gem with significant configuration
|
310
|
-
#
|
311
|
-
# @see yaml_evaluate
|
312
|
-
# @see temp_it
|
313
|
-
#
|
290
|
+
# @see yaml_evaluate, temp_it
|
314
291
|
# @param value [Hash] modified data from a wraith config or injected data
|
315
292
|
# @param name [String] ('wraith') config file name to write and eventually load
|
316
293
|
# @return [String] temp file path
|
317
294
|
def wraith_setup(value, name = 'phantomjs')
|
318
295
|
|
319
|
-
if @
|
320
|
-
value['domains'] =
|
296
|
+
if @settings.has_key?(:urls)
|
297
|
+
value['domains'] = @settings[:urls]
|
321
298
|
else
|
322
299
|
value['domains'] = {}
|
323
300
|
# @see #domain
|
324
301
|
value['domains']['main'] = domain
|
325
302
|
end
|
326
303
|
|
304
|
+
# Set wraith defaults unless they're already defined
|
327
305
|
# Wraith requires this screen_width config to be present
|
328
|
-
value['screen_widths'] ||= [
|
329
|
-
|
330
|
-
value['paths'] = @yaml['paths']
|
306
|
+
value['screen_widths'] ||= [1280, 1024, 767]
|
307
|
+
value['fuzz'] ||= '20%'
|
331
308
|
value['threshold'] ||= 0
|
332
309
|
|
333
|
-
|
334
|
-
#
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
310
|
+
value['paths'] = @settings[:paths]
|
311
|
+
temp_it("#{name}.yaml", value.to_yaml)
|
312
|
+
end
|
313
|
+
|
314
|
+
# Apply wraith defaults/merge existing config
|
315
|
+
# @since 0.1.5
|
316
|
+
# @see yaml_evaluate
|
317
|
+
# @param value [Hash]
|
318
|
+
def evaluate_for_wraith(value)
|
319
|
+
@settings[:wraith] = {}
|
320
|
+
|
321
|
+
if value.include?('browser')
|
322
|
+
value['browser'].each do |browser, browser_value|
|
323
|
+
next if browser_value.is_a?(FalseClass)
|
324
|
+
|
325
|
+
# @todo a snap file cannot be set in the config
|
326
|
+
snap_file = case browser
|
327
|
+
when 'casperjs' then 'casper'
|
328
|
+
when 'nojs' then 'nojs'
|
329
|
+
else 'snap'
|
330
|
+
end
|
331
|
+
|
332
|
+
new_data = {
|
333
|
+
'browser' => [{ browser.to_s => browser.to_s }],
|
334
|
+
'directory' => "maximus_wraith_#{browser}",
|
335
|
+
'history_dir' => "maximus_wraith_history_#{browser}",
|
336
|
+
'snap_file' => File.join(File.dirname(__FILE__), "config/wraith/#{snap_file}.js")
|
337
|
+
}
|
338
|
+
|
339
|
+
@settings[:wraith][browser.to_sym] = wraith_setup(new_data, "maximus_wraith_#{browser}")
|
340
|
+
end
|
341
|
+
else
|
342
|
+
append_value = {
|
343
|
+
'browser' => { 'phantomjs' => 'phantomjs' },
|
344
|
+
'directory' => 'maximus_wraith_phantomjs',
|
345
|
+
'history_dir' => 'maximus_wraith_history_phantomjs',
|
346
|
+
'snap_file' => File.join(File.dirname(__FILE__), "config/wraith/snap.js")
|
347
|
+
}
|
348
|
+
@settings[:wraith][:phantomjs] = wraith_setup value.merge(append_value)
|
349
|
+
end
|
350
|
+
|
339
351
|
end
|
340
352
|
|
341
353
|
end
|