defi 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -39
- data/lib/defi.rb +0 -4
- data/lib/defi/challenge.rb +0 -15
- data/lib/defi/value.rb +1 -18
- 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: ad4d58a63b7a9509a6e1fd7338e4357707f370102faae9d2afadd764c0a2eda2
|
4
|
+
data.tar.gz: f9ba83d33a13843117b7a2ecd90a118916fb428560ae458a2be4d49753cf4d24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13b9ee894ab62139d2351f0307c832a7a9b83687d67ae735db1ff1fab9b67a600d4a6f67b29ff87afde0b075744bf9d4bffb7a1963d984fa4107cb5b4e13280c
|
7
|
+
data.tar.gz: 1137cd5cc9c9eea4aa19ed7443fd321fc778ca1eb12e0061cea3db844b9a904f932ec6e6862e6f0c03b9876a90b57d2df5b22951d2d2aac83a68f1c06447250b
|
data/README.md
CHANGED
@@ -1,24 +1,12 @@
|
|
1
1
|
# Defi
|
2
2
|
|
3
3
|
[![Build Status](https://api.travis-ci.org/fixrb/defi.svg?branch=master)][travis]
|
4
|
-
[![Code Climate](https://codeclimate.com/github/fixrb/defi/badges/gpa.svg)][codeclimate]
|
5
4
|
[![Gem Version](https://badge.fury.io/rb/defi.svg)][gem]
|
6
5
|
[![Inline docs](https://inch-ci.org/github/fixrb/defi.svg?branch=master)][inchpages]
|
7
6
|
[![Documentation](https://img.shields.io/:yard-docs-38c800.svg)][rubydoc]
|
8
7
|
|
9
8
|
> Challenge library.
|
10
9
|
|
11
|
-
## Contact
|
12
|
-
|
13
|
-
* Home page: https://github.com/fixrb/defi
|
14
|
-
* Bugs/issues: https://github.com/fixrb/defi/issues
|
15
|
-
|
16
|
-
## Rubies
|
17
|
-
|
18
|
-
* [MRI](https://www.ruby-lang.org/)
|
19
|
-
* [Rubinius](https://rubinius.com/)
|
20
|
-
* [JRuby](https://www.jruby.org/)
|
21
|
-
|
22
10
|
## Installation
|
23
11
|
|
24
12
|
Add this line to your application's Gemfile:
|
@@ -57,47 +45,35 @@ Defi.send(:gsub!, 'world', 'Alice').to!(some_text).call # => "hello Alice"
|
|
57
45
|
some_text # => "hello world"
|
58
46
|
```
|
59
47
|
|
60
|
-
##
|
48
|
+
## Contact
|
61
49
|
|
62
|
-
|
63
|
-
|
64
|
-
Although these checksums do not prevent malicious users from tampering with a
|
65
|
-
built Gem they can be used for basic integrity verification purposes.
|
50
|
+
* Home page: https://github.com/fixrb/defi
|
51
|
+
* Bugs/issues: https://github.com/fixrb/defi/issues
|
66
52
|
|
67
|
-
|
68
|
-
example:
|
53
|
+
## Rubies
|
69
54
|
|
70
|
-
|
71
|
-
|
55
|
+
* [MRI](https://www.ruby-lang.org/)
|
56
|
+
* [Rubinius](https://rubinius.com/)
|
57
|
+
* [JRuby](https://www.jruby.org/)
|
72
58
|
|
73
59
|
## Versioning
|
74
60
|
|
75
61
|
__Defi__ follows [Semantic Versioning 2.0](https://semver.org/).
|
76
62
|
|
77
|
-
## Contributing
|
78
|
-
|
79
|
-
1. [Fork it](https://github.com/fixrb/defi/fork)
|
80
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
81
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
82
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
83
|
-
5. Create a new Pull Request
|
84
|
-
|
85
63
|
## License
|
86
64
|
|
87
|
-
|
88
|
-
|
89
|
-
[gem]: https://rubygems.org/gems/defi
|
90
|
-
[travis]: https://travis-ci.org/fixrb/defi
|
91
|
-
[codeclimate]: https://codeclimate.com/github/fixrb/defi
|
92
|
-
[inchpages]: https://inch-ci.org/github/fixrb/defi
|
93
|
-
[rubydoc]: https://rubydoc.info/gems/defi/frames
|
65
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
94
66
|
|
95
67
|
***
|
96
68
|
|
97
69
|
<p>
|
98
|
-
This project is sponsored by
|
99
|
-
|
70
|
+
This project is sponsored by:<br />
|
100
71
|
<a href="https://sashite.com/"><img
|
101
|
-
src="https://github.com/fixrb/defi/raw/
|
72
|
+
src="https://github.com/fixrb/defi/raw/master/img/sashite.png"
|
102
73
|
alt="Sashite" /></a>
|
103
74
|
</p>
|
75
|
+
|
76
|
+
[gem]: https://rubygems.org/gems/defi
|
77
|
+
[travis]: https://travis-ci.org/fixrb/defi
|
78
|
+
[inchpages]: https://inch-ci.org/github/fixrb/defi
|
79
|
+
[rubydoc]: https://rubydoc.info/gems/defi/frames
|
data/lib/defi.rb
CHANGED
@@ -2,13 +2,9 @@
|
|
2
2
|
|
3
3
|
# Namespace for the Defi library.
|
4
4
|
#
|
5
|
-
# @api public
|
6
|
-
#
|
7
5
|
module Defi
|
8
6
|
# Expectations are built with this method.
|
9
7
|
#
|
10
|
-
# @api public
|
11
|
-
#
|
12
8
|
# @example The challenge
|
13
9
|
# send(:foo) # => #<Defi::Challenge:0x007f96a40925f8 @method=:foo, @args=[]>
|
14
10
|
#
|
data/lib/defi/challenge.rb
CHANGED
@@ -4,14 +4,9 @@ require 'aw'
|
|
4
4
|
|
5
5
|
module Defi
|
6
6
|
# This class contains a challenge to apply against an object.
|
7
|
-
#
|
8
|
-
# @api private
|
9
|
-
#
|
10
7
|
class Challenge < ::BasicObject
|
11
8
|
# Initialize the challenge class.
|
12
9
|
#
|
13
|
-
# @api private
|
14
|
-
#
|
15
10
|
# @param method [#to_sym] The method to send to an object.
|
16
11
|
# @param args [Array] Any arguments of the method.
|
17
12
|
# @param opts [Hash] Any keyword arguments of the method.
|
@@ -23,8 +18,6 @@ module Defi
|
|
23
18
|
@block = block
|
24
19
|
end
|
25
20
|
|
26
|
-
# @api public
|
27
|
-
#
|
28
21
|
# @param object [#object_id] The object to challenge.
|
29
22
|
#
|
30
23
|
# @return [Defi::Value] The actual value, to raise or to return.
|
@@ -32,8 +25,6 @@ module Defi
|
|
32
25
|
Value.new { object.public_send(@method, *@args, **@opts, &@block) }
|
33
26
|
end
|
34
27
|
|
35
|
-
# @api public
|
36
|
-
#
|
37
28
|
# @param object [#object_id] The object to challenge in code isolation.
|
38
29
|
#
|
39
30
|
# @return [Defi::Value] The actual value, to raise or to return.
|
@@ -45,8 +36,6 @@ module Defi
|
|
45
36
|
|
46
37
|
# Properties of the challenge.
|
47
38
|
#
|
48
|
-
# @api public
|
49
|
-
#
|
50
39
|
# @return [Hash] The properties of the challenge.
|
51
40
|
def to_h
|
52
41
|
{
|
@@ -59,8 +48,6 @@ module Defi
|
|
59
48
|
|
60
49
|
# String of the challenge.
|
61
50
|
#
|
62
|
-
# @api public
|
63
|
-
#
|
64
51
|
# @return [String] The string representation of the challenge.
|
65
52
|
def to_s
|
66
53
|
string = ".#{@method}"
|
@@ -84,8 +71,6 @@ module Defi
|
|
84
71
|
|
85
72
|
# A string containing a human-readable representation of the challenge.
|
86
73
|
#
|
87
|
-
# @api public
|
88
|
-
#
|
89
74
|
# @return [String] The human-readable representation of the challenge.
|
90
75
|
def inspect
|
91
76
|
inspected_method = @method.inspect
|
data/lib/defi/value.rb
CHANGED
@@ -3,16 +3,12 @@
|
|
3
3
|
module Defi
|
4
4
|
# This class contains an object that returned or raised during the initialize.
|
5
5
|
#
|
6
|
-
# @api private
|
7
|
-
#
|
8
6
|
class Value
|
9
7
|
# @return [#object_id] The returned or the raised object.
|
10
8
|
attr_reader :object
|
11
9
|
|
12
10
|
# Initialize the value class.
|
13
11
|
#
|
14
|
-
# @api public
|
15
|
-
#
|
16
12
|
# @yieldreturn [#object_id] The challenged code.
|
17
13
|
# rubocop:disable Lint/RescueException
|
18
14
|
def initialize
|
@@ -33,8 +29,6 @@ module Defi
|
|
33
29
|
object
|
34
30
|
end
|
35
31
|
|
36
|
-
# @api public
|
37
|
-
#
|
38
32
|
# @return [Boolean] The value was raised (or returned)?
|
39
33
|
def raised?
|
40
34
|
@raised
|
@@ -42,8 +36,6 @@ module Defi
|
|
42
36
|
|
43
37
|
# Properties of the value.
|
44
38
|
#
|
45
|
-
# @api public
|
46
|
-
#
|
47
39
|
# @return [Hash] The properties of the value.
|
48
40
|
def to_h
|
49
41
|
{
|
@@ -54,23 +46,14 @@ module Defi
|
|
54
46
|
|
55
47
|
# String of the value.
|
56
48
|
#
|
57
|
-
# @api public
|
58
|
-
#
|
59
49
|
# @return [String] The string representation of the value.
|
60
50
|
def to_s
|
61
|
-
string =
|
62
|
-
'raise'
|
63
|
-
else
|
64
|
-
'return'
|
65
|
-
end
|
66
|
-
|
51
|
+
string = raised? ? 'raise' : 'return'
|
67
52
|
"#{string} #{object}"
|
68
53
|
end
|
69
54
|
|
70
55
|
# A string containing a human-readable representation of the value.
|
71
56
|
#
|
72
|
-
# @api public
|
73
|
-
#
|
74
57
|
# @return [String] The human-readable representation of the value.
|
75
58
|
def inspect
|
76
59
|
"Value(object: #{object}, raised: #{raised?})"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: defi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Kato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aw
|