quietbacktrace 0.0.9 → 0.1.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.
- data/History.txt +5 -0
- data/Manifest.txt +0 -1
- data/Rakefile +1 -1
- data/lib/aliasing.rb +63 -56
- data/lib/attribute_accessors.rb +84 -76
- metadata +3 -4
- data/bin/quietbacktrace +0 -0
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/Rakefile
CHANGED
data/lib/aliasing.rb
CHANGED
@@ -1,4 +1,10 @@
|
|
1
1
|
# :stopdoc:
|
2
|
+
#
|
3
|
+
# Snipped directly from ActiveSupport from Rails 1.2.3
|
4
|
+
# If Quiet Backtrace is run from a Rails app, the actual ActiveSupport
|
5
|
+
# methods will be used. That way, alias_method_chain will not be
|
6
|
+
# overridden in your Rails app if Quiet Backtrace is installed.
|
7
|
+
#
|
2
8
|
# Copyright (c) 2005-2006 David Heinemeier Hansson
|
3
9
|
#
|
4
10
|
# Permission is hereby granted, free of charge, to any person obtaining
|
@@ -21,62 +27,63 @@
|
|
21
27
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
28
|
|
23
29
|
# activesupport/lib/activesupport/core_ext/module/aliasing.rb
|
30
|
+
unless defined?(ActiveSupport)
|
31
|
+
class Module # :nodoc:
|
32
|
+
# Encapsulates the common pattern of:
|
33
|
+
#
|
34
|
+
# alias_method :foo_without_feature, :foo
|
35
|
+
# alias_method :foo, :foo_with_feature
|
36
|
+
#
|
37
|
+
# With this, you simply do:
|
38
|
+
#
|
39
|
+
# alias_method_chain :foo, :feature
|
40
|
+
#
|
41
|
+
# And both aliases are set up for you.
|
42
|
+
#
|
43
|
+
# Query and bang methods (foo?, foo!) keep the same punctuation:
|
44
|
+
#
|
45
|
+
# alias_method_chain :foo?, :feature
|
46
|
+
#
|
47
|
+
# is equivalent to
|
48
|
+
#
|
49
|
+
# alias_method :foo_without_feature?, :foo?
|
50
|
+
# alias_method :foo?, :foo_with_feature?
|
51
|
+
#
|
52
|
+
# so you can safely chain foo, foo?, and foo! with the same feature.
|
53
|
+
def alias_method_chain(target, feature)
|
54
|
+
# Strip out punctuation on predicates or bang methods since
|
55
|
+
# e.g. target?_without_feature is not a valid method name.
|
56
|
+
aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1
|
57
|
+
yield(aliased_target, punctuation) if block_given?
|
58
|
+
alias_method "#{aliased_target}_without_#{feature}#{punctuation}", target
|
59
|
+
alias_method target, "#{aliased_target}_with_#{feature}#{punctuation}"
|
60
|
+
end
|
24
61
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
#
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
yield(aliased_target, punctuation) if block_given?
|
52
|
-
alias_method "#{aliased_target}_without_#{feature}#{punctuation}", target
|
53
|
-
alias_method target, "#{aliased_target}_with_#{feature}#{punctuation}"
|
54
|
-
end
|
55
|
-
|
56
|
-
# Allows you to make aliases for attributes, which includes
|
57
|
-
# getter, setter, and query methods.
|
58
|
-
#
|
59
|
-
# Example:
|
60
|
-
#
|
61
|
-
# class Content < ActiveRecord::Base
|
62
|
-
# # has a title attribute
|
63
|
-
# end
|
64
|
-
#
|
65
|
-
# class Email < ActiveRecord::Base
|
66
|
-
# alias_attribute :subject, :title
|
67
|
-
# end
|
68
|
-
#
|
69
|
-
# e = Email.find(1)
|
70
|
-
# e.title # => "Superstars"
|
71
|
-
# e.subject # => "Superstars"
|
72
|
-
# e.subject? # => true
|
73
|
-
# e.subject = "Megastars"
|
74
|
-
# e.title # => "Megastars"
|
75
|
-
def alias_attribute(new_name, old_name)
|
76
|
-
module_eval <<-STR, __FILE__, __LINE__+1
|
77
|
-
def #{new_name}; #{old_name}; end
|
78
|
-
def #{new_name}?; #{old_name}?; end
|
79
|
-
def #{new_name}=(v); self.#{old_name} = v; end
|
80
|
-
STR
|
62
|
+
# Allows you to make aliases for attributes, which includes
|
63
|
+
# getter, setter, and query methods.
|
64
|
+
#
|
65
|
+
# Example:
|
66
|
+
#
|
67
|
+
# class Content < ActiveRecord::Base
|
68
|
+
# # has a title attribute
|
69
|
+
# end
|
70
|
+
#
|
71
|
+
# class Email < ActiveRecord::Base
|
72
|
+
# alias_attribute :subject, :title
|
73
|
+
# end
|
74
|
+
#
|
75
|
+
# e = Email.find(1)
|
76
|
+
# e.title # => "Superstars"
|
77
|
+
# e.subject # => "Superstars"
|
78
|
+
# e.subject? # => true
|
79
|
+
# e.subject = "Megastars"
|
80
|
+
# e.title # => "Megastars"
|
81
|
+
def alias_attribute(new_name, old_name)
|
82
|
+
module_eval <<-STR, __FILE__, __LINE__+1
|
83
|
+
def #{new_name}; #{old_name}; end
|
84
|
+
def #{new_name}?; #{old_name}?; end
|
85
|
+
def #{new_name}=(v); self.#{old_name} = v; end
|
86
|
+
STR
|
87
|
+
end
|
81
88
|
end
|
82
89
|
end
|
data/lib/attribute_accessors.rb
CHANGED
@@ -1,4 +1,10 @@
|
|
1
1
|
# :stopdoc:
|
2
|
+
#
|
3
|
+
# Snipped directly from ActiveSupport from Rails 1.2.3
|
4
|
+
# If Quiet Backtrace is run from a Rails app, the actual ActiveSupport
|
5
|
+
# methods will be used. That way, mattr_accessor and cattr_accessor will
|
6
|
+
# not be overridden in your Rails app if Quiet Backtrace is installed.
|
7
|
+
#
|
2
8
|
# Copyright (c) 2005-2006 David Heinemeier Hansson
|
3
9
|
#
|
4
10
|
# Permission is hereby granted, free of charge, to any person obtaining
|
@@ -24,100 +30,102 @@
|
|
24
30
|
#
|
25
31
|
# Extends the module object with module and instance accessors for class attributes,
|
26
32
|
# just like the native attr* accessors for instance attributes.
|
27
|
-
|
28
|
-
|
29
|
-
syms
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
@@#{sym}
|
34
|
-
|
33
|
+
unless defined?(ActiveSupport)
|
34
|
+
class Module # :nodoc:
|
35
|
+
def mattr_reader(*syms)
|
36
|
+
syms.each do |sym|
|
37
|
+
next if sym.is_a?(Hash)
|
38
|
+
class_eval(<<-EOS, __FILE__, __LINE__)
|
39
|
+
unless defined? @@#{sym}
|
40
|
+
@@#{sym} = nil
|
41
|
+
end
|
35
42
|
|
36
|
-
|
37
|
-
|
38
|
-
|
43
|
+
def self.#{sym}
|
44
|
+
@@#{sym}
|
45
|
+
end
|
39
46
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
47
|
+
def #{sym}
|
48
|
+
@@#{sym}
|
49
|
+
end
|
50
|
+
EOS
|
51
|
+
end
|
44
52
|
end
|
45
|
-
end
|
46
53
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
+
def mattr_writer(*syms)
|
55
|
+
options = syms.last.is_a?(Hash) ? syms.pop : {}
|
56
|
+
syms.each do |sym|
|
57
|
+
class_eval(<<-EOS, __FILE__, __LINE__)
|
58
|
+
unless defined? @@#{sym}
|
59
|
+
@@#{sym} = nil
|
60
|
+
end
|
54
61
|
|
55
|
-
|
56
|
-
|
57
|
-
|
62
|
+
def self.#{sym}=(obj)
|
63
|
+
@@#{sym} = obj
|
64
|
+
end
|
58
65
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
66
|
+
#{"
|
67
|
+
def #{sym}=(obj)
|
68
|
+
@@#{sym} = obj
|
69
|
+
end
|
70
|
+
" unless options[:instance_writer] == false }
|
71
|
+
EOS
|
72
|
+
end
|
65
73
|
end
|
66
|
-
end
|
67
74
|
|
68
|
-
|
69
|
-
|
70
|
-
|
75
|
+
def mattr_accessor(*syms)
|
76
|
+
mattr_reader(*syms)
|
77
|
+
mattr_writer(*syms)
|
78
|
+
end
|
71
79
|
end
|
72
|
-
end
|
73
80
|
|
74
|
-
# activesupport/lib/activesupport/core_ext/class/attribute_accessors.rb
|
81
|
+
# activesupport/lib/activesupport/core_ext/class/attribute_accessors.rb
|
75
82
|
|
76
|
-
# Extends the class object with class and instance accessors for class attributes,
|
77
|
-
# just like the native attr* accessors for instance attributes.
|
78
|
-
class Class # :nodoc:
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
83
|
+
# Extends the class object with class and instance accessors for class attributes,
|
84
|
+
# just like the native attr* accessors for instance attributes.
|
85
|
+
class Class # :nodoc:
|
86
|
+
def cattr_reader(*syms)
|
87
|
+
syms.flatten.each do |sym|
|
88
|
+
next if sym.is_a?(Hash)
|
89
|
+
class_eval(<<-EOS, __FILE__, __LINE__)
|
90
|
+
unless defined? @@#{sym}
|
91
|
+
@@#{sym} = nil
|
92
|
+
end
|
86
93
|
|
87
|
-
|
88
|
-
|
89
|
-
|
94
|
+
def self.#{sym}
|
95
|
+
@@#{sym}
|
96
|
+
end
|
90
97
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
98
|
+
def #{sym}
|
99
|
+
@@#{sym}
|
100
|
+
end
|
101
|
+
EOS
|
102
|
+
end
|
95
103
|
end
|
96
|
-
end
|
97
104
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
+
def cattr_writer(*syms)
|
106
|
+
options = syms.last.is_a?(Hash) ? syms.pop : {}
|
107
|
+
syms.flatten.each do |sym|
|
108
|
+
class_eval(<<-EOS, __FILE__, __LINE__)
|
109
|
+
unless defined? @@#{sym}
|
110
|
+
@@#{sym} = nil
|
111
|
+
end
|
105
112
|
|
106
|
-
|
107
|
-
|
108
|
-
|
113
|
+
def self.#{sym}=(obj)
|
114
|
+
@@#{sym} = obj
|
115
|
+
end
|
109
116
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
117
|
+
#{"
|
118
|
+
def #{sym}=(obj)
|
119
|
+
@@#{sym} = obj
|
120
|
+
end
|
121
|
+
" unless options[:instance_writer] == false }
|
122
|
+
EOS
|
123
|
+
end
|
116
124
|
end
|
117
|
-
end
|
118
125
|
|
119
|
-
|
120
|
-
|
121
|
-
|
126
|
+
def cattr_accessor(*syms)
|
127
|
+
cattr_reader(*syms)
|
128
|
+
cattr_writer(*syms)
|
129
|
+
end
|
122
130
|
end
|
123
131
|
end
|
metadata
CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: quietbacktrace
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0
|
6
|
+
version: 0.1.0
|
7
7
|
date: 2007-12-03 00:00:00 -05:00
|
8
8
|
summary: quiet_backtrace suppresses the noise in your Test::Unit backtrace. It also provides hooks for you to add additional filters.
|
9
9
|
require_paths:
|
@@ -33,7 +33,6 @@ files:
|
|
33
33
|
- Manifest.txt
|
34
34
|
- README.txt
|
35
35
|
- Rakefile
|
36
|
-
- bin/quietbacktrace
|
37
36
|
- init.rb
|
38
37
|
- lib/aliasing.rb
|
39
38
|
- lib/attribute_accessors.rb
|
@@ -48,8 +47,8 @@ extra_rdoc_files:
|
|
48
47
|
- History.txt
|
49
48
|
- Manifest.txt
|
50
49
|
- README.txt
|
51
|
-
executables:
|
52
|
-
|
50
|
+
executables: []
|
51
|
+
|
53
52
|
extensions: []
|
54
53
|
|
55
54
|
requirements: []
|
data/bin/quietbacktrace
DELETED
File without changes
|