i18n-date 0.0.5 → 0.0.6

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.
@@ -1,5 +1,5 @@
1
1
  module I18n
2
2
  module Date
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
data/lib/i18n-date.rb CHANGED
@@ -11,6 +11,8 @@ class Date
11
11
  end
12
12
 
13
13
  private
14
+
15
+ NonValidObject = 'Invalid object, it should be a String'
14
16
 
15
17
  PREPOSITIONS = (%w/de/) if !Object.const_defined?('PREPOSITIONS')
16
18
 
@@ -58,6 +60,9 @@ class Date
58
60
  end
59
61
 
60
62
  def self.month_to_english(string)
63
+
64
+ raise NonValidObject if string.nil? || !string.kind_of?(String)
65
+
61
66
  string = remove_prepositions(string) # remove prepositions
62
67
  matching_month = string.match(/[\w]+[^\d],\s(?<date>.*)$/)
63
68
  # just for dates that have day name and then current date
data/spec/date_spec.rb CHANGED
@@ -30,4 +30,11 @@ describe Date do
30
30
 
31
31
  end
32
32
 
33
+ it "should return an error message when object to parse is not a string" do
34
+ begin
35
+ Date.month_to_english(1)
36
+ rescue RuntimeError => e
37
+ e.to_s.should be_eql('Invalid object, it should be a String')
38
+ end
39
+ end
33
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-date
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: