active_object 2.3.3 → 2.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cbc23095c7b3464b7b1c8228d9dc012518a0b709
4
- data.tar.gz: bb17069b3db4919dfc86234e006e2ebd96dbbe9a
3
+ metadata.gz: d5caf3978a5c9afbb864ee78e79d35c1ce0f0ba5
4
+ data.tar.gz: 12b206e1043a27d5fc2d813778e82f52577739a7
5
5
  SHA512:
6
- metadata.gz: 8d8658ff16fd54a29d74e0ba472c2a36fbe1ecb015126920ec83a0d1da3704af4a99698d727a20938bf503b3ceec5ee7dbfaa1b1ba612a3ece7c8de550d19f19
7
- data.tar.gz: 62ca6202ee16f2bcd6f4df0c9fa0181f88c432d1aa8cdc7d90486f46ba8e968220e1848e563545388f852ee578ff1500d14c03d0436fb7e6eae871e447648065
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
- `Labelize` and `Labelize!` capitalizes each word in a string. `Rails Safe`
1522
+ `labelize` and `labelize!` transforms a string to a human readable string.
1523
1523
 
1524
1524
  ```ruby
1525
- "example string".titleize #=> "Example String"
1526
- "_example_string_id".titleize #=> "Example String ID"
1527
- "ExampleString".titleize #=> "Example String"
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:####
@@ -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(/\b(?<!['’`])[a-z]/) { $&.capitalize }
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!
@@ -1,3 +1,3 @@
1
1
  module ActiveObject
2
- VERSION = "2.3.3"
2
+ VERSION = "2.3.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.3
4
+ version: 2.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez