symilaa 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in symilaa.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ Hello.
2
+
3
+ There will be some stuff here soon.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,22 @@
1
+ require 'RMagick'
2
+
3
+ module Symilaa
4
+ class Screenshot
5
+ SIMILARITY_THRESHOLD = 0.0002
6
+
7
+ attr_reader :path
8
+
9
+ def initialize path
10
+ @path = path
11
+ end
12
+
13
+ def == other
14
+ this_one = Magick::Image.read(@path).first
15
+ that_one = Magick::Image.read(other.path).first
16
+
17
+ similiarity_factor = this_one.compare_channel(that_one, Magick::MeanAbsoluteErrorMetric)[1]
18
+
19
+ similiarity_factor <= SIMILARITY_THRESHOLD
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module Symilaa
2
+ VERSION = "0.0.1"
3
+ end
data/lib/symilaa.rb ADDED
@@ -0,0 +1,2 @@
1
+ require "symilaa/version"
2
+ require 'symilaa/screenshot'
data/symilaa.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "symilaa/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "symilaa"
7
+ s.version = Symilaa::VERSION
8
+ s.authors = ["jamienglish,drpep"]
9
+ s.email = ["skyhelpcentre@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Compares images for similarity. Amazebears.}
12
+ s.description = %q{Using the wonders of RMagick, this wonderful gem will produce a boolean result based on the computed similarity
13
+ of the two images passed.}
14
+
15
+ s.rubyforge_project = "symilaa"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ # specify any dependencies here; for example:
23
+ s.add_development_dependency "minitest"
24
+ s.add_runtime_dependency "rmagick"
25
+ end
Binary file
@@ -0,0 +1,33 @@
1
+ gem 'minitest'
2
+ require 'minitest/autorun'
3
+ require_relative '../../lib/symilaa/screenshot'
4
+
5
+ module Symilaa
6
+ class TestScreenshot < Minitest::Unit::TestCase
7
+ GRYLLS = File.expand_path '../fixtures/bear_grylls.png', File.dirname(__FILE__)
8
+ GRYLLS_SLIGHT_DIFF = File.expand_path '../fixtures/bear_grylls_slightly_different.png', File.dirname(__FILE__)
9
+ GRYLLS_DIFF = File.expand_path '../fixtures/bear_grylls_different.png', File.dirname(__FILE__)
10
+
11
+ def test_equality_when_images_altered
12
+ one = Screenshot.new GRYLLS
13
+ two = Screenshot.new GRYLLS_DIFF
14
+
15
+ refute one == two
16
+ end
17
+
18
+ def test_equality_when_images_similar
19
+ one = Screenshot.new GRYLLS
20
+ two = Screenshot.new GRYLLS_SLIGHT_DIFF
21
+
22
+ assert one == two
23
+ end
24
+
25
+ def test_equality_when_identical
26
+ one = Screenshot.new GRYLLS
27
+ two = Screenshot.new GRYLLS
28
+
29
+ assert one == two
30
+ end
31
+ end
32
+ end
33
+
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: symilaa
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - jamienglish,drpep
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-08 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: minitest
16
+ requirement: &23720640 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *23720640
25
+ - !ruby/object:Gem::Dependency
26
+ name: rmagick
27
+ requirement: &23719940 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *23719940
36
+ description: ! "Using the wonders of RMagick, this wonderful gem will produce a boolean
37
+ result based on the computed similarity\n of the two images passed."
38
+ email:
39
+ - skyhelpcentre@gmail.com
40
+ executables: []
41
+ extensions: []
42
+ extra_rdoc_files: []
43
+ files:
44
+ - .gitignore
45
+ - Gemfile
46
+ - README.md
47
+ - Rakefile
48
+ - lib/symilaa.rb
49
+ - lib/symilaa/screenshot.rb
50
+ - lib/symilaa/version.rb
51
+ - symilaa.gemspec
52
+ - test/fixtures/bear_grylls.png
53
+ - test/fixtures/bear_grylls_different.png
54
+ - test/fixtures/bear_grylls_slightly_different.png
55
+ - test/symilaa/test_screenshot.rb
56
+ homepage: ''
57
+ licenses: []
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project: symilaa
76
+ rubygems_version: 1.8.10
77
+ signing_key:
78
+ specification_version: 3
79
+ summary: Compares images for similarity. Amazebears.
80
+ test_files: []