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 +4 -4
- data/README.md +2 -2
- data/lib/veil.rb +14 -19
- data/test/test_veil.rb +12 -1
- data/veils.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e17ed55e57e44a067b74f7e777e807966a4ee95bb959cd02955e6b2de37ee13
|
4
|
+
data.tar.gz: bcc1eede5094552059590051a2157719e89f6126fc62623b5172337540504396
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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/
|
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/
|
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)
|
data/lib/veil.rb
CHANGED
@@ -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
|
-
|
53
|
-
|
54
|
-
|
55
|
-
if
|
56
|
-
@
|
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
|
-
@
|
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
|
data/test/test_veil.rb
CHANGED
@@ -45,10 +45,21 @@ class VeilTest < Minitest::Test
|
|
45
45
|
assert_equal(5, foo.read(5))
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
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
|
data/veils.gemspec
CHANGED
@@ -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
|
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
|
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-
|
11
|
+
date: 2020-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|