cowtech-extensions 1.6.4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/cowtech-extensions.gemspec +1 -0
- data/lib/cowtech-extensions/boolean.rb +0 -4
- data/lib/cowtech-extensions/datetime.rb +60 -70
- data/lib/cowtech-extensions/utils.rb +35 -1
- data/lib/cowtech-extensions/version.rb +3 -3
- data/spec/cowtech-extensions/datetime_spec.rb +146 -0
- data/spec/cowtech-extensions/object_spec.rb +7 -19
- data/spec/cowtech-extensions/pathname_spec.rb +1 -3
- data/spec/cowtech-extensions_spec.rb +21 -3
- metadata +27 -11
data/cowtech-extensions.gemspec
CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |gem|
|
|
23
23
|
gem.require_paths = ["lib"]
|
24
24
|
|
25
25
|
gem.add_dependency("actionpack", "~> 3.0")
|
26
|
+
gem.add_dependency("tzinfo", "~> 0.3.33")
|
26
27
|
|
27
28
|
gem.add_development_dependency("rspec", "~> 2.10")
|
28
29
|
gem.add_development_dependency("rcov", "~> 1.0.0")
|
@@ -4,24 +4,30 @@
|
|
4
4
|
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
5
5
|
#
|
6
6
|
|
7
|
-
# TODO: To test
|
8
7
|
module Cowtech
|
9
8
|
module Extensions
|
10
9
|
module DateTime
|
11
10
|
extend ActiveSupport::Concern
|
12
11
|
|
13
|
-
included do
|
14
|
-
cattr_accessor :date_names
|
15
|
-
end
|
16
|
-
|
17
12
|
module ClassMethods
|
13
|
+
def days(short = true)
|
14
|
+
days = Cowtech::Extensions.settings.date_names[short ? :short_days : :long_days]
|
15
|
+
(1..7).to_a.collect { |i|
|
16
|
+
{:value => i.to_s, :label=> days[i - 1]}
|
17
|
+
}
|
18
|
+
|
19
|
+
end
|
20
|
+
|
18
21
|
def months(short = true)
|
19
|
-
|
22
|
+
months = Cowtech::Extensions.settings.date_names[short ? :short_months : :long_months]
|
23
|
+
(1..12).collect { |i|
|
24
|
+
{:value => i.to_s.rjust(2, "0"), :label=> months.at(i - 1)}
|
25
|
+
}
|
20
26
|
end
|
21
27
|
|
22
28
|
def years(offset = 10, also_future = true, reference = nil)
|
23
29
|
y = (reference || Date.today).year
|
24
|
-
(y - offset..(also_future ? y + offset : y)).collect { |year| {:value => year} }
|
30
|
+
(y - offset..(also_future ? y + offset : y)).collect { |year| {:value => year, :label => year} }
|
25
31
|
end
|
26
32
|
|
27
33
|
def easter(year = nil)
|
@@ -51,94 +57,78 @@ module Cowtech
|
|
51
57
|
Date.civil(year, month, day)
|
52
58
|
end
|
53
59
|
|
54
|
-
def cowtech_extensions_setup
|
55
|
-
DateTime::date_names ||= {
|
56
|
-
:months => ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
57
|
-
:short_months => ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
58
|
-
:days => ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
|
59
|
-
:short_days => ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
|
60
|
-
}
|
61
|
-
|
62
|
-
self.custom_formats.each_pair do |k, v| Time::DATE_FORMATS[k] = v end
|
63
|
-
end
|
64
|
-
|
65
|
-
def custom_formats
|
66
|
-
@@custom_formats ||= {
|
67
|
-
:ct_date => "%Y-%m-%d",
|
68
|
-
:ct_time => "%H:%M:%S",
|
69
|
-
:ct_date_time => "%F %T",
|
70
|
-
:ct_iso_8601 => "%FT%T%z"
|
71
|
-
}
|
72
|
-
end
|
73
|
-
|
74
60
|
def custom_format(key)
|
75
|
-
|
61
|
+
Cowtech::Extensions.settings.date_formats.fetch(key.to_sym, key).ensure_string
|
76
62
|
end
|
77
63
|
|
78
64
|
def is_valid?(value, format = "%F %T")
|
79
65
|
rv = true
|
80
66
|
|
67
|
+
format = self.custom_format(format)
|
68
|
+
|
81
69
|
begin
|
82
|
-
DateTime.strptime(value, format)
|
83
|
-
rescue
|
70
|
+
::DateTime.strptime(value, format)
|
71
|
+
rescue => e
|
84
72
|
rv = false
|
85
73
|
end
|
86
74
|
|
87
75
|
rv
|
88
76
|
end
|
89
|
-
end
|
90
77
|
|
91
|
-
|
92
|
-
|
93
|
-
ua = (self.respond_to?(:utc) ? self : self.to_datetime).utc
|
94
|
-
::Time.utc(ua.year, ua.month, ua.day, ua.hour, ua.min, ua.sec)
|
78
|
+
def rational_offset(tz = ::Time.zone)
|
79
|
+
Rational((tz.tzinfo.current_period.utc_offset / 3600), 24)
|
95
80
|
end
|
81
|
+
end
|
96
82
|
|
97
|
-
|
98
|
-
|
99
|
-
|
83
|
+
def utc_time
|
84
|
+
ua = (self.respond_to?(:utc) ? self : self.to_datetime).utc
|
85
|
+
::Time.utc(ua.year, ua.month, ua.day, ua.hour, ua.min, ua.sec)
|
86
|
+
end
|
100
87
|
|
101
|
-
|
102
|
-
|
103
|
-
|
88
|
+
def in_months(base = nil)
|
89
|
+
base ||= Date.today.year
|
90
|
+
((self.year) - base) * 12 + self.month
|
91
|
+
end
|
92
|
+
|
93
|
+
def padded_month
|
94
|
+
self.month.to_s.rjust(2, "0")
|
95
|
+
end
|
104
96
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
97
|
+
def lstrftime(format = nil)
|
98
|
+
rv = nil
|
99
|
+
names = Cowtech::Extensions.settings.date_names
|
100
|
+
|
101
|
+
final_format = ::DateTime.custom_format(format).ensure_string.gsub(/(%{1,2}[ab])/i) do |match|
|
102
|
+
mrv = match
|
103
|
+
|
104
|
+
if match !~ /^%%/ then
|
105
|
+
case match
|
106
|
+
when "%a"
|
107
|
+
mrv = names[:short_days][self.wday]
|
108
|
+
when "%A"
|
109
|
+
mrv = names[:long_days][self.wday]
|
110
|
+
when "%b"
|
111
|
+
mrv = names[:short_months][self.month - 1]
|
112
|
+
when "%B"
|
113
|
+
mrv = names[:long_months][self.month - 1]
|
122
114
|
end
|
123
115
|
|
124
|
-
mrv
|
116
|
+
mrv.sub!("%", "%%")
|
125
117
|
end
|
126
118
|
|
127
|
-
|
119
|
+
mrv
|
128
120
|
end
|
129
121
|
|
130
|
-
|
131
|
-
|
132
|
-
end
|
122
|
+
self.strftime(final_format)
|
123
|
+
end
|
133
124
|
|
134
|
-
|
135
|
-
|
136
|
-
|
125
|
+
def local_strftime(format = nil)
|
126
|
+
(self.respond_to?(:in_time_zone) ? self.in_time_zone : self).strftime(::DateTime.custom_format(format))
|
127
|
+
end
|
137
128
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
#end
|
129
|
+
def local_lstrftime(format = nil)
|
130
|
+
(self.respond_to?(:in_time_zone) ? self.in_time_zone : self).lstrftime(format)
|
131
|
+
end
|
142
132
|
end
|
143
133
|
end
|
144
134
|
end
|
@@ -7,7 +7,7 @@
|
|
7
7
|
module Cowtech
|
8
8
|
module Extensions
|
9
9
|
class Settings
|
10
|
-
attr_reader :format_number, :date_names, :
|
10
|
+
attr_reader :format_number, :boolean_names, :date_names, :date_formats
|
11
11
|
|
12
12
|
def self.instance
|
13
13
|
@@instance ||= Cowtech::Extensions::Settings.new
|
@@ -16,6 +16,8 @@ module Cowtech
|
|
16
16
|
def initialize
|
17
17
|
self.setup_format_number
|
18
18
|
self.setup_boolean_names
|
19
|
+
self.setup_date_formats
|
20
|
+
self.setup_date_names
|
19
21
|
end
|
20
22
|
|
21
23
|
def setup_format_number(prec = 2, decimal_separator = ".", add_string = "", k_separator = ",")
|
@@ -30,6 +32,38 @@ module Cowtech
|
|
30
32
|
def setup_boolean_names(true_name = "Yes", false_name = "No")
|
31
33
|
@boolean_names = {true => true_name, false => false_name}
|
32
34
|
end
|
35
|
+
|
36
|
+
def setup_date_formats(formats = nil, replace = false)
|
37
|
+
formats = {
|
38
|
+
:ct_date => "%Y-%m-%d",
|
39
|
+
:ct_time => "%H:%M:%S",
|
40
|
+
:ct_date_time => "%F %T",
|
41
|
+
:ct_iso_8601 => "%FT%T%z"
|
42
|
+
} if formats.blank?
|
43
|
+
|
44
|
+
if !replace then
|
45
|
+
@date_formats ||= {}
|
46
|
+
@date_formats.merge!(formats)
|
47
|
+
else
|
48
|
+
@date_formats = formats
|
49
|
+
end
|
50
|
+
|
51
|
+
@date_formats.each_pair do |k, v| Time::DATE_FORMATS[k] = v end
|
52
|
+
end
|
53
|
+
|
54
|
+
def setup_date_names(long_months = nil, short_months = nil, long_days = nil, short_days = nil)
|
55
|
+
long_months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] if long_months.blank?
|
56
|
+
short_months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] if short_months.blank?
|
57
|
+
long_days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] if long_days.blank?
|
58
|
+
short_days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] if short_days.blank?
|
59
|
+
|
60
|
+
@date_names = {
|
61
|
+
:long_months => long_months,
|
62
|
+
:short_months => short_months,
|
63
|
+
:long_days => long_days,
|
64
|
+
:short_days => short_days
|
65
|
+
}
|
66
|
+
end
|
33
67
|
end
|
34
68
|
|
35
69
|
module Exceptions
|
@@ -7,5 +7,151 @@
|
|
7
7
|
require "spec_helper"
|
8
8
|
|
9
9
|
describe Cowtech::Extensions::DateTime do
|
10
|
+
let(:random_reference) { DateTime.civil(1990 + rand(30), 1 + rand(10), 1 + rand(25), 1 + rand(20), 1 + rand(58), 1 + rand(58)).in_time_zone }
|
11
|
+
let(:fixed_reference){
|
12
|
+
tz = ActiveSupport::TimeZone[7]
|
13
|
+
date = DateTime.civil(2005, 6, 7, 8, 9, 10, DateTime.rational_offset(tz))
|
14
|
+
}
|
10
15
|
|
16
|
+
describe "#days" do
|
17
|
+
it "should return the list of the days of the week" do
|
18
|
+
DateTime.days.should be_kind_of(Array)
|
19
|
+
DateTime.days[3].should == {:value => "4", :label => "Wed"}
|
20
|
+
DateTime.days(false).should be_kind_of(Array)
|
21
|
+
DateTime.days(false)[3].should == {:value => "4", :label => "Wednesday"}
|
22
|
+
|
23
|
+
Cowtech::Extensions.settings.setup_date_names(nil, nil, 7.times.collect {|i| (i + 1).to_s * 2}, 7.times.collect {|i| (i + 1).to_s})
|
24
|
+
DateTime.days.should be_kind_of(Array)
|
25
|
+
DateTime.days[3].should == {:value => "4", :label => "4"}
|
26
|
+
DateTime.days(false).should be_kind_of(Array)
|
27
|
+
DateTime.days(false)[3].should == {:value => "4", :label => "44"}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#months" do
|
32
|
+
it "should return the list of the months of the year" do
|
33
|
+
DateTime.months.should be_kind_of(Array)
|
34
|
+
DateTime.months[6].should == {:value => "07", :label => "Jul"}
|
35
|
+
DateTime.months(false).should be_kind_of(Array)
|
36
|
+
DateTime.months(false)[6].should == {:value => "07", :label => "July"}
|
37
|
+
|
38
|
+
Cowtech::Extensions.settings.setup_date_names(12.times.collect {|i| (i + 1).to_s * 2}, 12.times.collect {|i| (i + 1).to_s}, nil, nil)
|
39
|
+
DateTime.months.should be_kind_of(Array)
|
40
|
+
DateTime.months[6].should == {:value => "07", :label => "7"}
|
41
|
+
DateTime.months(false).should be_kind_of(Array)
|
42
|
+
DateTime.months(false)[6].should == {:value => "07", :label => "77"}
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#years" do
|
48
|
+
it "should return a range of years" do
|
49
|
+
DateTime.years.collect(&:value).should == (Date.today.year - 10..Date.today.year + 10).to_a
|
50
|
+
DateTime.years(5).collect(&:value).should == (Date.today.year - 5..Date.today.year + 5).to_a
|
51
|
+
DateTime.years(5, false).collect(&:value).should == (Date.today.year - 5..Date.today.year).to_a
|
52
|
+
DateTime.years(5, false, Date.civil(1900, 1, 1)).collect(&:value).should == (1895..1900).to_a
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#easter" do
|
57
|
+
it "should compute the valid Easter day" do
|
58
|
+
{1984 => "0422", 1995 => "0416", 2006 => "0416", 2017 => "0416"}.each do |year, date|
|
59
|
+
DateTime.easter(year).strftime("%Y%m%d").should == "#{year}#{date}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#custom_format" do
|
65
|
+
it "should find the format" do
|
66
|
+
DateTime.custom_format(:ct_date).should == "%Y-%m-%d"
|
67
|
+
DateTime.custom_format("ct_date").should == "%Y-%m-%d"
|
68
|
+
|
69
|
+
Cowtech::Extensions.settings.setup_date_formats({:ct_foo => "%ABC"})
|
70
|
+
|
71
|
+
DateTime.custom_format(:ct_foo).should == "%ABC"
|
72
|
+
DateTime.custom_format("ct_foo").should == "%ABC"
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should return the key if format is not found" do DateTime.custom_format(:ct_unused) == "ct_unused" end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#is_valid?" do
|
79
|
+
it "should recognize a valid date" do
|
80
|
+
DateTime.is_valid?("2012-04-05", "%F").should be_true
|
81
|
+
DateTime.is_valid?("2012-04-05", :ct_date).should be_true
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should fail if the argument or the format is not valid" do
|
85
|
+
DateTime.is_valid?("ABC", "%F").should be_false
|
86
|
+
DateTime.is_valid?("2012-04-05", "%X").should be_false
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "#rational_offset" do
|
91
|
+
it "should return the correct rational value" do
|
92
|
+
DateTime.rational_offset(ActiveSupport::TimeZone[4]).should == Rational(4, 24)
|
93
|
+
DateTime.rational_offset(ActiveSupport::TimeZone[-7]).should == Rational(-7, 24)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe "#utc_time" do
|
98
|
+
it "should convert to UTC Time" do random_reference.utc_time.should be_kind_of(Time) end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "#in_months" do
|
102
|
+
it "should return the amount of months passed since the start of the reference year" do
|
103
|
+
Date.today.in_months.should == Date.today.month
|
104
|
+
fixed_reference.in_months(2000).should == 66
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "#padded_month" do
|
109
|
+
it "should pad the month number" do
|
110
|
+
random_reference.padded_month.should == random_reference.month.to_s.rjust(2, "0")
|
111
|
+
Date.civil(2000, 8, 8).padded_month.should == "08"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "#lstrftime" do
|
116
|
+
it "should return corrected formatted string" do
|
117
|
+
fixed_reference.lstrftime(:db).should == "db"
|
118
|
+
fixed_reference.lstrftime("%F").should == "2005-06-07"
|
119
|
+
fixed_reference.lstrftime(:ct_iso_8601).should == "2005-06-07T08:09:10+0700"
|
120
|
+
|
121
|
+
Cowtech::Extensions.settings.setup_date_names
|
122
|
+
Cowtech::Extensions.settings.setup_date_formats({:ct_local_test => "%a %A %b %B %d %Y %H"})
|
123
|
+
fixed_reference.lstrftime(:ct_local_test).should == "Tue Tuesday Jun June 07 2005 08"
|
124
|
+
|
125
|
+
Cowtech::Extensions.settings.setup_date_names(
|
126
|
+
12.times.collect {|i| (i + 1).to_s * 2}, 12.times.collect {|i| (i + 1).to_s},
|
127
|
+
7.times.collect {|i| (i + 1).to_s * 2}, 7.times.collect {|i| (i + 1).to_s}
|
128
|
+
)
|
129
|
+
|
130
|
+
fixed_reference.lstrftime(:ct_local_test).should == "3 33 6 66 07 2005 08"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe "#local_strftime" do
|
135
|
+
it "should retrieve the date in the current timezone" do
|
136
|
+
::Time.zone = ActiveSupport::TimeZone[0]
|
137
|
+
Cowtech::Extensions.settings.setup_date_formats({:ct_local_test => "%a %A %b %B %d %Y %H"})
|
138
|
+
fixed_reference.local_strftime(:ct_local_test).should == "Tue Tuesday Jun June 07 2005 01"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe "#local_lstrftime" do
|
143
|
+
it "should retrieve the date in the current timezone" do
|
144
|
+
::Time.zone = ActiveSupport::TimeZone[0]
|
145
|
+
|
146
|
+
Cowtech::Extensions.settings.setup_date_names
|
147
|
+
Cowtech::Extensions.settings.setup_date_formats({:ct_local_test => "%a %A %b %B %d %Y %H"})
|
148
|
+
|
149
|
+
Cowtech::Extensions.settings.setup_date_names(
|
150
|
+
12.times.collect {|i| (i + 1).to_s * 2}, 12.times.collect {|i| (i + 1).to_s},
|
151
|
+
7.times.collect {|i| (i + 1).to_s * 2}, 7.times.collect {|i| (i + 1).to_s}
|
152
|
+
)
|
153
|
+
|
154
|
+
fixed_reference.local_lstrftime(:ct_local_test).should == "3 33 6 66 07 2005 01"
|
155
|
+
end
|
156
|
+
end
|
11
157
|
end
|
@@ -30,7 +30,7 @@ describe Cowtech::Extensions::Object do
|
|
30
30
|
it "should return true for a invalid number" do
|
31
31
|
"s213".is_number?.should be_false
|
32
32
|
nil.is_number?.should be_false
|
33
|
-
|
33
|
+
end
|
34
34
|
end
|
35
35
|
|
36
36
|
describe "#is_integer?" do
|
@@ -80,9 +80,7 @@ describe Cowtech::Extensions::Object do
|
|
80
80
|
0.is_boolean?.should be_true
|
81
81
|
end
|
82
82
|
|
83
|
-
it "should return true for a invalid boolean" do
|
84
|
-
"11".is_boolean?.should be_false
|
85
|
-
end
|
83
|
+
it "should return true for a invalid boolean" do "11".is_boolean?.should be_false end
|
86
84
|
end
|
87
85
|
|
88
86
|
describe "#ensure_string" do
|
@@ -106,13 +104,9 @@ describe Cowtech::Extensions::Object do
|
|
106
104
|
"+1.231,45".to_float.should == 1231.45
|
107
105
|
end
|
108
106
|
|
109
|
-
it "should return 0.0 for a invalid number without a default" do
|
110
|
-
"s213".to_float.should == 0.0
|
111
|
-
end
|
107
|
+
it "should return 0.0 for a invalid number without a default" do "s213".to_float.should == 0.0 end
|
112
108
|
|
113
|
-
it "should return the default for a invalid number" do
|
114
|
-
"s213".to_float(1.0).should == 1.0
|
115
|
-
end
|
109
|
+
it "should return the default for a invalid number" do "s213".to_float(1.0).should == 1.0 end
|
116
110
|
end
|
117
111
|
|
118
112
|
describe "#to_integer" do
|
@@ -123,13 +117,9 @@ describe Cowtech::Extensions::Object do
|
|
123
117
|
"-123".to_integer.should == -123
|
124
118
|
end
|
125
119
|
|
126
|
-
it "should return 0 for a invalid number without a default" do
|
127
|
-
"s213".to_integer.should == 0
|
128
|
-
end
|
120
|
+
it "should return 0 for a invalid number without a default" do "s213".to_integer.should == 0 end
|
129
121
|
|
130
|
-
it "should return the default for a invalid number" do
|
131
|
-
"s213".to_integer(1).should == 1
|
132
|
-
end
|
122
|
+
it "should return the default for a invalid number" do "s213".to_integer(1).should == 1 end
|
133
123
|
end
|
134
124
|
|
135
125
|
describe "#to_boolean" do
|
@@ -206,8 +196,6 @@ describe Cowtech::Extensions::Object do
|
|
206
196
|
reference.debug_dump(:yaml, false).should == reference.to_yaml
|
207
197
|
end
|
208
198
|
|
209
|
-
it "should raise an exception if requested" do
|
210
|
-
expect { {:a => "b"}.debug_dump }.to raise_error(Cowtech::Extensions::Exceptions::Dump)
|
211
|
-
end
|
199
|
+
it "should raise an exception if requested" do expect { {:a => "b"}.debug_dump }.to raise_error(Cowtech::Extensions::Exceptions::Dump) end
|
212
200
|
end
|
213
201
|
end
|
@@ -10,8 +10,6 @@ describe Cowtech::Extensions::Pathname do
|
|
10
10
|
let(:reference) { Pathname.new($0) }
|
11
11
|
|
12
12
|
describe "#components" do
|
13
|
-
it "should return the components of the path" do
|
14
|
-
([""] + reference.components).should == reference.to_s.split("/")
|
15
|
-
end
|
13
|
+
it "should return the components of the path" do ([""] + reference.components).should == reference.to_s.split("/") end
|
16
14
|
end
|
17
15
|
end
|
@@ -1,9 +1,27 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Cowtech::Extensions do
|
4
|
-
describe "#load!" do
|
5
|
-
|
6
|
-
|
4
|
+
describe "#load! should load extensions" do
|
5
|
+
Cowtech::Extensions.load!
|
6
|
+
|
7
|
+
it "for Boolean" do
|
8
|
+
true.should respond_to("value")
|
9
|
+
true.should respond_to("to_i")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "for DateTime" do
|
13
|
+
DateTime.should respond_to("custom_format")
|
14
|
+
DateTime.now.should respond_to("lstrftime")
|
7
15
|
end
|
16
|
+
|
17
|
+
it "for Hash" do {:a => "b"}.should respond_to("a") end
|
18
|
+
|
19
|
+
it "for Math" do Math.should respond_to("min") end
|
20
|
+
|
21
|
+
it "for Object" do 0.should respond_to("debug_dump") end
|
22
|
+
|
23
|
+
it "for Pathname" do Pathname.new($0).should respond_to("components") end
|
24
|
+
|
25
|
+
it "for String" do "".should respond_to("remove_accents") end
|
8
26
|
end
|
9
27
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cowtech-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
|
-
-
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version:
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 2.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Shogun
|
@@ -33,9 +33,25 @@ dependencies:
|
|
33
33
|
type: :runtime
|
34
34
|
version_requirements: *id001
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
36
|
+
name: tzinfo
|
37
37
|
prerelease: false
|
38
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 81
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
- 3
|
47
|
+
- 33
|
48
|
+
version: 0.3.33
|
49
|
+
type: :runtime
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: rspec
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
39
55
|
none: false
|
40
56
|
requirements:
|
41
57
|
- - ~>
|
@@ -46,11 +62,11 @@ dependencies:
|
|
46
62
|
- 10
|
47
63
|
version: "2.10"
|
48
64
|
type: :development
|
49
|
-
version_requirements: *
|
65
|
+
version_requirements: *id003
|
50
66
|
- !ruby/object:Gem::Dependency
|
51
67
|
name: rcov
|
52
68
|
prerelease: false
|
53
|
-
requirement: &
|
69
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
54
70
|
none: false
|
55
71
|
requirements:
|
56
72
|
- - ~>
|
@@ -62,11 +78,11 @@ dependencies:
|
|
62
78
|
- 0
|
63
79
|
version: 1.0.0
|
64
80
|
type: :development
|
65
|
-
version_requirements: *
|
81
|
+
version_requirements: *id004
|
66
82
|
- !ruby/object:Gem::Dependency
|
67
83
|
name: pry
|
68
84
|
prerelease: false
|
69
|
-
requirement: &
|
85
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
70
86
|
none: false
|
71
87
|
requirements:
|
72
88
|
- - ~>
|
@@ -78,7 +94,7 @@ dependencies:
|
|
78
94
|
- 9
|
79
95
|
version: 0.9.9
|
80
96
|
type: :development
|
81
|
-
version_requirements: *
|
97
|
+
version_requirements: *id005
|
82
98
|
description: Several Ruby object enhancements.
|
83
99
|
email:
|
84
100
|
- shogun_panda@me.com
|