Skip to content

Commit

Permalink
add email search year
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-chechaev committed Nov 17, 2016
1 parent 63504c7 commit e64d75f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/dates_from_string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def get_clear_text
@clear_text.strip
end

def email_date(email)
email.match(/(?:(?:19|20)[0-9]{2})/).to_s
end

def date_format_by_country(date_format)
DATE_COUNTRY_FORMAT[date_format.to_sym].call
end
Expand Down
2 changes: 1 addition & 1 deletion lib/dates_from_string/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class DatesFromString
VERSION = "1.1.0"
VERSION = "1.2.0"
end
24 changes: 24 additions & 0 deletions spec/dates_from_string_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -585,5 +585,29 @@
expect(subject.get_clear_text).to eq(output)
end

it "find year in email one" do
date_from_string = DatesFromString.new()
input = '[email protected]'
output = "1988"

expect(date_from_string.email_date(input)).to eq(output)
end

it "find year in email two" do
date_from_string = DatesFromString.new()
input = '[email protected]'
output = "1988"

expect(date_from_string.email_date(input)).to eq(output)
end

it "find year in email three" do
date_from_string = DatesFromString.new()
input = '[email protected]'
output = "1988"

expect(date_from_string.email_date(input)).to eq(output)
end

end
end

0 comments on commit e64d75f

Please sign in to comment.