datify 0.20.0 → 0.50.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,35 @@
1
1
  = datify
2
2
 
3
- Description goes here.
3
+ Datify is a rubygem to convert a string storing a date or a time in a proper
4
+ Time ruby object.
5
+ Imagine you have a text file containing a list of string formatted this way
6
+ 'day-month-year' and you want to have fulle featured Time object now you can
7
+ with _datify_.
8
+
9
+ *NEWS*
10
+ From the version 0.50 and beyond, you don't have to call internal Datify::Engine methods anymore, but eventually you may want to use two new methods _datify_ has added to String class.
11
+
12
+ If you require the _datify_ gem, your strings will acquire:
13
+ is_time? - a boolean checking out if the string is a good datetime
14
+ to_time - the core method returning a Time object for the self class
15
+
16
+ The API now is even easier.
17
+ "23-giu-1976".is_time? _~> true_
18
+ "23-giu-1976".to_time _1976-06-23 00:00:00 +0200_
19
+
20
+ Of course you can work in the previous way as well.
21
+
22
+ require 'datify'
23
+
24
+ my_date = Datify::Engine.new('16-giu-1976')
25
+ puts my_date.date.to_s
26
+
27
+ That's it!
28
+
29
+ == Install
30
+
31
+ You may want to install _datify_ with the following command:
32
+ gem install datify
4
33
 
5
34
  == Contributing to datify
6
35
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.20.0
1
+ 0.50.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{datify}
8
- s.version = "0.20.0"
8
+ s.version = "0.50.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Paolo Perego"]
12
- s.date = %q{2011-05-19}
12
+ s.date = %q{2011-05-20}
13
13
  s.description = %q{Datify is a rubygem to convert a string storing a date or a time in a proper Time ruby object}
14
14
  s.email = %q{thesp0nge@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -30,7 +30,8 @@ Gem::Specification.new do |s|
30
30
  "lib/datify/engine.rb",
31
31
  "lib/datify/language.rb",
32
32
  "spec/datify_spec.rb",
33
- "spec/spec_helper.rb"
33
+ "spec/spec_helper.rb",
34
+ "spec/string_spec.rb"
34
35
  ]
35
36
  s.homepage = %q{http://github.com/thesp0nge/datify}
36
37
  s.licenses = ["BSD"]
@@ -1 +1,11 @@
1
1
  require 'datify/engine'
2
+
3
+ class String
4
+ def is_time?
5
+ Datify::Engine.new(self).valid?
6
+ end
7
+
8
+ def to_time
9
+ Datify::Engine.new(self).date
10
+ end
11
+ end
@@ -1,5 +1,4 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
- require 'singleton'
3
2
 
4
3
  module Datify
5
4
  describe Engine do
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe String, "datify" do
4
+ it "should have the to_time method" do
5
+ "A string".methods.index('to_time'.to_sym).should_not be_nil
6
+ end
7
+
8
+ it "should have the is_time? method" do
9
+ "A string".methods.index('is_time?'.to_sym).should_not be_nil
10
+ end
11
+
12
+ it "should return a valid Time object for valid dates" do
13
+ "23-giu-1973".is_time?.should be_true
14
+ "23-giu-1973".to_time.should be_a(Time)
15
+ end
16
+ it "should tell an invalid date is invalid" do
17
+ "This is not a date".is_time?.should be_false
18
+ end
19
+
20
+ it "should return a nil object when trying to convert an invalid date" do
21
+ "This is not a date".to_time.should be_nil
22
+ end
23
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 20
7
+ - 50
8
8
  - 0
9
- version: 0.20.0
9
+ version: 0.50.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Paolo Perego
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-05-19 00:00:00 +02:00
17
+ date: 2011-05-20 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -114,6 +114,7 @@ files:
114
114
  - lib/datify/language.rb
115
115
  - spec/datify_spec.rb
116
116
  - spec/spec_helper.rb
117
+ - spec/string_spec.rb
117
118
  has_rdoc: true
118
119
  homepage: http://github.com/thesp0nge/datify
119
120
  licenses:
@@ -128,7 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
129
  requirements:
129
130
  - - ">="
130
131
  - !ruby/object:Gem::Version
131
- hash: -2152520314938993170
132
+ hash: -540711405540705868
132
133
  segments:
133
134
  - 0
134
135
  version: "0"