defi 2.0.4 → 2.0.7

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: a2ca2a81be0ee760282fe5770efa1d904340038738e18fc2a40f096bd6b134f7
4
- data.tar.gz: b05c6ff311cfefed5bf83658b6724f9e50e18540eac9f60d34d63cd6c8b5bbed
3
+ metadata.gz: 45f62cb331ea97335ed07945d26c22a25f3ee7c826ded161d1432018e2e1005c
4
+ data.tar.gz: 1067904cd927baeb4c4f5bb8a52260ff813b66f1987e774baaf5916dd10922fa
5
5
  SHA512:
6
- metadata.gz: 80ab8c348a30fea63fd20999d66f5ab7ccf5b75625c2c586362e1cd5e382c0c50078b03466043f67ba148f09e124bec27b0bce1b1809356fcac9fd02f6061dc4
7
- data.tar.gz: 157e0feba92506feb2f005078e85179ea005a3040d1907c812972c7aec57d9c9d4f901ec2562de41346807dfe70d434063d444d311e1b83881ea7940e8375697
6
+ metadata.gz: 7fbd50efbc1db138975db94ab8c5b876b203443719d780032ac97a2e9129366b85dec847fc8cff0655b3046b02b423f8f2717c8c36b6c11fe45ba03772fc674e
7
+ data.tar.gz: a6ee3bb73c8dbbca088d2df08239f31c3451b0bee4075d4f6499d1d45625daab3314ce954fcde3b354d3a564bcbee3557201f74fa7fce65640776ada36e9a214
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2020 Cyril Kato
3
+ Copyright (c) 2015-2022 Cyril Kato
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,9 +1,10 @@
1
1
  # Defi
2
2
 
3
- [![Build Status](https://api.travis-ci.org/fixrb/defi.svg?branch=master)][travis]
4
- [![Gem Version](https://badge.fury.io/rb/defi.svg)][gem]
5
- [![Inline docs](https://inch-ci.org/github/fixrb/defi.svg?branch=master)][inchpages]
6
- [![Documentation](https://img.shields.io/:yard-docs-38c800.svg)][rubydoc]
3
+ [![Version](https://img.shields.io/github/v/tag/fixrb/defi?label=Version&logo=github)](https://github.com/fixrb/defi/releases)
4
+ [![Yard documentation](https://img.shields.io/badge/Yard-documentation-blue.svg?logo=github)](https://rubydoc.info/github/fixrb/defi/main)
5
+ [![CI](https://github.com/fixrb/defi/workflows/CI/badge.svg?branch=main)](https://github.com/fixrb/defi/actions?query=workflow%3Aci+branch%3Amain)
6
+ [![RuboCop](https://github.com/fixrb/defi/workflows/RuboCop/badge.svg?branch=main)](https://github.com/fixrb/defi/actions?query=workflow%3Arubocop+branch%3Amain)
7
+ [![License](https://img.shields.io/github/license/fixrb/defi?label=License&logo=github)](https://github.com/fixrb/defi/raw/main/LICENSE.md)
7
8
 
8
9
  > Challenge library.
9
10
 
@@ -12,16 +13,20 @@
12
13
  Add this line to your application's Gemfile:
13
14
 
14
15
  ```ruby
15
- gem 'defi'
16
+ gem "defi"
16
17
  ```
17
18
 
18
19
  And then execute:
19
20
 
20
- $ bundle
21
+ ```sh
22
+ bundle install
23
+ ```
21
24
 
22
25
  Or install it yourself as:
23
26
 
24
- $ gem install defi
27
+ ```sh
28
+ gem install defi
29
+ ```
25
30
 
26
31
  ## Usage
27
32
 
@@ -34,27 +39,20 @@ Defi.send(:*, 7).to(6).call # => 42
34
39
  Now, let's challenge "`foo`" with `boom` method:
35
40
 
36
41
  ```ruby
37
- Defi.send(:boom).to('foo').call # NoMethodError: undefined method `boom' for "foo":String
42
+ Defi.send(:boom).to("foo").call # NoMethodError: undefined method `boom' for "foo":String
38
43
  ```
39
44
 
40
45
  Let's challenge "`hello world`" with `gsub!` in isolation:
41
46
 
42
47
  ```ruby
43
- some_text = 'hello world'
44
- Defi.send(:gsub!, 'world', 'Alice').to!(some_text).call # => "hello Alice"
48
+ some_text = "hello world"
49
+ Defi.send(:gsub!, "world", "Alice").to!(some_text).call # => "hello Alice"
45
50
  some_text # => "hello world"
46
51
  ```
47
52
 
48
53
  ## Contact
49
54
 
50
- * Home page: https://github.com/fixrb/defi
51
- * Bugs/issues: https://github.com/fixrb/defi/issues
52
-
53
- ## Rubies
54
-
55
- * [MRI](https://www.ruby-lang.org/)
56
- * [Rubinius](https://rubinius.com/)
57
- * [JRuby](https://www.jruby.org/)
55
+ * Source code: https://github.com/fixrb/defi/issues
58
56
 
59
57
  ## Versioning
60
58
 
@@ -62,18 +60,13 @@ __Defi__ follows [Semantic Versioning 2.0](https://semver.org/).
62
60
 
63
61
  ## License
64
62
 
65
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
63
+ The [gem](https://rubygems.org/gems/defi) is available as open source under the terms of the [MIT License](https://github.com/fixrb/defi/raw/main/LICENSE.md).
66
64
 
67
65
  ***
68
66
 
69
67
  <p>
70
68
  This project is sponsored by:<br />
71
69
  <a href="https://sashite.com/"><img
72
- src="https://github.com/fixrb/defi/raw/master/img/sashite.png"
70
+ src="https://github.com/fixrb/defi/raw/main/img/sashite.png"
73
71
  alt="Sashite" /></a>
74
72
  </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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'aw'
3
+ require "aw"
4
4
 
5
5
  module Defi
6
6
  # This class contains a challenge to apply against an object.
@@ -18,25 +18,11 @@ module Defi
18
18
  @block = block
19
19
  end
20
20
 
21
- # @see https://twitter.com/kamipo/status/1213030647591137280
22
- if ::RUBY_VERSION > '2.7'
23
- # @param object [#object_id] The object to challenge.
24
- #
25
- # @return [Defi::Value] The actual value, to raise or to return.
26
- def to(object)
27
- Value.new { object.public_send(@method, *@args, **@opts, &@block) }
28
- end
29
- else
30
- # @param object [#object_id] The object to challenge.
31
- #
32
- # @return [Defi::Value] The actual value, to raise or to return.
33
- def to(object)
34
- if @opts.empty?
35
- Value.new { object.public_send(@method, *@args, &@block) }
36
- else
37
- Value.new { object.public_send(@method, *@args, **@opts, &@block) }
38
- end
39
- end
21
+ # @param object [#object_id] The object to challenge.
22
+ #
23
+ # @return [Defi::Value] The actual value, to raise or to return.
24
+ def to(object)
25
+ Value.new { object.public_send(@method, *@args, **@opts, &@block) }
40
26
  end
41
27
 
42
28
  # @param object [#object_id] The object to challenge in code isolation.
@@ -60,6 +46,10 @@ module Defi
60
46
  }
61
47
  end
62
48
 
49
+ # rubocop:disable Metrics/AbcSize
50
+ # rubocop:disable Metrics/CyclomaticComplexity
51
+ # rubocop:disable Metrics/MethodLength
52
+
63
53
  # String of the challenge.
64
54
  #
65
55
  # @return [String] The string representation of the challenge.
@@ -70,9 +60,9 @@ module Defi
70
60
 
71
61
  stringified_args = @args.inspect[1..-2]
72
62
  stringified_opts = @opts.inspect[1..-2]
73
- stringified_block = '<Proc>' unless @block.nil?
63
+ stringified_block = "<Proc>" unless @block.nil?
74
64
 
75
- string += '('
65
+ string += "("
76
66
 
77
67
  stringified_items = []
78
68
 
@@ -80,9 +70,13 @@ module Defi
80
70
  stringified_items << stringified_opts unless @opts.empty?
81
71
  stringified_items << stringified_block unless @block.nil?
82
72
 
83
- string + stringified_items.join(', ') + ')'
73
+ "#{string}#{stringified_items.join(", ")})"
84
74
  end
85
75
 
76
+ # rubocop:enable Metrics/AbcSize
77
+ # rubocop:enable Metrics/CyclomaticComplexity
78
+ # rubocop:enable Metrics/MethodLength
79
+
86
80
  # A string containing a human-readable representation of the challenge.
87
81
  #
88
82
  # @return [String] The human-readable representation of the challenge.
@@ -90,16 +84,16 @@ module Defi
90
84
  inspected_method = @method.inspect
91
85
  inspected_args = @args.inspect
92
86
  inspected_opts = @opts.inspect
93
- inspected_block = @block.nil? ? 'nil' : '<Proc>'
94
-
95
- 'Defi(' \
96
- "method: #{inspected_method}, " \
97
- "args: #{ inspected_args }, " \
98
- "opts: #{ inspected_opts }, " \
99
- "block: #{ inspected_block }" \
100
- ')'
87
+ inspected_block = @block.nil? ? "nil" : "<Proc>"
88
+
89
+ "Defi(" \
90
+ "method: #{inspected_method}, " \
91
+ "args: #{inspected_args}, " \
92
+ "opts: #{inspected_opts}, " \
93
+ "block: #{inspected_block}" \
94
+ ")"
101
95
  end
102
96
  end
103
97
  end
104
98
 
105
- require_relative 'value'
99
+ require_relative "value"
data/lib/defi/value.rb CHANGED
@@ -48,8 +48,7 @@ module Defi
48
48
  #
49
49
  # @return [String] The string representation of the value.
50
50
  def to_s
51
- string = raised? ? 'raise' : 'return'
52
- "#{string} #{object}"
51
+ "#{raise_or_return} #{object}"
53
52
  end
54
53
 
55
54
  # A string containing a human-readable representation of the value.
@@ -58,5 +57,12 @@ module Defi
58
57
  def inspect
59
58
  "Value(object: #{object}, raised: #{raised?})"
60
59
  end
60
+
61
+ private
62
+
63
+ # @return [String] A "raise" or "return" string.
64
+ def raise_or_return
65
+ raised? ? "raise" : "return"
66
+ end
61
67
  end
62
68
  end
data/lib/defi.rb CHANGED
@@ -5,18 +5,18 @@
5
5
  module Defi
6
6
  # Expectations are built with this method.
7
7
  #
8
- # @example The challenge
8
+ # @example A :foo challenge
9
9
  # send(:foo) # => #<Defi::Challenge:0x007f96a40925f8 @method=:foo, @args=[]>
10
10
  #
11
11
  # @param method [#to_sym] The method to send to an object.
12
12
  # @param args [Array] Any arguments of the method.
13
- # @param opts [Hash] Any keyword arguments of the method.
13
+ # @param kwargs [Hash] Any keyword arguments of the method.
14
14
  # @param block [Proc] Any block argument of the method.
15
15
  #
16
16
  # @return [Challenge] The challenge instance.
17
- def self.send(method, *args, **opts, &block)
18
- Challenge.new(method, *args, **opts, &block)
17
+ def self.send(method, *args, **kwargs, &block)
18
+ Challenge.new(method, *args, **kwargs, &block)
19
19
  end
20
20
  end
21
21
 
22
- require_relative File.join('defi', 'challenge')
22
+ require_relative File.join("defi", "challenge")
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
4
+ version: 2.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Kato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-09 00:00:00.000000000 Z
11
+ date: 2022-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aw
@@ -16,56 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.10
19
+ version: 0.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.10
26
+ version: 0.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '2.1'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '2.1'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '13.0'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '13.0'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rubocop
56
+ name: rubocop-md
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0.79'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '0.79'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rubocop-performance
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -80,34 +80,62 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-thread_safety
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: simplecov
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
- - - "~>"
115
+ - - ">="
88
116
  - !ruby/object:Gem::Version
89
- version: '0.17'
117
+ version: '0'
90
118
  type: :development
91
119
  prerelease: false
92
120
  version_requirements: !ruby/object:Gem::Requirement
93
121
  requirements:
94
- - - "~>"
122
+ - - ">="
95
123
  - !ruby/object:Gem::Version
96
- version: '0.17'
124
+ version: '0'
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: yard
99
127
  requirement: !ruby/object:Gem::Requirement
100
128
  requirements:
101
- - - "~>"
129
+ - - ">="
102
130
  - !ruby/object:Gem::Version
103
- version: '0.9'
131
+ version: '0'
104
132
  type: :development
105
133
  prerelease: false
106
134
  version_requirements: !ruby/object:Gem::Requirement
107
135
  requirements:
108
- - - "~>"
136
+ - - ">="
109
137
  - !ruby/object:Gem::Version
110
- version: '0.9'
138
+ version: '0'
111
139
  description: Challenge library.
112
140
  email: contact@cyril.email
113
141
  executables: []
@@ -122,7 +150,8 @@ files:
122
150
  homepage: https://github.com/fixrb/defi
123
151
  licenses:
124
152
  - MIT
125
- metadata: {}
153
+ metadata:
154
+ rubygems_mfa_required: 'true'
126
155
  post_install_message:
127
156
  rdoc_options: []
128
157
  require_paths:
@@ -131,14 +160,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
160
  requirements:
132
161
  - - ">="
133
162
  - !ruby/object:Gem::Version
134
- version: '0'
163
+ version: 2.7.0
135
164
  required_rubygems_version: !ruby/object:Gem::Requirement
136
165
  requirements:
137
166
  - - ">="
138
167
  - !ruby/object:Gem::Version
139
168
  version: '0'
140
169
  requirements: []
141
- rubygems_version: 3.1.2
170
+ rubygems_version: 3.1.6
142
171
  signing_key:
143
172
  specification_version: 4
144
173
  summary: Challenge library.