footing 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3f04e649ba636544080c07a1ad7761f5c651c8ea
4
+ data.tar.gz: 297c0852ba8345a9ae906717b96ee43c03d2f9a6
5
+ SHA512:
6
+ metadata.gz: f82d06e716fae130a33167feb967bbadf2d918039bf17e67e1430a87ff37ad5cf1b84302717a36cc9dc2b0009e855cc58d83fedda5ae824ed6c72b03c6e25e5b
7
+ data.tar.gz: 2bea338d92a93f6bace21ef5bb018eb3d2ceab3ecdcac6c5af170b1fc97fb7ded7423232a55a62cb07b14bc31258180efd8da1bbb13cbc99a8352607fd442e7a
@@ -6,24 +6,24 @@ PATH
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- binding_of_caller (0.7.1)
9
+ binding_of_caller (0.7.2)
10
10
  debug_inspector (>= 0.0.1)
11
11
  coderay (1.0.9)
12
12
  debug_inspector (0.0.2)
13
- method_source (0.8.1)
13
+ method_source (0.8.2)
14
14
  micro_mock (1.1.0)
15
- micro_test (0.3.7)
15
+ micro_test (0.4.0)
16
16
  os
17
17
  os (0.9.6)
18
- pry (0.9.12)
19
- coderay (~> 1.0.5)
18
+ pry (0.9.12.4)
19
+ coderay (~> 1.0)
20
20
  method_source (~> 0.8)
21
21
  slop (~> 3.4)
22
- pry-stack_explorer (0.4.9)
22
+ pry-stack_explorer (0.4.9.1)
23
23
  binding_of_caller (>= 0.7)
24
- pry (~> 0.9.11)
25
- rake (10.0.4)
26
- slop (3.4.4)
24
+ pry (>= 0.9.11)
25
+ rake (10.1.0)
26
+ slop (3.4.6)
27
27
 
28
28
  PLATFORMS
29
29
  ruby
data/README.md CHANGED
@@ -5,26 +5,28 @@
5
5
  [![Code Climate](https://codeclimate.com/github/hopsoft/footing.png)](https://codeclimate.com/github/hopsoft/footing)
6
6
 
7
7
  Footing provides some sanity for monkey patching practices.
8
+
8
9
  It's also a utility lib that contains additional functionality for core objects that you might find useful.
10
+ Think of it as a lightweight version of ActiveSupport that doesn't implicitly change native behavior.
9
11
 
10
12
  #### NOTE: this lib is experimental at the moment
11
13
 
12
14
  ## No implicit monkey patching
13
15
 
14
- **No surprises here.** You must explicitly patch.
16
+ You must explicitly apply monkey patches.
15
17
 
16
18
  ```ruby
17
- # some examples of explicit patching
18
19
  Footing.patch! String, Footing::String
19
20
  Footing.patch! Numeric, Footing::Numeric
20
21
  ```
21
22
 
23
+ Patches are visible in the classes ancestry.
24
+
22
25
  ```ruby
23
- # instrospect the changes
24
26
  String.ancestors
25
27
  [
26
28
  String,
27
- Footing::String,
29
+ Footing::String, # <--
28
30
  Comparable,
29
31
  Object,
30
32
  Kernel,
@@ -34,7 +36,7 @@ String.ancestors
34
36
  Numeric.ancestors
35
37
  [
36
38
  Numeric,
37
- Footing::Numeric,
39
+ Footing::Numeric, # <--
38
40
  Comparable,
39
41
  Object,
40
42
  Kernel,
@@ -49,7 +51,7 @@ If you don't want to corrupt the entire runtime, you can patch an instance.
49
51
  ```ruby
50
52
  s = "foo"
51
53
  Footing.patch! s, Footing::String
52
- s.respond_to? :escape # => true
54
+ s.respond_to? :escape # => true
53
55
  "foo".respond_to? :escape # => false
54
56
  ```
55
57
 
@@ -70,19 +72,10 @@ Footing.util! Footing::String
70
72
  Footing::String.escape "foo", "o" # => "f\\o\\o"
71
73
  ```
72
74
 
73
- ## Kick the tires
75
+ ## The Library
74
76
 
75
- 1. `git clone git://github.com/hopsoft/footing.git`
76
- 1. `cd /path/to/footing`
77
- 1. `bundle`
78
- 1. `./test`
79
- 1. `./console`
80
- 1. `Footing.patch! String, Footing::String`
77
+ The suite of functionality is pretty small right now.
78
+ Poke around the [extensions directory](https://github.com/hopsoft/footing/tree/master/lib/footing/extensions) to see what's available.
81
79
 
82
- or
80
+ Pull requests welcome.
83
81
 
84
- 1. `gem install footing`
85
- 1. `irb`
86
- 1. `require 'rubygems'`
87
- 1. `require 'footing'`
88
- 1. `Footing.patch! String, Footing::String`
@@ -1,3 +1,4 @@
1
+ require "delegate"
1
2
  require File.join(File.dirname(__FILE__), "footing", "version")
2
3
 
3
4
  module Footing
@@ -32,7 +33,7 @@ module Footing
32
33
  context = class << obj
33
34
  self
34
35
  end
35
- rescue Exception => ex
36
+ rescue Exception
36
37
  end
37
38
  end
38
39
 
@@ -49,25 +50,17 @@ module Footing
49
50
  # This allows users to invoke utility methods rather than monkey patching if they so desire.
50
51
  # @param [Module] mod The Module to setup util methods for.
51
52
  def self.util!(mod)
52
- proxy = ::Object.new
53
- proxy_eigen = class << proxy
54
- self
55
- end
56
-
53
+ proxy = Class.new(SimpleDelegator)
57
54
  Footing.patch! proxy, mod
58
55
 
59
- eigen = class << mod
60
- self
61
- end
62
-
63
- mod.instance_methods(false).each do |method|
64
- eigen.send :define_method, method do |*args|
65
- o = args.first || proxy
66
- m = proxy_eigen.instance_method(method)
67
- if m.parameters.empty?
68
- m.bind(o).call
56
+ mod.instance_methods(false).each do |method_name|
57
+ mod.define_singleton_method(method_name) do |target, *args|
58
+ method = proxy.instance_method(method_name)
59
+ target = proxy.new(target)
60
+ if method.parameters.empty?
61
+ method.bind(target).call
69
62
  else
70
- m.bind(o).call(*args)
63
+ method.bind(target).call(*args)
71
64
  end
72
65
  end
73
66
  end
@@ -3,10 +3,10 @@ module Footing
3
3
 
4
4
  # Returns the eigen class for the object.
5
5
  def eigen
6
- eigen = class << self
6
+ class << self
7
7
  self
8
8
  end
9
- rescue Exception => ex
9
+ rescue Exception
10
10
  nil
11
11
  end
12
12
 
@@ -1,3 +1,3 @@
1
1
  module Footing
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -1,94 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: footing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
5
- prerelease:
4
+ version: 0.1.8
6
5
  platform: ruby
7
6
  authors:
8
7
  - Nathan Hopkins
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-20 00:00:00.000000000 Z
11
+ date: 2013-11-26 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: micro_test
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: micro_mock
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: pry
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: pry-stack_explorer
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  description: A utility belt lib with sane monkey patching.
@@ -117,27 +106,26 @@ files:
117
106
  homepage: https://github.com/hopsoft/footing
118
107
  licenses:
119
108
  - MIT
109
+ metadata: {}
120
110
  post_install_message:
121
111
  rdoc_options: []
122
112
  require_paths:
123
113
  - lib
124
114
  required_ruby_version: !ruby/object:Gem::Requirement
125
- none: false
126
115
  requirements:
127
- - - ! '>='
116
+ - - '>='
128
117
  - !ruby/object:Gem::Version
129
118
  version: '0'
130
119
  required_rubygems_version: !ruby/object:Gem::Requirement
131
- none: false
132
120
  requirements:
133
- - - ! '>='
121
+ - - '>='
134
122
  - !ruby/object:Gem::Version
135
123
  version: '0'
136
124
  requirements: []
137
125
  rubyforge_project:
138
- rubygems_version: 1.8.23
126
+ rubygems_version: 2.0.3
139
127
  signing_key:
140
- specification_version: 3
128
+ specification_version: 4
141
129
  summary: A utility belt lib with sane monkey patching.
142
130
  test_files:
143
131
  - lib/footing/extensions/array.rb