address_line_divider 1.0.3 → 1.0.4

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: be149c4f4c64a96b9b83a516c3302aef706c8322f37d6a132a5ae49980585bd9
4
- data.tar.gz: 31b6a557f012035fe67769f670574c14620fe485f5e6ba51c8192959638d7d5f
3
+ metadata.gz: e6ef2ffffc4e459d9c4ebf283cb7eafaf2c725ceff1da8ae3f06fcfbc77b8f45
4
+ data.tar.gz: f72ee12e5fdb98453d3653175fba57567d48da21e6917b125d60e04d93e76497
5
5
  SHA512:
6
- metadata.gz: 7c2d9f0f18f68cf871f6c96e44d06ed4aaaeb49d4980c5913194a0db590cd7d1186b8566004e3bbd101e6e11214dbd1d101ce0d26f68263181c3bfa84dc039fb
7
- data.tar.gz: 5bb7ed14e52d695d2cb117dbf496df17eef46e1a59798263ec4d3e790e37262fe44f203149d82aabbf3f70f0863d86d1dea53289c50617f06639903e3368c195
6
+ metadata.gz: 93f7cec2d436c1eb97459451d5b7a38505355d7b730d1886b4db37bdce2bf4ecfad02a29ed90cfd8478a5ee5d572aa516ca91d54142c48a43465507ac249325a
7
+ data.tar.gz: 19459ff082a0d8ad3c33369c4d4b0a2fa351a6e8cc941973258bf0ed5f637def7b9b88f238804d37c7d60b5cab57174f513e05a231b3356e1cc991280de62107
@@ -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
+
@@ -1,9 +1,9 @@
1
- name: Ruby
1
+ name: CI
2
2
 
3
- on: [push,pull_request]
3
+ on: [push]
4
4
 
5
5
  jobs:
6
- build:
6
+ ci:
7
7
  runs-on: ubuntu-latest
8
8
  steps:
9
9
  - uses: actions/checkout@v2
data/.rubocop.yml CHANGED
@@ -1,6 +1,9 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 2.4
3
3
 
4
+ Metrics/BlockLength:
5
+ Enabled: false
6
+
4
7
  Style/Documentation:
5
8
  Enabled: false
6
9
 
data/CHANGELOG.md CHANGED
@@ -1,11 +1,12 @@
1
1
  # Changelog
2
-
3
- ## V1.0.3
2
+ ## v1.0.4
3
+ * Improve Regex
4
+ ## v1.0.3
4
5
  * Small fixes
5
6
  * CI Status badge
6
- ## V1.0.2
7
+ ## v1.0.2
7
8
  * Add MIT LICENSE
8
- ## V1.0.0
9
+ ## v1.0.0
9
10
  ### Initial version
10
11
  #### Features
11
12
  * Parse address lines using a Regex
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- address_line_divider (1.0.3)
4
+ address_line_divider (1.0.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
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)
2
4
  # AddressLineDivider
3
5
 
4
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.
@@ -16,8 +16,21 @@ module AddressLineDivider
16
16
  private
17
17
 
18
18
  def parse_using_regex(address_line)
19
- /^(?<street>\D+) (?<street_no>.*)/ =~ address_line
20
- [street, street_no]
19
+ last_number_index = address_line.index(last_number(address_line))
20
+ street_name = address_line[0..last_number_index - 1].strip
21
+ street_no = address_line[last_number_index..-1].strip
22
+
23
+ [street_name, street_no]
24
+ end
25
+
26
+ def last_number(address_line)
27
+ squish(address_line).split(" ").select do |substr|
28
+ substr =~ /[[:digit:]]/
29
+ end.last
30
+ end
31
+
32
+ def squish(string)
33
+ string.gsub(" ", " ").strip
21
34
  end
22
35
 
23
36
  def search_street_on_file(address_line)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AddressLineDivider
4
- VERSION = "1.0.3"
4
+ VERSION = "1.0.4"
5
5
  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.3
4
+ version: 1.0.4
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-13 00:00:00.000000000 Z
11
+ date: 2021-07-15 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"