wraithを試してみた

スクリーンショットを比較するツールwraithを試してみた。

ruby、PhantomJSなどで構成されている。
BBC-News/wraith

インストール

インストール用のshellを取得実行する形式。
macosxではbrewを使って必要なライブラリをインストールするようになっている。

$ curl -fsSL https://raw.github.com/bbc-news/wraith/go | bash
Downloading Wraith
######################################################################## 100.0%

Extracting to current directory
Error: You must `brew link jpeg' before imagemagick can be installed
==> Downloading http://phantomjs.googlecode.com/files/phantomjs-1.9.1-macosx.zip
######################################################################## 100.0%
🍺  /usr/local/Cellar/phantomjs/1.9.1: 104 files, 11M, built in 6 seconds
You can now run Wraith, awesome!


imagemagickが入らなかったので指示通りにbrew link jpegを実行

$ brew link jpeg
Linking /usr/local/Cellar/jpeg/8d... 0 symlinks created


もう一度インストール

curl -fsSL https://raw.github.com/bbc-news/wraith/go | bash
Downloading Wraith
######################################################################## 100.0%

Extracting to current directory
==> Installing imagemagick dependency: libtool
==> Downloading http://ftpmirror.gnu.org/libtool/libtool-2.4.2.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/libtool/2.4.2 --program-prefix=g --enable-ltdl-install
==> make install
==> Caveats
In order to prevent conflicts with Apple's own libtool we have prepended a "g"
so, you have instead: glibtool and glibtoolize.
==> Summary
🍺  /usr/local/Cellar/libtool/2.4.2: 66 files, 2.2M, built in 15 seconds
==> Installing imagemagick dependency: libpng
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/libpng-1.5.14.mountain_lion.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libpng-1.5.14.mountain_lion.bottle.tar.gz
🍺  /usr/local/Cellar/libpng/1.5.14: 15 files, 1.0M
==> Installing imagemagick dependency: freetype
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/freetype-2.4.11.mountain_lion.bottle.tar.gz
######################################################################## 100.0%
==> Pouring freetype-2.4.11.mountain_lion.bottle.tar.gz
🍺  /usr/local/Cellar/freetype/2.4.11: 57 files, 2.5M
==> Installing imagemagick
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/imagemagick-6.8.0-10.mountain_lion.bottle.1.tar.gz
######################################################################## 100.0%
==> Pouring imagemagick-6.8.0-10.mountain_lion.bottle.1.tar.gz
🍺  /usr/local/Cellar/imagemagick/6.8.0-10: 1401 files, 44M
You can now run Wraith, awesome!

ok

設定

config.yamlで比較するサイトのドメイン、width、パスを指定する

# Add only 2 domains, key will act as a label
domains:
  uk: "http://google.com"
  france: "http://google.fr"

#Type screen widths below, here are a couple of examples
screen_widths:
  - 320
  - 600
  - 768
  - 1024
  - 1280

#Type page URL paths below, here are a couple of examples
paths:
  search_page: /imghp
  map_page: /maps

実行

rake

結果

shots/{label}以下にスクリーンショットが保存される

例えば、shots/map_pageに
320_france.pngと320_uk.pngがそれぞれ保存され、2つの画像のdiffが320_diff.pngとして保存される。
diff画像は差分の箇所が青く表示される。

320_diff.png


余談

リポジトリに.ruby-versionが置いてあるが、rvmでインストールできなかった

$ rvm install ruby-1.9.3-p385
No binary rubies available for: downloads/ruby-1.9.3-p385.
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies.
Building 'ruby-1.9.3-p385' using clang - but it's not (fully) supported, expect errors.
Installing Ruby from source to: /Users/yuhei/.rvm/rubies/ruby-1.9.3-p385, this may take a while depending on your cpu(s)...
ruby-1.9.3-p385 - #downloading ruby-1.9.3-p385, this may take a while depending on your connection...
Error running '/Users/yuhei/.rvm/scripts/fetch http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p385.tar.bz2', please read /Users/yuhei/.rvm/log/ruby-1.9.3-p385/fetch.log
There has been an error fetching the ruby interpreter. Halting the installation.
Ruby 'ruby-1.9.3-p385' was built using clang - but it's not (fully) supported, expect errors.


こちらを参考にして入れた
osx - Installing Ruby on Mac OS X 10.8.2 - Stack Overflow


以下はインストール時のコンソールを(一応)コピーしたもの

$ brew update
Already up-to-date.

$  brew tap homebrew/dupes
Cloning into '/usr/local/Library/Taps/homebrew-dupes'...
remote: Counting objects: 965, done.
remote: Compressing objects: 100% (535/535), done.
remote: Total 965 (delta 531), reused 846 (delta 430)
Receiving objects: 100% (965/965), 171.66 KiB | 47 KiB/s, done.
Resolving deltas: 100% (531/531), done.
Tapped 40 formula

$ brew install apple-gcc42
==> Downloading http://r.research.att.com/tools/gcc-42-5666.3-darwin11.pkg
######################################################################## 100.0%
==> Caveats
NOTE:
This formula provides components that were removed from XCode in the 4.2
release. There is no reason to install this formula if you are using a
version of XCode prior to 4.2.

This formula contains compilers built from Apple's GCC sources, build
5666.3, available from:

  http://opensource.apple.com/tarballs/gcc

All compilers have a `-4.2` suffix. A GFortran compiler is also included.
==> Summary
🍺  /usr/local/Cellar/apple-gcc42/4.2.1-5666.3: 104 files, 75M, built in 56 seconds

$ rvm get stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   184  100   184    0     0    185      0 --:--:-- --:--:-- --:--:--   283
100 13784  100 13784    0     0   7337      0  0:00:01  0:00:01 --:--:--  101k
Downloading RVM from wayneeseguin branch stable
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   124  100   124    0     0     93      0  0:00:01  0:00:01 --:--:--   160
100 1081k  100 1081k    0     0   238k      0  0:00:04  0:00:04 --:--:--  417k

Upgrading the RVM installation in /Users/yuhei/.rvm/
    RVM PATH line found in /Users/yuhei/.bashrc.
    RVM PATH line not found for Zsh, run the installer with '--auto-dotfiles' to fix it.
    RVM sourcing line found in /Users/yuhei/.bashrc.
    RVM sourcing line not found for Zsh, run the installer with '--auto-dotfiles' to fix it.
    Installing rvm gem in 1 gemsets .......
Upgrade of RVM in /Users/yuhei/.rvm/ is complete.

# Yuhei Omori,
#
#   Thank you for using RVM!
#   I sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne

# In case of problems:
#      run and read: rvm notes
#         read docs: http://rvm.io/
#        talk to us: http://webchat.freenode.net/?channels=rvm (http://freenode.net/faq.shtml#plusr)
#   read cheatsheet: http://cheat.errtheblog.com/s/rvm
#  watch screencast: http://screencasts.org/episodes/how-to-use-rvm
# open a bug report: https://github.com/wayneeseguin/rvm/issues

Upgrade Notes:

  * Zsh 4.3.15 is buggy, be careful with it, it can break RVM, especially multiuser installations,
    You should consider downgrading Zsh to 4.3.12 which has proven to work more reliable with RVM.
  * If you encounter any issues with a ruby 'X' your best bet is to:
      rvm get head && rvm reinstall X --debug

  * RVM will run 'rvm requirements' by default, to disable run:
      echo rvm_autolibs_flag=0 >> ~/.rvmrc

  * RVM will set first installed ruby as default and use it if run as function.
    To avoid this behavior either use full path to rvm binary or prefix it with `command `.

  * To update RVM loading code run 'rvm get ... --auto-dotfiles'

  * RVM will try automatically use available package manager, might require `sudo`,
    read more about it in `rvm help autolibs`

  * RVM 1.20 changes default behavior of Autolibs to Enabled - if you prefer the 1.19 behavior
    then run "rvm autolibs read fail", read more details: rvm help autolibs

  * RVM 1.20.12 removes thee automated --progress-bar from curl options,
    if you liked this then you can restore this behavior with:

      echo progress-bar >> ~/.curlrc


RVM reloaded!

$ rvm install ruby-1.9.3-p385
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.8/x86_64/ruby-1.9.3-p385.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Installing requirements for osx, might require sudo password.
Already up-to-date.
Installing required packages: autoconf, automake, libyaml, libksba, openssl. - using Zsh, can not show progress, be patient...
Certificates in '/usr/local/etc/openssl/cert.pem' already are up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/yuhei/.rvm/rubies/ruby-1.9.3-p385, this may take a while depending on your cpu(s)...
ruby-1.9.3-p385 - #downloading ruby-1.9.3-p385, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 9786k  100 9786k    0     0  1462k      0  0:00:06  0:00:06 --:--:-- 1417k
ruby-1.9.3-p385 - #extracting ruby-1.9.3-p385 to /Users/yuhei/.rvm/src/ruby-1.9.3-p385 - using Zsh, can not show progress, be patient...
ruby-1.9.3-p385 - #extracted to /Users/yuhei/.rvm/src/ruby-1.9.3-p385
ruby-1.9.3-p385 - #configuring - using Zsh, can not show progress, be patient...
ruby-1.9.3-p385 - #compiling - using Zsh, can not show progress, be patient...
ruby-1.9.3-p385 - #installing - using Zsh, can not show progress, be patient...
Retrieving rubygems-2.0.6
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  328k  100  328k    0     0   519k      0 --:--:-- --:--:-- --:--:-- 1392k
Extracting rubygems-2.0.6 ...
Removing old Rubygems files...
Installing rubygems-2.0.6 for ruby-1.9.3-p385...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Installation of rubygems completed successfully.
Saving wrappers to '/Users/yuhei/.rvm/wrappers/ruby-1.9.3-p385'........
 - using Zsh, can not show progress, be patient...
ruby-1.9.3-p385 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
ruby-1.9.3-p385 - #importing default gemsets, this may take time - using Zsh, can not show progress, be patient...
Install of ruby-1.9.3-p385 - #complete