proc_party 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e703533fbe63bfdaa02caedb32a5a9409ad0fde6
4
+ data.tar.gz: ddaf1000c16e4a6e21d0f554d470d3cc4f30d252
5
+ SHA512:
6
+ metadata.gz: ef6abfba5a6cfaece36585a258a0795266df12c064a1b8878cb6312298d43b3cf73fabc0b3ae7fabd5f359c47d95a10dd312db9fd75611c822998d6c133354f4
7
+ data.tar.gz: 3a060a93fc17a4bd7937eee597955998f24a58874c2e29aec3daab7e65d0a1ba40a73d5a3cf51267254a9f3585da093a9200bdc20ec52390f81fec899b65af18
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rubocop.yml ADDED
@@ -0,0 +1,67 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+
4
+ Bundler/OrderedGems:
5
+ Enabled: false
6
+
7
+ Metrics/LineLength:
8
+ IgnoredPatterns:
9
+ - !ruby/regexp /^\s*#/
10
+
11
+ Metrics/BlockLength:
12
+ Exclude:
13
+ - db/schema.rb
14
+ - config/initializers/**/*
15
+
16
+ Style/AlignParameters:
17
+ EnforcedStyle: with_fixed_indentation
18
+
19
+ Style/AsciiComments:
20
+ Enabled: false
21
+
22
+ Style/Documentation:
23
+ Enabled: false
24
+
25
+ Style/EmptyLinesAroundBlockBody:
26
+ Exclude:
27
+ - db/schema.rb
28
+
29
+ Style/EmptyMethod:
30
+ Enabled: false
31
+
32
+ Style/ExtraSpacing:
33
+ AllowForAlignment: false
34
+
35
+ Style/FrozenStringLiteralComment:
36
+ Enabled: false
37
+
38
+ Style/GuardClause:
39
+ Enabled: false
40
+
41
+ Style/IfUnlessModifier:
42
+ Enabled: false
43
+
44
+ Style/MultilineMethodCallIndentation:
45
+ EnforcedStyle: indented_relative_to_receiver
46
+
47
+ Style/NegatedIf:
48
+ Enabled: false
49
+
50
+ Style/NumericLiterals:
51
+ Exclude:
52
+ - db/schema.rb
53
+
54
+ Style/SpaceInLambdaLiteral:
55
+ EnforcedStyle: require_space
56
+
57
+ Style/StringLiterals:
58
+ EnforcedStyle: double_quotes
59
+
60
+ Style/StringLiteralsInInterpolation:
61
+ Enabled: false
62
+
63
+ Style/TrailingCommaInArguments:
64
+ EnforcedStyleForMultiline: comma
65
+
66
+ Style/TrailingCommaInLiteral:
67
+ EnforcedStyleForMultiline: comma
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.14.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in proc_party.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Zach Ahn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # ProcParty
2
+
3
+ Ever had a class with just one method? Maybe it was named `#call` or `#process`?
4
+
5
+ Ever wanted to `(1..3).map(&Identity.new)` or `Guest.all.each(&GiveCar.new)`?
6
+
7
+ Proc party! 🎉 🎉 🎉
8
+
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem "proc_party"
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ class Identity
27
+ include ProcParty
28
+
29
+ def call(n)
30
+ n
31
+ end
32
+ end
33
+
34
+ (1..3).map(&Identity.new) # => [1, 2, 3]
35
+
36
+
37
+ class GiveCar
38
+ include ProcParty
39
+
40
+ def call(guest)
41
+ guest.cars.push(Car.new)
42
+ guest.save
43
+ guest
44
+ end
45
+ end
46
+
47
+ Guest.all.each(&GiveCar.new).each(&:celebrate!)
48
+ ```
49
+
50
+
51
+ ## Development
52
+
53
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
54
+ `rake test` to run the tests. You can also run `bin/console` for an interactive
55
+ prompt that will allow you to experiment.
56
+
57
+ To install this gem onto your local machine, run `bundle exec rake install`. To
58
+ release a new version, update the version number in `proc_party.gemspec`, and
59
+ then run `bundle exec rake release`, which will create a git tag for the
60
+ version, push git commits and tags, and push the `.gem` file to
61
+ [rubygems.org][rubygems].
62
+
63
+
64
+ ## Contributing
65
+
66
+ Bug reports and pull requests are welcome on GitHub at
67
+ [https://github.com/zachahn/proc_party][home].
68
+
69
+
70
+ ## License
71
+
72
+ The gem is available as open source under the terms of the
73
+ [MIT License][mit].
74
+
75
+
76
+ [home]: https://github.com/zachahn/proc_party
77
+ [rubygems]: https://rubygems.org
78
+ [mit]: http://opensource.org/licenses/MIT
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task default: :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "proc_party"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/rake ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ require "rubygems"
16
+ require "bundler/setup"
17
+
18
+ load Gem.bin_path("rake", "rake")
data/bin/rubocop ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rubocop' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ require "rubygems"
16
+ require "bundler/setup"
17
+
18
+ load Gem.bin_path("rubocop", "rubocop")
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/proc_party.rb ADDED
@@ -0,0 +1,37 @@
1
+ module ProcParty
2
+ def to_proc
3
+ method(:call).to_proc
4
+ end
5
+
6
+ def [](*args)
7
+ call(*args)
8
+ end
9
+
10
+ def ===(*args)
11
+ call(*args)
12
+ end
13
+
14
+ def arity
15
+ to_proc.arity
16
+ end
17
+
18
+ def curry(*arg)
19
+ to_proc.curry(*arg)
20
+ end
21
+
22
+ def lambda?
23
+ to_proc.lambda?
24
+ end
25
+
26
+ def parameters
27
+ method(:call).parameters
28
+ end
29
+
30
+ def source_location
31
+ method(:call).source_location
32
+ end
33
+
34
+ def yield(*args)
35
+ call(*args)
36
+ end
37
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "proc_party"
5
+ spec.version = "0.2.0"
6
+ spec.authors = ["Zach Ahn"]
7
+ spec.email = ["engineering@zachahn.com"]
8
+
9
+ spec.homepage = "https://github.com/zachahn/proc_party"
10
+ spec.summary = "Procs everywhere"
11
+ spec.description =
12
+ "ProcParty makes classes with a #call method act like procs. " \
13
+ "Documentation for this release is located in " \
14
+ "#{spec.homepage}/blob/v#{spec.version}/README.md"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.14"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "minitest", "~> 5.0"
27
+ spec.add_development_dependency "rubocop"
28
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: proc_party
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Zach Ahn
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-04-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: 'ProcParty makes classes with a #call method act like procs. Documentation
70
+ for this release is located in https://github.com/zachahn/proc_party/blob/v0.2.0/README.md'
71
+ email:
72
+ - engineering@zachahn.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rubocop.yml"
79
+ - ".travis.yml"
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/rake
86
+ - bin/rubocop
87
+ - bin/setup
88
+ - lib/proc_party.rb
89
+ - proc_party.gemspec
90
+ homepage: https://github.com/zachahn/proc_party
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.6.8
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: Procs everywhere
114
+ test_files: []