kerryb-right_aws 1.7.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.
@@ -0,0 +1,111 @@
1
+ # If ActiveSupport is loaded, then great - use it. But we don't
2
+ # want a dependency on it, so if it's not present, define the few
3
+ # extensions that we want to use...
4
+ unless defined? ActiveSupport::CoreExtensions
5
+ # These are ActiveSupport-;like extensions to do a few handy things in the gems
6
+ # Derived from ActiveSupport, so the AS copyright notice applies:
7
+ #
8
+ #
9
+ #
10
+ # Copyright (c) 2005 David Heinemeier Hansson
11
+ #
12
+ # Permission is hereby granted, free of charge, to any person obtaining
13
+ # a copy of this software and associated documentation files (the
14
+ # "Software"), to deal in the Software without restriction, including
15
+ # without limitation the rights to use, copy, modify, merge, publish,
16
+ # distribute, sublicense, and/or sell copies of the Software, and to
17
+ # permit persons to whom the Software is furnished to do so, subject to
18
+ # the following conditions:
19
+ #
20
+ # The above copyright notice and this permission notice shall be
21
+ # included in all copies or substantial portions of the Software.
22
+ #
23
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
+ #++
31
+ #
32
+ #
33
+ class String #:nodoc:
34
+
35
+ # Constantize tries to find a declared constant with the name specified
36
+ # in the string. It raises a NameError when the name is not in CamelCase
37
+ # or is not initialized.
38
+ #
39
+ # Examples
40
+ # "Module".constantize #=> Module
41
+ # "Class".constantize #=> Class
42
+ def constantize()
43
+ unless /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/ =~ self
44
+ raise NameError, "#{self.inspect} is not a valid constant name!"
45
+ end
46
+
47
+ Object.module_eval("::#{$1}", __FILE__, __LINE__)
48
+ end
49
+
50
+ end
51
+
52
+
53
+ class Object #:nodoc:
54
+ # "", " ", nil, [], and {} are blank
55
+ def blank?
56
+ if respond_to?(:empty?) && respond_to?(:strip)
57
+ empty? or strip.empty?
58
+ elsif respond_to?(:empty?)
59
+ empty?
60
+ else
61
+ !self
62
+ end
63
+ end
64
+ end
65
+
66
+ class NilClass #:nodoc:
67
+ def blank?
68
+ true
69
+ end
70
+ end
71
+
72
+ class FalseClass #:nodoc:
73
+ def blank?
74
+ true
75
+ end
76
+ end
77
+
78
+ class TrueClass #:nodoc:
79
+ def blank?
80
+ false
81
+ end
82
+ end
83
+
84
+ class Array #:nodoc:
85
+ alias_method :blank?, :empty?
86
+ end
87
+
88
+ class Hash #:nodoc:
89
+ alias_method :blank?, :empty?
90
+
91
+ # Return a new hash with all keys converted to symbols.
92
+ def symbolize_keys
93
+ inject({}) do |options, (key, value)|
94
+ options[key.to_sym] = value
95
+ options
96
+ end
97
+ end
98
+ end
99
+
100
+ class String #:nodoc:
101
+ def blank?
102
+ empty? || strip.empty?
103
+ end
104
+ end
105
+
106
+ class Numeric #:nodoc:
107
+ def blank?
108
+ false
109
+ end
110
+ end
111
+ end