cowtech-extensions 2.5.1 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -103,9 +103,9 @@
103
103
  </div>
104
104
 
105
105
  <div id="footer">
106
- Generated on Fri Jul 20 10:23:55 2012 by
106
+ Generated on Fri Jul 20 14:28:06 2012 by
107
107
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
- 0.8.2.1 (ruby-1.8.7).
108
+ 0.8.2.1 (ruby-1.9.2).
109
109
  </div>
110
110
 
111
111
  </body>
@@ -311,7 +311,7 @@ module Cowtech
311
311
 
312
312
  ::ActiveSupport::TimeZone.all.each do |zone|
313
313
  @zones_names[dst_key] << zone.to_s
314
- @zones_names[dst_key] << zone.to_s_with_dst(dst_label)
314
+ @zones_names[dst_key] << zone.to_s_with_dst(dst_label) if zone.uses_dst?
315
315
  end
316
316
  end
317
317
 
@@ -438,6 +438,17 @@ module Cowtech
438
438
  # @param dst_label [String] Label for the DST indication. Defaults to `(Daylight Saving Time)`.
439
439
  # @param year [Fixnum] The year to which refer to. Defaults to the current year.
440
440
  # @return [String] The name for the zone with DST or `nil`, if the timezone doesn't use DST for that year.
441
+ def dst_name(dst_label = nil, year = nil)
442
+ dst_label ||= "(Daylight Saving Time)"
443
+
444
+ self.uses_dst?(year) ? "#{name} #{dst_label}" : nil
445
+ end
446
+
447
+ # Returns a string representation for this zone with DST (Daylight Saving Time) active.
448
+ #
449
+ # @param dst_label [String] Label for the DST indication. Defaults to `(Daylight Saving Time)`.
450
+ # @param year [Fixnum] The year to which refer to. Defaults to the current year.
451
+ # @return [String] The string representation for the zone with DST or `nil`, if the timezone doesn't use DST for that year.
441
452
  def to_s_with_dst(dst_label = nil, year = nil)
442
453
  dst_label ||= "(Daylight Saving Time)"
443
454
 
@@ -450,20 +461,20 @@ module Cowtech
450
461
  end
451
462
  end
452
463
 
453
- # Returns the parametized name for this zone.
464
+ # Returns a parametized string representation for this zone.
454
465
  #
455
466
  # @param with_offset [Boolean] If to include offset into the representation.
456
- # @return [String] The parametized name for this zone.
467
+ # @return [String] The parametized string representation for this zone.
457
468
  def to_s_parameterized(with_offset = true)
458
469
  ::ActiveSupport::TimeZone.parameterize_zone(self.to_s, with_offset)
459
470
  end
460
471
 
461
- # Returns the parametized name for this zone with DST (Daylight Saving Time) active.
472
+ # Returns a parametized string representation for this zone with DST (Daylight Saving Time) active.
462
473
  #
463
474
  # @param dst_label [String] Label for the DST indication. Defaults to `(Daylight Saving Time)`.
464
475
  # @param with_offset [Boolean] If to include offset into the representation.
465
476
  # @param year [Fixnum] The year to which refer to. Defaults to the current year.
466
- # @return [String] The parametized name for this zone with DST or `nil`, if the timezone doesn't use DST for that year.
477
+ # @return [String] The parametized string representation for this zone with DST or `nil`, if the timezone doesn't use DST for that year.
467
478
  def to_s_with_dst_parameterized(dst_label = nil, with_offset = true, year = nil)
468
479
  rv = self.to_s_with_dst(dst_label, year)
469
480
  rv ? ::ActiveSupport::TimeZone.parameterize_zone(rv) : nil
@@ -24,15 +24,15 @@ module Cowtech
24
24
  #
25
25
  # @return [Settings] The singleton instance of the settings.
26
26
  def self.instance
27
- @instance ||= self.new()
27
+ @instance ||= self.new
28
28
  end
29
29
 
30
30
  # Initializes a new settings object.
31
31
  def initialize
32
- self.setup_format_number()
33
- self.setup_boolean_names()
34
- self.setup_date_formats()
35
- self.setup_date_names()
32
+ self.setup_format_number
33
+ self.setup_boolean_names
34
+ self.setup_date_formats
35
+ self.setup_date_names
36
36
  end
37
37
 
38
38
  # Setups formatters for a number.
@@ -14,10 +14,10 @@ module Cowtech
14
14
  MAJOR = 2
15
15
 
16
16
  # The minor version.
17
- MINOR = 5
17
+ MINOR = 6
18
18
 
19
19
  # The patch version.
20
- PATCH = 1
20
+ PATCH = 0
21
21
 
22
22
  # The current version of cowtech-extensions.
23
23
  STRING = [MAJOR, MINOR, PATCH].compact.join(".")
@@ -287,6 +287,15 @@ describe Cowtech::Extensions::TimeZone do
287
287
  end
288
288
  end
289
289
 
290
+ describe "#dst_name" do
291
+ it "should correctly get zone name with DST" do
292
+ reference_zone.dst_name.should == "Mountain Time (US & Canada) (Daylight Saving Time)"
293
+ reference_zone.dst_name("DST").should == "Mountain Time (US & Canada) DST"
294
+ reference_zone.dst_name(nil, 1000).should be_nil
295
+ zone_without_dst.to_s_with_dst.should be_nil
296
+ end
297
+ end
298
+
290
299
  describe "#dst_correction" do
291
300
  it "should correctly detect offset usage" do
292
301
  reference_zone.dst_correction.should == 3600
@@ -306,7 +315,7 @@ describe Cowtech::Extensions::TimeZone do
306
315
  end
307
316
 
308
317
  describe "#to_s_with_dst" do
309
- it "should correctly format zone name" do
318
+ it "should correctly format zone with DST" do
310
319
  reference_zone.to_s_with_dst.should == "(GMT-06:00) Mountain Time (US & Canada) (Daylight Saving Time)"
311
320
  reference_zone.to_s_with_dst("DST").should == "(GMT-06:00) Mountain Time (US & Canada) DST"
312
321
  reference_zone.to_s_with_dst(nil, 1000).should be_nil
@@ -315,14 +324,14 @@ describe Cowtech::Extensions::TimeZone do
315
324
  end
316
325
 
317
326
  describe "#to_s_parameterized" do
318
- it "should correctly parameterize zone name" do
327
+ it "should correctly format (parameterized) zone" do
319
328
  reference_zone.to_s_parameterized.should == ::ActiveSupport::TimeZone.parameterize_zone(reference_zone)
320
329
  reference_zone.to_s_parameterized(false).should == ::ActiveSupport::TimeZone.parameterize_zone(reference_zone, false)
321
330
  end
322
331
  end
323
332
 
324
333
  describe "#to_s_with_dst_parameterized" do
325
- it "should correctly parameterize zone name" do
334
+ it "should correctly format (parameterized) zone with DST" do
326
335
  reference_zone.to_s_with_dst_parameterized.should == "-0600@mountain-time-us-canada-daylight-saving-time"
327
336
  reference_zone.to_s_with_dst_parameterized("DST").should == "-0600@mountain-time-us-canada-dst"
328
337
  reference_zone.to_s_with_dst_parameterized(nil, false, 1000).should be_nil
metadata CHANGED
@@ -1,176 +1,167 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: cowtech-extensions
3
- version: !ruby/object:Gem::Version
4
- hash: 25
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.6.0
5
5
  prerelease:
6
- segments:
7
- - 2
8
- - 5
9
- - 1
10
- version: 2.5.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Shogun
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-07-20 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-07-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: json
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
18
+ requirements:
26
19
  - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 11
29
- segments:
30
- - 1
31
- - 7
32
- - 0
20
+ - !ruby/object:Gem::Version
33
21
  version: 1.7.0
34
22
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: actionpack
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 1.7.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: actionpack
32
+ requirement: !ruby/object:Gem::Requirement
40
33
  none: false
41
- requirements:
34
+ requirements:
42
35
  - - ~>
43
- - !ruby/object:Gem::Version
44
- hash: 7
45
- segments:
46
- - 3
47
- - 0
48
- version: "3.0"
36
+ - !ruby/object:Gem::Version
37
+ version: '3.0'
49
38
  type: :runtime
50
- version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
52
- name: tzinfo
53
39
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
55
41
  none: false
56
- requirements:
42
+ requirements:
57
43
  - - ~>
58
- - !ruby/object:Gem::Version
59
- hash: 19
60
- segments:
61
- - 0
62
- - 3
63
- - 0
44
+ - !ruby/object:Gem::Version
45
+ version: '3.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: tzinfo
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
64
53
  version: 0.3.0
65
54
  type: :runtime
66
- version_requirements: *id003
67
- - !ruby/object:Gem::Dependency
68
- name: rspec
69
55
  prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
71
57
  none: false
72
- requirements:
58
+ requirements:
73
59
  - - ~>
74
- - !ruby/object:Gem::Version
75
- hash: 35
76
- segments:
77
- - 2
78
- - 11
79
- - 0
60
+ - !ruby/object:Gem::Version
61
+ version: 0.3.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
80
69
  version: 2.11.0
81
70
  type: :development
82
- version_requirements: *id004
83
- - !ruby/object:Gem::Dependency
84
- name: simplecov
85
71
  prerelease: false
86
- requirement: &id005 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
87
73
  none: false
88
- requirements:
74
+ requirements:
89
75
  - - ~>
90
- - !ruby/object:Gem::Version
91
- hash: 7
92
- segments:
93
- - 0
94
- - 6
95
- - 0
76
+ - !ruby/object:Gem::Version
77
+ version: 2.11.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: simplecov
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
96
85
  version: 0.6.0
97
86
  type: :development
98
- version_requirements: *id005
99
- - !ruby/object:Gem::Dependency
100
- name: pry
101
87
  prerelease: false
102
- requirement: &id006 !ruby/object:Gem::Requirement
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 0.6.0
94
+ - !ruby/object:Gem::Dependency
95
+ name: pry
96
+ requirement: !ruby/object:Gem::Requirement
103
97
  none: false
104
- requirements:
98
+ requirements:
105
99
  - - ~>
106
- - !ruby/object:Gem::Version
107
- hash: 35
108
- segments:
109
- - 0
110
- - 9
111
- - 9
112
- - 0
100
+ - !ruby/object:Gem::Version
113
101
  version: 0.9.9.0
114
102
  type: :development
115
- version_requirements: *id006
116
- - !ruby/object:Gem::Dependency
117
- name: yard
118
103
  prerelease: false
119
- requirement: &id007 !ruby/object:Gem::Requirement
104
+ version_requirements: !ruby/object:Gem::Requirement
120
105
  none: false
121
- requirements:
106
+ requirements:
122
107
  - - ~>
123
- - !ruby/object:Gem::Version
124
- hash: 63
125
- segments:
126
- - 0
127
- - 8
128
- - 0
108
+ - !ruby/object:Gem::Version
109
+ version: 0.9.9.0
110
+ - !ruby/object:Gem::Dependency
111
+ name: yard
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
129
117
  version: 0.8.0
130
118
  type: :development
131
- version_requirements: *id007
132
- - !ruby/object:Gem::Dependency
133
- name: redcarpet
134
119
  prerelease: false
135
- requirement: &id008 !ruby/object:Gem::Requirement
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 0.8.0
126
+ - !ruby/object:Gem::Dependency
127
+ name: redcarpet
128
+ requirement: !ruby/object:Gem::Requirement
136
129
  none: false
137
- requirements:
130
+ requirements:
138
131
  - - ~>
139
- - !ruby/object:Gem::Version
140
- hash: 11
141
- segments:
142
- - 2
143
- - 1
144
- - 0
132
+ - !ruby/object:Gem::Version
145
133
  version: 2.1.0
146
134
  type: :development
147
- version_requirements: *id008
148
- - !ruby/object:Gem::Dependency
149
- name: github-markup
150
135
  prerelease: false
151
- requirement: &id009 !ruby/object:Gem::Requirement
136
+ version_requirements: !ruby/object:Gem::Requirement
152
137
  none: false
153
- requirements:
138
+ requirements:
154
139
  - - ~>
155
- - !ruby/object:Gem::Version
156
- hash: 3
157
- segments:
158
- - 0
159
- - 7
160
- - 0
140
+ - !ruby/object:Gem::Version
141
+ version: 2.1.0
142
+ - !ruby/object:Gem::Dependency
143
+ name: github-markup
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
161
149
  version: 0.7.0
162
150
  type: :development
163
- version_requirements: *id009
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: 0.7.0
164
158
  description: Several Ruby object enhancements.
165
- email:
159
+ email:
166
160
  - shogun_panda@me.com
167
161
  executables: []
168
-
169
162
  extensions: []
170
-
171
163
  extra_rdoc_files: []
172
-
173
- files:
164
+ files:
174
165
  - .gitignore
175
166
  - .yardopts
176
167
  - Gemfile
@@ -233,38 +224,29 @@ files:
233
224
  - spec/spec_helper.rb
234
225
  homepage: http://github.com/ShogunPanda/cowtech-extensions
235
226
  licenses: []
236
-
237
227
  post_install_message:
238
228
  rdoc_options: []
239
-
240
- require_paths:
229
+ require_paths:
241
230
  - lib
242
- required_ruby_version: !ruby/object:Gem::Requirement
231
+ required_ruby_version: !ruby/object:Gem::Requirement
243
232
  none: false
244
- requirements:
245
- - - ">="
246
- - !ruby/object:Gem::Version
247
- hash: 3
248
- segments:
249
- - 0
250
- version: "0"
251
- required_rubygems_version: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ! '>='
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
237
+ required_rubygems_version: !ruby/object:Gem::Requirement
252
238
  none: false
253
- requirements:
254
- - - ">="
255
- - !ruby/object:Gem::Version
256
- hash: 3
257
- segments:
258
- - 0
259
- version: "0"
239
+ requirements:
240
+ - - ! '>='
241
+ - !ruby/object:Gem::Version
242
+ version: '0'
260
243
  requirements: []
261
-
262
244
  rubyforge_project: cowtech-extensions
263
245
  rubygems_version: 1.8.24
264
246
  signing_key:
265
247
  specification_version: 3
266
248
  summary: Several Ruby object enhancements.
267
- test_files:
249
+ test_files:
268
250
  - spec/coverage_helper.rb
269
251
  - spec/cowtech-extensions/boolean_spec.rb
270
252
  - spec/cowtech-extensions/datetime_spec.rb