cezanne 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 891c5e89caa9580135d9536f8406e58e50f6e994
4
- data.tar.gz: 8d7762429284a5570dbe0d219894a50ebaa85c13
3
+ metadata.gz: 5722f440d0998e44a91a5bcaa8c7281d410c4f0c
4
+ data.tar.gz: ebb5cd76d7c9d148d86e4c98c6888fba798fa0c9
5
5
  SHA512:
6
- metadata.gz: 71972499b7cf750c379041e50728cf8088ddf23b7caa860e8bed713cda0fa288c1b14e8a572662a5e374d8bf8c696f0a03b5d56fc98f7faf28ff4686f79de302
7
- data.tar.gz: 4540b47068fb2e735337656082c3bd6f825d85c88626bb5c6fc4061efd36822489d95cafd9e320e88ed56ccfd568565c59abdb56e051d0cf29f7cca65bbeef8f
6
+ metadata.gz: 9d9cca0a8a7177adc4a561487e68cb431164ca17d22098f269f5c35ab9347ac512a0b1998d84751c3b5558396fc4e26faa53d860fbb9a5954a13d4c3825ec61d
7
+ data.tar.gz: 46031a34b2013d200151972f515a4da07522cabc93ac8cc9c712f26555347eab5389f2476cd134e2ce45c26d1d2cf5f5c1506f54bcbb0322c47720e7aa6a65d8
data/lib/cezanne/image.rb CHANGED
@@ -5,14 +5,19 @@ module Cezanne
5
5
  class Image
6
6
  attr_reader :path, :picture
7
7
 
8
- def initialize path
8
+ def initialize path, opts
9
9
  @path = path
10
10
  @picture = Magick::Image.read(@path).first
11
+ if opts[:crop]
12
+ crop! *opts[:crop]
13
+ end
11
14
  end
12
15
 
13
16
  def crop! *coords
14
17
  if coords.length == 2 then coords = [0, 0, *coords] end # treat them as widht and height
18
+ coords.push true # get rid of offset after cropping :)
15
19
  @picture.crop!(*coords)
20
+ @picture.write(@path)
16
21
  end
17
22
 
18
23
  def width
@@ -1,3 +1,3 @@
1
1
  module Cezanne
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/cezanne.rb CHANGED
@@ -6,8 +6,8 @@ require "cezanne/comparison"
6
6
 
7
7
  module Cezanne
8
8
 
9
- def check_visual_regression_for page_name
10
- screenshot = take_screenshot page_name
9
+ def check_visual_regression_for page_name, opts = {}
10
+ screenshot = take_screenshot page_name, opts
11
11
  reference_screenshot = get_reference_screenshot_for page_name
12
12
 
13
13
  unless reference_screenshot
@@ -25,10 +25,10 @@ module Cezanne
25
25
 
26
26
  private
27
27
 
28
- def take_screenshot page_name
28
+ def take_screenshot page_name, opts
29
29
  path = File.join( local_files.path_for(:tmp), file_name_for(page_name) )
30
30
  page.driver.browser.save_screenshot(path)
31
- image(path)
31
+ image(path, opts)
32
32
  end
33
33
 
34
34
 
@@ -50,7 +50,7 @@ module Cezanne
50
50
  FileUtils.mv(screenshot.path, local_files.path_for(:diff))
51
51
  end
52
52
 
53
- def image path
54
- Cezanne::Image.new(path)
53
+ def image path, opts = {}
54
+ Cezanne::Image.new(path, opts)
55
55
  end
56
56
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Cezanne::Image do
4
4
 
5
- let(:image) { Cezanne::Image.new('spec/images/page_name_browser_version.gif') }
5
+ let(:image) { Cezanne::Image.new('spec/images/page_name_browser_version.gif', {}) }
6
6
 
7
7
  describe '#initialize' do
8
8
 
@@ -39,8 +39,8 @@ describe Cezanne::Image do
39
39
  width = 5
40
40
  height = 10
41
41
  image.crop!(x,y,width,height)
42
- expect(image.width).to be 5
43
- expect(image.height).to be 10
42
+ expect(image.width).to be 4
43
+ expect(image.height).to be 8
44
44
  end
45
45
 
46
46
  it 'accepts width and height alone' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cezanne
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sky Haiku
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-14 00:00:00.000000000 Z
11
+ date: 2014-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler