patched 0.0.3
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 +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +62 -0
- data/Rakefile +10 -0
- data/lib/patched.rb +32 -0
- data/lib/patched/version.rb +3 -0
- data/patched.gemspec +27 -0
- data/spec/spec_helper.rb +5 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ed48318cd83e8f567f300bd64e2742daae4af3e2
|
4
|
+
data.tar.gz: 84c89cee6858811d44654ff7a444d6f9ce2610c6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b968389251d042f56e2b1880e8c66566a6183e5d0d3fd780e06d297368cf38edd5342002b35f3e6bab342ef27b105c16f6053ed97767c0a8110f9f068180a378
|
7
|
+
data.tar.gz: e6ec97b5eaed723bc03fc54d7fdbc298eaa6b4d594eb245037ddac1311fc258609acb7cfa9ccb9b0ae336dd4aaa5f0b0063ddb48178b1d631c93bd50bcd14e96
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Lee Machin
|
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,62 @@
|
|
1
|
+
# Patched
|
2
|
+
|
3
|
+
Create one-off refinements for classes, without (most) of the boilerplate.
|
4
|
+
|
5
|
+
## Installing
|
6
|
+
|
7
|
+
Put this in your Gemfile:
|
8
|
+
|
9
|
+
```shell
|
10
|
+
gem 'patched'
|
11
|
+
```
|
12
|
+
|
13
|
+
Or this in your terminal:
|
14
|
+
|
15
|
+
```shell
|
16
|
+
gem install patched
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Basically, this:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
using patched(ClassName) {
|
25
|
+
# add methods to ClassName here
|
26
|
+
}
|
27
|
+
```
|
28
|
+
|
29
|
+
The syntax is, unfortunately, quite important.
|
30
|
+
|
31
|
+
### Example
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
class LolMaths
|
35
|
+
|
36
|
+
include Patched
|
37
|
+
|
38
|
+
using patched(Fixnum) {
|
39
|
+
def to_word
|
40
|
+
case self
|
41
|
+
when 0 then "zero"
|
42
|
+
when 1 then "one"
|
43
|
+
when 2 then "two"
|
44
|
+
# ...
|
45
|
+
end
|
46
|
+
end
|
47
|
+
}
|
48
|
+
|
49
|
+
def add(*numbers)
|
50
|
+
numbers.reduce("") {|sum, num| sum + num.to_word }
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
```
|
55
|
+
|
56
|
+
## Tests
|
57
|
+
|
58
|
+
Forthcoming.
|
59
|
+
|
60
|
+
## Contributing
|
61
|
+
|
62
|
+
Any ideas or attempts to make this less of a horrible hack would be very much appreciated.
|
data/Rakefile
ADDED
data/lib/patched.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require "sourcify"
|
2
|
+
require "patched/version"
|
3
|
+
|
4
|
+
module Patched
|
5
|
+
|
6
|
+
def self.included(receiver)
|
7
|
+
receiver.extend ClassMethods
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.refinements
|
11
|
+
@refinements ||= {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.new_refinement(receiver, class_to_refine, &block)
|
15
|
+
refinement = Module.new
|
16
|
+
refinement.module_eval <<-RB, __FILE__, __LINE__
|
17
|
+
refine #{class_to_refine} do
|
18
|
+
#{block.to_source(strip_enclosure: true, ignore_nested: true)}
|
19
|
+
end
|
20
|
+
RB
|
21
|
+
|
22
|
+
module_name = "#{receiver}::#{class_to_refine}"
|
23
|
+
self.refinements[module_name] = refinement
|
24
|
+
end
|
25
|
+
|
26
|
+
module ClassMethods
|
27
|
+
def patched(klass, &block)
|
28
|
+
Patched.new_refinement(self, klass, &block)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/patched.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'patched/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "patched"
|
8
|
+
spec.version = Patched::VERSION
|
9
|
+
spec.authors = ["Lee Machin"]
|
10
|
+
spec.email = ["lee@new-bamboo.co.uk"]
|
11
|
+
spec.description = %q{One-time use refinements}
|
12
|
+
spec.summary = %q{Simple way to include one-off refinements in your code}
|
13
|
+
spec.homepage = "https://github.com/leemachin/patched"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.required_ruby_version = ">= 2.1.0"
|
17
|
+
|
18
|
+
spec.files = `git ls-files`.split($/)
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_dependency "sourcify", ">= 0.6.0.rc4"
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.1"
|
26
|
+
spec.add_development_dependency "minitest", "~> 5.2"
|
27
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: patched
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lee Machin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sourcify
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.6.0.rc4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.6.0.rc4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.2'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.2'
|
69
|
+
description: One-time use refinements
|
70
|
+
email:
|
71
|
+
- lee@new-bamboo.co.uk
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- lib/patched.rb
|
82
|
+
- lib/patched/version.rb
|
83
|
+
- patched.gemspec
|
84
|
+
- spec/spec_helper.rb
|
85
|
+
homepage: https://github.com/leemachin/patched
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 2.1.0
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.2.0
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: Simple way to include one-off refinements in your code
|
109
|
+
test_files:
|
110
|
+
- spec/spec_helper.rb
|