active_object 2.3.3 → 2.3.4
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.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/active_object/string.rb +7 -5
- data/lib/active_object/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5caf3978a5c9afbb864ee78e79d35c1ce0f0ba5
|
4
|
+
data.tar.gz: 12b206e1043a27d5fc2d813778e82f52577739a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7c8debf0bc5198d122b96a49af88511b87e04e181de534bacedaee992a560c8a9dd8cc96c17a361c35c12886ba916990654ff0a153aaae3eb9353c8922d2e35
|
7
|
+
data.tar.gz: 0610e5f37393d5c60ed81c76106efa4b39b41a82c06524f1f32a64b37d79990816d834ef2a9bb830457fdbc723904419a22addc1b7eb8416d8c833956a5c1888
|
data/README.md
CHANGED
@@ -1519,12 +1519,12 @@ false.truthy? #=> false
|
|
1519
1519
|
```
|
1520
1520
|
|
1521
1521
|
####Labelize:####
|
1522
|
-
`
|
1522
|
+
`labelize` and `labelize!` transforms a string to a human readable string.
|
1523
1523
|
|
1524
1524
|
```ruby
|
1525
|
-
"example string".
|
1526
|
-
"_example_string_id".
|
1527
|
-
"ExampleString".
|
1525
|
+
"example string".labelize #=> "Example string"
|
1526
|
+
"_example_string_id".labelize #=> "Example string ID"
|
1527
|
+
"ExampleString".labelize #=> "Example string"
|
1528
1528
|
```
|
1529
1529
|
|
1530
1530
|
####Last:####
|
data/lib/active_object/string.rb
CHANGED
@@ -129,7 +129,7 @@ class String
|
|
129
129
|
end
|
130
130
|
|
131
131
|
unless defined?(Rails)
|
132
|
-
def humanize(options
|
132
|
+
def humanize(options={})
|
133
133
|
underscore.
|
134
134
|
gsub(/_id\z/, ''.freeze).
|
135
135
|
tr('_'.freeze, ' '.freeze).
|
@@ -160,17 +160,19 @@ class String
|
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
163
|
-
def labelize
|
163
|
+
def labelize(options={})
|
164
164
|
underscore.
|
165
165
|
tr('_'.freeze, ' '.freeze).
|
166
166
|
squish.
|
167
|
-
gsub(
|
167
|
+
gsub(/([a-z\d]*)/i) { |s| s.downcase }.
|
168
|
+
gsub(/\A\w/) { |s| options.fetch(:capitalize, true) ? s.upcase : s }.
|
169
|
+
gsub(/ id\z/, ' ID'.freeze)
|
168
170
|
end
|
169
171
|
|
170
172
|
alias_method :labelcase, :labelize
|
171
173
|
|
172
|
-
def labelize!
|
173
|
-
replace(labelize)
|
174
|
+
def labelize!(options={})
|
175
|
+
replace(labelize(options))
|
174
176
|
end
|
175
177
|
|
176
178
|
alias_method :labelcase!, :labelize!
|