lazier 2.6.7 → 2.7.0
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.
- data/doc/Lazier.html +1 -1
- data/doc/Lazier/Boolean.html +2 -2
- data/doc/Lazier/DateTime.html +1 -1
- data/doc/Lazier/DateTime/ClassMethods.html +3 -3
- data/doc/Lazier/Exceptions.html +1 -1
- data/doc/Lazier/Exceptions/Dump.html +1 -1
- data/doc/Lazier/Exceptions/MissingTranslation.html +1 -1
- data/doc/Lazier/Hash.html +9 -17
- data/doc/Lazier/I18n.html +5 -75
- data/doc/Lazier/Localizer.html +2 -2
- data/doc/Lazier/Math.html +1 -1
- data/doc/Lazier/Math/ClassMethods.html +1 -1
- data/doc/Lazier/Object.html +76 -86
- data/doc/Lazier/Pathname.html +1 -1
- data/doc/Lazier/Settings.html +2 -2
- data/doc/Lazier/String.html +1 -1
- data/doc/Lazier/TimeZone.html +66 -89
- data/doc/Lazier/TimeZone/ClassMethods.html +1 -1
- data/doc/Lazier/Version.html +3 -3
- data/doc/_index.html +1 -1
- data/doc/file.README.html +1 -1
- data/doc/index.html +1 -1
- data/doc/method_list.html +81 -89
- data/doc/top-level-namespace.html +1 -1
- data/lib/lazier/boolean.rb +1 -1
- data/lib/lazier/datetime.rb +10 -14
- data/lib/lazier/hash.rb +3 -7
- data/lib/lazier/i18n.rb +1 -1
- data/lib/lazier/object.rb +5 -10
- data/lib/lazier/version.rb +2 -2
- data/spec/lazier/datetime_spec.rb +2 -2
- metadata +3 -3
@@ -103,7 +103,7 @@
|
|
103
103
|
</div>
|
104
104
|
|
105
105
|
<div id="footer">
|
106
|
-
Generated on
|
106
|
+
Generated on Thu Feb 28 08:44:08 2013 by
|
107
107
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
108
108
|
0.8.5.2 (ruby-1.9.3).
|
109
109
|
</div>
|
data/lib/lazier/boolean.rb
CHANGED
data/lib/lazier/datetime.rb
CHANGED
@@ -124,7 +124,7 @@ module Lazier
|
|
124
124
|
def easter(year = nil)
|
125
125
|
year = ::Date.today.year if !year.is_integer?
|
126
126
|
|
127
|
-
# Compute using
|
127
|
+
# Compute using Anonymous Gregorian Algorithm: http://en.wikipedia.org/wiki/Computus#Anonymous_Gregorian_algorithm
|
128
128
|
data = easter_start(year)
|
129
129
|
data = easter_part_1(data)
|
130
130
|
data = easter_part_2(year, data)
|
@@ -156,7 +156,7 @@ module Lazier
|
|
156
156
|
|
157
157
|
begin
|
158
158
|
::DateTime.strptime(value.ensure_string, format)
|
159
|
-
rescue =>
|
159
|
+
rescue => _
|
160
160
|
rv = false
|
161
161
|
end
|
162
162
|
|
@@ -176,7 +176,7 @@ module Lazier
|
|
176
176
|
# @param data [Fixnum] Partial variables from #easter_start.
|
177
177
|
# @return [Array] Partial variables for #easter_part_2.
|
178
178
|
def easter_part_1(data)
|
179
|
-
|
179
|
+
_, b, c = data
|
180
180
|
[
|
181
181
|
b - (b / 4.0).floor - ((b - ((b + 8) / 25.0).floor + 1) / 3.0).floor,
|
182
182
|
b % 4,
|
@@ -420,9 +420,6 @@ module Lazier
|
|
420
420
|
# @return [Fixnum|Rational] The offset of this timezone.
|
421
421
|
def current_offset(rational = false, date = nil)
|
422
422
|
date ||= ::DateTime.now
|
423
|
-
|
424
|
-
dst_period = self.dst_period
|
425
|
-
|
426
423
|
rv = (self.period_for_utc(date.utc).dst? ? self.dst_offset : self.offset)
|
427
424
|
rational ? self.class.rationalize_offset(rv) : rv
|
428
425
|
end
|
@@ -456,10 +453,10 @@ module Lazier
|
|
456
453
|
def dst_period(year = nil)
|
457
454
|
year ||= ::Date.today.year
|
458
455
|
|
459
|
-
|
456
|
+
northern_summer = ::DateTime.civil(year, 7, 15).utc # This is a representation of a summer period in the Northern Hemisphere.
|
460
457
|
southern_summer = ::DateTime.civil(year, 1, 15).utc # This is a representation of a summer period in the Northern Hemisphere.
|
461
458
|
|
462
|
-
period = self.period_for_utc(
|
459
|
+
period = self.period_for_utc(northern_summer)
|
463
460
|
period = self.period_for_utc(southern_summer) if !period.dst?
|
464
461
|
period.dst? ? period : nil
|
465
462
|
end
|
@@ -539,23 +536,22 @@ module Lazier
|
|
539
536
|
end
|
540
537
|
end
|
541
538
|
|
542
|
-
# Returns a
|
539
|
+
# Returns a parameterized string representation for this zone.
|
543
540
|
#
|
544
541
|
# @param with_offset [Boolean] If to include offset into the representation.
|
545
542
|
# @param name [String] The name to use for this zone. Defaults to the zone name.
|
546
|
-
# @return [String] The
|
543
|
+
# @return [String] The parameterized string representation for this zone.
|
547
544
|
def to_str_parameterized(with_offset = true, name = nil)
|
548
545
|
::ActiveSupport::TimeZone.parameterize_zone(name || self.to_str, with_offset)
|
549
546
|
end
|
550
547
|
|
551
|
-
# Returns a
|
548
|
+
# Returns a parameterized string representation for this zone with Daylight Saving Time (DST) active.
|
552
549
|
#
|
553
550
|
# @param dst_label [String] Label for the DST indication. Defaults to `(DST)`.
|
554
|
-
# @param with_offset [Boolean] If to include offset into the representation.
|
555
551
|
# @param year [Fixnum] The year to which refer to. Defaults to the current year.
|
556
552
|
# @param name [String] The name to use for this zone. Defaults to the zone name.
|
557
|
-
# @return [String] The
|
558
|
-
def to_str_with_dst_parameterized(dst_label = nil,
|
553
|
+
# @return [String] The parameterized string representation for this zone with DST or `nil`, if the timezone doesn't use DST for that year.
|
554
|
+
def to_str_with_dst_parameterized(dst_label = nil, year = nil, name = nil)
|
559
555
|
rv = self.to_str_with_dst(dst_label, year, name)
|
560
556
|
rv ? ::ActiveSupport::TimeZone.parameterize_zone(rv) : nil
|
561
557
|
end
|
data/lib/lazier/hash.rb
CHANGED
@@ -16,17 +16,13 @@ module Lazier
|
|
16
16
|
# @param block [Proc] *Unused.*
|
17
17
|
# @return [Object] The value for the key.
|
18
18
|
def method_missing(method, *args, &block)
|
19
|
-
rv = nil
|
20
|
-
|
21
19
|
if self.has_key?(method.to_sym) then
|
22
|
-
|
20
|
+
self[method.to_sym]
|
23
21
|
elsif self.has_key?(method.to_s) then
|
24
|
-
|
22
|
+
self[method.to_s]
|
25
23
|
else
|
26
|
-
|
24
|
+
::Hash.method_missing(method, *args, &block)
|
27
25
|
end
|
28
|
-
|
29
|
-
rv
|
30
26
|
end
|
31
27
|
|
32
28
|
# This is called when the user access a member using dotted notation.
|
data/lib/lazier/i18n.rb
CHANGED
data/lib/lazier/object.rb
CHANGED
@@ -14,20 +14,15 @@ module Lazier
|
|
14
14
|
#
|
15
15
|
# @return [String] The normalized number.
|
16
16
|
def normalize_number
|
17
|
-
|
18
|
-
|
19
|
-
if self == true then
|
20
|
-
rv = "1"
|
17
|
+
if self.is_a?(TrueClass) then
|
18
|
+
"1"
|
21
19
|
elsif !self then
|
22
|
-
|
20
|
+
"0"
|
23
21
|
else
|
24
|
-
rv = self.ensure_string.strip
|
25
|
-
rv = rv.split(/[\.,]/)
|
22
|
+
rv = self.ensure_string.strip.split(/[\.,]/)
|
26
23
|
rv[-1] = "." + rv[-1] if rv.length > 1
|
27
|
-
rv
|
24
|
+
rv.join("")
|
28
25
|
end
|
29
|
-
|
30
|
-
rv
|
31
26
|
end
|
32
27
|
|
33
28
|
# Checks if the object is a valid number.
|
data/lib/lazier/version.rb
CHANGED
@@ -349,8 +349,8 @@ describe Lazier::TimeZone do
|
|
349
349
|
it "should correctly format (parameterized) zone with Daylight Saving Time" do
|
350
350
|
expect(reference_zone.to_str_with_dst_parameterized).to eq("-0600@america-denver-dst")
|
351
351
|
expect(reference_zone.to_str_with_dst_parameterized("Daylight Saving Time")).to eq("-0600@america-denver-daylight-saving-time")
|
352
|
-
expect(reference_zone.to_str_with_dst_parameterized(nil,
|
353
|
-
expect(reference_zone.to_str_with_dst_parameterized("Daylight Saving Time",
|
352
|
+
expect(reference_zone.to_str_with_dst_parameterized(nil, 1000)).to be_nil
|
353
|
+
expect(reference_zone.to_str_with_dst_parameterized("Daylight Saving Time", nil, "NAME SPACE")).to eq("-0600@name-space-daylight-saving-time")
|
354
354
|
expect(zone_without_dst.to_str_with_dst_parameterized).to be_nil
|
355
355
|
end
|
356
356
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lazier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
171
|
version: '0'
|
172
172
|
segments:
|
173
173
|
- 0
|
174
|
-
hash:
|
174
|
+
hash: 1543346769697772444
|
175
175
|
requirements: []
|
176
176
|
rubyforge_project: lazier
|
177
177
|
rubygems_version: 1.8.25
|