edits 0.2.2 → 0.3.0

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1b79624e5ce72cbf1e7623ecb909c42b1fc6a82763e922b30b25589a040f2c1
4
- data.tar.gz: 26175c109066ecc63c4df37493493011724e9e4dfe0c57cbae47411f6a4daf85
3
+ metadata.gz: 1c829d27a322f8c9b3ad50437a3b66d2548ccfc40d435ebaee4c362b22802fb8
4
+ data.tar.gz: dd351b715125154bd7f9b37b98fd1f75aea504163fe550795c0615af1fea9b65
5
5
  SHA512:
6
- metadata.gz: 7c4b25223ef3db51afad11160fab94028fe5ab9d35f8918b63ac6cc5c3894245bea843247717ef1f93e627923dbdaf6c5844a4a0863f00598515bf0e07aa87a8
7
- data.tar.gz: 4d060b4eebc4a2cad7b37b1ba6e4e30a4c5c2f38640ce2244960bf5ee0cba06b62ac577beb271e0919df784c999e69a740d4ec47daedac0cf1f06f4c395d7ce4
6
+ metadata.gz: 8d5b3cd301621b913768f63c50f4876a340f620c22c2fbe68d1659bd1566141f6a737264dfb3da15f0b7a7e1a567a1036dcd978cd9c2001210f843a1e5da8f93
7
+ data.tar.gz: 821c4cd4acf9e2b9e25c21ce2f61a4f489838c4252fd6c4e0fd323fe9b5f3baaa1948e3ab87b0c1448830e39c9ff2362aa457e4fe9ce902994545dd8c986137e
data/.rspec CHANGED
@@ -1,2 +1 @@
1
- --format documentation
2
1
  --color
@@ -10,11 +10,14 @@ Metrics/PerceivedComplexity:
10
10
  Enabled: false
11
11
  Metrics/BlockLength:
12
12
  Exclude:
13
+ - edits.gemspec
13
14
  - "tasks/**/*.rake"
14
15
 
16
+ Style/NumericPredicate:
17
+ Enabled: false
15
18
  Style/StringLiterals:
16
19
  EnforcedStyle: double_quotes
17
- Layout/AlignParameters:
20
+ Layout/ParameterAlignment:
18
21
  EnforcedStyle: with_fixed_indentation
19
22
  Layout/MultilineMethodCallIndentation:
20
23
  EnforcedStyle: indented
@@ -1,26 +1,29 @@
1
- sudo: false
1
+ os: linux
2
2
  language: ruby
3
3
  cache: bundler
4
4
  rvm:
5
- - 2.3
6
5
  - 2.4
7
- - 2.5.3
8
- - 2.6
6
+ - 2.5
7
+ - 2.6.5
8
+ - 2.7
9
9
  - ruby-head
10
10
  - rbx-3
11
- matrix:
12
- allow_failures:
13
- - rvm: ruby-head
14
- - rvm: rbx-3
15
- fast_finish: true
16
11
  before_install:
17
12
  - gem update --system
18
13
  - gem install bundler
14
+ - sudo apt-get install jq
15
+ - curl -LSs "$(curl -LSs https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/latest | jq -r '.assets | map({name, browser_download_url} | select(.name | endswith(".jar"))) | .[0].browser_download_url')" -o codacy-coverage-reporter-assembly.jar
16
+ after_success:
17
+ - java -jar codacy-coverage-reporter-assembly.jar report -l Ruby -r coverage/lcov/edits.lcov
19
18
  jobs:
19
+ allow_failures:
20
+ - rvm: ruby-head
21
+ - rvm: rbx-3
22
+ fast_finish: true
20
23
  include:
21
24
  - stage: gem release
22
25
  if: tag IS present
23
- rvm: 2.5.3
26
+ rvm: 2.6.5
24
27
  script: echo "Deploying to rubygems.org ..."
25
28
  deploy:
26
29
  provider: rubygems
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Edits
2
2
 
3
+ [![Gem Version](https://img.shields.io/gem/v/edits.svg)](https://rubygems.org/gems/edits)
3
4
  [![Build Status](https://travis-ci.org/tcrouch/edits.svg?branch=master)](https://travis-ci.org/tcrouch/edits)
4
5
  [![Codacy Badge](https://api.codacy.com/project/badge/Grade/64cb50b8e9ce4ec2a752d091e441b09d)](https://app.codacy.com/app/t.crouch/edits?utm_source=github.com&utm_medium=referral&utm_content=tcrouch/edits&utm_campaign=Badge_Grade_Dashboard)
5
6
  [![Inline docs](http://inch-ci.org/github/tcrouch/edits.svg?branch=master)](http://inch-ci.org/github/tcrouch/edits)
@@ -19,11 +20,15 @@ gem 'edits'
19
20
 
20
21
  And then execute:
21
22
 
22
- $ bundle
23
+ ```console
24
+ $ bundle
25
+ ```
23
26
 
24
27
  Or install it yourself as:
25
28
 
26
- $ gem install edits
29
+ ```console
30
+ $ gem install edits
31
+ ```
27
32
 
28
33
  ## Usage
29
34
 
@@ -28,9 +28,10 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_development_dependency "benchmark-ips", "~> 2.7"
30
30
  spec.add_development_dependency "bundler", "~> 2.0"
31
- spec.add_development_dependency "codacy-coverage", "~> 2.1"
32
- spec.add_development_dependency "rake", "~> 12.1"
31
+ spec.add_development_dependency "rake", "~> 13.0"
33
32
  spec.add_development_dependency "redcarpet", "~> 3.4"
34
33
  spec.add_development_dependency "rspec", "~> 3.6"
34
+ spec.add_development_dependency "simplecov", "~> 0.18"
35
+ spec.add_development_dependency "simplecov-lcov", "~> 0.8"
35
36
  spec.add_development_dependency "yard", "~> 0.9"
36
37
  end
@@ -26,8 +26,8 @@ module Edits
26
26
 
27
27
  rows = seq1.length
28
28
  cols = seq2.length
29
- return cols if rows.zero?
30
- return rows if cols.zero?
29
+ return cols if rows == 0
30
+ return rows if cols == 0
31
31
 
32
32
  # 'infinite' edit distance for padding cost matrix.
33
33
  # Can be any value > max[rows, cols]
@@ -78,7 +78,7 @@ module Edits
78
78
 
79
79
  matrix[row + 1][col + 1] = cost
80
80
 
81
- last_match_col = col if sub_cost.zero?
81
+ last_match_col = col if sub_cost == 0
82
82
  end
83
83
 
84
84
  item_history[seq1_item] = row
@@ -25,7 +25,7 @@ module Edits
25
25
  seq2 = seq2.codepoints if seq2.is_a? String
26
26
 
27
27
  m, t = jaro_matches(seq1, seq2)
28
- return 0.0 if m.zero?
28
+ return 0.0 if m == 0
29
29
 
30
30
  m = m.to_f
31
31
  ((m / seq1.length) + (m / seq2.length) + ((m - t) / m)) / 3
@@ -78,7 +78,7 @@ module Edits
78
78
  end
79
79
  end
80
80
 
81
- return [0, 0] if matches.zero?
81
+ return [0, 0] if matches == 0
82
82
 
83
83
  transposes = 0
84
84
  j = 0
@@ -30,8 +30,8 @@ module Edits
30
30
 
31
31
  rows = seq1.length
32
32
  cols = seq2.length
33
- return cols if rows.zero?
34
- return rows if cols.zero?
33
+ return cols if rows == 0
34
+ return rows if cols == 0
35
35
 
36
36
  # Initialize first row of cost matrix.
37
37
  # The full initial state where cols=3, rows=2 would be:
@@ -82,8 +82,8 @@ module Edits
82
82
 
83
83
  rows = seq1.length
84
84
  cols = seq2.length
85
- return cols > max ? max : cols if rows.zero?
86
- return rows > max ? max : rows if cols.zero?
85
+ return cols > max ? max : cols if rows == 0
86
+ return rows > max ? max : rows if cols == 0
87
87
  return max if (cols - rows) >= max
88
88
 
89
89
  # array of codepoints outperforms String
@@ -103,7 +103,7 @@ module Edits
103
103
  max_col = row + max
104
104
  max_col = cols - 1 if max_col > cols - 1
105
105
 
106
- prev_col_cost = min_col.zero? ? row + 1 : inf
106
+ prev_col_cost = min_col == 0 ? row + 1 : inf
107
107
  seq1_item = seq1[row]
108
108
  diagonal = cols - rows + row
109
109
 
@@ -34,8 +34,8 @@ module Edits
34
34
 
35
35
  rows = seq1.length
36
36
  cols = seq2.length
37
- return cols if rows.zero?
38
- return rows if cols.zero?
37
+ return cols if rows == 0
38
+ return rows if cols == 0
39
39
 
40
40
  # retain previous two rows of cost matrix
41
41
  lastlast_row = []
@@ -57,8 +57,8 @@ module Edits
57
57
 
58
58
  cols.times do |col|
59
59
  sub_cost = seq1_item == seq2[col] ? 0 : 1
60
- is_swap = sub_cost.positive? &&
61
- row.positive? && col.positive? &&
60
+ is_swap = sub_cost > 0 &&
61
+ row > 0 && col > 0 &&
62
62
  seq1_item == seq2[col - 1] &&
63
63
  seq1[row - 1] == seq2[col]
64
64
 
@@ -102,8 +102,8 @@ module Edits
102
102
 
103
103
  rows = seq1.length
104
104
  cols = seq2.length
105
- return cols > max ? max : cols if rows.zero?
106
- return rows > max ? max : rows if cols.zero?
105
+ return cols > max ? max : cols if rows == 0
106
+ return rows > max ? max : rows if cols == 0
107
107
  return max if (cols - rows) >= max
108
108
 
109
109
  # array of codepoints outperforms String
@@ -129,7 +129,7 @@ module Edits
129
129
  max_col = row + max
130
130
  max_col = cols - 1 if max_col > cols - 1
131
131
 
132
- curr_row[min_col] = min_col.zero? ? row + 1 : inf
132
+ curr_row[min_col] = min_col == 0 ? row + 1 : inf
133
133
  seq1_item = seq1[row]
134
134
  diagonal = cols - rows + row
135
135
 
@@ -137,8 +137,8 @@ module Edits
137
137
  return max if diagonal == col && last_row[col] >= max
138
138
 
139
139
  sub_cost = seq1_item == seq2[col] ? 0 : 1
140
- is_swap = sub_cost.positive? &&
141
- row.positive? && col.positive? &&
140
+ is_swap = sub_cost > 0 &&
141
+ row > 0 && col > 0 &&
142
142
  seq1_item == seq2[col - 1] &&
143
143
  seq1[row - 1] == seq2[col]
144
144
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Edits
4
4
  # Current gem version
5
- VERSION = "0.2.2"
5
+ VERSION = "0.3.0"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edits
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Crouch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-28 00:00:00.000000000 Z
11
+ date: 2020-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips
@@ -39,61 +39,75 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: codacy-coverage
42
+ name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.1'
47
+ version: '13.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
- version: '2.1'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rake
56
+ name: redcarpet
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '12.1'
61
+ version: '3.4'
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
- version: '12.1'
68
+ version: '3.4'
69
69
  - !ruby/object:Gem::Dependency
70
- name: redcarpet
70
+ name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '3.4'
75
+ version: '3.6'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '3.4'
82
+ version: '3.6'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rspec
84
+ name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '3.6'
89
+ version: '0.18'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '3.6'
96
+ version: '0.18'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov-lcov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.8'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.8'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: yard
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -160,7 +174,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
174
  - !ruby/object:Gem::Version
161
175
  version: '0'
162
176
  requirements: []
163
- rubygems_version: 3.0.3
177
+ rubyforge_project:
178
+ rubygems_version: 2.7.7
164
179
  signing_key:
165
180
  specification_version: 4
166
181
  summary: A collection of edit distance algorithms.