active_object 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/active_object/array.rb +6 -6
- data/lib/active_object/enumerable.rb +3 -3
- data/lib/active_object/hash.rb +21 -21
- data/lib/active_object/numeric.rb +18 -16
- data/lib/active_object/object.rb +4 -4
- data/lib/active_object/string.rb +32 -32
- data/lib/active_object/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 338a756fe3022d25112ff46e8ed0ecf5e440802f
|
4
|
+
data.tar.gz: a106f60c397ee297ea41cb25c14a41b41cedf409
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6934080ed8fb2ba7800456ba45060c5309abcc6a12421c5aa03977e7763f1fc3049ecdc215df479d51613d497a614c0959843bc0fdc685e9605f91a40c70458
|
7
|
+
data.tar.gz: 04d344c1bd0d18bfef39f1f842ccc1d232a1e28426ea96148cd3f2859c32b9e06c273611e82f8db94bd5e6614871a2fbd669a356ab11d0fb408d38deabee4f7e
|
data/README.md
CHANGED
@@ -1181,8 +1181,8 @@ h.slice!(:a, :b) #=> { c: 3, d: 4 }
|
|
1181
1181
|
`shift` and `shift!` removes the first instance of a string.
|
1182
1182
|
|
1183
1183
|
```ruby
|
1184
|
-
"this thing that thing".
|
1185
|
-
"this thing that thing".
|
1184
|
+
"this thing that thing".shift("thing") #=> "this that thing"
|
1185
|
+
"this thing that thing".shift("this", "that") #=> " thing thing"
|
1186
1186
|
```
|
1187
1187
|
|
1188
1188
|
####Slugify:####
|
data/lib/active_object/array.rb
CHANGED
@@ -8,7 +8,7 @@ class Array
|
|
8
8
|
self[0...-1]
|
9
9
|
end
|
10
10
|
|
11
|
-
unless
|
11
|
+
unless defined?(Rails)
|
12
12
|
def from(position)
|
13
13
|
self[position, size] || []
|
14
14
|
end
|
@@ -21,7 +21,7 @@ class Array
|
|
21
21
|
r > 0 ? collection << self[-r, r] : collection
|
22
22
|
end
|
23
23
|
|
24
|
-
unless
|
24
|
+
unless defined?(Rails)
|
25
25
|
def in_groups(number, fill_with=nil)
|
26
26
|
collection_size = size
|
27
27
|
division = collection_size.div(number)
|
@@ -40,7 +40,7 @@ class Array
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
unless
|
43
|
+
unless defined?(Rails)
|
44
44
|
def in_groups_of(number, fill_with=nil)
|
45
45
|
if number.to_i <= 0
|
46
46
|
raise ArgumentError,
|
@@ -58,7 +58,7 @@ class Array
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
unless
|
61
|
+
unless defined?(Rails)
|
62
62
|
def split(number=nil)
|
63
63
|
if block_given?
|
64
64
|
inject([[]]) do |results, element|
|
@@ -85,13 +85,13 @@ class Array
|
|
85
85
|
reject { |v| v.blank? }
|
86
86
|
end
|
87
87
|
|
88
|
-
unless
|
88
|
+
unless defined?(Rails)
|
89
89
|
def to(position)
|
90
90
|
position >= 0 ? first(position + 1) : self[0..position]
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
unless
|
94
|
+
unless defined?(Rails)
|
95
95
|
def to_sentence(options={})
|
96
96
|
options.assert_valid_keys(:words_connector, :two_words_connector, :last_word_connector)
|
97
97
|
|
@@ -39,7 +39,7 @@ module Enumerable
|
|
39
39
|
(found_count > n) ? false : n == found_count
|
40
40
|
end
|
41
41
|
|
42
|
-
unless
|
42
|
+
unless defined?(Rails)
|
43
43
|
def exclude?(object)
|
44
44
|
!include?(object)
|
45
45
|
end
|
@@ -57,7 +57,7 @@ module Enumerable
|
|
57
57
|
each_with_object(Hash.new(0)) { |e, a| a[e] += 1 }
|
58
58
|
end
|
59
59
|
|
60
|
-
unless
|
60
|
+
unless defined?(Rails)
|
61
61
|
def many?
|
62
62
|
found_count = 0
|
63
63
|
if block_given?
|
@@ -138,7 +138,7 @@ module Enumerable
|
|
138
138
|
Math.sqrt(variance)
|
139
139
|
end
|
140
140
|
|
141
|
-
unless
|
141
|
+
unless defined?(Rails)
|
142
142
|
def sum(identity=0, &block)
|
143
143
|
if block_given?
|
144
144
|
map(&block).sum(identity)
|
data/lib/active_object/hash.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Hash
|
2
2
|
|
3
|
-
unless
|
3
|
+
unless defined?(Rails)
|
4
4
|
def assert_valid_keys(*valid_keys)
|
5
5
|
valid_keys.flatten!
|
6
6
|
each_key do |k|
|
@@ -12,25 +12,25 @@ class Hash
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
unless
|
15
|
+
unless defined?(Rails)
|
16
16
|
def compact
|
17
17
|
select { |k,v| !v.nil? }
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
unless
|
21
|
+
unless defined?(Rails)
|
22
22
|
def compact!
|
23
23
|
reject! { |k,v| v.nil? }
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
unless
|
27
|
+
unless defined?(Rails)
|
28
28
|
def deep_merge(other_hash, &block)
|
29
29
|
dup.deep_merge!(other_hash, &block)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
unless
|
33
|
+
unless defined?(Rails)
|
34
34
|
def deep_merge!(other_hash, &block)
|
35
35
|
other_hash.each_pair do |current_key, other_value|
|
36
36
|
this_value = self[current_key]
|
@@ -45,13 +45,13 @@ class Hash
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
unless
|
48
|
+
unless defined?(Rails)
|
49
49
|
def except(*keys)
|
50
50
|
dup.except!(*keys)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
unless
|
54
|
+
unless defined?(Rails)
|
55
55
|
def except!(*keys)
|
56
56
|
keys.each { |k| delete(k) }
|
57
57
|
self
|
@@ -70,13 +70,13 @@ class Hash
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
unless
|
73
|
+
unless defined?(Rails)
|
74
74
|
def only(*keys)
|
75
75
|
dup.only!(*keys)
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
unless
|
79
|
+
unless defined?(Rails)
|
80
80
|
def only!(*args)
|
81
81
|
hash = {}
|
82
82
|
args.each {|k| hash[k] = self[k] if self.has_key?(k) }
|
@@ -94,25 +94,25 @@ class Hash
|
|
94
94
|
self
|
95
95
|
end
|
96
96
|
|
97
|
-
unless
|
97
|
+
unless defined?(Rails)
|
98
98
|
def reverse_merge(other_hash)
|
99
99
|
other_hash.merge(self)
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
-
unless
|
103
|
+
unless defined?(Rails)
|
104
104
|
def reverse_merge!(other_hash)
|
105
105
|
merge!(other_hash) { |k,l,r| l }
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
-
unless
|
109
|
+
unless defined?(Rails)
|
110
110
|
def slice(*keys)
|
111
111
|
keys.each_with_object(self.class.new) { |k, h| h[k] = self[k] if has_key?(k) }
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
-
unless
|
115
|
+
unless defined?(Rails)
|
116
116
|
def slice!(*keys)
|
117
117
|
omit = slice(*self.keys - keys)
|
118
118
|
hash = slice(*keys)
|
@@ -125,13 +125,13 @@ class Hash
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
-
unless
|
128
|
+
unless defined?(Rails)
|
129
129
|
def stringify_keys
|
130
130
|
dup.stringify_keys!
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
|
-
unless
|
134
|
+
unless defined?(Rails)
|
135
135
|
def stringify_keys!
|
136
136
|
inject({}) do |options,(k,v)|
|
137
137
|
options[k.to_s] = v
|
@@ -148,13 +148,13 @@ class Hash
|
|
148
148
|
reject! { |k,v| v.blank? }
|
149
149
|
end
|
150
150
|
|
151
|
-
unless
|
151
|
+
unless defined?(Rails)
|
152
152
|
def symbolize_keys
|
153
153
|
dup.symbolize_keys!
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
157
|
-
unless
|
157
|
+
unless defined?(Rails)
|
158
158
|
def symbolize_keys!
|
159
159
|
inject({}) do |options, (k,v)|
|
160
160
|
options[(k.to_sym rescue k) || k] = v
|
@@ -174,13 +174,13 @@ class Hash
|
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
177
|
-
unless
|
177
|
+
unless defined?(Rails)
|
178
178
|
def transform_keys(&block)
|
179
179
|
dup.transform_keys!(&block)
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
183
|
-
unless
|
183
|
+
unless defined?(Rails)
|
184
184
|
def transform_keys!(&block)
|
185
185
|
return(enum_for(:transform_keys!)) unless block_given?
|
186
186
|
keys.each { |k| self[yield(k)] = delete(k) }
|
@@ -188,13 +188,13 @@ class Hash
|
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
191
|
-
unless
|
191
|
+
unless defined?(Rails)
|
192
192
|
def transform_values(&block)
|
193
193
|
dup.transform_values!(&block)
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
197
|
-
unless
|
197
|
+
unless defined?(Rails)
|
198
198
|
def transform_values!(&block)
|
199
199
|
return(enum_for(:transform_values!)) unless block_given?
|
200
200
|
each { |k,v| self[k] = yield(v) }
|
@@ -7,12 +7,14 @@ class Numeric
|
|
7
7
|
HECTO = DECA * 10
|
8
8
|
KILO = HECTO * 10
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
unless defined?(Rails)
|
11
|
+
KILOBYTE = 1024
|
12
|
+
MEGABYTE = KILOBYTE * 1024
|
13
|
+
GIGABYTE = MEGABYTE * 1024
|
14
|
+
TERABYTE = GIGABYTE * 1024
|
15
|
+
PETABYTE = TERABYTE * 1024
|
16
|
+
EXABYTE = PETABYTE * 1024
|
17
|
+
end
|
16
18
|
|
17
19
|
FEET = 12
|
18
20
|
YARD = FEET * 3
|
@@ -37,7 +39,7 @@ class Numeric
|
|
37
39
|
self + n
|
38
40
|
end
|
39
41
|
|
40
|
-
unless
|
42
|
+
unless defined?(Rails)
|
41
43
|
def bytes
|
42
44
|
self
|
43
45
|
end
|
@@ -103,7 +105,7 @@ class Numeric
|
|
103
105
|
self / n
|
104
106
|
end
|
105
107
|
|
106
|
-
unless
|
108
|
+
unless defined?(Rails)
|
107
109
|
def exabytes
|
108
110
|
self * EXABYTE
|
109
111
|
end
|
@@ -117,7 +119,7 @@ class Numeric
|
|
117
119
|
|
118
120
|
alias_method :foot, :feet
|
119
121
|
|
120
|
-
unless
|
122
|
+
unless defined?(Rails)
|
121
123
|
def gigabytes
|
122
124
|
self * GIGABYTE
|
123
125
|
end
|
@@ -155,7 +157,7 @@ class Numeric
|
|
155
157
|
|
156
158
|
alias_method :inch, :inches
|
157
159
|
|
158
|
-
unless
|
160
|
+
unless defined?(Rails)
|
159
161
|
def kilobytes
|
160
162
|
self * KILOBYTE
|
161
163
|
end
|
@@ -181,7 +183,7 @@ class Numeric
|
|
181
183
|
|
182
184
|
alias_method :metric_ton, :metric_tons
|
183
185
|
|
184
|
-
unless
|
186
|
+
unless defined?(Rails)
|
185
187
|
def megabytes
|
186
188
|
self * MEGABYTE
|
187
189
|
end
|
@@ -229,7 +231,7 @@ class Numeric
|
|
229
231
|
self * n
|
230
232
|
end
|
231
233
|
|
232
|
-
unless
|
234
|
+
unless defined?(Rails)
|
233
235
|
def multiple_of?(number)
|
234
236
|
number != 0 ? modulo(number).zero? : zero?
|
235
237
|
end
|
@@ -245,7 +247,7 @@ class Numeric
|
|
245
247
|
self < 0
|
246
248
|
end
|
247
249
|
|
248
|
-
unless
|
250
|
+
unless defined?(Rails)
|
249
251
|
def ordinal
|
250
252
|
abs_number = abs
|
251
253
|
|
@@ -262,7 +264,7 @@ class Numeric
|
|
262
264
|
end
|
263
265
|
end
|
264
266
|
|
265
|
-
unless
|
267
|
+
unless defined?(Rails)
|
266
268
|
def ordinalize
|
267
269
|
"#{self}#{self.ordinal}"
|
268
270
|
end
|
@@ -294,7 +296,7 @@ class Numeric
|
|
294
296
|
ljust_count >= num_count ? string.ljust(ljust_count, pad_number.to_s) : string[0..(ljust_count - 1)]
|
295
297
|
end
|
296
298
|
|
297
|
-
unless
|
299
|
+
unless defined?(Rails)
|
298
300
|
def petabytes
|
299
301
|
self * PETABYTE
|
300
302
|
end
|
@@ -336,7 +338,7 @@ class Numeric
|
|
336
338
|
self - n
|
337
339
|
end
|
338
340
|
|
339
|
-
unless
|
341
|
+
unless defined?(Rails)
|
340
342
|
def terabytes
|
341
343
|
self * TERABYTE
|
342
344
|
end
|
data/lib/active_object/object.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Object
|
2
2
|
|
3
|
-
unless
|
3
|
+
unless defined?(Rails)
|
4
4
|
def blank?
|
5
5
|
object = self
|
6
6
|
object = object.strip if respond_to?(:strip)
|
@@ -16,19 +16,19 @@ class Object
|
|
16
16
|
to_s == to_s.reverse
|
17
17
|
end
|
18
18
|
|
19
|
-
unless
|
19
|
+
unless defined?(Rails)
|
20
20
|
def present?
|
21
21
|
!blank?
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
unless
|
25
|
+
unless defined?(Rails)
|
26
26
|
def try(*a, &b)
|
27
27
|
try!(*a, &b) if a.empty? || respond_to?(a.first)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
unless
|
31
|
+
unless defined?(Rails)
|
32
32
|
def try!(*a, &b)
|
33
33
|
if a.empty? && block_given?
|
34
34
|
b.arity.zero? ? instance_eval(&b) : yield(self)
|
data/lib/active_object/string.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
class String
|
2
2
|
|
3
|
-
unless
|
3
|
+
unless defined?(Rails)
|
4
4
|
def at(position)
|
5
5
|
self[position]
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
|
-
unless
|
9
|
+
unless defined?(Rails)
|
10
10
|
def camelize(first_letter=:upper)
|
11
11
|
if first_letter != :lower
|
12
12
|
to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
|
@@ -18,7 +18,7 @@ class String
|
|
18
18
|
alias_method :camelcase, :camelize
|
19
19
|
end
|
20
20
|
|
21
|
-
unless
|
21
|
+
unless defined?(Rails)
|
22
22
|
def camelize!(first_letter=:upper)
|
23
23
|
replace(camelize(first_letter))
|
24
24
|
end
|
@@ -26,37 +26,37 @@ class String
|
|
26
26
|
alias_method :camelcase!, :camelize!
|
27
27
|
end
|
28
28
|
|
29
|
-
unless
|
29
|
+
unless defined?(Rails)
|
30
30
|
def classify
|
31
31
|
to_s.sub(/.*\./, "").camelize
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
unless
|
35
|
+
unless defined?(Rails)
|
36
36
|
def classify!
|
37
37
|
replace(classify)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
unless
|
41
|
+
unless defined?(Rails)
|
42
42
|
def dasherize
|
43
43
|
gsub(/_/, "-")
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
unless
|
47
|
+
unless defined?(Rails)
|
48
48
|
def dasherize!
|
49
49
|
replace(dasherize)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
unless
|
53
|
+
unless defined?(Rails)
|
54
54
|
def demodulize
|
55
55
|
to_s.gsub(/^.*::/, "")
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
unless
|
59
|
+
unless defined?(Rails)
|
60
60
|
def demodulize!
|
61
61
|
replace(demodulize)
|
62
62
|
end
|
@@ -79,26 +79,26 @@ class String
|
|
79
79
|
"#{self[0,offset]}#{separator}#{self[-offset,offset]}"
|
80
80
|
end
|
81
81
|
|
82
|
-
unless
|
82
|
+
unless defined?(Rails)
|
83
83
|
def exclude?(string)
|
84
84
|
!include?(string)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
unless
|
88
|
+
unless defined?(Rails)
|
89
89
|
def first(limit=1)
|
90
90
|
return("") if limit.zero?
|
91
91
|
limit >= size ? self.dup : to(limit - 1)
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
unless
|
95
|
+
unless defined?(Rails)
|
96
96
|
def from(position)
|
97
97
|
self[position..-1]
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
|
-
unless
|
101
|
+
unless defined?(Rails)
|
102
102
|
def humanize(options = {})
|
103
103
|
underscore.
|
104
104
|
gsub(/_id\z/, "").
|
@@ -108,13 +108,13 @@ class String
|
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
-
unless
|
111
|
+
unless defined?(Rails)
|
112
112
|
def humanize!(options={})
|
113
113
|
replace(humanize(options))
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
-
unless
|
117
|
+
unless defined?(Rails)
|
118
118
|
def indent(amount, indent_string=nil, indent_empty_lines=false)
|
119
119
|
indent_string = indent_string || self[/^[ \t]/] || " "
|
120
120
|
substitutes = indent_empty_lines ? /^/ : /^(?!$)/
|
@@ -122,13 +122,13 @@ class String
|
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
|
-
unless
|
125
|
+
unless defined?(Rails)
|
126
126
|
def indent!(amount, indent_string=nil, indent_empty_lines=false)
|
127
127
|
replace(indent(amount, indent_string, indent_empty_lines))
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
-
unless
|
131
|
+
unless defined?(Rails)
|
132
132
|
def last(limit=1)
|
133
133
|
return("") if limit.zero?
|
134
134
|
limit >= size ? self.dup : from(-limit)
|
@@ -139,19 +139,19 @@ class String
|
|
139
139
|
!upcase? && !downcase?
|
140
140
|
end
|
141
141
|
|
142
|
-
unless
|
142
|
+
unless defined?(Rails)
|
143
143
|
def ordinal
|
144
144
|
to_i.ordinal
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
148
|
-
unless
|
148
|
+
unless defined?(Rails)
|
149
149
|
def ordinalize
|
150
150
|
to_i.ordinalize
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
154
|
-
unless
|
154
|
+
unless defined?(Rails)
|
155
155
|
def parameterize(sep="-")
|
156
156
|
underscore.
|
157
157
|
gsub(/\s+/, "_").
|
@@ -160,7 +160,7 @@ class String
|
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
163
|
-
unless
|
163
|
+
unless defined?(Rails)
|
164
164
|
def parameterize!(sep="-")
|
165
165
|
replace(parameterize(sep))
|
166
166
|
end
|
@@ -170,7 +170,7 @@ class String
|
|
170
170
|
split('').map { |c| "#{c}#{delimiter}" }.join
|
171
171
|
end
|
172
172
|
|
173
|
-
unless
|
173
|
+
unless defined?(Rails)
|
174
174
|
def remove(*patterns)
|
175
175
|
string = dup
|
176
176
|
patterns.each do |pattern|
|
@@ -180,7 +180,7 @@ class String
|
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
183
|
-
unless
|
183
|
+
unless defined?(Rails)
|
184
184
|
def remove!(*patterns)
|
185
185
|
replace(remove(*patterns))
|
186
186
|
end
|
@@ -218,19 +218,19 @@ class String
|
|
218
218
|
replace(slugify)
|
219
219
|
end
|
220
220
|
|
221
|
-
unless
|
221
|
+
unless defined?(Rails)
|
222
222
|
def squish
|
223
223
|
strip.gsub(/\s+/, ' ')
|
224
224
|
end
|
225
225
|
end
|
226
226
|
|
227
|
-
unless
|
227
|
+
unless defined?(Rails)
|
228
228
|
def squish!
|
229
229
|
replace(squish)
|
230
230
|
end
|
231
231
|
end
|
232
232
|
|
233
|
-
unless
|
233
|
+
unless defined?(Rails)
|
234
234
|
def titleize
|
235
235
|
underscore.
|
236
236
|
humanize.
|
@@ -240,7 +240,7 @@ class String
|
|
240
240
|
alias_method :titlecase, :titleize
|
241
241
|
end
|
242
242
|
|
243
|
-
unless
|
243
|
+
unless defined?(Rails)
|
244
244
|
def titleize!
|
245
245
|
replace(titleize)
|
246
246
|
end
|
@@ -248,13 +248,13 @@ class String
|
|
248
248
|
alias_method :titlecase!, :titleize!
|
249
249
|
end
|
250
250
|
|
251
|
-
unless
|
251
|
+
unless defined?(Rails)
|
252
252
|
def to(position)
|
253
253
|
self[0..position]
|
254
254
|
end
|
255
255
|
end
|
256
256
|
|
257
|
-
unless
|
257
|
+
unless defined?(Rails)
|
258
258
|
def truncate(truncate_at, options={})
|
259
259
|
return(dup) unless length > truncate_at
|
260
260
|
|
@@ -271,7 +271,7 @@ class String
|
|
271
271
|
end
|
272
272
|
end
|
273
273
|
|
274
|
-
unless
|
274
|
+
unless defined?(Rails)
|
275
275
|
def truncate_words(words_count, options={})
|
276
276
|
sep = options[:separator] || /\s+/
|
277
277
|
sep = Regexp.escape(sep.to_s) unless Regexp === sep
|
@@ -284,7 +284,7 @@ class String
|
|
284
284
|
end
|
285
285
|
end
|
286
286
|
|
287
|
-
unless
|
287
|
+
unless defined?(Rails)
|
288
288
|
def underscore
|
289
289
|
gsub(/::/, '/').
|
290
290
|
gsub(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2').
|
@@ -294,7 +294,7 @@ class String
|
|
294
294
|
end
|
295
295
|
end
|
296
296
|
|
297
|
-
unless
|
297
|
+
unless defined?(Rails)
|
298
298
|
def underscore!
|
299
299
|
replace(underscore)
|
300
300
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02
|
11
|
+
date: 2015-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|