friendly_extensions 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/app/helpers/friends_forms_helper.rb +27 -0
- data/app/helpers/friends_labeled_form_helper.rb +124 -0
- data/app/models/friends_label.rb +22 -0
- data/config/initializers/values.rb +24 -0
- data/db/migrate/20140326005600_create_labels.rb +13 -0
- data/lib/alphanumeric.rb +76 -0
- data/lib/array.rb +280 -0
- data/lib/boolean.rb +32 -0
- data/lib/chars_2_remove.rb +349 -0
- data/lib/date_n_time.rb +198 -0
- data/lib/friendly_extensions/engine.rb +10 -0
- data/lib/friendly_extensions.rb +17 -0
- data/lib/hash.rb +38 -0
- data/lib/nil_class.rb +12 -0
- data/lib/numbers.rb +180 -0
- data/lib/smart_currency.rb +66 -0
- data/lib/string_and_more.rb +301 -0
- data/test/array_test.rb +213 -0
- data/test/array_test.rb.orig +221 -0
- data/test/dummy_class.rb +36 -0
- data/test/hash_test.rb +46 -0
- data/test/numeric_test.rb +94 -0
- data/test/numeric_test.rb.orig +94 -0
- data/test/string_test.rb +56 -0
- metadata +89 -0
@@ -0,0 +1,349 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
# Lists of character replacements like ASCII and HTML entities
|
3
|
+
module Chars2Remove
|
4
|
+
|
5
|
+
# List with internation chars and their ASCII replacement
|
6
|
+
CHARS = {
|
7
|
+
"¡" => "",
|
8
|
+
"&" => "",
|
9
|
+
"¢" => "",
|
10
|
+
"£" => "",
|
11
|
+
"¤" => "",
|
12
|
+
"¥" => "",
|
13
|
+
"¦" => "",
|
14
|
+
"§" => "",
|
15
|
+
"¨" => "",
|
16
|
+
"©" => "(C)",
|
17
|
+
"ª" => "",
|
18
|
+
"«" => "<",
|
19
|
+
"¬" => "-",
|
20
|
+
"" => "-",
|
21
|
+
"®" => "(R)",
|
22
|
+
"¯" => "",
|
23
|
+
"°" => "",
|
24
|
+
"±" => "",
|
25
|
+
"²" => "",
|
26
|
+
"³" => "",
|
27
|
+
"´" => "",
|
28
|
+
"µ" => "n",
|
29
|
+
"¶" => "",
|
30
|
+
"·" => "",
|
31
|
+
"¸" => "",
|
32
|
+
"¹" => "",
|
33
|
+
"º" => "",
|
34
|
+
"»" => ">",
|
35
|
+
"¼" => "",
|
36
|
+
"½" => "",
|
37
|
+
"¾" => "",
|
38
|
+
"¿" => "?",
|
39
|
+
"Ä" => "Ae",
|
40
|
+
"À" => "A",
|
41
|
+
"Á" => "A",
|
42
|
+
"Â" => "A",
|
43
|
+
"Ã" => "A",
|
44
|
+
"Å" => "A",
|
45
|
+
"Æ" => "Ae",
|
46
|
+
"Ç" => "C",
|
47
|
+
"È" => "E",
|
48
|
+
"É" => "E",
|
49
|
+
"Ê" => "E",
|
50
|
+
"Ë" => "E",
|
51
|
+
"Ì" => "I",
|
52
|
+
"Í" => "I",
|
53
|
+
"Î" => "I",
|
54
|
+
"Ï" => "I",
|
55
|
+
"Ð" => "D",
|
56
|
+
"Ñ" => "N",
|
57
|
+
"Ö" => "Oe",
|
58
|
+
"Ò" => "O",
|
59
|
+
"Ó" => "O",
|
60
|
+
"Ô" => "O",
|
61
|
+
"Õ" => "O",
|
62
|
+
"×" => "x",
|
63
|
+
"Ø" => "Oe",
|
64
|
+
"Ü" => "Ue",
|
65
|
+
"Ù" => "U",
|
66
|
+
"Ú" => "U",
|
67
|
+
"Û" => "U",
|
68
|
+
"Ý" => "y",
|
69
|
+
"Þ" => "p",
|
70
|
+
"ä" => "ae",
|
71
|
+
"ö" => "oe",
|
72
|
+
"ü" => "ue",
|
73
|
+
"ß" => "ss",
|
74
|
+
"à" => "a",
|
75
|
+
"á" => "a",
|
76
|
+
"â" => "a",
|
77
|
+
"ã" => "a",
|
78
|
+
"å" => "a",
|
79
|
+
"æ" => "ae",
|
80
|
+
"ç" => "c",
|
81
|
+
"è" => "e",
|
82
|
+
"é" => "e",
|
83
|
+
"ê" => "e",
|
84
|
+
"ë" => "e",
|
85
|
+
"ì" => "i",
|
86
|
+
"í" => "i",
|
87
|
+
"î" => "i",
|
88
|
+
"ï" => "i",
|
89
|
+
"ð" => "o",
|
90
|
+
"ñ" => "n",
|
91
|
+
"ò" => "o",
|
92
|
+
"ó" => "o",
|
93
|
+
"ô" => "o",
|
94
|
+
"õ" => "o",
|
95
|
+
"÷" => "x",
|
96
|
+
"ø" => "o",
|
97
|
+
"ù" => "u",
|
98
|
+
"ú" => "u",
|
99
|
+
"û" => "u",
|
100
|
+
"ý" => "y",
|
101
|
+
"þ" => "y",
|
102
|
+
"ÿ" => "y"
|
103
|
+
}
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
# These charaters mustn't be removed in HTML mode!
|
108
|
+
# All HTML Entities
|
109
|
+
ENTITIES = {
|
110
|
+
'Â' => {:html => 'Â' , :dec => 'Â' , :hex => 'Â' },
|
111
|
+
'â' => {:html => 'â' , :dec => 'â' , :hex => 'â' },
|
112
|
+
'´' => {:html => '´' , :dec => '´' , :hex => '´' },
|
113
|
+
'Æ' => {:html => 'Æ' , :dec => 'Æ' , :hex => 'Æ' },
|
114
|
+
'æ' => {:html => 'æ' , :dec => 'æ' , :hex => 'æ' },
|
115
|
+
'À' => {:html => 'À' , :dec => 'À' , :hex => 'À' },
|
116
|
+
'à' => {:html => 'à' , :dec => 'à' , :hex => 'à' },
|
117
|
+
'ℵ' => {:html => 'ℵ' , :dec => 'ℵ' , :hex => 'ℵ' },
|
118
|
+
'Α' => {:html => 'Α' , :dec => 'Α' , :hex => 'Α' },
|
119
|
+
'α' => {:html => 'α' , :dec => 'α' , :hex => 'α' },
|
120
|
+
'∧' => {:html => '∧' , :dec => '∧' , :hex => '∧' },
|
121
|
+
'∠' => {:html => '∠' , :dec => '∠' , :hex => '∠' },
|
122
|
+
'Å' => {:html => 'Å' , :dec => 'Å' , :hex => 'Å' },
|
123
|
+
'å' => {:html => 'å' , :dec => 'å' , :hex => 'å' },
|
124
|
+
'≈' => {:html => '≈' , :dec => '≈' , :hex => '≈' },
|
125
|
+
'Ã' => {:html => 'Ã' , :dec => 'Ã' , :hex => 'Ã' },
|
126
|
+
'ã' => {:html => 'ã' , :dec => 'ã' , :hex => 'ã' },
|
127
|
+
'Ä' => {:html => 'Ä' , :dec => 'Ä' , :hex => 'Ä' },
|
128
|
+
'ä' => {:html => 'ä' , :dec => 'ä' , :hex => 'ä' },
|
129
|
+
'„' => {:html => '„' , :dec => '„' , :hex => '„' },
|
130
|
+
'Β' => {:html => 'Β' , :dec => 'Β' , :hex => 'Β' },
|
131
|
+
'β' => {:html => 'β' , :dec => 'β' , :hex => 'β' },
|
132
|
+
'¦' => {:html => '¦' , :dec => '¦' , :hex => '¦' },
|
133
|
+
'•' => {:html => '•' , :dec => '•' , :hex => '•' },
|
134
|
+
'∩' => {:html => '∩' , :dec => '∩' , :hex => '∩' },
|
135
|
+
'Ç' => {:html => 'Ç' , :dec => 'Ç' , :hex => 'Ç' },
|
136
|
+
'ç' => {:html => 'ç' , :dec => 'ç' , :hex => 'ç' },
|
137
|
+
'¸' => {:html => '¸' , :dec => '¸' , :hex => '¸' },
|
138
|
+
'¢' => {:html => '¢' , :dec => '¢' , :hex => '¢' },
|
139
|
+
'Χ' => {:html => 'Χ' , :dec => 'Χ' , :hex => 'Χ' },
|
140
|
+
'χ' => {:html => 'χ' , :dec => 'χ' , :hex => 'χ' },
|
141
|
+
'ˆ' => {:html => 'ˆ' , :dec => 'ˆ' , :hex => 'ˆ' },
|
142
|
+
'♣' => {:html => '♣' , :dec => '♣' , :hex => '♣' },
|
143
|
+
'≅' => {:html => '≅' , :dec => '≅' , :hex => '≅' },
|
144
|
+
'©' => {:html => '©' , :dec => '©' , :hex => '©' },
|
145
|
+
'↵' => {:html => '↵' , :dec => '↵' , :hex => '↵' },
|
146
|
+
'∪' => {:html => '∪' , :dec => '∪' , :hex => '∪' },
|
147
|
+
'¤' => {:html => '¤' , :dec => '¤' , :hex => '¤' },
|
148
|
+
'‡' => {:html => '‡' , :dec => '‡' , :hex => '‡' },
|
149
|
+
'†' => {:html => '†' , :dec => '†' , :hex => '†' },
|
150
|
+
'⇓' => {:html => '⇓' , :dec => '⇓' , :hex => '⇓' },
|
151
|
+
'↓' => {:html => '↓' , :dec => '↓' , :hex => '↓' },
|
152
|
+
'°' => {:html => '°' , :dec => '°' , :hex => '°' },
|
153
|
+
'Δ' => {:html => 'Δ' , :dec => 'Δ' , :hex => 'Δ' },
|
154
|
+
'δ' => {:html => 'δ' , :dec => 'δ' , :hex => 'δ' },
|
155
|
+
'♦' => {:html => '♦' , :dec => '&v#9830;', :hex => '♦' },
|
156
|
+
'÷' => {:html => '÷' , :dec => '÷' , :hex => '÷' },
|
157
|
+
'É' => {:html => 'É' , :dec => 'É' , :hex => 'É' },
|
158
|
+
'é' => {:html => 'é' , :dec => 'é' , :hex => 'é' },
|
159
|
+
'Ê' => {:html => 'Ê' , :dec => 'Ê' , :hex => 'Ê' },
|
160
|
+
'ê' => {:html => 'ê' , :dec => 'ê' , :hex => 'ê' },
|
161
|
+
'È' => {:html => 'È' , :dec => 'È' , :hex => 'È' },
|
162
|
+
'è' => {:html => 'è' , :dec => 'è' , :hex => 'è' },
|
163
|
+
'∅' => {:html => '∅' , :dec => '∅' , :hex => '∅' },
|
164
|
+
'Ε' => {:html => 'Ε' , :dec => 'Ε' , :hex => 'Ε' },
|
165
|
+
'ε' => {:html => 'ε' , :dec => 'ε' , :hex => 'ε' },
|
166
|
+
'≡' => {:html => '≡' , :dec => '≡' , :hex => '≡' },
|
167
|
+
'Η' => {:html => 'Η' , :dec => 'Η' , :hex => 'Η' },
|
168
|
+
'η' => {:html => 'η' , :dec => 'η' , :hex => 'η' },
|
169
|
+
'Ð' => {:html => 'Ð' , :dec => 'Ð' , :hex => 'Ð' },
|
170
|
+
'ð' => {:html => 'ð' , :dec => 'ð' , :hex => 'ð' },
|
171
|
+
'Ë' => {:html => 'Ë' , :dec => 'Ë' , :hex => 'Ë' },
|
172
|
+
'ë' => {:html => 'ë' , :dec => 'ë' , :hex => 'ë' },
|
173
|
+
'€' => {:html => '€' , :dec => '€' , :hex => '€' },
|
174
|
+
'∃' => {:html => '∃' , :dec => '∃' , :hex => '∃' },
|
175
|
+
'ƒ' => {:html => 'ƒ' , :dec => 'ƒ' , :hex => 'ƒ' },
|
176
|
+
'∀' => {:html => '∀' , :dec => '∀' , :hex => '∀' },
|
177
|
+
'½' => {:html => '½' , :dec => '½' , :hex => '½' },
|
178
|
+
'¼' => {:html => '¼' , :dec => '¼' , :hex => '¼' },
|
179
|
+
'¾' => {:html => '¾' , :dec => '¾' , :hex => '¾' },
|
180
|
+
'Γ' => {:html => 'Γ' , :dec => 'Γ' , :hex => 'Γ' },
|
181
|
+
'γ' => {:html => 'γ' , :dec => 'γ' , :hex => 'γ' },
|
182
|
+
'≥' => {:html => '≥' , :dec => '≥' , :hex => '≥' },
|
183
|
+
'⇔' => {:html => '⇔' , :dec => '⇔' , :hex => '⇔' },
|
184
|
+
'↔' => {:html => '↔' , :dec => '↔' , :hex => '↔' },
|
185
|
+
'♥' => {:html => '♥' , :dec => '♥' , :hex => '♥' },
|
186
|
+
'…' => {:html => '…' , :dec => '…' , :hex => '…' },
|
187
|
+
'Í' => {:html => 'Í' , :dec => 'Í' , :hex => 'Í' },
|
188
|
+
'í' => {:html => 'í' , :dec => 'í' , :hex => 'í' },
|
189
|
+
'Î' => {:html => 'Î' , :dec => 'Î' , :hex => 'Î' },
|
190
|
+
'î' => {:html => 'î' , :dec => 'î' , :hex => 'î' },
|
191
|
+
'¡' => {:html => '¡' , :dec => '¡' , :hex => '¡' },
|
192
|
+
'Ì' => {:html => 'Ì' , :dec => 'Ì' , :hex => 'Ì' },
|
193
|
+
'ì' => {:html => 'ì' , :dec => 'ì' , :hex => 'ì' },
|
194
|
+
'ℑ' => {:html => 'ℑ' , :dec => 'ℑ' , :hex => 'ℑ' },
|
195
|
+
'∞' => {:html => '∞' , :dec => '∞' , :hex => '∞' },
|
196
|
+
'∫' => {:html => '∫' , :dec => '∫' , :hex => '∫' },
|
197
|
+
'Ι' => {:html => 'Ι' , :dec => 'Ι' , :hex => 'Ι' },
|
198
|
+
'ι' => {:html => 'ι' , :dec => 'ι' , :hex => 'ι' },
|
199
|
+
'¿' => {:html => '¿' , :dec => '¿' , :hex => '¿' },
|
200
|
+
'∈' => {:html => '∈' , :dec => '∈' , :hex => '∈' },
|
201
|
+
'Ï' => {:html => 'Ï' , :dec => 'Ï' , :hex => 'Ï' },
|
202
|
+
'ï' => {:html => 'ï' , :dec => 'ï' , :hex => 'ï' },
|
203
|
+
'Κ' => {:html => 'Κ' , :dec => 'Κ' , :hex => 'Κ' },
|
204
|
+
'κ' => {:html => 'κ' , :dec => 'κ' , :hex => 'κ' },
|
205
|
+
'Λ' => {:html => 'Λ' , :dec => 'Λ' , :hex => 'Λ' },
|
206
|
+
'λ' => {:html => 'λ' , :dec => 'λ' , :hex => 'λ' },
|
207
|
+
'⟨' => {:html => '⟨' , :dec => '〈' , :hex => '〈' },
|
208
|
+
'«' => {:html => '«' , :dec => '«' , :hex => '«' },
|
209
|
+
'⇐' => {:html => '⇐' , :dec => '⇐' , :hex => '⇐' },
|
210
|
+
'←' => {:html => '←' , :dec => '←' , :hex => '←' },
|
211
|
+
'⌈' => {:html => '⌈' , :dec => '⌈' , :hex => '⌈' },
|
212
|
+
'“' => {:html => '“' , :dec => '“' , :hex => '“' },
|
213
|
+
'≤' => {:html => '≤' , :dec => '≤' , :hex => '≤' },
|
214
|
+
'⌊' => {:html => '⌊' , :dec => '⌊' , :hex => '⌊' },
|
215
|
+
'∗' => {:html => '∗' , :dec => '∗' , :hex => '∗' },
|
216
|
+
'◊' => {:html => '◊' , :dec => '◊' , :hex => '◊' },
|
217
|
+
'‹' => {:html => '‹' , :dec => '‹' , :hex => '‹' },
|
218
|
+
'‘' => {:html => '‘' , :dec => '‘' , :hex => '‘' },
|
219
|
+
'¯' => {:html => '¯' , :dec => '¯' , :hex => '¯' },
|
220
|
+
'—' => {:html => '—' , :dec => '—' , :hex => '—' },
|
221
|
+
'µ' => {:html => 'µ' , :dec => 'µ' , :hex => 'µ' },
|
222
|
+
'·' => {:html => '·' , :dec => '·' , :hex => '·' },
|
223
|
+
'−' => {:html => '−' , :dec => '−' , :hex => '−' },
|
224
|
+
'Μ' => {:html => 'Μ' , :dec => 'Μ' , :hex => 'Μ' },
|
225
|
+
'μ' => {:html => 'μ' , :dec => 'μ' , :hex => 'μ' },
|
226
|
+
'∇' => {:html => '∇' , :dec => '∇' , :hex => '∇' },
|
227
|
+
'–' => {:html => '–' , :dec => '–' , :hex => '–' },
|
228
|
+
'≠' => {:html => '≠' , :dec => '≠' , :hex => '≠' },
|
229
|
+
'∋' => {:html => '∋' , :dec => '∋' , :hex => '∋' },
|
230
|
+
'¬' => {:html => '¬' , :dec => '¬' , :hex => '¬' },
|
231
|
+
'∉' => {:html => '∉' , :dec => '∉' , :hex => '∉' },
|
232
|
+
'⊄' => {:html => '⊄' , :dec => '⊄' , :hex => '⊄' },
|
233
|
+
'Ñ' => {:html => 'Ñ' , :dec => 'Ñ' , :hex => 'Ñ' },
|
234
|
+
'ñ' => {:html => 'ñ' , :dec => 'ñ' , :hex => 'ñ' },
|
235
|
+
'Ν' => {:html => 'Ν' , :dec => 'Ν' , :hex => 'Ν' },
|
236
|
+
'ν' => {:html => 'ν' , :dec => 'ν' , :hex => 'ν' },
|
237
|
+
'Ó' => {:html => 'Ó' , :dec => 'Ó' , :hex => 'Ó' },
|
238
|
+
'ó' => {:html => 'ó' , :dec => 'ó' , :hex => 'ó' },
|
239
|
+
'Ô' => {:html => 'Ô' , :dec => 'Ô' , :hex => 'Ô' },
|
240
|
+
'ô' => {:html => 'ô' , :dec => 'ô' , :hex => 'ô' },
|
241
|
+
'Œ' => {:html => 'Œ' , :dec => 'Œ' , :hex => 'Œ' },
|
242
|
+
'œ' => {:html => 'œ' , :dec => 'œ' , :hex => 'œ' },
|
243
|
+
'Ò' => {:html => 'Ò' , :dec => 'Ò' , :hex => 'Ò' },
|
244
|
+
'ò' => {:html => 'ò' , :dec => 'ò' , :hex => 'ò' },
|
245
|
+
'‾' => {:html => '‾' , :dec => '‾' , :hex => '‾' },
|
246
|
+
'Ω' => {:html => 'Ω' , :dec => 'Ω' , :hex => 'Ω' },
|
247
|
+
'ω' => {:html => 'ω' , :dec => 'ω' , :hex => 'ω' },
|
248
|
+
'Ο' => {:html => 'Ο' , :dec => 'Ο' , :hex => 'Ο' },
|
249
|
+
'ο' => {:html => 'ο' , :dec => 'ο' , :hex => 'ο' },
|
250
|
+
'⊕' => {:html => '⊕' , :dec => '⊕' , :hex => '⊕' },
|
251
|
+
'∨' => {:html => '∨' , :dec => '∨' , :hex => '∨' },
|
252
|
+
'ª' => {:html => 'ª' , :dec => 'ª' , :hex => 'ª' },
|
253
|
+
'º' => {:html => 'º' , :dec => 'º' , :hex => 'º' },
|
254
|
+
'Ø' => {:html => 'Ø' , :dec => 'Ø' , :hex => 'Ø' },
|
255
|
+
'ø' => {:html => 'ø' , :dec => 'ø' , :hex => 'ø' },
|
256
|
+
'Õ' => {:html => 'Õ' , :dec => 'Õ' , :hex => 'Õ' },
|
257
|
+
'õ' => {:html => 'õ' , :dec => 'õ' , :hex => 'õ' },
|
258
|
+
'⊗' => {:html => '⊗' , :dec => '⊗' , :hex => '⊗' },
|
259
|
+
'Ö' => {:html => 'Ö' , :dec => 'Ö' , :hex => 'Ö' },
|
260
|
+
'ö' => {:html => 'ö' , :dec => 'ö' , :hex => 'ö' },
|
261
|
+
'¶' => {:html => '¶' , :dec => '¶' , :hex => '¶' },
|
262
|
+
'∂' => {:html => '∂' , :dec => '∂' , :hex => '∂' },
|
263
|
+
'‰' => {:html => '‰' , :dec => '‰' , :hex => '‰' },
|
264
|
+
'⊥' => {:html => '⊥' , :dec => '⊥' , :hex => '⊥' },
|
265
|
+
'Φ' => {:html => 'Φ' , :dec => 'Φ' , :hex => 'Φ' },
|
266
|
+
'φ' => {:html => 'φ' , :dec => 'φ' , :hex => 'φ' },
|
267
|
+
'Π' => {:html => 'Π' , :dec => 'Π' , :hex => 'Π' },
|
268
|
+
'π' => {:html => 'π' , :dec => 'π' , :hex => 'π' },
|
269
|
+
'ϖ' => {:html => 'ϖ' , :dec => 'ϖ' , :hex => 'ϖ' },
|
270
|
+
'±' => {:html => '±' , :dec => '±' , :hex => '±' },
|
271
|
+
'£' => {:html => '£' , :dec => '£' , :hex => '£' },
|
272
|
+
'″' => {:html => '″' , :dec => '″' , :hex => '″' },
|
273
|
+
'′' => {:html => '′' , :dec => '′' , :hex => '′' },
|
274
|
+
'∏' => {:html => '∏' , :dec => '∏' , :hex => '∏' },
|
275
|
+
'∝' => {:html => '∝' , :dec => '∝' , :hex => '∝' },
|
276
|
+
'Ψ' => {:html => 'Ψ' , :dec => 'Ψ' , :hex => 'Ψ' },
|
277
|
+
'ψ' => {:html => 'ψ' , :dec => 'ψ' , :hex => 'ψ' },
|
278
|
+
'√' => {:html => '√' , :dec => '√' , :hex => '√' },
|
279
|
+
'⟩' => {:html => '⟩' , :dec => '〉' , :hex => '〉' },
|
280
|
+
'»' => {:html => '»' , :dec => '»' , :hex => '»' },
|
281
|
+
'⇒' => {:html => '⇒' , :dec => '⇒' , :hex => '⇒' },
|
282
|
+
'→' => {:html => '→' , :dec => '→' , :hex => '→' },
|
283
|
+
'⌉' => {:html => '⌉' , :dec => '⌉' , :hex => '⌉' },
|
284
|
+
'”' => {:html => '”' , :dec => '”' , :hex => '”' },
|
285
|
+
'ℜ' => {:html => 'ℜ' , :dec => 'ℜ' , :hex => 'ℜ' },
|
286
|
+
'®' => {:html => '®' , :dec => '®' , :hex => '®' },
|
287
|
+
'⌋' => {:html => '⌋' , :dec => '⌋' , :hex => '⌋' },
|
288
|
+
'Ρ' => {:html => 'Ρ' , :dec => 'Ρ' , :hex => 'Ρ' },
|
289
|
+
'ρ' => {:html => 'ρ' , :dec => 'ρ' , :hex => 'ρ' },
|
290
|
+
'›' => {:html => '›' , :dec => '›' , :hex => '›' },
|
291
|
+
'’' => {:html => '’' , :dec => '’' , :hex => '’' },
|
292
|
+
'‚' => {:html => '‚' , :dec => '‚' , :hex => '‚' },
|
293
|
+
'Š' => {:html => 'Š' , :dec => 'Š' , :hex => 'Š' },
|
294
|
+
'š' => {:html => 'š' , :dec => 'š' , :hex => 'š' },
|
295
|
+
'⋅' => {:html => '⋅' , :dec => '⋅' , :hex => '⋅' },
|
296
|
+
'§' => {:html => '§' , :dec => '§' , :hex => '§' },
|
297
|
+
'Σ' => {:html => 'Σ' , :dec => 'Σ' , :hex => 'Σ' },
|
298
|
+
'σ' => {:html => 'σ' , :dec => 'σ' , :hex => 'σ' },
|
299
|
+
'ς' => {:html => 'ς' , :dec => 'ς' , :hex => 'ς' },
|
300
|
+
'∼' => {:html => '∼' , :dec => '∼' , :hex => '∼' },
|
301
|
+
'♠' => {:html => '♠' , :dec => '♠' , :hex => '♠' },
|
302
|
+
'⊂' => {:html => '⊂' , :dec => '⊂' , :hex => '⊂' },
|
303
|
+
'⊆' => {:html => '⊆' , :dec => '⊆' , :hex => '⊆' },
|
304
|
+
'∑' => {:html => '∑' , :dec => '∑' , :hex => '∑' },
|
305
|
+
'⊃' => {:html => '⊃' , :dec => '⊃' , :hex => '⊃' },
|
306
|
+
'¹' => {:html => '¹' , :dec => '¹' , :hex => '¹' },
|
307
|
+
'²' => {:html => '²' , :dec => '²' , :hex => '²' },
|
308
|
+
'³' => {:html => '³' , :dec => '³' , :hex => '³' },
|
309
|
+
'⊇' => {:html => '⊇' , :dec => '⊇' , :hex => '⊇' },
|
310
|
+
'ß' => {:html => 'ß' , :dec => 'ß' , :hex => 'ß' },
|
311
|
+
'Τ' => {:html => 'Τ' , :dec => 'Τ' , :hex => 'Τ' },
|
312
|
+
'τ' => {:html => 'τ' , :dec => 'τ' , :hex => 'τ' },
|
313
|
+
'∴' => {:html => '∴' , :dec => '∴' , :hex => '∴' },
|
314
|
+
'Θ' => {:html => 'Θ' , :dec => 'Θ' , :hex => 'Θ' },
|
315
|
+
'θ' => {:html => 'θ' , :dec => 'θ' , :hex => 'θ' },
|
316
|
+
'ϑ' => {:html => 'ϑ' , :dec => 'ϑ' , :hex => 'ϑ' },
|
317
|
+
'Þ' => {:html => 'Þ' , :dec => 'Þ' , :hex => 'Þ' },
|
318
|
+
'þ' => {:html => 'þ' , :dec => 'þ' , :hex => 'þ' },
|
319
|
+
'˜' => {:html => '˜' , :dec => '˜' , :hex => '˜' },
|
320
|
+
'×' => {:html => '×' , :dec => '×' , :hex => '×' },
|
321
|
+
'™' => {:html => '™' , :dec => '™' , :hex => '™' },
|
322
|
+
'Ú' => {:html => 'Ú' , :dec => 'Ú' , :hex => 'Ú' },
|
323
|
+
'ú' => {:html => 'ú' , :dec => 'ú' , :hex => 'ú' },
|
324
|
+
'⇑' => {:html => '⇑' , :dec => '⇑' , :hex => '⇑' },
|
325
|
+
'↑' => {:html => '↑' , :dec => '↑' , :hex => '↑' },
|
326
|
+
'Û' => {:html => 'Û' , :dec => 'Û' , :hex => 'Û' },
|
327
|
+
'û' => {:html => 'û' , :dec => 'û' , :hex => 'û' },
|
328
|
+
'Ù' => {:html => 'Ù' , :dec => 'Ù' , :hex => 'Ù' },
|
329
|
+
'ù' => {:html => 'ù' , :dec => 'ù' , :hex => 'ù' },
|
330
|
+
'¨' => {:html => '¨' , :dec => '¨' , :hex => '¨' },
|
331
|
+
'ϒ' => {:html => 'ϒ' , :dec => 'ϒ' , :hex => 'ϒ' },
|
332
|
+
'Υ' => {:html => 'Υ' , :dec => 'Υ' , :hex => 'Υ' },
|
333
|
+
'υ' => {:html => 'υ' , :dec => 'υ' , :hex => 'υ' },
|
334
|
+
'Ü' => {:html => 'Ü' , :dec => 'Ü' , :hex => 'Ü' },
|
335
|
+
'ü' => {:html => 'ü' , :dec => 'ü' , :hex => 'ü' },
|
336
|
+
'℘' => {:html => '℘' , :dec => '℘' , :hex => '℘' },
|
337
|
+
'Ξ' => {:html => 'Ξ' , :dec => 'Ξ' , :hex => 'Ξ' },
|
338
|
+
'ξ' => {:html => 'ξ' , :dec => 'ξ' , :hex => 'ξ' },
|
339
|
+
'Ý' => {:html => 'Ý' , :dec => 'Ý' , :hex => 'Ý' },
|
340
|
+
'ý' => {:html => 'ý' , :dec => 'ý' , :hex => 'ý' },
|
341
|
+
'¥' => {:html => '¥' , :dec => '¥' , :hex => '¥' },
|
342
|
+
'Ÿ' => {:html => 'Ÿ' , :dec => 'Ÿ' , :hex => 'Ÿ' },
|
343
|
+
'ÿ' => {:html => 'ÿ' , :dec => 'ÿ' , :hex => 'ÿ' },
|
344
|
+
'Ζ' => {:html => 'Ζ' , :dec => 'Ζ' , :hex => 'Ζ' },
|
345
|
+
'ζ' => {:html => 'ζ' , :dec => 'ζ' , :hex => 'ζ' }
|
346
|
+
}
|
347
|
+
|
348
|
+
|
349
|
+
end
|
data/lib/date_n_time.rb
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
# Extend Date, DateTime and Time
|
3
|
+
module DateNTime
|
4
|
+
Date.class_eval do
|
5
|
+
|
6
|
+
def self.new_from_params(p)
|
7
|
+
return Date.new(p["starts_at(1i)"].to_i, p["starts_at(2i)"].to_i, p["starts_at(3i)"].to_i)
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_short_stamp(options = {})
|
11
|
+
return self.strftime('%d%m%y')
|
12
|
+
end
|
13
|
+
|
14
|
+
# Return the current age base on a birthdate which is self
|
15
|
+
def age_calc
|
16
|
+
now = Time.now.to_date
|
17
|
+
now.year - self.year - (self.change(:year=>now.year)>now ? 1 : 0) #rescue 0
|
18
|
+
end
|
19
|
+
|
20
|
+
# return next month
|
21
|
+
def next_month
|
22
|
+
return self+1.month
|
23
|
+
end
|
24
|
+
|
25
|
+
# return previous month
|
26
|
+
def prev_month
|
27
|
+
return self-1.month
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_de(options = {})
|
31
|
+
self.strftime('%d.%m.%Y')
|
32
|
+
end
|
33
|
+
|
34
|
+
def short_date
|
35
|
+
self.strftime('%d.%m.')
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_sql
|
39
|
+
self.strftime('%Y-%m-%d')
|
40
|
+
end
|
41
|
+
|
42
|
+
def month_name
|
43
|
+
MONTH_TO_VIEW[self.month] rescue self
|
44
|
+
end
|
45
|
+
|
46
|
+
def month_name_full
|
47
|
+
"#{MONTH_TO_VIEW[self.month]} #{self.year}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def month_label
|
51
|
+
self.strftime('%m/%Y')
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_i
|
55
|
+
self.to_s.gsub("-", "").to_i
|
56
|
+
end
|
57
|
+
|
58
|
+
def to_zodiac
|
59
|
+
zodiacs = {
|
60
|
+
[1, 1, 1, 20] => "Steinbock",
|
61
|
+
[1, 21, 2, 19] => "Wassermann",
|
62
|
+
[2, 20, 3, 20] => "Fische",
|
63
|
+
[3, 21, 4, 20] => "Widder",
|
64
|
+
[4, 21, 5, 21] => "Stier",
|
65
|
+
[5, 22, 6, 21] => "Zwilling",
|
66
|
+
[6, 22, 7, 22] => "Krebs",
|
67
|
+
[7, 23, 8, 21] => "Löwe",
|
68
|
+
[8, 22, 9, 23] => "Junfrau",
|
69
|
+
[9, 24, 10, 23] => "Wage",
|
70
|
+
[10, 24, 11, 22] => "Skorpion",
|
71
|
+
[11, 23, 12, 22] => "Schütze",
|
72
|
+
[12, 23, 12, 31] => "Steinbock"
|
73
|
+
}
|
74
|
+
|
75
|
+
zodiacs.each do |key, value|
|
76
|
+
date1 = Date.new(self.year, key[0], key[1])
|
77
|
+
date2 = Date.new(self.year, key[2], key[3])
|
78
|
+
if self >= date1 and self <= date2
|
79
|
+
return value
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.month_array(start_date, end_date)
|
86
|
+
dates_start = Date.new(start_date.year, start_date.month)
|
87
|
+
dates_end = Date.new(end_date.year, end_date.month)+1.month
|
88
|
+
|
89
|
+
dates_array = []
|
90
|
+
|
91
|
+
current_date = dates_start
|
92
|
+
while current_date < dates_end
|
93
|
+
sdate = current_date
|
94
|
+
edate = current_date+1.month - 1.second
|
95
|
+
|
96
|
+
dates_array << {:start_date => sdate, :end_date => edate}
|
97
|
+
|
98
|
+
current_date = current_date +1.month
|
99
|
+
end
|
100
|
+
return dates_array
|
101
|
+
end
|
102
|
+
|
103
|
+
def months_between(date2 = Time.now.to_date, options={:abs => true})
|
104
|
+
date1 = self
|
105
|
+
abs = 1
|
106
|
+
|
107
|
+
if date1.to_date > date2.to_date
|
108
|
+
abs = -1 if options[:abs] == false
|
109
|
+
recent_date = date1.to_date
|
110
|
+
past_date = date2.to_date
|
111
|
+
else
|
112
|
+
recent_date = date2.to_date
|
113
|
+
past_date = date1.to_date
|
114
|
+
end
|
115
|
+
|
116
|
+
return ((recent_date.month - past_date.month) + (12 * (recent_date.year - past_date.year))) * abs
|
117
|
+
end
|
118
|
+
|
119
|
+
# first day of current month
|
120
|
+
def first_of_month
|
121
|
+
Date.new(self.year, self.month)
|
122
|
+
end
|
123
|
+
|
124
|
+
def self.end_of_month(date = Date.new(Time.now.year, Time.now.month))
|
125
|
+
DateTime.end_of_month(date)
|
126
|
+
end
|
127
|
+
|
128
|
+
def self.prev_months(i=12)
|
129
|
+
dates = []
|
130
|
+
|
131
|
+
i.times do |x|
|
132
|
+
dates << Date.new(Time.now.year, Time.now.month)-(i-x).months
|
133
|
+
end
|
134
|
+
return dates
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.this_month
|
138
|
+
Date.new(Time.now.year, Time.now.month)
|
139
|
+
end
|
140
|
+
|
141
|
+
def self.next_month
|
142
|
+
self.this_month + 1.month
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
DateTime.class_eval do
|
148
|
+
|
149
|
+
def self.end_of_month(date = Date.new(Time.now.year, Time.now.month))
|
150
|
+
date = Date.new(date.year, date.month)
|
151
|
+
(date+1.month)-1.second
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
# sql-formatted string for datetime
|
156
|
+
def to_sql
|
157
|
+
self.strftime("%Y-%m-%d %H:%M:%S")
|
158
|
+
end
|
159
|
+
|
160
|
+
def months_between(date2 = Time.now.to_date, options={:abs => true})
|
161
|
+
self.to_date.months_between(date2, options)
|
162
|
+
end
|
163
|
+
|
164
|
+
def to_de(options = {})
|
165
|
+
if options[:only_time] == true
|
166
|
+
return self.strftime('%H:%M')
|
167
|
+
else
|
168
|
+
return self.strftime('%d.%m.%Y - %H:%M')
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def self.new_from_params(p)
|
173
|
+
return DateTime.new(p["starts_at(1i)"].to_i, p["starts_at(2i)"].to_i, p["starts_at(3i)"].to_i, p["starts_at(4i)"].to_i, p["starts_at(5i)"].to_i)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
Time.class_eval do
|
178
|
+
|
179
|
+
def self.end_of_month(date = Date.new(Time.now.year, Time.now.month))
|
180
|
+
DateTime.end_of_month(date)
|
181
|
+
end
|
182
|
+
|
183
|
+
# sql-formatted string for datetime
|
184
|
+
def to_sql
|
185
|
+
self.to_datetime.to_sql
|
186
|
+
end
|
187
|
+
|
188
|
+
def to_de(options = {})
|
189
|
+
if options[:only_time] == true
|
190
|
+
return self.strftime('%H:%M')
|
191
|
+
else
|
192
|
+
return self.strftime('%d.%m.%Y - %H:%M')
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
|
197
|
+
end
|
198
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
# All dit janze zeug laden
|
3
|
+
|
4
|
+
require "friendly_extensions/engine"
|
5
|
+
|
6
|
+
require "array"
|
7
|
+
require "date_n_time"
|
8
|
+
require "numbers"
|
9
|
+
require "hash"
|
10
|
+
require "string_and_more"
|
11
|
+
require "boolean"
|
12
|
+
require "nil_class"
|
13
|
+
|
14
|
+
# SmartCurrency jetzt auch hier (26.03.2013, 16:30, Florian Eck)
|
15
|
+
require 'smart_currency'
|
16
|
+
|
17
|
+
ActiveRecord::Base.send(:include, SmartCurrency) if defined?(ActiveRecord)
|
data/lib/hash.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module HashExt
|
3
|
+
Hash.class_eval do
|
4
|
+
|
5
|
+
|
6
|
+
# returns an array containing the hash values
|
7
|
+
# ordered either by hash key or hash value
|
8
|
+
# userful for building select_tag data from hash
|
9
|
+
# tested
|
10
|
+
def ordered(by = 1)
|
11
|
+
if by == :key
|
12
|
+
by = 0
|
13
|
+
elsif by == :value
|
14
|
+
by = 1
|
15
|
+
end
|
16
|
+
self.to_a.sort_by {|x| x[by].inspect}
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
# useful function for extracting form data from serveral checkboxes which will return a hash like:
|
21
|
+
# {:chk_1, => 0, :chk_2, => 1, :chk_3, => 1, ...}
|
22
|
+
# .extract_data would return [:chk_2, :chk_3]
|
23
|
+
# using slice = "chk_" would return [2,3]
|
24
|
+
def extract_data(slice = nil, trigger = "1")
|
25
|
+
data = []
|
26
|
+
self.each do |value, status|
|
27
|
+
value = value.to_s
|
28
|
+
if slice.nil?
|
29
|
+
data << value if status == trigger
|
30
|
+
else
|
31
|
+
data << value.split(slice).last if status == trigger
|
32
|
+
end
|
33
|
+
end
|
34
|
+
return data
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|