Skip to content

Commit 1913913

Browse files
committed
1 parent b559a98 commit 1913913

File tree

13 files changed

+141
-86
lines changed

13 files changed

+141
-86
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ jobs:
1717
bundler-cache: true
1818
- name: RSpec
1919
run: bundle exec rspec
20+
- name: Standard
21+
run: bundle exec standardrb --no-fix

.rubocop.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

.standard.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fix: true
2+
parallel: true

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
source 'https://rubygems.org'
1+
source "https://rubygems.org"
22

33
# Specify your gem's dependencies in simplify_rb.gemspec
44
gemspec

Gemfile.lock

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,20 @@ PATH
66
GEM
77
remote: https://rubygems.org/
88
specs:
9+
ast (2.4.3)
910
diff-lcs (1.6.2)
11+
json (2.15.1)
12+
language_server-protocol (3.17.0.5)
13+
lint_roller (1.1.0)
14+
parallel (1.27.0)
15+
parser (3.3.9.0)
16+
ast (~> 2.4.1)
17+
racc
18+
prism (1.6.0)
19+
racc (1.8.1)
20+
rainbow (3.1.1)
1021
rake (13.3.0)
22+
regexp_parser (2.11.3)
1123
rspec (3.13.2)
1224
rspec-core (~> 3.13.0)
1325
rspec-expectations (~> 3.13.0)
@@ -21,6 +33,40 @@ GEM
2133
diff-lcs (>= 1.2.0, < 2.0)
2234
rspec-support (~> 3.13.0)
2335
rspec-support (3.13.6)
36+
rubocop (1.80.2)
37+
json (~> 2.3)
38+
language_server-protocol (~> 3.17.0.2)
39+
lint_roller (~> 1.1.0)
40+
parallel (~> 1.10)
41+
parser (>= 3.3.0.2)
42+
rainbow (>= 2.2.2, < 4.0)
43+
regexp_parser (>= 2.9.3, < 3.0)
44+
rubocop-ast (>= 1.46.0, < 2.0)
45+
ruby-progressbar (~> 1.7)
46+
unicode-display_width (>= 2.4.0, < 4.0)
47+
rubocop-ast (1.47.1)
48+
parser (>= 3.3.7.2)
49+
prism (~> 1.4)
50+
rubocop-performance (1.25.0)
51+
lint_roller (~> 1.1)
52+
rubocop (>= 1.75.0, < 2.0)
53+
rubocop-ast (>= 1.38.0, < 2.0)
54+
ruby-progressbar (1.13.0)
55+
standard (1.51.1)
56+
language_server-protocol (~> 3.17.0.2)
57+
lint_roller (~> 1.0)
58+
rubocop (~> 1.80.2)
59+
standard-custom (~> 1.0.0)
60+
standard-performance (~> 1.8)
61+
standard-custom (1.0.2)
62+
lint_roller (~> 1.0)
63+
rubocop (~> 1.50)
64+
standard-performance (1.8.0)
65+
lint_roller (~> 1.1)
66+
rubocop-performance (~> 1.25.0)
67+
unicode-display_width (3.2.0)
68+
unicode-emoji (~> 4.1)
69+
unicode-emoji (4.1.0)
2470

2571
PLATFORMS
2672
arm64-darwin-24
@@ -30,6 +76,7 @@ DEPENDENCIES
3076
rake
3177
rspec
3278
simplify_rb!
79+
standard
3380

3481
BUNDLED WITH
3582
2.7.2

Rakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
require 'bundler/gem_tasks'
2-
require 'rspec/core/rake_task'
1+
require "bundler/gem_tasks"
2+
require "rspec/core/rake_task"
33

44
RSpec::Core::RakeTask.new(:spec)
55
task default: [:spec]

example/example.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
require 'simplify_rb'
1+
require "simplify_rb"
22

33
points = [
4-
{ x: 51.5256, y: -0.0875 },
5-
{ x: 51.7823, y: -0.0912 }
4+
{x: 51.5256, y: -0.0875},
5+
{x: 51.7823, y: -0.0912}
66
]
77
tolerance = 1
88
high_quality = true

lib/simplify_rb.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
require 'simplify_rb/version'
2-
require 'simplify_rb/point'
3-
require 'simplify_rb/radial_distance_simplifier'
4-
require 'simplify_rb/douglas_peucker_simplifier'
1+
require "simplify_rb/version"
2+
require "simplify_rb/point"
3+
require "simplify_rb/radial_distance_simplifier"
4+
require "simplify_rb/douglas_peucker_simplifier"
55

66
module SimplifyRb
77
class Simplifier
88
def process(raw_points, tolerance = 1, highest_quality = false)
9-
raise ArgumentError.new('raw_points must be enumerable') unless raw_points.is_a? Enumerable
9+
raise ArgumentError.new("raw_points must be enumerable") unless raw_points.is_a? Enumerable
1010

1111
return raw_points if raw_points.length <= 1
1212

lib/simplify_rb/douglas_peucker_simplifier.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module SimplifyRb
44
class DouglasPeuckerSimplifier
55
def process(points, sq_tolerance)
66
points.first.keep = true
7-
points.last.keep = true
7+
points.last.keep = true
88

99
simplify_douglas_peucker(points, sq_tolerance)
1010
.select(&:keep)
@@ -16,7 +16,7 @@ def process(points, sq_tolerance)
1616

1717
def simplify_douglas_peucker(points, sq_tolerance)
1818
first_i = 0
19-
last_i = points.length - 1
19+
last_i = points.length - 1
2020
index = nil
2121
stack = []
2222

@@ -55,8 +55,8 @@ def calc_max_sq_dist(first_i, last_i, points)
5555

5656
# Square distance from a point to a segment
5757
def get_sq_seg_dist(point, point_1, point_2)
58-
x = point_1.x
59-
y = point_1.y
58+
x = point_1.x
59+
y = point_1.y
6060
dx = point_2.x - x
6161
dy = point_2.y - y
6262

lib/simplify_rb/point.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ def parse_x_y(raw_point)
2121
x = nil
2222
y = nil
2323

24-
if raw_point.kind_of? Hash
25-
x = raw_point[:x] || raw_point['x']
26-
y = raw_point[:y] || raw_point['y']
24+
if raw_point.is_a? Hash
25+
x = raw_point[:x] || raw_point["x"]
26+
y = raw_point[:y] || raw_point["y"]
2727
elsif raw_point.respond_to?(:x) && raw_point.respond_to?(:y)
2828
x = raw_point.x
2929
y = raw_point.y
3030
end
3131

3232
if x.nil? || y.nil?
33-
raise ArgumentError.new('Points must have :x and :y values')
33+
raise ArgumentError.new("Points must have :x and :y values")
3434
end
3535

3636
[x, y]

0 commit comments

Comments
 (0)