address_line_divider 1.0.2 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/cd.yml +31 -0
- data/.github/workflows/main.yml +3 -3
- data/.gitignore +2 -0
- data/.rubocop.yml +9 -0
- data/CHANGELOG.md +11 -3
- data/Gemfile.lock +1 -1
- data/README.md +3 -0
- data/address_line_divider.gemspec +2 -2
- data/lib/address_line_divider/address_parser.rb +30 -5
- data/lib/address_line_divider/configuration.rb +2 -1
- data/lib/address_line_divider/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 678fdc52d5f68e75e97ff2f67d260c325747273287c4e0fe7054dbca7258277c
|
4
|
+
data.tar.gz: 1c5b3ffda58132cafcf8632d06a1b77243cccd096b680a634f3b0b7ca070164c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b02307bdbad519d388d2f3c97d1849b61404c1629174c90f2b43026371fdaeeb387013d0528e51687b65ad99c0c52ec8b62de19b1aa90d3e9b1cab06fcaf8d68
|
7
|
+
data.tar.gz: 66a5ddc6ed60ec17c49683e9e017ae114ebb65130c3b21bb885152923e3e0cd02649003157e5e125d7cc2f1a64f633fffa264cd113f1b77e8a923510ef44b1d8
|
@@ -0,0 +1,31 @@
|
|
1
|
+
name: CD
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
types: [closed]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
log:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
steps:
|
11
|
+
- name: Log
|
12
|
+
run: |
|
13
|
+
echo "GITHUB_REF: $GITHUB_REF"
|
14
|
+
echo "github.head_ref: ${{ github.head_ref }}"
|
15
|
+
echo "github.base_ref: ${{ github.base_ref }}"
|
16
|
+
echo "contains(github.head_ref, 'release/v'): ${{ contains(github.head_ref, 'release/v') }}"
|
17
|
+
echo "github.base_ref == 'master': ${{ github.base_ref == 'master' }}"
|
18
|
+
echo "github.event.pull_request.merged: ${{ github.event.pull_request.merged }}"
|
19
|
+
cd:
|
20
|
+
runs-on: ubuntu-latest
|
21
|
+
if: ${{ contains(github.head_ref, 'release/v') && github.base_ref == 'master' && github.event.pull_request.merged == true }}
|
22
|
+
steps:
|
23
|
+
- uses: actions/checkout@v2
|
24
|
+
|
25
|
+
- name: Release Gem
|
26
|
+
uses: cadwallion/publish-rubygems-action@master
|
27
|
+
env:
|
28
|
+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
29
|
+
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
|
30
|
+
RELEASE_COMMAND: bundle exec rake release
|
31
|
+
|
data/.github/workflows/main.yml
CHANGED
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
# Changelog
|
2
|
-
|
3
|
-
|
2
|
+
## v1.0.6
|
3
|
+
* Improve verifying results.
|
4
|
+
## v1.0.5
|
5
|
+
* Verify results and return nil if it's invalid.
|
6
|
+
## v1.0.4
|
7
|
+
* Improve Regex
|
8
|
+
## v1.0.3
|
9
|
+
* Small fixes
|
10
|
+
* CI Status badge
|
11
|
+
## v1.0.2
|
4
12
|
* Add MIT LICENSE
|
5
|
-
##
|
13
|
+
## v1.0.0
|
6
14
|
### Initial version
|
7
15
|
#### Features
|
8
16
|
* Parse address lines using a Regex
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
[![Ruby](https://github.com/matiasalbarello/address_line_divider/actions/workflows/main.yml/badge.svg)](https://github.com/matiasalbarello/address_line_divider/actions/workflows/main.yml)
|
2
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/a99a88d28ad37a79dbf6/maintainability)](https://codeclimate.com/github/codeclimate/codeclimate/maintainability)
|
3
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/a99a88d28ad37a79dbf6/test_coverage)](https://codeclimate.com/github/codeclimate/codeclimate/test_coverage)
|
1
4
|
# AddressLineDivider
|
2
5
|
|
3
6
|
The purpose of this GEM is to provide a tool to correctly parse address lines into Street + Street Number. Sometimes it's trivial and it can be solved with a regular expression, but when the street itself contains numbers, the task needs some extra considerations.
|
@@ -7,11 +7,11 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.version = AddressLineDivider::VERSION
|
8
8
|
spec.authors = ["Matias Albarello"]
|
9
9
|
spec.email = ["matias.albarello@gmail.com"]
|
10
|
-
spec.licenses = [
|
10
|
+
spec.licenses = ["MIT"]
|
11
11
|
|
12
12
|
spec.summary = "Divide an address line into street and street number based on a Streets file."
|
13
13
|
spec.homepage = "https://github.com/matiasalbarello/address_line_divider"
|
14
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
15
15
|
|
16
16
|
spec.metadata["homepage_uri"] = spec.homepage
|
17
17
|
spec.metadata["source_code_uri"] = spec.homepage
|
@@ -8,16 +8,41 @@ module AddressLineDivider
|
|
8
8
|
|
9
9
|
def parse(address_line)
|
10
10
|
street = search_street_on_file(address_line)
|
11
|
-
|
11
|
+
result = [street, street_no(address_line, street)] if street
|
12
|
+
result ||= parse_using_regex(address_line)
|
12
13
|
|
13
|
-
|
14
|
+
return if invalid_result(address_line, result)
|
15
|
+
|
16
|
+
result
|
14
17
|
end
|
15
18
|
|
16
19
|
private
|
17
20
|
|
18
21
|
def parse_using_regex(address_line)
|
19
|
-
|
20
|
-
|
22
|
+
last_number = last_number(address_line)
|
23
|
+
return unless last_number
|
24
|
+
|
25
|
+
last_number_index = address_line.index(last_number)
|
26
|
+
street_name = address_line[0..last_number_index - 1].strip
|
27
|
+
street_no = address_line[last_number_index..-1].strip
|
28
|
+
|
29
|
+
[street_name, street_no]
|
30
|
+
end
|
31
|
+
|
32
|
+
def invalid_result(address_line, result)
|
33
|
+
result.nil? ||
|
34
|
+
result.any? { |r| r.nil? || r.strip.empty? } ||
|
35
|
+
squish(result.join(" ")) != squish(address_line)
|
36
|
+
end
|
37
|
+
|
38
|
+
def last_number(address_line)
|
39
|
+
squish(address_line).split(" ").select do |substr|
|
40
|
+
substr =~ /[[:digit:]]/
|
41
|
+
end.last
|
42
|
+
end
|
43
|
+
|
44
|
+
def squish(string)
|
45
|
+
string.gsub(" ", " ").strip
|
21
46
|
end
|
22
47
|
|
23
48
|
def search_street_on_file(address_line)
|
@@ -35,4 +60,4 @@ module AddressLineDivider
|
|
35
60
|
address_line.gsub(street, "").strip
|
36
61
|
end
|
37
62
|
end
|
38
|
-
end
|
63
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: address_line_divider
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matias Albarello
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -17,6 +17,7 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- ".github/workflows/cd.yml"
|
20
21
|
- ".github/workflows/main.yml"
|
21
22
|
- ".gitignore"
|
22
23
|
- ".rspec"
|
@@ -50,7 +51,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
51
|
requirements:
|
51
52
|
- - ">="
|
52
53
|
- !ruby/object:Gem::Version
|
53
|
-
version: 2.
|
54
|
+
version: 2.4.0
|
54
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
56
|
requirements:
|
56
57
|
- - ">="
|