expletive_infixation 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: 2e2fce60c43c79e98c3abd97dfa11b9bd910d859
4
+ data.tar.gz: 7f2ab95649bbbd475bcb7c2df5869f094d4d6089
5
+ SHA512:
6
+ metadata.gz: bc5e820cb53fcffd34c6f8a5fd3ce1a834987c2131a44248d6fafc76963fdf63121152ac8a8d181be47af68ca0d8fd0a53e2f01f1ef3af69d14182d753e3c7b2
7
+ data.tar.gz: d9457aaf3552592a91f5e5c585153208d7072960ff3e8b0755f5ac74e2255429899ec2bfdae6c522213f7af6d24ea913182356d5f3ce3b5be96b2b52700a3ec6
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in expletive_infixation.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 horribleideas
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 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,
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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # Expletive Infixation
2
+
3
+ Adds expletive infixes to ruby method names. Abso-freakin'-lutely!
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'expletive_infixation'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install expletive_infixation
18
+
19
+ ## Usage
20
+
21
+ Don't.
22
+
23
+ Standard usage.
24
+
25
+ ```ruby
26
+
27
+ require 'expletive_infixation'
28
+
29
+ a = [1,2,3,4,5]
30
+
31
+ a.sort_freakin_by! {|n| -n }
32
+
33
+ # => [5,4,3,2,1]
34
+ ```
35
+
36
+
37
+ Custom expletive.
38
+
39
+ ```ruby
40
+
41
+ require 'expletive_infixation'
42
+
43
+ ExpletiveInfixation.expletive_infix = 'gosh_darn'
44
+
45
+ a = [1,2,3,4,5]
46
+
47
+ a.each_with_gosh_darn_index do |n, i|
48
+ # ...
49
+ end
50
+ ```
51
+
52
+ ## Tests
53
+
54
+ $ ruby test/test_freakin_case.rb
55
+ Yep, SeriousThing.is_freakin_true?
56
+ Yep, SeriousThing.new.is_freakin_true?
57
+ Yep, SeriousThing.freakin_truthy?
58
+ Yep, SeriousThing.is_freakin_false? went 'undefined method `is_freakin_false?' for SeriousThing:Class'
59
+ Yep, SeriousThing.is_false? went 'undefined method `is_false?' for SeriousThing:Class'
60
+ Yep, SeriousThing.respond_to? :is_freakin_true?
61
+ Yep, SeriousThing.respond_to? :freakin_truthy?
62
+ Yep, SeriousThing.is_gosh_darn_true?
63
+ Yep, SeriousThing.is_freakin_true? went 'undefined method `is_freakin_true?' for SeriousThing:Class'
64
+
65
+ ## Contributing
66
+
67
+ 1. Fork it ( https://github.com/horribleideas/expletive_infixation/fork )
68
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
69
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
70
+ 4. Push to the branch (`git push origin my-new-feature`)
71
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'expletive_infixation/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "expletive_infixation"
8
+ spec.version = ExpletiveInfixation::VERSION
9
+ spec.authors = ["Kale Worsley"]
10
+ spec.email = ["kale@worsley.co.nz"]
11
+ spec.summary = %q{Adds expletive infixes to ruby method names.}
12
+ spec.description = %q{Adds expletive infixes to ruby method names. Abso-freakin'-lutely!}
13
+ spec.homepage = "https://github.com/horribleideas/expletive_infixation/fork"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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.6"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "pry"
24
+ end
@@ -0,0 +1,14 @@
1
+ require "expletive_infixation/version"
2
+ require "expletive_infixation/ext/object"
3
+
4
+ module ExpletiveInfixation
5
+ DEFAULT_EXPLETIVE = 'freakin'
6
+
7
+ def self.expletive_infix
8
+ Regexp.new("_?#{@expletive_infix || DEFAULT_EXPLETIVE}_?")
9
+ end
10
+
11
+ def self.expletive_infix=(regexp)
12
+ @expletive_infix = regexp
13
+ end
14
+ end
@@ -0,0 +1,43 @@
1
+ class Object
2
+
3
+ def method_missing(name, *args, &block)
4
+ m = Explete.target_method(self, name) and send m, *args, &block or super
5
+ end
6
+
7
+ def respond_to_missing?(name, include_private=false)
8
+ !!Explete.target_method(self, name) or super
9
+ end
10
+
11
+ end
12
+
13
+ # Save cognitive overhead by having this in the same file
14
+ class Explete < Struct.new(:object, :method)
15
+ INFIX_SUBSTITUTIONS = ['', '_'].freeze # such performance.
16
+
17
+ def self.target_method(*args)
18
+ new(*args).target_method
19
+ end
20
+
21
+ def target_method
22
+ infix =~ method and find_real_method
23
+ end
24
+
25
+ def infix
26
+ ExpletiveInfixation.expletive_infix
27
+ end
28
+
29
+ def find_real_method
30
+ possible_method_names.find { |m| object.respond_to? m }
31
+ end
32
+
33
+ def possible_method_names
34
+ INFIX_SUBSTITUTIONS.map &infix_substitution
35
+ end
36
+
37
+ # like a pro.
38
+ def infix_substitution
39
+ -> (substitution) { method.to_s.gsub infix, substitution }
40
+ end
41
+
42
+ end
43
+
@@ -0,0 +1,3 @@
1
+ module ExpletiveInfixation
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,15 @@
1
+ class SeriousThing
2
+
3
+ def self.truthy?
4
+ true
5
+ end
6
+
7
+ def self.is_true?
8
+ true
9
+ end
10
+
11
+ def is_true?
12
+ self.class.is_true?
13
+ end
14
+
15
+ end
@@ -0,0 +1,18 @@
1
+ $: << 'lib/'
2
+ require 'expletive_infixation'
3
+ require_relative 'serious_thing'
4
+ require_relative 'wow'
5
+
6
+ make_sure "SeriousThing.is_freakin_true?"
7
+ make_sure "SeriousThing.new.is_freakin_true?"
8
+ make_sure "SeriousThing.freakin_truthy?"
9
+ no_way "SeriousThing.is_freakin_false?"
10
+ no_way "SeriousThing.is_false?"
11
+
12
+ make_sure "SeriousThing.respond_to? :is_freakin_true?"
13
+ make_sure "SeriousThing.respond_to? :freakin_truthy?"
14
+
15
+ ExpletiveInfixation.expletive_infix = 'gosh_darn'
16
+
17
+ make_sure "SeriousThing.is_gosh_darn_true?"
18
+ no_way "SeriousThing.is_freakin_true?"
data/test/wow.rb ADDED
@@ -0,0 +1,27 @@
1
+ ANSI_GREEN = 32
2
+ ANSI_RED = 31
3
+
4
+ def pass(message)
5
+ puts_color ANSI_GREEN, "Yep, "+message
6
+ end
7
+
8
+ def fail(message)
9
+ puts_color ANSI_RED, "Dang, "+message
10
+ end
11
+
12
+ def puts_color(color_code, message)
13
+ puts "\e[0;#{color_code}m" << message << "\e[0m"
14
+ true
15
+ end
16
+
17
+ def make_sure(ruby)
18
+ eval(ruby) and pass "#{ruby}" or fail "no way #{ruby}"
19
+ rescue => e
20
+ fail "#{ruby} went '#{e}'"
21
+ end
22
+
23
+ def no_way(ruby)
24
+ eval(ruby) and fail "#{ruby}" or pass "no way #{ruby}"
25
+ rescue => e
26
+ pass "#{ruby} went '#{e}'"
27
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: expletive_infixation
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kale Worsley
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-19 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.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
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
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Adds expletive infixes to ruby method names. Abso-freakin'-lutely!
56
+ email:
57
+ - kale@worsley.co.nz
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE
65
+ - README.md
66
+ - Rakefile
67
+ - expletive_infixation.gemspec
68
+ - lib/expletive_infixation.rb
69
+ - lib/expletive_infixation/ext/object.rb
70
+ - lib/expletive_infixation/version.rb
71
+ - test/serious_thing.rb
72
+ - test/test_freakin_case.rb
73
+ - test/wow.rb
74
+ homepage: https://github.com/horribleideas/expletive_infixation/fork
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.2.2
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Adds expletive infixes to ruby method names.
98
+ test_files:
99
+ - test/serious_thing.rb
100
+ - test/test_freakin_case.rb
101
+ - test/wow.rb