symilaa 0.0.1.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,3 +1,25 @@
1
1
  Hello.
2
2
 
3
- There will be some stuff here soon.
3
+ Sometimes it is nice to compare two images with one another. We find this
4
+ particularly handy for testing browser screenshots.
5
+
6
+ With Symilaa, this is particularly easy.
7
+
8
+ 1. How to do it.
9
+ ----------------
10
+
11
+ ```ruby
12
+ one = Symilaa::Screenshot.new 'image.png'
13
+ two = Symilaa::Screenshot.new 'slightly_different_image.png'
14
+ three = Symilaa::Screenshot.new 'very_different_image.png'
15
+
16
+ one == one
17
+ #=> true
18
+ one == two
19
+ #=> false
20
+ one.similar_to? two
21
+ #=> true
22
+ one.similar_to? three
23
+ #=> false
24
+ ```
25
+ That's it. Have a nice life.
@@ -1,4 +1,5 @@
1
1
  require 'RMagick'
2
+ require 'fileutils'
2
3
 
3
4
  module Symilaa
4
5
  class Screenshot
@@ -11,6 +12,10 @@ module Symilaa
11
12
  end
12
13
 
13
14
  def == other
15
+ FileUtils.cmp path, other.path
16
+ end
17
+
18
+ def similar_to? other
14
19
  this_one = Magick::Image.read(@path).first
15
20
  that_one = Magick::Image.read(other.path).first
16
21
 
@@ -1,3 +1,3 @@
1
1
  module Symilaa
2
- VERSION = "0.0.1.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -19,7 +19,7 @@ module Symilaa
19
19
  one = Screenshot.new GRYLLS
20
20
  two = Screenshot.new GRYLLS_SLIGHT_DIFF
21
21
 
22
- assert one == two
22
+ refute one == two
23
23
  end
24
24
 
25
25
  def test_equality_when_identical
@@ -28,6 +28,27 @@ module Symilaa
28
28
 
29
29
  assert one == two
30
30
  end
31
+
32
+ def test_similar_when_identical
33
+ one = Screenshot.new GRYLLS
34
+ two = Screenshot.new GRYLLS
35
+
36
+ assert one.similar_to? two
37
+ end
38
+
39
+ def test_similar_when_similar
40
+ one = Screenshot.new GRYLLS
41
+ two = Screenshot.new GRYLLS_SLIGHT_DIFF
42
+
43
+ assert one.similar_to? two
44
+ end
45
+
46
+ def test_similar_when_different
47
+ one = Screenshot.new GRYLLS
48
+ two = Screenshot.new GRYLLS_DIFF
49
+
50
+ refute one.similar_to? two
51
+ end
31
52
  end
32
53
  end
33
54
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: symilaa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-11-08 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
16
- requirement: &20562660 !ruby/object:Gem::Requirement
16
+ requirement: &16724680 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *20562660
24
+ version_requirements: *16724680
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rmagick
27
- requirement: &20562000 !ruby/object:Gem::Requirement
27
+ requirement: &16723940 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *20562000
35
+ version_requirements: *16723940
36
36
  description: ! "Using the wonders of RMagick, this wonderful gem will produce a boolean
37
37
  result based on the computed similarity\n of the two images passed."
38
38
  email: