veils 0.0.1 → 0.1.0

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
2
  SHA256:
3
- metadata.gz: 28e3a15982feac585072903852cf0d915c26142081d0d1866e73811db8880ac2
4
- data.tar.gz: 552a7dcd62680dee1ac43023113b584bbaa4780e1d42c7a0db856568528f55c2
3
+ metadata.gz: 4e17ed55e57e44a067b74f7e777e807966a4ee95bb959cd02955e6b2de37ee13
4
+ data.tar.gz: bcc1eede5094552059590051a2157719e89f6126fc62623b5172337540504396
5
5
  SHA512:
6
- metadata.gz: 24b7089456ae3e48d368455604fe1afeadfbd77f571c5c84b8f009262bfb4e8620d06dc47d9d91266f55702ec35be4de8971e4da84d96e4a620164fbba16f315
7
- data.tar.gz: cfa0ac89ba68aa920137fabd71128d6a73acd2d0488c0116c7a392d4a787c499337ebdee4faff39ccd936cf2758c9f12d12f3f1114718d882e5d78ac15ac7843
6
+ metadata.gz: 653490f8e6aa789b305334cab1c62c06047768b6c6617cde88f3c9516c29571315716470a9aa6db38145c60da7d85c6e0ebee3352311dc6dd9c8bb8d8a4ea094
7
+ data.tar.gz: f7951bab961d687b1fe768ae1f9c45c0a333e284fccf9627f32fe7990ebc68078ad83270e4a2daf175a0c631b02d416c4fde8b4dc155ce4822cbc1df26227845
data/README.md CHANGED
@@ -5,9 +5,9 @@
5
5
  [![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)
6
6
 
7
7
  [![Build Status](https://travis-ci.org/yegor256/veils.svg)](https://travis-ci.org/yegor256/veils)
8
- [![Build status](https://ci.appveyor.com/api/projects/status/e61qudqccs0fu8xt?svg=true)](https://ci.appveyor.com/project/yegor256/veils)
8
+ [![Build status](https://ci.appveyor.com/api/projects/status/pexc3cg49m75c0r6?svg=true)](https://ci.appveyor.com/project/yegor256/veils)
9
9
  [![Gem Version](https://badge.fury.io/rb/veils.svg)](http://badge.fury.io/rb/veils)
10
- [![Maintainability](https://api.codeclimate.com/v1/badges/224939b58aa606fdd56c/maintainability)](https://codeclimate.com/github/yegor256/veils/maintainability)
10
+ [![Maintainability](https://api.codeclimate.com/v1/badges/51b007d0eb24ceeeca94/maintainability)](https://codeclimate.com/github/yegor256/veils/maintainability)
11
11
  [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/yegor256/veils/master/frames)
12
12
 
13
13
  [![Hits-of-Code](https://hitsofcode.com/github/yegor256/veils)](https://hitsofcode.com/view/github/yegor256/veils)
@@ -48,16 +48,23 @@ class Veil
48
48
  end
49
49
 
50
50
  def method_missing(*args)
51
+ method = args[0]
51
52
  if @pierced
52
- through(args)
53
- else
54
- method = args[0]
55
- if @methods.key?(method)
56
- @methods[method]
53
+ unless @origin.respond_to?(method)
54
+ raise "Method #{method} is absent in #{@origin}"
55
+ end
56
+ if block_given?
57
+ @origin.__send__(*args) do |*a|
58
+ yield(*a)
59
+ end
57
60
  else
58
- @pierced = true
59
- through(args)
61
+ @origin.__send__(*args)
60
62
  end
63
+ elsif @methods.key?(method)
64
+ @methods[method]
65
+ else
66
+ @pierced = true
67
+ method_missing(*args)
61
68
  end
62
69
  end
63
70
 
@@ -68,16 +75,4 @@ class Veil
68
75
  def respond_to_missing?(_method, _include_private = false)
69
76
  true
70
77
  end
71
-
72
- private
73
-
74
- def through(args)
75
- method = args[0]
76
- unless @origin.respond_to?(method)
77
- raise "Method #{method} is absent in #{@origin}"
78
- end
79
- @origin.__send__(*args) do |*a|
80
- yield(*a) if block_given?
81
- end
82
- end
83
78
  end
@@ -45,10 +45,21 @@ class VeilTest < Minitest::Test
45
45
  assert_equal(5, foo.read(5))
46
46
  end
47
47
 
48
- def test_behaves_like_array
48
+ def test_behaves_like_array_with_json
49
49
  origin = [1, 2, 3]
50
50
  foo = Veil.new(origin)
51
51
  assert(foo.respond_to?(:to_json))
52
52
  assert_equal(JSON.pretty_generate(origin), JSON.pretty_generate(foo))
53
53
  end
54
+
55
+ def test_iterates_array
56
+ origin = [1, 2, 3]
57
+ foo = Veil.new(origin, count: 1)
58
+ assert_equal(1, foo.count)
59
+ assert(!foo.empty?)
60
+ assert_equal(3, foo.count)
61
+ observed = 0
62
+ foo.each { |_| observed += 1 }
63
+ assert_equal(3, observed)
64
+ end
54
65
  end
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
31
31
  s.rubygems_version = '2.3.3'
32
32
  s.required_ruby_version = '>=2.3'
33
33
  s.name = 'veils'
34
- s.version = '0.0.1'
34
+ s.version = '0.1.0'
35
35
  s.license = 'MIT'
36
36
  s.summary = 'Ruby Veil Objects'
37
37
  s.description = 'Decorate your existing Ruby object with veils
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: veils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-08 00:00:00.000000000 Z
11
+ date: 2020-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest