cmeiklejohn-aws 2.3.8

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,119 @@
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
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
+ camel_cased_word = self
44
+ names = camel_cased_word.split('::')
45
+ names.shift if names.empty? || names.first.empty?
46
+
47
+ constant = Object
48
+ names.each do |name|
49
+ if Module.method(:const_get).arity == 1
50
+ constant = constant.const_get(name) || constant.const_missing(name)
51
+ else
52
+ constant = constant.const_get(name, false) || constant.const_missing(name)
53
+ end
54
+ end
55
+ constant
56
+ end
57
+
58
+ end
59
+
60
+
61
+ class Object #:nodoc:
62
+ # "", " ", nil, [], and {} are blank
63
+ def blank?
64
+ if respond_to?(:empty?) && respond_to?(:strip)
65
+ empty? or strip.empty?
66
+ elsif respond_to?(:empty?)
67
+ empty?
68
+ else
69
+ !self
70
+ end
71
+ end
72
+ end
73
+
74
+ class NilClass #:nodoc:
75
+ def blank?
76
+ true
77
+ end
78
+ end
79
+
80
+ class FalseClass #:nodoc:
81
+ def blank?
82
+ true
83
+ end
84
+ end
85
+
86
+ class TrueClass #:nodoc:
87
+ def blank?
88
+ false
89
+ end
90
+ end
91
+
92
+ class Array #:nodoc:
93
+ alias_method :blank?, :empty?
94
+ end
95
+
96
+ class Hash #:nodoc:
97
+ alias_method :blank?, :empty?
98
+
99
+ # Return a new hash with all keys converted to symbols.
100
+ def symbolize_keys
101
+ inject({}) do |options, (key, value)|
102
+ options[key.to_sym] = value
103
+ options
104
+ end
105
+ end
106
+ end
107
+
108
+ class String #:nodoc:
109
+ def blank?
110
+ empty? || strip.empty?
111
+ end
112
+ end
113
+
114
+ class Numeric #:nodoc:
115
+ def blank?
116
+ false
117
+ end
118
+ end
119
+ end