mack-facets 0.7.1.1 → 0.8.0
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.
@@ -0,0 +1,16 @@
|
|
1
|
+
class File
|
2
|
+
|
3
|
+
alias_class_method :join
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
# Join now works like it should! It calls .to_s on each of the args
|
8
|
+
# pass in. It handles nested Arrays, etc...
|
9
|
+
def join(*args)
|
10
|
+
fs = [args].flatten
|
11
|
+
_original_join(fs.collect{|c| c.to_s})
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -3,6 +3,52 @@ require 'stringio'
|
|
3
3
|
|
4
4
|
module Kernel
|
5
5
|
|
6
|
+
# Aliases an instance method to a new name. It will only do the aliasing once, to prevent
|
7
|
+
# issues with reloading a class and causing a StackLevel too deep error.
|
8
|
+
# The method takes two arguments, the first is the original name of the method, the second,
|
9
|
+
# optional, parameter is the new name of the method. If you don't specify a new method name
|
10
|
+
# it will be generated with _original_<original_name>.
|
11
|
+
#
|
12
|
+
# Example:
|
13
|
+
# class Popcorn < Corn
|
14
|
+
# alias_instance_method :poppy
|
15
|
+
# alias_instance_method :corny, :old_corny
|
16
|
+
# def poppy
|
17
|
+
# 2 * _original_poppy
|
18
|
+
# end
|
19
|
+
# def corny
|
20
|
+
# 'pop' + old_corny
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
def alias_instance_method(orig_name, new_name = "_original_#{orig_name}")
|
24
|
+
alias_method new_name.to_sym, orig_name.to_sym unless method_defined?(new_name.to_s)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Aliases a class method to a new name. It will only do the aliasing once, to prevent
|
28
|
+
# issues with reloading a class and causing a StackLevel too deep error.
|
29
|
+
# The method takes two arguments, the first is the original name of the method, the second,
|
30
|
+
# optional, parameter is the new name of the method. If you don't specify a new method name
|
31
|
+
# it will be generated with _original_<original_name>.
|
32
|
+
#
|
33
|
+
# Example:
|
34
|
+
# class President
|
35
|
+
# alias_class_method :good
|
36
|
+
# alias_class_method :bad, :old_bad
|
37
|
+
# def self.good
|
38
|
+
# 'Bill ' + _original_good
|
39
|
+
# end
|
40
|
+
# def self.bad
|
41
|
+
# "Either #{old_bad}"
|
42
|
+
# end
|
43
|
+
# end
|
44
|
+
def alias_class_method(orig_name, new_name = "_original_#{orig_name}")
|
45
|
+
eval(%{
|
46
|
+
class << self
|
47
|
+
alias_method :#{new_name}, :#{orig_name} unless method_defined?("#{new_name}")
|
48
|
+
end
|
49
|
+
})
|
50
|
+
end
|
51
|
+
|
6
52
|
def pp_to_s(object)
|
7
53
|
pp_out = StringIO.new
|
8
54
|
PP.pp(object,pp_out)
|
@@ -1,5 +1,12 @@
|
|
1
1
|
class Object
|
2
2
|
|
3
|
+
def define_instance_method(sym, &block)
|
4
|
+
mod = Module.new do
|
5
|
+
define_method(sym, &block)
|
6
|
+
end
|
7
|
+
self.extend mod
|
8
|
+
end
|
9
|
+
|
3
10
|
# Includes a module into the current Class, and changes all the module's public methods to protected.
|
4
11
|
#
|
5
12
|
# Example:
|
data/lib/mack-facets.rb
CHANGED
@@ -23,7 +23,7 @@ require 'extlib/hook'
|
|
23
23
|
require path
|
24
24
|
end
|
25
25
|
|
26
|
-
[:array, :class, :hash, :kernel, :math, :module, :object, :string, :symbol, :nil_class, :date_time].each do |k|
|
26
|
+
[:array, :class, :hash, :kernel, :math, :module, :object, :string, :symbol, :nil_class, :date_time, :file].each do |k|
|
27
27
|
path = File.join(fl, "extensions", "#{k}")
|
28
28
|
require path
|
29
29
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mack-facets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- markbates
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-10-06 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- lib/mack-facets/extensions/array.rb
|
57
57
|
- lib/mack-facets/extensions/class.rb
|
58
58
|
- lib/mack-facets/extensions/date_time.rb
|
59
|
+
- lib/mack-facets/extensions/file.rb
|
59
60
|
- lib/mack-facets/extensions/hash.rb
|
60
61
|
- lib/mack-facets/extensions/kernel.rb
|
61
62
|
- lib/mack-facets/extensions/math.rb
|
@@ -96,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
97
|
requirements: []
|
97
98
|
|
98
99
|
rubyforge_project: magrathea
|
99
|
-
rubygems_version: 1.
|
100
|
+
rubygems_version: 1.3.0
|
100
101
|
signing_key:
|
101
102
|
specification_version: 2
|
102
103
|
summary: Ruby language extensions for Mack
|