dates_from_string 0.4.0 → 0.5.0

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: a3a11b4fa95109a8912aeafc2f26059329ab202a
4
- data.tar.gz: 82965858f5db7e757f59c052d9efdaa602b38bcf
3
+ metadata.gz: dcccdda19e565c99699a5f0d8c6fb817d638dac1
4
+ data.tar.gz: ee541a880654b1303f544ddc3b8daa77a8ee18e2
5
5
  SHA512:
6
- metadata.gz: 5c6150df8d07c0f8fae1e3c88a9dd2ff1bafeee14c777b865cf81c4263860cbe9014bc0420d5c3d79e3bf0c8abe249effae70febda78c872207d8389bb71d8d8
7
- data.tar.gz: 5c22bb5e72c83bb798e5f585c1b17b1971c131c98889fb4c56aec5448f9c117d9ba00bb35500ea615746dd469bc71abbe5b8ef85b7003c19e5eb98ad536c7ad0
6
+ metadata.gz: 4923d3dab2741a944e9850fd705e12734ce8b0a7380f54f7fa29b0cb6c701589cdeb0a450ece7c822c60eba2e4749c82df7d853888ff3fa30526e5feed4d852a
7
+ data.tar.gz: 3162c55e8fe7585ba3ade3de7646ab8952774f1f34e8e0cde1b6ef39a0af612abbf4071e7642085928fbce3d1c557eb96a39b110486b88f83097078e48390a93
data/README.md CHANGED
@@ -88,6 +88,13 @@ dates_from_string.get_structure(input)
88
88
  # {:type=>:month, :value=>"04", :distance=>1, :key_words=>[]},
89
89
  # {:type=>:year, :value=>"1948", :distance=>0, :key_words=>[]}]
90
90
  #
91
+
92
+ input = 'circa 1960 and full date 07 Jun 1941'
93
+ #=> return
94
+ #[{:type=>:year, :value=>"1960", :distance=>5, :key_words=>[]},
95
+ #{:type=>:day, :value=>"07", :distance=>1, :key_words=>[]},
96
+ #{:type=>:month, :value=>"06", :distance=>1, :key_words=>[]},
97
+ #{:type=>:year, :value=>"1941", :distance=>0, :key_words=>[]}]
91
98
  ```
92
99
 
93
100
  ## Development
@@ -66,18 +66,18 @@ class DatesFromString
66
66
  end
67
67
 
68
68
  def get_full_date(string)
69
- if string =~ (/\d{4}-\d{2}-\d{2}/)
70
- string.split("-")
71
- elsif string =~ (/\d{2}-\d{2}-\d{4}/)
72
- string.split("-").reverse
73
- elsif string =~ (/\d{4}\.\d{2}\.\d{2}/)
74
- string.split(".")
75
- elsif string =~ (/\d{2}\.\d{2}\.\d{4}/)
76
- string.split(".").reverse
77
- elsif string =~ (/\d{4}\/\d{2}\/\d{2}/)
78
- string.split("/")
79
- elsif string =~ (/\d{2}\/\d{2}\/\d{4}/)
80
- string.split("/").reverse
69
+ if (result = string.match(/\d{4}-\d{2}-\d{2}/))
70
+ result.to_s.split("-")
71
+ elsif (result = string.match(/\d{2}-\d{2}-\d{4}/))
72
+ result.to_s.split("-").reverse
73
+ elsif (result = string.match(/\d{4}\.\d{2}\.\d{2}/))
74
+ result.to_s.split(".")
75
+ elsif (result = string.match(/\d{2}\.\d{2}\.\d{4}/))
76
+ result.to_s.split(".").reverse
77
+ elsif (result = string.match(/\d{4}\/\d{2}\/\d{2}/))
78
+ result.to_s.split("/")
79
+ elsif (result = string.match(/\d{2}\/\d{2}\/\d{4}/))
80
+ result.to_s.split("/").reverse
81
81
  # elsif string =~(/\d{2}\s{1}(Jan|Feb|Mar|Apr|May|Jun|Jul|Apr|Sep|Oct|Nov|Dec)\s{1}\d{4}/)
82
82
  # string.to_date.to_s.split("-")
83
83
  else
@@ -1,3 +1,3 @@
1
1
  class DatesFromString
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
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: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Chechaev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-29 00:00:00.000000000 Z
11
+ date: 2015-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler