active_object 2.3.2 → 2.3.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b0eef8faa20c01684d36801a020a31d34420332f
4
- data.tar.gz: 6c89d8ba975cfa15fecaa0a94f35e03322ce2232
3
+ metadata.gz: cbc23095c7b3464b7b1c8228d9dc012518a0b709
4
+ data.tar.gz: bb17069b3db4919dfc86234e006e2ebd96dbbe9a
5
5
  SHA512:
6
- metadata.gz: a1507142ee692f5eb01542ea879566f45942155293a280ca1349e41a673012faf67874a6fdfc5fbc850c93e7c6dbf253d147b2393cf943fb5f14f5cceafb1e60
7
- data.tar.gz: f1fdf318e3c7a63e4a03ac96854564a786ccd2a240622b853e5130be7ec98ddffe357ce13585562fd1a603d84d95680c1db5331f9ff2742725cc870e5435ca15
6
+ metadata.gz: 8d8658ff16fd54a29d74e0ba472c2a36fbe1ecb015126920ec83a0d1da3704af4a99698d727a20938bf503b3ceec5ee7dbfaa1b1ba612a3ece7c8de550d19f19
7
+ data.tar.gz: 62ca6202ee16f2bcd6f4df0c9fa0181f88c432d1aa8cdc7d90486f46ba8e968220e1848e563545388f852ee578ff1500d14c03d0436fb7e6eae871e447648065
data/README.md CHANGED
@@ -1506,7 +1506,7 @@ false.truthy? #=> false
1506
1506
 
1507
1507
  ```ruby
1508
1508
  "ExampleString".humanize #=> "Example string"
1509
- "example_string".humanize #=> "Example string"
1509
+ "_example_string_id".humanize #=> "Example string"
1510
1510
  "example_string".humanize(capitalize: false) #=> "example string"
1511
1511
  ```
1512
1512
 
@@ -1518,6 +1518,15 @@ false.truthy? #=> false
1518
1518
  "example".indent(2, "\t") #=> "\t\texample"
1519
1519
  ```
1520
1520
 
1521
+ ####Labelize:####
1522
+ `Labelize` and `Labelize!` capitalizes each word in a string. `Rails Safe`
1523
+
1524
+ ```ruby
1525
+ "example string".titleize #=> "Example String"
1526
+ "_example_string_id".titleize #=> "Example String ID"
1527
+ "ExampleString".titleize #=> "Example String"
1528
+ ```
1529
+
1521
1530
  ####Last:####
1522
1531
  `last` returns the last character of the string. If a limit is supplied, returns a substring from the end of the string until it reaches the limit value (counting backwards). If the given limit is greater than or equal to the string length, returns a copy of self. `Rails Safe`
1523
1532
 
@@ -1635,9 +1644,9 @@ false.truthy? #=> false
1635
1644
  `titleize` and `titleize!` capitalizes each word in a string. `Rails Safe`
1636
1645
 
1637
1646
  ```ruby
1638
- "example string".titleize #=> "Example String"
1639
- "example_string".titleize #=> "Example String"
1640
- "ExampleString".titleize #=> "Example String"
1647
+ "example string".titleize #=> "Example String"
1648
+ "_example_string_id".titleize #=> "Example String"
1649
+ "ExampleString".titleize #=> "Example String"
1641
1650
  ```
1642
1651
 
1643
1652
  ####To:####
@@ -22,5 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler"
23
23
  spec.add_development_dependency "coveralls"
24
24
  spec.add_development_dependency "rake"
25
- spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "rspec", "~> 3.4.0"
26
26
  end
@@ -96,11 +96,11 @@ module Enumerable
96
96
  end
97
97
 
98
98
  def max(identity=0)
99
- self.length > 0 ? sort.last : identity
99
+ length > 0 ? sort.last : identity
100
100
  end
101
101
 
102
102
  def min(identity=0)
103
- self.length > 0 ? sort.first : identity
103
+ length > 0 ? sort.first : identity
104
104
  end
105
105
 
106
106
  def mean(identity=0)
@@ -133,6 +133,7 @@ class String
133
133
  underscore.
134
134
  gsub(/_id\z/, ''.freeze).
135
135
  tr('_'.freeze, ' '.freeze).
136
+ squish.
136
137
  gsub(/([a-z\d]*)/i) { |s| s.downcase }.
137
138
  gsub(/\A\w/) { |s| options.fetch(:capitalize, true) ? s.upcase : s }
138
139
  end
@@ -159,6 +160,21 @@ class String
159
160
  end
160
161
  end
161
162
 
163
+ def labelize
164
+ underscore.
165
+ tr('_'.freeze, ' '.freeze).
166
+ squish.
167
+ gsub(/\b(?<!['’`])[a-z]/) { $&.capitalize }
168
+ end
169
+
170
+ alias_method :labelcase, :labelize
171
+
172
+ def labelize!
173
+ replace(labelize)
174
+ end
175
+
176
+ alias_method :labelcase!, :labelize!
177
+
162
178
  unless defined?(Rails)
163
179
  def last(limit=1)
164
180
  return(''.freeze) if limit.zero?
@@ -1,3 +1,3 @@
1
1
  module ActiveObject
2
- VERSION = "2.3.2"
2
+ VERSION = "2.3.3"
3
3
  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: 2.3.2
4
+ version: 2.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-24 00:00:00.000000000 Z
11
+ date: 2015-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 3.4.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 3.4.0
69
69
  description: Class extensions of commonly used ruby object helpers.
70
70
  email:
71
71
  - j.gomez@drexed.com