lazy_object 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ebb871ef07298953b636aa9828c59f34798fce67
4
- data.tar.gz: 2e8e8311a5aa1d96849518eb6b8a12cea99615cb
2
+ SHA256:
3
+ metadata.gz: 9fa7eb3857a682996ac6ffe73f5e8cd71f5a4d4779226328931bd9db0c36da25
4
+ data.tar.gz: 97954d2a1890e404532550032e3eb6ae2b11b9e4c9aad48a05948b11e409c1a4
5
5
  SHA512:
6
- metadata.gz: fe6da338b447ba9457679df275a22a8ec07a4f8bd86849054c0e9f8c754ac4a7cf011b971fac1b88d5d316fd3a9c9c9b04373931c7ac1e60ffa0729ccb527e60
7
- data.tar.gz: 0db17e239189b4c24fdf06614c44f578c54ccf8eef0c8a29950b60aba4b94543edb55c06fdf5e352847de299e9dcd8297e2a33c2d97caba00d97d0a8337360be
6
+ metadata.gz: 434a3bdd6b382e2a1ec48cd365dda8c97fc4ea2fa214348e4d2815e5e93e5715c5a9656384e63f899c21c65b343ffde320016b9cb07d564ed61f5d684ebcc446
7
+ data.tar.gz: b7c2f19501981b4eea60409548856241d27fce4292dd9ec31448a144eb5e8ce1110f4fbf1b8bf6b42156b181d189ad4f25d180dca7d2d84969082ccd18017a92
@@ -1 +1 @@
1
- ruby-2.1
1
+ 2.4
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.6"
21
+ spec.add_development_dependency "bundler", "~> 2.0"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency 'rspec'
24
24
  end
@@ -9,15 +9,26 @@
9
9
  # lazy = LazyObject.new { VeryExpensiveObject.new } # At this point the VeryExpensiveObject hasn't been initialized yet.
10
10
  # lazy.get_expensive_results(foo, bar) # Initializes VeryExpensiveObject and calls 'get_expensive_results' on it, passing in foo and bar
11
11
  class LazyObject < BasicObject
12
-
13
12
  def self.version
14
- '0.0.2'
13
+ '0.0.3'
15
14
  end
16
15
 
17
16
  def initialize(&callable)
18
17
  @__callable__ = callable
19
18
  end
20
19
 
20
+ def ==(item)
21
+ __target_object__ == item
22
+ end
23
+
24
+ def !=(item)
25
+ __target_object__ != item
26
+ end
27
+
28
+ def !
29
+ !__target_object__
30
+ end
31
+
21
32
  # Cached target object.
22
33
  def __target_object__
23
34
  @__target_object__ ||= @__callable__.call
@@ -26,4 +26,25 @@ RSpec.describe LazyObject do
26
26
  expect( lazy_object.method_with_yield(:baz) { |foo| "--#{foo}--" } ).to eq('--baz--')
27
27
  end
28
28
 
29
+ context "equality operators" do
30
+ it 'should return correct value when comparing' do
31
+ one = LazyObject.new { 1 }
32
+ expect(one).to eq(1)
33
+ end
34
+
35
+ specify "==" do
36
+ foo = LazyObject.new { :foo }
37
+ expect(foo == :foo).to eq(true)
38
+ end
39
+
40
+ specify "!=" do
41
+ foo = LazyObject.new { :foo }
42
+ expect(foo != :foo).to eq(false)
43
+ end
44
+
45
+ specify "!" do
46
+ foo = LazyObject.new { :foo }
47
+ expect(!foo).to eq(false)
48
+ end
49
+ end
29
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazy_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arthur Shagall
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-06 00:00:00.000000000 Z
12
+ date: 2019-06-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '1.6'
20
+ version: '2.0'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '1.6'
27
+ version: '2.0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  requirements: []
95
95
  rubyforge_project:
96
- rubygems_version: 2.4.3
96
+ rubygems_version: 2.7.9
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: Lazily initialized object wrapper.