suggest_rb 0.1.0 → 0.2.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
- SHA1:
3
- metadata.gz: b4767a25d85dccc93708b86da3fc1abaf21163f1
4
- data.tar.gz: 9dac49839363b1aa5cea4c1905797d41a7d9ecf1
2
+ SHA256:
3
+ metadata.gz: e61c1dd1cb882f09e1c11a1f7adfe9d123aa770a28e2578a2785025bc6ee1cbc
4
+ data.tar.gz: 5f3e5ed7bbaa495ba9844412c39fb47d6b686d8dec109a0aeedb4713c0f64f9f
5
5
  SHA512:
6
- metadata.gz: 01fe386299c1c54e02833812316aa96097243eeef9460474bdbd28b8d4e1535d4db8ae961db7be8baa98a31ba649b6ddd04ebaf2e85e6dfbc04eae758ad1984f
7
- data.tar.gz: 143bd64a2fee717bfdf443fa1f788014141112aef692ca7e9c5bf7befe64ccce04bab339c22cbdb19cd6f7a6e1c980bc0134f1aaa3191ff699d7d74ce982eefa
6
+ metadata.gz: 1037bab415285b2009496fb5b37e2c8b56593e5a62e5142b262fefa86978c94fedaef70b4f48ebc4fb9707a4dde5c5711843bd110a866d1c5a5e8ff523362568
7
+ data.tar.gz: 544907353e5c561b26edc69b20eecca87bc4070af9284cde736f37d3fa193068748b4a260dfbd0191c538cf4783c7be84134c2a6f01f8a3a3e80368ad965b633
@@ -1,3 +1,3 @@
1
1
  module Suggest
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/suggest.rb CHANGED
@@ -2,14 +2,34 @@ require "suggest/version"
2
2
  require "set"
3
3
 
4
4
  module Suggest
5
- SUGGEST_MODS = Set.new([Array, Enumerable, String, Hash, Regexp, Integer])
6
- UNSAFE = Set.new([Array.instance_method(:cycle)])
5
+ SUGGEST_MODS = Set.new([
6
+ Array,
7
+ Enumerable,
8
+ String,
9
+ Hash,
10
+ Regexp,
11
+ Integer,
12
+ Set
13
+ ])
14
+
15
+ UNSAFE_WITH_BLOCK = Set.new([
16
+ [Array, :cycle],
17
+ [Enumerable, :cycle]
18
+ ])
19
+
20
+ INCONSISTENT = Set.new([
21
+ [Array, :sample],
22
+ [Array, :shuffle],
23
+ [Array, :shuffle!]
24
+ ])
7
25
 
8
26
  module Mixin
9
27
  def what_returns?(expected, args: [], allow_mutation: false)
10
28
  block = Proc.new if block_given?
11
29
 
12
- applicable_methods = self.methods.map(&method(:method)).select { |m| SUGGEST_MODS.include?(m.owner) }
30
+ applicable_methods = self.methods.map(&method(:method)).select do |m|
31
+ SUGGEST_MODS.include?(m.owner) && !INCONSISTENT.include?([m.owner, m.name])
32
+ end
13
33
 
14
34
  applicable_methods.select do |m|
15
35
  arity = m.arity
@@ -17,7 +37,7 @@ module Suggest
17
37
 
18
38
  post = clone
19
39
  if block
20
- next if UNSAFE.include?(m.unbind)
40
+ next if UNSAFE_WITH_BLOCK.include?([m.owner, m.name])
21
41
  result = post.public_send(m.name, *args, &block) rescue next
22
42
  else
23
43
  result = post.public_send(m.name, *args) rescue next
@@ -33,7 +53,9 @@ module Suggest
33
53
  args = opts[:args] || []
34
54
  block = Proc.new if block_given?
35
55
 
36
- applicable_methods = self.methods.map(&method(:method)).select { |m| SUGGEST_MODS.include?(m.owner) }
56
+ applicable_methods = self.methods.map(&method(:method)).select do |m|
57
+ SUGGEST_MODS.include?(m.owner) && !INCONSISTENT.include?([m.owner, m.name])
58
+ end
37
59
 
38
60
  applicable_methods.select do |m|
39
61
  arity = m.arity
@@ -41,7 +63,7 @@ module Suggest
41
63
 
42
64
  post = clone
43
65
  if block
44
- next if UNSAFE.include?(m.unbind)
66
+ next if UNSAFE_WITH_BLOCK.include?([m.owner, m.name])
45
67
  result = post.public_send(m.name, *args, &block) rescue next
46
68
  else
47
69
  result = post.public_send(m.name, *args) rescue next
data/suggest.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.17"
24
+ spec.add_development_dependency "bundler"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
26
  spec.add_development_dependency "minitest", "~> 5.0"
27
27
  spec.add_development_dependency "minitest-tagz"
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: suggest_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Bodah
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-14 00:00:00.000000000 Z
11
+ date: 2019-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.17'
19
+ version: '0'
20
20
  type: :development
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: '1.17'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  version: '0'
117
117
  requirements: []
118
118
  rubyforge_project:
119
- rubygems_version: 2.5.2.3
119
+ rubygems_version: 2.7.6
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: tells you which method does the thing you want to do