Class: Wraith::Wraith
- Inherits:
-
Object
- Object
- Wraith::Wraith
- Defined in:
- lib/wraith/wraith.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
- #base_domain ⇒ Object
- #base_domain_label ⇒ Object
- #comp_domain ⇒ Object
- #comp_domain_label ⇒ Object
- #directory ⇒ Object
- #domains ⇒ Object
- #engine ⇒ Object
- #fuzz ⇒ Object
-
#initialize(config_name) ⇒ Wraith
constructor
A new instance of Wraith.
- #mode ⇒ Object
- #paths ⇒ Object
- #phantomjs_options ⇒ Object
- #sitemap ⇒ Object
- #snap_file ⇒ Object
- #spider_days ⇒ Object
- #spider_file ⇒ Object
- #spider_skips ⇒ Object
- #widths ⇒ Object
Constructor Details
#initialize(config_name) ⇒ Wraith
Returns a new instance of Wraith.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/wraith/wraith.rb', line 6 def initialize(config_name) if File.exist?(config_name) && File.extname(config_name) == '.yaml' @config = YAML.load(File.open(config_name)) else @config = YAML.load(File.open("configs/#{config_name}.yaml")) end rescue puts 'unable to find config' exit 1 end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
4 5 6 |
# File 'lib/wraith/wraith.rb', line 4 def config @config end |
Instance Method Details
#base_domain ⇒ Object
33 34 35 |
# File 'lib/wraith/wraith.rb', line 33 def base_domain domains[base_domain_label] end |
#base_domain_label ⇒ Object
41 42 43 |
# File 'lib/wraith/wraith.rb', line 41 def base_domain_label domains.keys[0] end |
#comp_domain ⇒ Object
37 38 39 |
# File 'lib/wraith/wraith.rb', line 37 def comp_domain domains[comp_domain_label] end |
#comp_domain_label ⇒ Object
45 46 47 |
# File 'lib/wraith/wraith.rb', line 45 def comp_domain_label domains.keys[1] end |
#directory ⇒ Object
17 18 19 |
# File 'lib/wraith/wraith.rb', line 17 def directory @config['directory'].first end |
#domains ⇒ Object
29 30 31 |
# File 'lib/wraith/wraith.rb', line 29 def domains @config['domains'] end |
#engine ⇒ Object
69 70 71 |
# File 'lib/wraith/wraith.rb', line 69 def engine @config['browser'] end |
#fuzz ⇒ Object
73 74 75 |
# File 'lib/wraith/wraith.rb', line 73 def fuzz @config['fuzz'] end |
#mode ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/wraith/wraith.rb', line 77 def mode if %w(diffs_only diffs_first alphanumeric).include?(@config['mode']) @config['mode'] else 'alphanumeric' end end |
#paths ⇒ Object
65 66 67 |
# File 'lib/wraith/wraith.rb', line 65 def paths @config['paths'] end |
#phantomjs_options ⇒ Object
85 86 87 |
# File 'lib/wraith/wraith.rb', line 85 def @config['phantomjs_options'] end |
#sitemap ⇒ Object
57 58 59 |
# File 'lib/wraith/wraith.rb', line 57 def sitemap @config['sitemap'] end |
#snap_file ⇒ Object
21 22 23 |
# File 'lib/wraith/wraith.rb', line 21 def snap_file @config['snap_file'] ? @config['snap_file'] : File.('lib/wraith/javascript/snap.js') end |
#spider_days ⇒ Object
53 54 55 |
# File 'lib/wraith/wraith.rb', line 53 def spider_days @config['spider_days'] end |
#spider_file ⇒ Object
49 50 51 |
# File 'lib/wraith/wraith.rb', line 49 def spider_file @config['spider_file'] ? @config['spider_file'] : 'spider.txt' end |
#spider_skips ⇒ Object
61 62 63 |
# File 'lib/wraith/wraith.rb', line 61 def spider_skips @config['spider_skips'] end |
#widths ⇒ Object
25 26 27 |
# File 'lib/wraith/wraith.rb', line 25 def widths @config['screen_widths'] end |