libpuzzle 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/extconf.rb +1 -0
- data/ext/libpuzzle.c +19 -4
- data/lib/libpuzzle.rb +2 -1
- data/lib/puzzle/version.rb +3 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61fff184af161b5377a6694aabd10ac0ba055d8e
|
4
|
+
data.tar.gz: d9b307424e770443fc1e3bc2d6489f53494146cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3f9271ab2cc92f18fbbef4bf72c5cd01d3437b7a47210f3bdd63d9a808e77167690249a5014833327a661f6adc8c09841fd3c028629f7e6b08a66419a516ad6
|
7
|
+
data.tar.gz: a832703673a611fc3fe1ffb900d9b8b54c1a2fe50a99fbb6ec06763aca6d63a777e22e8cac5b4a188ec7d6e840721202afa516859f651dcbd302cbd307b03adb
|
data/ext/extconf.rb
CHANGED
data/ext/libpuzzle.c
CHANGED
@@ -42,8 +42,22 @@ static VALUE distance(VALUE p1, VALUE p2){
|
|
42
42
|
return rb_float_new(_distance(p1, p2));
|
43
43
|
}
|
44
44
|
|
45
|
-
static VALUE
|
46
|
-
|
45
|
+
static VALUE similar(int argc, VALUE *argv, VALUE self){
|
46
|
+
VALUE puzzle, opt;
|
47
|
+
double threshold = 0.6;
|
48
|
+
|
49
|
+
rb_scan_args(argc, argv, "1:", &puzzle, &opt);
|
50
|
+
|
51
|
+
if (!NIL_P(opt)) {
|
52
|
+
VALUE rb_threshold = rb_hash_aref(opt, ID2SYM(rb_intern("threshold")));
|
53
|
+
if(RB_FLOAT_TYPE_P(rb_threshold)) threshold = NUM2DBL(rb_threshold);
|
54
|
+
}
|
55
|
+
return _distance(self, puzzle) < threshold ? Qtrue : Qfalse;
|
56
|
+
}
|
57
|
+
|
58
|
+
static VALUE equal(int argc, VALUE *argv, VALUE str){
|
59
|
+
rb_warn("Puzzle#== is deprecated; use #similar? instead");
|
60
|
+
return similar(argc, argv, str);
|
47
61
|
}
|
48
62
|
|
49
63
|
static VALUE compress(VALUE self){
|
@@ -83,6 +97,7 @@ void Init_puzzle_ext(void){
|
|
83
97
|
rb_define_singleton_method(rb_cPuzzle, "new", new, 1);
|
84
98
|
rb_define_singleton_method(rb_cPuzzle, "uncompress", uncompress, 1);
|
85
99
|
rb_define_method(rb_cPuzzle, "distance", distance, 1);
|
86
|
-
rb_define_method(rb_cPuzzle, "==", equal, 1);
|
100
|
+
rb_define_method(rb_cPuzzle, "==", equal, -1);
|
101
|
+
rb_define_method(rb_cPuzzle, "similar?", similar, -1);
|
87
102
|
rb_define_method(rb_cPuzzle, "compress", compress, 0);
|
88
|
-
}
|
103
|
+
}
|
data/lib/libpuzzle.rb
CHANGED
data/lib/puzzle/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libpuzzle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jian Weihang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
version: '0'
|
99
99
|
requirements: []
|
100
100
|
rubyforge_project:
|
101
|
-
rubygems_version: 2.4
|
101
|
+
rubygems_version: 2.6.4
|
102
102
|
signing_key:
|
103
103
|
specification_version: 4
|
104
104
|
summary: A library to find similar pictures with libpuzzle
|