lazier 3.3.9 → 3.3.10
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -0
- data/doc/Lazier.html +119 -57
- data/doc/Lazier/Boolean.html +3 -3
- data/doc/Lazier/Configuration.html +3 -3
- data/doc/Lazier/DateTime.html +3 -3
- data/doc/Lazier/DateTime/ClassMethods.html +3 -3
- data/doc/Lazier/Exceptions.html +3 -3
- data/doc/Lazier/Exceptions/Debug.html +3 -3
- data/doc/Lazier/Exceptions/MissingTranslation.html +3 -3
- data/doc/Lazier/Hash.html +3 -3
- data/doc/Lazier/I18n.html +3 -3
- data/doc/Lazier/Localizer.html +3 -3
- data/doc/Lazier/Math.html +3 -3
- data/doc/Lazier/Math/ClassMethods.html +3 -3
- data/doc/Lazier/Object.html +4 -4
- data/doc/Lazier/Pathname.html +3 -3
- data/doc/Lazier/Settings.html +3 -3
- data/doc/Lazier/String.html +3 -3
- data/doc/Lazier/TimeZone.html +3 -3
- data/doc/Lazier/TimeZone/ClassMethods.html +3 -3
- data/doc/Lazier/Version.html +4 -4
- data/doc/_index.html +4 -4
- data/doc/css/style.css +1 -1
- data/doc/file.README.html +5 -4
- data/doc/frames.html +5 -7
- data/doc/index.html +5 -4
- data/doc/js/app.js +7 -2
- data/doc/method_list.html +58 -52
- data/doc/top-level-namespace.html +3 -3
- data/lazier.gemspec +1 -0
- data/lib/lazier.rb +10 -5
- data/lib/lazier/object.rb +1 -1
- data/lib/lazier/version.rb +1 -1
- data/spec/lazier/datetime_spec.rb +1 -1
- data/spec/lazier/hash_spec.rb +11 -0
- data/spec/lazier/object_spec.rb +16 -15
- metadata +5 -3
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Top Level Namespace
|
8
8
|
|
9
|
-
— Documentation by YARD 0.8.7
|
9
|
+
— Documentation by YARD 0.8.7.3
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -103,9 +103,9 @@
|
|
103
103
|
</div>
|
104
104
|
|
105
105
|
<div id="footer">
|
106
|
-
Generated on Mon
|
106
|
+
Generated on Mon Dec 2 15:35:19 2013 by
|
107
107
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
108
|
-
0.8.7 (ruby-2.0.0).
|
108
|
+
0.8.7.3 (ruby-2.0.0).
|
109
109
|
</div>
|
110
110
|
|
111
111
|
</body>
|
data/lazier.gemspec
CHANGED
data/lib/lazier.rb
CHANGED
@@ -41,12 +41,15 @@ module Lazier
|
|
41
41
|
# @option boolean Extensions for boolean values.
|
42
42
|
# @option string Extensions for strings.
|
43
43
|
# @option hash Extensions for hashs.
|
44
|
+
# @option hash_method_access Extensions for hash to allow method access. Not included by default.
|
44
45
|
# @option datetime Extensions date and time objects.
|
45
46
|
# @option math Extensions for Math module.
|
46
47
|
# @option pathname Extensions for path objects.
|
47
48
|
# @return [Settings] The settings for the extensions.
|
48
49
|
def self.load!(*what)
|
49
|
-
|
50
|
+
modules = what.present? ? what.flatten.uniq.compact.map(&:to_s) : ["object", "boolean", "string", "hash", "datetime", "math", "pathname"]
|
51
|
+
modules.each { |w| ::Lazier.send("load_#{w}") }
|
52
|
+
|
50
53
|
yield if block_given?
|
51
54
|
::Lazier::Settings.instance
|
52
55
|
end
|
@@ -76,10 +79,12 @@ module Lazier
|
|
76
79
|
|
77
80
|
# Loads Hash extensions.
|
78
81
|
def self.load_hash
|
79
|
-
::Hash.class_eval
|
80
|
-
|
81
|
-
|
82
|
-
|
82
|
+
::Hash.class_eval { include ::Lazier::Hash }
|
83
|
+
end
|
84
|
+
|
85
|
+
# Loads Hash method access extensions.
|
86
|
+
def self.load_hash_method_access
|
87
|
+
::Hash.class_eval { include Hashie::Extensions::MethodAccess }
|
83
88
|
end
|
84
89
|
|
85
90
|
# Loads DateTime extensions.
|
data/lib/lazier/object.rb
CHANGED
@@ -116,7 +116,7 @@ module Lazier
|
|
116
116
|
#
|
117
117
|
# @return [Boolean] The boolean representation of the object.
|
118
118
|
def to_boolean
|
119
|
-
is_a?(TrueClass) || self == 1.0 || self == 1 || ensure_string =~ ::Lazier::Object::BOOLEAN_TRUE_MATCHER || false
|
119
|
+
is_a?(TrueClass) || self == 1.0 || self == 1 || !!(ensure_string =~ ::Lazier::Object::BOOLEAN_TRUE_MATCHER) || false
|
120
120
|
end
|
121
121
|
|
122
122
|
# Converts the object to a integer.
|
data/lib/lazier/version.rb
CHANGED
@@ -51,7 +51,7 @@ describe Lazier::DateTime do
|
|
51
51
|
it "should return a range of years" do
|
52
52
|
expect(::DateTime.years).to eq((::Date.today.year - 10..::Date.today.year + 10).to_a)
|
53
53
|
expect(::DateTime.years(5)).to eq((::Date.today.year - 5..::Date.today.year + 5).to_a)
|
54
|
-
expect(::DateTime.years(5, true, nil, true).map
|
54
|
+
expect(::DateTime.years(5, true, nil, true).map {|d| d[:value]}).to eq((::Date.today.year - 5..::Date.today.year + 5).to_a)
|
55
55
|
expect(::DateTime.years(5, false)).to eq((::Date.today.year - 5..::Date.today.year).to_a)
|
56
56
|
expect(::DateTime.years(5, false, 1900)).to eq((1895..1900).to_a)
|
57
57
|
end
|
data/spec/lazier/hash_spec.rb
CHANGED
@@ -17,7 +17,18 @@ describe Lazier::Hash do
|
|
17
17
|
::Lazier.load!
|
18
18
|
end
|
19
19
|
|
20
|
+
|
21
|
+
describe "method access" do
|
22
|
+
it "it is not enabled by default" do
|
23
|
+
expect { reference.b }.to raise_error(NoMethodError)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
20
27
|
describe "allows access to keys using dotted notation" do
|
28
|
+
before(:each) do
|
29
|
+
::Lazier.load!(:hash_method_access)
|
30
|
+
end
|
31
|
+
|
21
32
|
it "should allow method reference for symbol key" do
|
22
33
|
reference.b.f = 4
|
23
34
|
|
data/spec/lazier/object_spec.rb
CHANGED
@@ -228,24 +228,25 @@ describe Lazier::Object do
|
|
228
228
|
|
229
229
|
describe "#to_boolean" do
|
230
230
|
it "should return true for a valid true boolean" do
|
231
|
-
expect(true.to_boolean).to
|
232
|
-
expect("
|
233
|
-
expect("
|
234
|
-
expect("
|
235
|
-
expect(1.to_boolean).to
|
236
|
-
expect(1.
|
231
|
+
expect(true.to_boolean.class).to eq(TrueClass)
|
232
|
+
expect("true".to_boolean.class).to eq(TrueClass)
|
233
|
+
expect("y".to_boolean.class).to eq(TrueClass)
|
234
|
+
expect("yes".to_boolean.class).to eq(TrueClass)
|
235
|
+
expect("1".to_boolean.class).to eq(TrueClass)
|
236
|
+
expect(1.to_boolean.class).to eq(TrueClass)
|
237
|
+
expect(1.0.to_boolean.class).to eq(TrueClass)
|
237
238
|
end
|
238
239
|
|
239
240
|
it "should return false for all other values" do
|
240
|
-
expect(false.to_boolean).to
|
241
|
-
expect(nil.to_boolean).to
|
242
|
-
expect("n".to_boolean).to
|
243
|
-
expect("no".to_boolean).to
|
244
|
-
expect("2".to_boolean).to
|
245
|
-
expect(2.0.to_boolean).to
|
246
|
-
expect("false".to_boolean).to
|
247
|
-
expect("abc".to_boolean).to
|
248
|
-
expect(0.to_boolean).to
|
241
|
+
expect(false.to_boolean.class).to eq(FalseClass)
|
242
|
+
expect(nil.to_boolean.class).to eq(FalseClass)
|
243
|
+
expect("n".to_boolean.class).to eq(FalseClass)
|
244
|
+
expect("no".to_boolean.class).to eq(FalseClass)
|
245
|
+
expect("2".to_boolean.class).to eq(FalseClass)
|
246
|
+
expect(2.0.to_boolean.class).to eq(FalseClass)
|
247
|
+
expect("false".to_boolean.class).to eq(FalseClass)
|
248
|
+
expect("abc".to_boolean.class).to eq(FalseClass)
|
249
|
+
expect(0.to_boolean.class).to eq(FalseClass)
|
249
250
|
end
|
250
251
|
end
|
251
252
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lazier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shogun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- .travis-gemfile
|
92
92
|
- .travis.yml
|
93
93
|
- .yardopts
|
94
|
+
- CHANGELOG.md
|
94
95
|
- Gemfile
|
95
96
|
- README.md
|
96
97
|
- Rakefile
|
@@ -160,7 +161,8 @@ files:
|
|
160
161
|
- spec/lazier_spec.rb
|
161
162
|
- spec/spec_helper.rb
|
162
163
|
homepage: http://sw.cow.tc/lazier
|
163
|
-
licenses:
|
164
|
+
licenses:
|
165
|
+
- MIT
|
164
166
|
metadata: {}
|
165
167
|
post_install_message:
|
166
168
|
rdoc_options: []
|