fuzzy-date 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/lib/fuzzy-date.rb +15 -8
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 264e777d85860b2076170b396de54ed3df1fa26a
4
- data.tar.gz: c80cc54168d8ab911d08d97d34208f9fd7f2ba36
3
+ metadata.gz: 79b9096445fca7db3278f700ad1df4d49963526b
4
+ data.tar.gz: ac5141a7cfe0c17aa0398f0e88c0e5bee2ef67cf
5
5
  SHA512:
6
- metadata.gz: 72b5a5a0623ebbf7908295b0bf04291765630d1317ce61b2fad77cf36cfddc55a80e9a2f56aee226c020a123b5e3c9fd81caeb6b8120e604b6b2aca0cfcab43d
7
- data.tar.gz: 2701bc6fa8ae4a648fe89c1b2aedba5adaf65b534569420023390e797a107823c9e4e32622df669d8605278830445bef8687c7695f63a317ff940373070fc4b7
6
+ metadata.gz: af1096e90f53de76e59308f280be35e39b4d927ab866107aa1822f6d8577d482200166e6432cb131240360e7afafe94c794bd98ec99b938d942a80b87e49cc0e
7
+ data.tar.gz: d8fe6b9bf8c51530e25951c12e243da9ca0f6302a7fd375d5a7ab8bf96b554771a145c09e1aeec4e73ce6b02e5611d97ac85ebcdd1672165593861c75ab67643
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) <year> <copyright holders>
3
+ Copyright (c) 2014 Digital Charleston, LLC
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -2,6 +2,8 @@ require 'date'
2
2
 
3
3
  class FuzzyDate
4
4
 
5
+ DATE_SEPARATOR = '[^A-Za-z0-9]'
6
+
5
7
  @month_names = {
6
8
  1 => 'January',
7
9
  2 => 'February',
@@ -101,17 +103,11 @@ class FuzzyDate
101
103
 
102
104
  return '' if date == ''
103
105
 
104
- date_parts = {}
105
- date_parts[ :original ] = date
106
- date_parts[ :circa ] = false
107
- date_parts[ :year ] = nil
108
- date_parts[ :month ] = nil
109
- date_parts[ :day ] = nil
110
- date_parts[ :era ] = 'AD'
106
+ date_parts = set_up_date_parts date
111
107
 
112
108
  date_in_parts = []
113
109
 
114
- date_separator = Regexp.new '[^A-Za-z0-9]', true
110
+ date_separator = Regexp.new DATE_SEPARATOR, true
115
111
 
116
112
  #- Split the string
117
113
 
@@ -238,4 +234,15 @@ class FuzzyDate
238
234
  def self.clean_parameter( date )
239
235
  date.to_s.strip if date.respond_to? :to_s
240
236
  end
237
+
238
+ def self.set_up_date_parts( date )
239
+ date_parts = {}
240
+ date_parts[ :original ] = date
241
+ date_parts[ :circa ] = false
242
+ date_parts[ :year ] = nil
243
+ date_parts[ :month ] = nil
244
+ date_parts[ :day ] = nil
245
+ date_parts[ :era ] = 'AD'
246
+ date_parts
247
+ end
241
248
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuzzy-date
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Cole