invokable 0.7.2 → 1.0.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: ff6115c057fbcfffd52d6037a190e9a36b23018f1c2b0745b2b9c7bb333cb86c
4
- data.tar.gz: 4ebd7bdb25bdfbde7a762d333b9215f8e13909091fab11c1f048f52447e19b3c
3
+ metadata.gz: 18c3cf809df359e8e89d764f5111d97b33ce63802d5e4ee1c01be83eed583d5c
4
+ data.tar.gz: b431129c01229cdac6751df4e5d03a756f0852ca9aa6e78cae7e2ff7d7caf36d
5
5
  SHA512:
6
- metadata.gz: 0d021ad9461294d8ee384d2302d25012b148e614c0deab1025d77da3a53355bbe62d326d9f29f15ed0685113523a577b13eef7a4d30ab81e323efaa59cecfb0a
7
- data.tar.gz: 5469ed8b60c2d81cc89ad7f0a6debabf76b4f55e944f110365c2ed41db25379833f970acc288426ce61b123fffb6f3964cacc2d7ccc4689f9b7d3011b1654c02
6
+ metadata.gz: 56d344edf79caf64a9dec52fba375b2455c889e097dbf5be2fdf074c2ac4ee0eaf3f882e4bf55f638cb47b3de1cc00b57e56cf47910731dea825be8042d1c074
7
+ data.tar.gz: 465820b6b31e9a99046098fd51ccc6eccc341e9aac0ef2595faca93abde00b6c9de5452fb54b5016b351eb73455c58ecdae8ed84dbb4505c5bb25345fa5e0046
@@ -1,20 +1,35 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
1
8
  name: Ruby
2
9
 
3
- on: [push]
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
4
15
 
5
16
  jobs:
6
- build:
17
+ test:
7
18
 
8
19
  runs-on: ubuntu-latest
20
+ strategy:
21
+ matrix:
22
+ ruby-version: ['2.4', '2.5', '2.6', '2.7', '3.0']
9
23
 
10
24
  steps:
11
25
  - uses: actions/checkout@v2
12
- - name: Set up Ruby 2.6
13
- uses: actions/setup-ruby@v1
26
+ - name: Set up Ruby
27
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
28
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
29
+ # uses: ruby/setup-ruby@v1
30
+ uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
14
31
  with:
15
- ruby-version: 2.6.x
16
- - name: Build and test with Rake
17
- run: |
18
- gem install bundler
19
- bundle install --jobs 4 --retry 3
20
- bundle exec rake
32
+ ruby-version: ${{ matrix.ruby-version }}
33
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
34
+ - name: Run tests
35
+ run: bundle exec rake
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.4
4
+ - 2.5
5
+ - 2.6
6
+ - 2.7
7
+ - 3.0
8
+ - jruby
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.0.0
4
+
5
+ - More robust testing
6
+ - Better error handling
7
+ - Keyword argument support
8
+
3
9
  ## 0.7.2
4
10
 
5
11
  Variable arity invoker methods are handled properly. Variable arity initializers will result in a more meaningful exception being raised.
data/Gemfile CHANGED
@@ -1,15 +1,7 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in data-functions.gemspec
6
3
  gemspec
7
4
 
8
5
  group :development do
9
- gem 'pry'
10
6
  gem 'yard'
11
7
  end
12
-
13
- group :test do
14
- gem 'gen-test'
15
- end
@@ -1,53 +1,38 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- invokable (0.7.2)
4
+ invokable (1.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- coderay (1.1.2)
10
- concurrent-ruby (1.1.5)
11
- diff-lcs (1.3)
12
- faker (1.9.6)
13
- i18n (>= 0.7)
14
- gen-test (0.1.1)
15
- faker (~> 1.9.6)
16
- regexp-examples (~> 1.5.0)
17
- i18n (1.8.2)
18
- concurrent-ruby (~> 1.0)
19
- method_source (0.9.2)
20
- pry (0.12.2)
21
- coderay (~> 1.1.0)
22
- method_source (~> 0.9.0)
9
+ diff-lcs (1.4.4)
23
10
  rake (13.0.1)
24
- regexp-examples (1.5.1)
25
- rspec (3.9.0)
26
- rspec-core (~> 3.9.0)
27
- rspec-expectations (~> 3.9.0)
28
- rspec-mocks (~> 3.9.0)
29
- rspec-core (3.9.1)
30
- rspec-support (~> 3.9.1)
31
- rspec-expectations (3.9.0)
11
+ rspec (3.10.0)
12
+ rspec-core (~> 3.10.0)
13
+ rspec-expectations (~> 3.10.0)
14
+ rspec-mocks (~> 3.10.0)
15
+ rspec-core (3.10.0)
16
+ rspec-support (~> 3.10.0)
17
+ rspec-expectations (3.10.0)
32
18
  diff-lcs (>= 1.2.0, < 2.0)
33
- rspec-support (~> 3.9.0)
34
- rspec-mocks (3.9.1)
19
+ rspec-support (~> 3.10.0)
20
+ rspec-mocks (3.10.0)
35
21
  diff-lcs (>= 1.2.0, < 2.0)
36
- rspec-support (~> 3.9.0)
37
- rspec-support (3.9.2)
38
- yard (0.9.24)
22
+ rspec-support (~> 3.10.0)
23
+ rspec-support (3.10.0)
24
+ yard (0.9.25)
39
25
 
40
26
  PLATFORMS
27
+ java
41
28
  ruby
42
29
 
43
30
  DEPENDENCIES
44
- bundler (~> 1.17)
45
- gen-test
31
+ bundler (~> 2.1)
46
32
  invokable!
47
- pry
48
33
  rake (~> 13.0)
49
34
  rspec (~> 3.0)
50
35
  yard
51
36
 
52
37
  BUNDLED WITH
53
- 1.17.3
38
+ 2.2.6
data/README.md CHANGED
@@ -162,6 +162,10 @@ Or install it yourself as:
162
162
  - [Clojure](https://clojure.org)
163
163
  - [Arc](http://www.arclanguage.org)
164
164
 
165
+ ## Support
166
+
167
+ Tested using MRI 2.4, 2.5, 2.6, 2.7, 3.0 and JRuby
168
+
165
169
  ## License
166
170
 
167
171
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
37
  spec.require_paths = ["lib"]
38
38
 
39
- spec.add_development_dependency "bundler", "~> 1.17"
39
+ spec.add_development_dependency "bundler", "~> 2.1"
40
40
  spec.add_development_dependency "rake", "~> 13.0"
41
41
  spec.add_development_dependency "rspec", "~> 3.0"
42
42
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'invokable/version'
2
4
  require 'invokable/core'
3
5
  require 'invokable/helpers'
@@ -39,6 +41,7 @@ module Invokable
39
41
  private
40
42
 
41
43
  INCLUDED_MODULES = [Core, Helpers].freeze
44
+ private_constant :INCLUDED_MODULES
42
45
 
43
46
  # The methods that are mixed into any class at the class level that includes {Invokable}.
44
47
  #
@@ -62,19 +65,30 @@ module Invokable
62
65
  # @version 0.6.0
63
66
  #
64
67
  # @see arity
65
- def call(*args)
66
- raise ArgumentError, "variable length initializer methods are not supported by Invokable" if initializer_arity < 0
67
-
68
- return new.call if arity.zero?
69
- return new(*args).call if args.length == initializer_arity && (invoker_arity.zero? || invoker_arity == -1)
70
- return new(*args) if args.length == initializer_arity
68
+ def call(*args, **kwargs)
69
+ initializer = initializer_arity
70
+ raise ArgumentError, "variable length initializer methods are not supported by Invokable try using `new' or `curry' instead" if initializer < 0
71
+ raise ArgumentError, "block arguments are not supported by Invokable" if block_given?
72
+
73
+ return new.call if arity.zero?
74
+
75
+ argc = kwargs.empty? ? args.length : args.length + 1
76
+ invoker = invoker_arity
77
+ return new(*args).call if argc == initializer && invoker.zero? && kwargs.empty?
78
+ return new(*args, **kwargs).call if argc == initializer && invoker.zero?
79
+ return new(*args).call if argc == initializer && invoker == -1 && kwargs.empty?
80
+ return new(*args).call(**kwargs) if argc == initializer && invoker == -1
81
+ return new(*args) if argc == initializer && kwargs.empty?
82
+ return new(*args, **kwargs) if argc == initializer
71
83
 
72
- if args.length == arity || invoker_arity < 0 && (args.length - initializer_arity) >= (invoker_arity.abs - 1)
73
- init_args = args.slice(0, initializer_arity)
74
- call_args = args.slice(initializer_arity, args.length)
75
- new(*init_args).call(*call_args)
84
+ if argc == arity || invoker_arity < 0 && (args.length - initializer) >= (invoker.abs - 1)
85
+ init_args = args.slice(0, initializer)
86
+ call_args = args.slice(initializer, args.length)
87
+ return new(*init_args).call(*call_args) if kwargs.empty?
88
+ return new(*init_args).call(*call_args, **kwargs)
76
89
  else
77
- raise ArgumentError, "wrong number of arguments (given #{args.length}, expected #{initializer_arity} or #{arity})"
90
+ raise ArgumentError, "wrong number of arguments (given #{args.length}, expected #{arity})" if initializer == arity
91
+ raise ArgumentError, "wrong number of arguments (given #{args.length}, expected #{initializer} or #{arity})"
78
92
  end
79
93
  end
80
94
 
@@ -1,3 +1,3 @@
1
1
  module Invokable
2
- VERSION = "0.7.2"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: invokable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delon Newman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-20 00:00:00.000000000 Z
11
+ date: 2021-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.17'
19
+ version: '2.1'
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: '2.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -63,6 +63,7 @@ files:
63
63
  - ".github/workflows/ruby.yml"
64
64
  - ".gitignore"
65
65
  - ".rspec"
66
+ - ".travis.yml"
66
67
  - CHANGELOG.md
67
68
  - Gemfile
68
69
  - Gemfile.lock
@@ -107,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
108
  - !ruby/object:Gem::Version
108
109
  version: '0'
109
110
  requirements: []
110
- rubygems_version: 3.0.6
111
+ rubygems_version: 3.2.3
111
112
  signing_key:
112
113
  specification_version: 4
113
114
  summary: Objects are functions! Treat any Object, Hashes, Arrays and Sets as Procs