dates_from_string 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d5ae34120cfd20381e8ea4fb005d4733c0dc623
4
- data.tar.gz: 18e134d732f77df7a41f0b00c368c6ac2fab3c61
3
+ metadata.gz: 48c0aa20cd9618285c004faf1e4edbbdca9ebbb9
4
+ data.tar.gz: eac2ddd3c3bf6aa0f12ac1473e972a07420c402d
5
5
  SHA512:
6
- metadata.gz: 9ec06d3b9db6b1ff654aa214290e535eff849befb5810369f9a2a6440e0c8ffc4d23e6c6f6b118c17f5b3f05ac9f0c32c8e0602414885789e4a862c9a4986b1b
7
- data.tar.gz: 64b4ea464200375891453194d69e5036cfd3e627c8f6d01beaa4de85830e75cc96f6d643f99959cb0fce5670bf16d4bcbde14aded301ae49a164c3bf15d24248
6
+ metadata.gz: 262f34a6fce751f4b1bdd43c83b68809c6568a2a448d8e2f7f7e01748e1080a341b60e0175fa9d58c9cf588c84e35be637a2581c6d4aa9b5466de6b597d92cb5
7
+ data.tar.gz: 464c4c303b29e9feae92884f11398f7d7fa5d2dc7543d5feca9ec407ae84fbc5d7d0ca335da4f340bfb112b2ef492811b1934f20d2eb4b5fea632afa93175a73
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  [![Build Status](https://travis-ci.org/sergey-chechaev/dates_from_string.svg?branch=master)](https://travis-ci.org/sergey-chechaev/dates_from_string)
3
3
  # DatesFromString
4
4
 
5
- Flexible solution for finding dates in text. After parsing text, gem return flexible structure of dates, that allow get date by you own logic use distance for next date type and key words between dates.
5
+ Flexible solution for finding dates in text. After parsing text, the gem return flexible structure of dates, that allow getting a date by you own logic use distance for next date type and keywords between dates. Gem also support find a year in email and find a date in structure.
6
6
 
7
7
 
8
8
  ## Installation
@@ -1,44 +1,9 @@
1
- require "dates_from_string/version"
2
- require "parsing_structure"
1
+ require 'dates_from_string/version'
2
+ require 'parsing_structure'
3
+ require 'dates_from_string/patterns'
3
4
 
4
5
  class DatesFromString
5
-
6
-
7
- PATTERNS = {
8
- [
9
- /\d{4}-\d{2}-\d{2}/,
10
- /\d{4}-\d{1}-\d{2}/,
11
- /\d{4}-\d{1}-\d{1}/,
12
- /\d{4}-\d{2}-\d{1}/,
13
- ] => -> string { string.to_s.split("-") },
14
- [
15
- /\d{2}-\d{2}-\d{4}/,
16
- /\d{2}-\d{1}-\d{4}/,
17
- /\d{1}-\d{1}-\d{4}/,
18
- /\d{1}-\d{2}-\d{4}/,
19
- ] => -> string { string.to_s.split("-").reverse },
20
- [
21
- /\d{4}\.\d{2}\.\d{2}/,
22
- /\d{4}\.\d{2}\.\d{1}/,
23
- ] => -> string { string.to_s.split(".") },
24
- [
25
- /\d{2}\.\d{2}\.\d{4}/,
26
- /\d{1}\.\d{2}\.\d{4}/,
27
- ] => -> string { string.to_s.split(".").reverse },
28
- [
29
- /\d{4}\/\d{2}\/\d{2}/,
30
- /\d{4}\/\d{2}\/\d{1}/,
31
- ] => -> string { string.to_s.split("/") },
32
- [
33
- /\d{2}\/\d{2}\/\d{4}/,
34
- /\d{1}\/\d{2}\/\d{4}/,
35
- ] => -> string { string.to_s.split("/").reverse },
36
- }
37
-
38
- DATE_COUNTRY_FORMAT = {
39
- default: -> {[:year,:month,:day]},
40
- usa: -> {[:year,:day,:month]}
41
- }
6
+ include Patterns
42
7
 
43
8
  def initialize(key_words = [], date_format: :default)
44
9
  @key_words = key_words
@@ -0,0 +1,37 @@
1
+ module Patterns
2
+ PATTERNS = {
3
+ [
4
+ /\d{4}-\d{2}-\d{2}/,
5
+ /\d{4}-\d{1}-\d{2}/,
6
+ /\d{4}-\d{1}-\d{1}/,
7
+ /\d{4}-\d{2}-\d{1}/
8
+ ] => ->(string) { string.to_s.split('-') },
9
+ [
10
+ /\d{2}-\d{2}-\d{4}/,
11
+ /\d{2}-\d{1}-\d{4}/,
12
+ /\d{1}-\d{1}-\d{4}/,
13
+ /\d{1}-\d{2}-\d{4}/
14
+ ] => ->(string) { string.to_s.split('-').reverse },
15
+ [
16
+ /\d{4}\.\d{2}\.\d{2}/,
17
+ /\d{4}\.\d{2}\.\d{1}/
18
+ ] => ->(string) { string.to_s.split('.') },
19
+ [
20
+ /\d{2}\.\d{2}\.\d{4}/,
21
+ /\d{1}\.\d{2}\.\d{4}/
22
+ ] => ->(string) { string.to_s.split('.').reverse },
23
+ [
24
+ /\d{4}\/\d{2}\/\d{2}/,
25
+ /\d{4}\/\d{2}\/\d{1}/
26
+ ] => ->(string) { string.to_s.split('/') },
27
+ [
28
+ /\d{2}\/\d{2}\/\d{4}/,
29
+ /\d{1}\/\d{2}\/\d{4}/
30
+ ] => ->(string) { string.to_s.split('/').reverse }
31
+ }.freeze
32
+
33
+ DATE_COUNTRY_FORMAT = {
34
+ default: -> { [:year, :month, :day] },
35
+ usa: -> { [:year, :day, :month] }
36
+ }.freeze
37
+ end
@@ -1,3 +1,3 @@
1
1
  class DatesFromString
2
- VERSION = "1.2.2"
2
+ VERSION = "1.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dates_from_string
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Chechaev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-18 00:00:00.000000000 Z
11
+ date: 2017-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -85,6 +85,7 @@ files:
85
85
  - bin/setup
86
86
  - dates_from_string.gemspec
87
87
  - lib/dates_from_string.rb
88
+ - lib/dates_from_string/patterns.rb
88
89
  - lib/dates_from_string/version.rb
89
90
  - lib/parsing_structure.rb
90
91
  homepage: ''