str_metrics 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 +4 -4
- data/README.md +3 -1
- data/extconf.rb +19 -2
- data/lib/str_metrics.rb +2 -1
- data/lib/str_metrics/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b9d4521b7b87e2eebace68bf7fae4f2dbf83074c6b6f2a7bebfc50c6023a693
|
4
|
+
data.tar.gz: 22e1df9500b78ab599e0acc8db77c459453b5bae4741bf62e0c05a359007ec10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecb25067d4e09964f6edbec296deb36b6ce107c71a67db9e486166ab72e0d5c72d892db9383db90ed81584509bcb6420986533cf39d3b3adbf2838f26a8f20ba
|
7
|
+
data.tar.gz: 037da668c2d9cee0d297b4c747c407b15317234d15e2293429e1a05f3f117d10bd46abe12600dd915fb5d7b066aeb77c1b69a0a2b283fd3483ba8137b9b71d2c
|
data/README.md
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# StrMetrics
|
2
2
|
|
3
3
|
[](https://github.com/anirbanmu/str_metrics/actions?query=workflow%3Achecks)
|
4
|
+
[](https://rubygems.org/gems/str_metrics)
|
5
|
+
[](LICENSE)
|
4
6
|
|
5
|
-
Ruby gem (native extension in Rust) providing implementations of various string metrics. Current metrics supported are: Sørensen–Dice, Levenshtein, Damerau–Levenshtein, Jaro & Jaro–Winkler. Strings that are UTF-8 encodable (convertible to UTF-8 representation) are supported. All comparison of strings is done at the grapheme cluster level as described by [Unicode Standard Annex #29](https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries); this may be different from many gems that calculate string metrics.
|
7
|
+
Ruby gem (native extension in Rust) providing implementations of various string metrics. Current metrics supported are: Sørensen–Dice, Levenshtein, Damerau–Levenshtein, Jaro & Jaro–Winkler. Strings that are UTF-8 encodable (convertible to UTF-8 representation) are supported. All comparison of strings is done at the grapheme cluster level as described by [Unicode Standard Annex #29](https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries); this may be different from many gems that calculate string metrics. Gem should work on Linux, MacOS & Windows.
|
6
8
|
|
7
9
|
## Getting Started
|
8
10
|
### Prerequisites
|
data/extconf.rb
CHANGED
@@ -1,14 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'ffi'
|
4
|
+
|
3
5
|
abort 'Rust compiler required (https://www.rust-lang.org/)' if `which rustc`.empty?
|
4
6
|
|
7
|
+
lib_name = FFI::Platform::OS == 'windows' ? 'str_metrics' : 'libstr_metrics'
|
8
|
+
src_path = File.expand_path(File.join(__dir__, 'target', 'release', "#{lib_name}.#{FFI::Platform::LIBSUFFIX}"))
|
9
|
+
dest_path = File.expand_path(File.join(__dir__, 'lib', 'str_metrics'))
|
10
|
+
|
11
|
+
if File::ALT_SEPARATOR
|
12
|
+
src_path = src_path.gsub(File::SEPARATOR, File::ALT_SEPARATOR)
|
13
|
+
dest_path = dest_path.gsub(File::SEPARATOR, File::ALT_SEPARATOR)
|
14
|
+
end
|
15
|
+
|
16
|
+
cp_cmd = if FFI::Platform::OS == 'windows'
|
17
|
+
"xcopy \"#{src_path}\" \"#{dest_path}\\*\""
|
18
|
+
else
|
19
|
+
"cp \"#{src_path}\" \"#{dest_path}\""
|
20
|
+
end
|
21
|
+
|
5
22
|
File.open('Makefile', 'wb') do |f|
|
6
23
|
f.puts(<<~MKCONTENT)
|
7
24
|
all:
|
8
25
|
\tcargo rustc --release
|
9
|
-
\
|
26
|
+
\t#{cp_cmd}
|
10
27
|
clean:
|
11
28
|
install:
|
12
|
-
\
|
29
|
+
\tcargo clean
|
13
30
|
MKCONTENT
|
14
31
|
end
|
data/lib/str_metrics.rb
CHANGED
@@ -9,7 +9,8 @@ module StrMetrics
|
|
9
9
|
module Native
|
10
10
|
extend FFI::Library
|
11
11
|
|
12
|
-
|
12
|
+
LIB_NAME = FFI::Platform::OS == 'windows' ? 'str_metrics' : 'libstr_metrics'
|
13
|
+
ffi_lib File.expand_path(File.join(__dir__, 'str_metrics', "#{LIB_NAME}.#{FFI::Platform::LIBSUFFIX}"))
|
13
14
|
|
14
15
|
attach_function :sorensen_dice_coefficient, %i[string string char], :double
|
15
16
|
attach_function :levenshtein_distance, %i[string string char], :int64
|
data/lib/str_metrics/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: str_metrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anirban Mukhopadhyay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -112,7 +112,7 @@ description: 'Ruby gem (native extension in Rust) providing implementations of v
|
|
112
112
|
string metrics. Current metrics supported are: Sørensen–Dice, Levenshtein, Damerau–Levenshtein,
|
113
113
|
Jaro & Jaro–Winkler. Strings that are UTF-8 encodable (convertible to UTF-8 representation)
|
114
114
|
are supported. All comparison of strings is done at the grapheme cluster level as
|
115
|
-
described by
|
115
|
+
described by Unicode Standard Annex #29 (https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries);
|
116
116
|
this may be different from many gems that calculate string metrics.'
|
117
117
|
email:
|
118
118
|
- anirban.mukhop@gmail.com
|
@@ -144,7 +144,7 @@ metadata:
|
|
144
144
|
homepage_uri: https://github.com/anirbanmu/str_metrics
|
145
145
|
bug_tracker_uri: https://github.com/anirbanmu/str_metrics/issues
|
146
146
|
source_code_uri: https://github.com/anirbanmu/str_metrics
|
147
|
-
changelog_uri: https://github.com/anirbanmu/str_metrics/blob/v0.1.
|
147
|
+
changelog_uri: https://github.com/anirbanmu/str_metrics/blob/v0.1.1/CHANGELOG.md
|
148
148
|
post_install_message:
|
149
149
|
rdoc_options: []
|
150
150
|
require_paths:
|