datify 0.20.0 → 0.50.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +30 -1
- data/VERSION +1 -1
- data/datify.gemspec +4 -3
- data/lib/datify.rb +10 -0
- data/spec/datify_spec.rb +0 -1
- data/spec/string_spec.rb +23 -0
- metadata +5 -4
data/README.rdoc
CHANGED
@@ -1,6 +1,35 @@
|
|
1
1
|
= datify
|
2
2
|
|
3
|
-
|
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.
|
1
|
+
0.50.0
|
data/datify.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{datify}
|
8
|
-
s.version = "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-
|
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"]
|
data/lib/datify.rb
CHANGED
data/spec/datify_spec.rb
CHANGED
data/spec/string_spec.rb
ADDED
@@ -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
|
-
-
|
7
|
+
- 50
|
8
8
|
- 0
|
9
|
-
version: 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-
|
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: -
|
132
|
+
hash: -540711405540705868
|
132
133
|
segments:
|
133
134
|
- 0
|
134
135
|
version: "0"
|