Skip to content

Commit

Permalink
removed duplication of core files
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisBAshton committed Aug 11, 2015
1 parent ed86edb commit afa232f
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 145 deletions.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions lib/wraith/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ class Wraith::CLI < Thor
attr_accessor :config_name

def self.source_root
File.expand_path("../../../templates/", __FILE__)
File.expand_path("../../../", __FILE__)
end

desc "setup", "creates config folder and default config"
def setup
template("configs/config.yaml", "configs/config.yaml")
template("javascript/snap.js", "javascript/snap.js")
template("configs/templates/config.yaml", "configs/config.yaml")
template("lib/wraith/javascript/snap.js", "javascript/snap.js")
end

desc "setup_casper", "creates config folder and default config for casper"
def setup_casper
template("configs/component.yaml", "configs/component.yaml")
template("javascript/casper.js", "javascript/casper.js")
template("javascript/beforeCapture.js", "javascript/beforeCapture.js")
template("configs/templates/component.yaml", "configs/component.yaml")
template("lib/wraith/javascript/casper.js", "javascript/casper.js")
template("lib/wraith/javascript/beforeCapture.js", "javascript/beforeCapture.js")
end

desc "reset_shots [config_name]", "removes all the files in the shots folder"
Expand Down
File renamed without changes.
40 changes: 34 additions & 6 deletions lib/wraith/javascript/casper.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,42 @@ var url = casper.cli.get(0);
var view_port_width = casper.cli.get(1);
var image_name = casper.cli.get(2);
var selector = casper.cli.get(3);
var globalBeforeCaptureJS = casper.cli.get(4);
var pathBeforeCaptureJS = casper.cli.get(5);

casper.start(url, function() {
this.viewport(view_port_width, 1500).then(function(){
this.wait(2000, function() {
this.captureSelector(image_name, selector);
console.log('Snapping ' + url + ' at width ' + view_port_width);
});
function snap() {
if (selector == undefined) {
this.capture(image_name);
}
else {
this.captureSelector(image_name, selector);
}
console.log('Snapping ' + url + ' at width ' + view_port_width);
}

casper.start();
casper.open(url);
casper.viewport(view_port_width, 1500);
casper.then(function() {
if (globalBeforeCaptureJS) {
require('./' + globalBeforeCaptureJS)(this);
}
});
casper.then(function() {
if (pathBeforeCaptureJS) {
require('./' + pathBeforeCaptureJS)(this);
}
});
// waits for all images to download before taking screenshots
// (broken images are a big cause of Wraith failures!)
// Credit: http://reff.it/8m3HYP
casper.waitFor(function() {
return this.evaluate(function() {
var images = document.getElementsByTagName('img');
return Array.prototype.every.call(images, function(i) { return i.complete; });
});
}, function then () {
snap.bind(this)();
});

casper.run();
48 changes: 0 additions & 48 deletions templates/javascript/casper.js

This file was deleted.

85 changes: 0 additions & 85 deletions templates/javascript/snap.js

This file was deleted.

0 comments on commit afa232f

Please sign in to comment.