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.
@@ -6,7 +6,7 @@
6
6
  <title>
7
7
  Top Level Namespace
8
8
 
9
- &mdash; Documentation by YARD 0.8.7
9
+ &mdash; 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 Sep 2 18:50:35 2013 by
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>
@@ -16,6 +16,7 @@ Gem::Specification.new do |gem|
16
16
 
17
17
  gem.authors = ["Shogun"]
18
18
  gem.email = ["shogun@cowtech.it"]
19
+ gem.license = "MIT"
19
20
 
20
21
  gem.files = `git ls-files`.split($\)
21
22
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -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
- (what.present? ? what : ["object", "boolean", "string", "hash", "datetime", "math", "pathname"]).each { |w| ::Lazier.send("load_#{w}") }
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 do
80
- include Hashie::Extensions::MethodAccess
81
- include ::Lazier::Hash
82
- end
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.
@@ -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.
@@ -16,7 +16,7 @@ module Lazier
16
16
  MINOR = 3
17
17
 
18
18
  # The patch version.
19
- PATCH = 9
19
+ PATCH = 10
20
20
 
21
21
  # The current version of lazier.
22
22
  STRING = [MAJOR, MINOR, PATCH].compact.join(".")
@@ -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(&:value)).to eq((::Date.today.year - 5..::Date.today.year + 5).to_a)
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
@@ -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
 
@@ -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 be_true
232
- expect("y".to_boolean).to be_true
233
- expect("yes".to_boolean).to be_true
234
- expect("1".to_boolean).to be_true
235
- expect(1.to_boolean).to be_true
236
- expect(1.0.to_boolean).to be_true
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 be_false
241
- expect(nil.to_boolean).to be_false
242
- expect("n".to_boolean).to be_false
243
- expect("no".to_boolean).to be_false
244
- expect("2".to_boolean).to be_false
245
- expect(2.0.to_boolean).to be_false
246
- expect("false".to_boolean).to be_false
247
- expect("abc".to_boolean).to be_false
248
- expect(0.to_boolean).to be_false
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.9
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-09-03 00:00:00.000000000 Z
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: []