average_hash 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZmNkN2ViMWQzMjgyMmE2MTVlNGU1MzMyODU5YWI4M2VkMWZmZDg0NA==
5
- data.tar.gz: !binary |-
6
- YjdlODY4NDdmMjMzN2EwN2ZiY2QxOGZjY2E1MjE0MDAwZjRiNTkyMA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- MTg4NzQyMjJiZDEyNmNjZDJjNjk5N2ZkYzhiMzg3MmFiYWQ1ZmY3NzBhNWIx
10
- MjhjNzJjMTVhY2VjZDJiZTBmYTY3ZjQ4NmJiMzhhMGY1Mzc0NTdhNjU3Mjhh
11
- MzBjMTgwYTczYjUyMzU5OTk4MGJlNWNjYTBiZmQwOTIzN2NhMDY=
12
- data.tar.gz: !binary |-
13
- ZmI4MTFiODBkZTcxMzJjMDk5ODEyNmZhNzZiODY5NmEyNDQwYjM5Y2UwYzI2
14
- ZjQxMDQ3OTk3ZTRiMGMwMDEzNGVlMjBmODNjOTMyMmJjNWI4OGY5NmUwYTQw
15
- OTQ4ZTA1OTk2OTA2ODRhZTE3OTVkNDc0NTRkYWEyODg5NDg5ZDY=
2
+ SHA256:
3
+ metadata.gz: 7e44e0b6a78babb7bf979e9772e0501f1b0407f6d0a340f004dcc1169207be99
4
+ data.tar.gz: 4365e9defedbc03701d3ffee77f3ba533ef30ac56848c06c80fd6e64c5a1dfbb
5
+ SHA512:
6
+ metadata.gz: bf98ffb941514f62206216aab5863180c94d781068ffff7409663503a4d5368fa8f2600cfb02fef576c7fc0a18c64b458a4a77fa428e50e146f541ffc4ea180e
7
+ data.tar.gz: 900af14c329acb50972bf4489a267ce5e45856e260c809d0680f18817466a34e86ba8b41a7a07fef8a4ac276f5a7b071d39ee3e638e19d91c606c6fe849ff486
@@ -0,0 +1 @@
1
+ repo_token: 3e5ngjiDD7uvAdoBJQvqVZVW3atI7K4rE
data/.gitignore CHANGED
@@ -6,9 +6,9 @@
6
6
  Gemfile.lock
7
7
  InstalledFiles
8
8
  _yardoc
9
- coverage
10
9
  doc/
11
10
  lib/bundler/man
11
+ vendor
12
12
  pkg
13
13
  rdoc
14
14
  spec/reports
@@ -1,8 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
3
  - 2.0.0
5
4
  - 2.1.1
5
+ - 2.2.4
6
+ - 2.3.0
6
7
 
7
8
  notifications:
8
9
  emails:
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in average_hash.gemspec
4
4
  gemspec
5
+
6
+ gem 'coveralls', require: false
data/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ [![Build Status](https://travis-ci.org/ToruIwashita/average_hash.svg?branch=master)](https://travis-ci.org/ToruIwashita/average_hash)
2
+ [![Coverage Status](https://coveralls.io/repos/ToruIwashita/average_hash/badge.svg?branch=master)](https://coveralls.io/r/ToruIwashita/average_hash?branch=master)
3
+ [![Code Climate](https://codeclimate.com/github/ToruIwashita/average_hash/badges/gpa.svg)](https://codeclimate.com/github/ToruIwashita/average_hash)
4
+
1
5
  # AverageHash
2
6
 
3
7
  Simple similarity calculation method of image. It is inspired by [Phashion](https://github.com/westonplatter/phashion).
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "bundler"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "rspec"
24
24
  spec.add_development_dependency "rmagick"
@@ -42,8 +42,8 @@ module AverageHash
42
42
  gray_scaled_pixels.reduce(0, :+) / image_pixel_count
43
43
  end
44
44
 
45
- def gray_scaled_pixel(num)
46
- px = pixel_at((num % RESIZNING_SIZE), (num / RESIZNING_SIZE))
45
+ def gray_scaled_pixel(index)
46
+ px = pixel_at((index % RESIZNING_SIZE), (index / RESIZNING_SIZE))
47
47
  px[INDEX_OF_R] * NTSC_COEFFICIENT_OF_R + px[INDEX_OF_G] * NTSC_COEFFICIENT_OF_G + px[INDEX_OF_B] * NTSC_COEFFICIENT_OF_B
48
48
  end
49
49
 
@@ -1,3 +1,3 @@
1
1
  module AverageHash
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -1,57 +1,51 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe AverageHash::Image do
4
+ let(:image_1) { AverageHash::Image.new(fixture_file_path('sample_1.jpg')) }
5
+ let(:image_2) { AverageHash::Image.new(fixture_file_path('sample_2.jpg')) }
6
+
4
7
  context 'fingerprint use sample_1.jpg' do
5
- it do
6
- image_1 = AverageHash::Image.new(fixture_file_path('sample_1.jpg'))
7
- expect(image_1.fingerprint).to eq 13158600607563222924
8
- end
8
+ it { expect(image_1.fingerprint).to eq 13158600607563222924 }
9
9
  end
10
10
 
11
11
  context 'fingerprint use sample_2.jpg' do
12
- it do
13
- image_2 = AverageHash::Image.new(fixture_file_path('sample_2.jpg'))
14
- expect(image_2.fingerprint).to eq 7870530257777914161
15
- end
12
+ it { expect(image_2.fingerprint).to eq 7870530257777914161 }
16
13
  end
17
14
 
18
15
  context 'use two jpg images' do
19
16
  before do
20
- @image_1 = AverageHash::Image.new(fixture_file_path('sample_1.jpg'))
21
- @image_2 = AverageHash::Image.new(fixture_file_path('sample_2.jpg'))
17
+ image_1
18
+ image_2
22
19
  end
23
20
 
24
21
  context '"sample_1" distance_from "sample_2"' do
25
- it { expect(@image_1.distance_from(@image_2)).to eq 36 }
22
+ it { expect(image_1.distance_from(image_2)).to eq 36 }
26
23
  end
27
24
 
28
25
  context '"sample_1" duplicate? "sample_2"' do
29
- it { expect(@image_1.duplicate?(@image_2)).to be_falsey }
26
+ it { expect(image_1.duplicate?(image_2)).to be_falsey }
30
27
  end
31
28
 
32
29
  context '"sample_1" duplicate? "sample_2" with threshold 35' do
33
- it { expect(@image_1.duplicate?(@image_2, threshold: 35)).to be_falsey }
30
+ it { expect(image_1.duplicate?(image_2, threshold: 35)).to be_falsey }
34
31
  end
35
32
 
36
33
  context '"sample_1" duplicate? "sample_2" with threshold 36' do
37
- it { expect(@image_1.duplicate?(@image_2, threshold: 36)).to be_truthy }
34
+ it { expect(image_1.duplicate?(image_2, threshold: 36)).to be_truthy }
38
35
  end
39
36
  end
40
37
 
41
38
  context 'use duplicate jpg image, "sample_1" duplicate? "sample_1"' do
42
- it do
43
- image_1_1 = AverageHash::Image.new(fixture_file_path('sample_1.jpg'))
44
- image_1_2 = AverageHash::Image.new(fixture_file_path('sample_1.jpg'))
45
- expect(image_1_1.duplicate?(image_1_2)).to be_truthy
46
- end
39
+ let(:image_2) { AverageHash::Image.new(fixture_file_path('sample_1.jpg')) }
40
+
41
+ it { expect(image_1.duplicate?(image_2)).to be_truthy }
47
42
  end
48
43
  end
49
44
 
50
45
  describe AverageHash::HashingStrategy do
46
+ let(:hashing_strategy) { AverageHash::HashingStrategy.new(fixture_file_path('sample_1.jpg')) }
47
+
51
48
  context 'generate_hash with argument "smaple_1.jpg"' do
52
- it do
53
- hashing_strategy = AverageHash::HashingStrategy.new(fixture_file_path('sample_1.jpg'))
54
- expect(hashing_strategy.generate_hash).to eq '1011011010011100101111011000100100001011000010111000111110001100'
55
- end
49
+ it { expect(hashing_strategy.generate_hash).to eq '1011011010011100101111011000100100001011000010111000111110001100' }
56
50
  end
57
51
  end
@@ -1,4 +1,6 @@
1
- # coding: utf-8
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
2
4
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
5
  require 'average_hash'
4
6
 
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: average_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ToruIwashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-07 00:00:00.000000000 Z
11
+ date: 2020-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rmagick
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Simple similarity calculation method of image
@@ -73,9 +73,10 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - .gitignore
77
- - .rspec
78
- - .travis.yml
76
+ - ".coveralls.yml"
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
79
80
  - Gemfile
80
81
  - LICENSE.txt
81
82
  - README.md
@@ -99,17 +100,16 @@ require_paths:
99
100
  - lib
100
101
  required_ruby_version: !ruby/object:Gem::Requirement
101
102
  requirements:
102
- - - ! '>='
103
+ - - ">="
103
104
  - !ruby/object:Gem::Version
104
105
  version: '0'
105
106
  required_rubygems_version: !ruby/object:Gem::Requirement
106
107
  requirements:
107
- - - ! '>='
108
+ - - ">="
108
109
  - !ruby/object:Gem::Version
109
110
  version: '0'
110
111
  requirements: []
111
- rubyforge_project:
112
- rubygems_version: 2.0.0
112
+ rubygems_version: 3.1.2
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: Simple similarity calculation method of image