object_thru 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1042aa2c3de8bf830c485f9f4068b37b0d921566
4
+ data.tar.gz: 5fc6f34783d6da948b45a05bf51845ca92aea0d9
5
+ SHA512:
6
+ metadata.gz: ae720be013241e25963c59ccdd02418ae01559ffb69d1b0d3366bb4f5e6c20b971043af08db041821f83781d9b743f310a120b2aabec75dff70fd10c3216d75d
7
+ data.tar.gz: 080f0b3c8a9107ef2c96a584d9a47e84e1ae82bf56de6e87a32139930646d482b61609f460ed630ff8feebc59eb7a139c7add41f139ed92513c9541024ee35a9
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in object_thru.gemspec
4
+ gemspec
5
+
6
+ if !ENV["CI"]
7
+ group :development do
8
+ gem "pry", "~> 0.9.12.6"
9
+ gem "pry-byebug", "<= 1.3.2"
10
+ gem "pry-rescue", "~> 1.4.1"
11
+ gem "pry-stack_explorer", "~> 0.4.9.1"
12
+ gem "pry-syntax-hacks", "~> 0.0.6"
13
+ end
14
+ end
15
+
16
+ group :test do
17
+ gem "codeclimate-test-reporter", require: nil
18
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Michael Sievers
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # ObjectThru
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'object_thru'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install object_thru
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/object_thru/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,11 @@
1
+ require "object_thru/version"
2
+
3
+ class Object
4
+ def thru(callable = nil)
5
+ if callable.respond_to?(:call)
6
+ callable.call(self)
7
+ elsif block_given?
8
+ yield self
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module ObjectThru
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'object_thru/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "object_thru"
8
+ spec.version = ObjectThru::VERSION
9
+ spec.authors = ["Michael Sievers"]
10
+ spec.summary = %q{Provides Object#thru as an complement to Object#tap}
11
+ spec.homepage = "https://github.com/msievers/object_thru"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files -z`.split("\x0")
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.7"
20
+ spec.add_development_dependency "rake", "~> 10.0"
21
+ spec.add_development_dependency "rspec", ">= 3.0.0", "< 4.0.0"
22
+ spec.add_development_dependency "simplecov", ">= 0.8.0"
23
+ end
@@ -0,0 +1,43 @@
1
+ describe ObjectThru do
2
+ it "adds #thru to Object" do
3
+ expect(Object.new).to respond_to(:thru)
4
+ end
5
+
6
+ describe "#thru" do
7
+ context "if a block is given" do
8
+ it "yields the object to the block" do
9
+ array = [1,2,3]
10
+
11
+ array.thru do |_array|
12
+ expect(array.object_id).to eq(_array.object_id)
13
+ end
14
+ end
15
+
16
+ it "returns the result of the block" do
17
+ array = [1,2,3]
18
+
19
+ result = array.thru do |_array|
20
+ array.first
21
+ end
22
+
23
+ expect(result).to eq(array.first)
24
+ end
25
+ end
26
+
27
+ context "if a callable is given" do
28
+ it "calls the callable with the object" do
29
+ callable = -> (object) { object }
30
+
31
+ some_object = Object.new
32
+ expect(some_object.thru(callable).object_id).to eq(some_object.object_id)
33
+ end
34
+
35
+ it "it returns the result of the callable" do
36
+ callable = -> (integer) { integer + 1 }
37
+
38
+ some_number = 1
39
+ expect(some_number.thru(callable)).to eq(callable.call(some_number))
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,26 @@
1
+ if ENV["CODECLIMATE_REPO_TOKEN"]
2
+ require "codeclimate-test-reporter"
3
+ CodeClimate::TestReporter.start
4
+ else
5
+ require "simplecov"
6
+ SimpleCov.start
7
+ end
8
+
9
+ begin
10
+ require "pry"
11
+ rescue LoadError
12
+ end
13
+
14
+ require "object_thru"
15
+
16
+ RSpec.configure do |config|
17
+ # begin --- rspec 3.1 generator
18
+ config.expect_with :rspec do |expectations|
19
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
20
+ end
21
+
22
+ config.mock_with :rspec do |mocks|
23
+ mocks.verify_partial_doubles = true
24
+ end
25
+ # end --- rspec 3.1 generator
26
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: object_thru
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Michael Sievers
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-26 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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.0
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: 4.0.0
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 3.0.0
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: 4.0.0
61
+ - !ruby/object:Gem::Dependency
62
+ name: simplecov
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 0.8.0
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 0.8.0
75
+ description:
76
+ email:
77
+ executables: []
78
+ extensions: []
79
+ extra_rdoc_files: []
80
+ files:
81
+ - ".gitignore"
82
+ - ".rspec"
83
+ - Gemfile
84
+ - LICENSE.txt
85
+ - README.md
86
+ - Rakefile
87
+ - lib/object_thru.rb
88
+ - lib/object_thru/version.rb
89
+ - object_thru.gemspec
90
+ - spec/object_thru_spec.rb
91
+ - spec/spec_helper.rb
92
+ homepage: https://github.com/msievers/object_thru
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.4.6
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Provides Object#thru as an complement to Object#tap
116
+ test_files:
117
+ - spec/object_thru_spec.rb
118
+ - spec/spec_helper.rb