reputs 0.0.1
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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/LICENSE.txt +22 -0
- data/README.md +61 -0
- data/Rakefile +1 -0
- data/lib/reputs.rb +8 -0
- data/lib/reputs/version.rb +3 -0
- data/reputs.gemspec +23 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0fe0fc530804647ca378ce1a08e9dfd9b9ff48df
|
4
|
+
data.tar.gz: 312e2c5670dc119214d150c32f956e7968fd2f44
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: addfa190dd25ee33713e6d09842e42a0429ee1b37035a8304eb4945f7a331a70c02cd0a03b833756d6b875a49d1dabc455cb7966c2d5abc39442401463cd31aa
|
7
|
+
data.tar.gz: ad7d1eb5d5aae294dd4789935a8b4cdecebc141530d93908ba94e2e6af11ef901cec2fbf16d971f96c3b9d2e9882ea81c0675ced2e1e65e58ca1cbf0762d7c4a
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 jeffreybiles
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
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, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 jeffreybiles
|
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,61 @@
|
|
1
|
+
#Reputs
|
2
|
+
###return + puts, because it's goddam useful
|
3
|
+
|
4
|
+
Let's say you want to debug a one-line function like this:
|
5
|
+
|
6
|
+
def so_hat(closet)
|
7
|
+
return all_the_radii(closet.hats(&:brim))
|
8
|
+
end
|
9
|
+
|
10
|
+
You want to figure out what exactly you're feeding into all_the_radii, but your first solution fails:
|
11
|
+
|
12
|
+
def so_hat(closet)
|
13
|
+
return all_the_radii(puts closet.hats(&:brim))
|
14
|
+
end
|
15
|
+
|
16
|
+
It fails because puts returns nil. You just fed all_the_radii nil. So terrible!
|
17
|
+
|
18
|
+
Your second solution is gross, but it works.
|
19
|
+
|
20
|
+
def so_hat(closet)
|
21
|
+
puts closet.hats(&:brim)
|
22
|
+
return all_the_radii(closet.hats(&:brim))
|
23
|
+
end
|
24
|
+
|
25
|
+
You then want to find out what all_the_radii is returning every time your program runs so_hat. Remembering that puts returns nil, you write your code like this:
|
26
|
+
|
27
|
+
def so_hat(closet)
|
28
|
+
puts closet.hats(&:brim)
|
29
|
+
puts all_the_radii(closet.hats(&:brim)
|
30
|
+
return all_the_radii(closet.hats(&:brim))
|
31
|
+
end
|
32
|
+
|
33
|
+
But then you realize that all_the_radii has side effects. Specifically, it steals all the radii from the hats, so when you get around to returning it you get a big fat 0. You gotta fix that, so now your code looks like this:
|
34
|
+
|
35
|
+
def so_hat(closet)
|
36
|
+
puts closet.hats(&:brim)
|
37
|
+
radii = all_the_radii(closet.hats(&:brim))
|
38
|
+
puts radii
|
39
|
+
return radii
|
40
|
+
end
|
41
|
+
|
42
|
+
Wow, your code sucks! I'm so glad seppuku is no longer a thing, because now you've lived long enough to realize that
|
43
|
+
|
44
|
+
##There's hope!!
|
45
|
+
|
46
|
+
This is what your code would look like if you were using reputs:
|
47
|
+
|
48
|
+
def so_hat(closet)
|
49
|
+
reputs all_the_radii(reputs closet.hats(&:brim))
|
50
|
+
end
|
51
|
+
|
52
|
+
Holy fuck, that's only two words away from what it was originally. So clear! So easy!
|
53
|
+
|
54
|
+
###Here's what reputs does
|
55
|
+
|
56
|
+
def reputs(thing)
|
57
|
+
puts thing
|
58
|
+
return thing
|
59
|
+
end
|
60
|
+
|
61
|
+
That is literally all, and yet it saved you gourdfuls of code. Giant gourds. Please enjoy your newly emptied gourds.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/reputs.rb
ADDED
data/reputs.gemspec
ADDED
@@ -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 'reputs/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "reputs"
|
8
|
+
spec.version = Reputs::VERSION
|
9
|
+
spec.authors = ["jeffreybiles"]
|
10
|
+
spec.email = ["bilesjeffrey@gmail.com"]
|
11
|
+
spec.description = %q{return + puts, how it really should work}
|
12
|
+
spec.summary = %q{return + puts, how it really should work}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: reputs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- jeffreybiles
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-02 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.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: return + puts, how it really should work
|
42
|
+
email:
|
43
|
+
- bilesjeffrey@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/reputs.rb
|
55
|
+
- lib/reputs/version.rb
|
56
|
+
- reputs.gemspec
|
57
|
+
homepage: ''
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.0.3
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: return + puts, how it really should work
|
81
|
+
test_files: []
|