creative_rails_utilities 0.3.1 → 0.3.2

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: 917c83b2eecccff1d15e944588440306749d9884
4
- data.tar.gz: f967b3848f59fe7b307bb161d4b6bf7973edb0d3
3
+ metadata.gz: 08df32abe84df0ba17bcd247dd52a6714f584a79
4
+ data.tar.gz: 6bd9acbc35e7926b8ce57f35c6fa7d693b29f101
5
5
  SHA512:
6
- metadata.gz: ae632aac59b682631cb0e92e620701995e91850f70f31980a9722615e6ba0313678ecfd35a98e6a2706bd0954c96a1baa9a6eb56c27ed6881393dd889f52ce88
7
- data.tar.gz: 2d90907055cbb0f4b2fef60ea359a2c03f8d56291639d2745637e541e378f7653089539dd49a19f4611bda5d4eef2a69e2d9a2cbebcadbd2e0126146852b44fb
6
+ metadata.gz: 4621a27d1b6cd706c1c6c417b5c093ce9de3da2e2bc9a6483754a5b1a929853b25d84d4adca3ba707fb3ddbdc4aedac908471800385845beb9ab98ab8d52e796
7
+ data.tar.gz: c28e943c38a022b676f6d132ce13104d0551acedff88388133fac2aeee3a051e8c7ca6766c11cb98a5c8274bc2ce6550f890763bacf762ec1ebcd82055f5a6d1
data/CHANGELOG.md CHANGED
@@ -2,11 +2,17 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ```
5
6
  ## [Release candidate][0.3.1-alpha.1]
6
7
  ### Added
7
8
  -
9
+ ```
8
10
 
9
- ## [0.3.1] - 2016-10-21
11
+ ## [0.3.2] - 2016-04-19
12
+ ### Added
13
+ - String#to_bool
14
+
15
+ ## [0.3.1] - 2016-01-21
10
16
  ### Added
11
17
  - String#unindent
12
18
 
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # CreativeRailsUtilities
2
2
 
3
3
  Defines extensions, useful and convenient methods on Ruby and Rails base classes.
4
- Requires `Ruby 2.1` for keyword arguments.
5
- Intended for Rails > 4.0.0, but will probably also work for older projects with robust Activesupport inclusion.
4
+ Requires `Ruby >=2.1` for keyword arguments.
5
+ Intended for `Rails >= 4.0.0`, but will probably work for older projects with robust Activesupport inclusion.
6
6
 
7
7
  ## Installation
8
8
 
9
- `gem 'creative_rails_utilities'` and `bundle`
9
+ `gem 'creative_rails_utilities', "~> 0.3.2"` and `bundle`
10
10
 
11
11
  ## Usage
12
12
 
@@ -138,6 +138,7 @@ some_hash.fast_sort_keys #=> some_sorted_hash
138
138
  # whole.safe_percent(part)
139
139
  100.safe_percent(50) #=> 50
140
140
  1.safe_percent(2) #=> 200
141
+ 3.0.safe_percent(1) #=> 33.333333333333336 # you should .round when calling this on floats
141
142
  0.safe_percent(0) #=> 0
142
143
  ```
143
144
 
@@ -166,6 +167,14 @@ ENDBAR
166
167
  string #=> "1..." instead of " 1..."
167
168
  ```
168
169
 
170
+ ```ruby
171
+ # Convert string to boolean.
172
+ "true".to_bool #=> true
173
+ "0".to_bool #=> false
174
+ "".to_bool #=> false
175
+ "y".to_bool #=> true
176
+ ```
177
+
169
178
  ## Development
170
179
  Use ruby >=2.1
171
180
 
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
 
13
13
  spec.summary = %q|Creative's assorted hacks, fixes and monkeypatches to Ruby and Rails base classes|
14
14
  spec.description = %q|Creative's assorted hacks, fixes and monkeypatches to Ruby and Rails base classes|
15
- spec.homepage = "https://github.com/CreativePublisher/rails_utilities"
15
+ spec.homepage = "https://github.com/CreativePublisher/creative_rails_utilities"
16
16
  spec.license = "MIT"
17
17
  spec.date = Date.today.to_s
18
18
 
@@ -20,4 +20,11 @@ class String
20
20
  gsub(/^#{self[/\A\s*/]}/, '')
21
21
  end
22
22
 
23
+ # Convert string to boolean.
24
+ def to_bool
25
+ return true if self[/\A(true)|(1)|(y(es)?)\z/i]
26
+ return false if self[/\A(false)|(0)|(no?)|(nil)\z/i] || self == ""
27
+ raise(ArgumentError.new "could not interpret '#{self}' as boolean.")
28
+ end
29
+
23
30
  end
@@ -1,3 +1,3 @@
1
1
  module CreativeRailsUtilities
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: creative_rails_utilities
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Creative
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-21 00:00:00.000000000 Z
11
+ date: 2016-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -164,7 +164,7 @@ files:
164
164
  - lib/creative_rails_utilities/string.rb
165
165
  - lib/creative_rails_utilities/version.rb
166
166
  - lib/creative_rails_utilities/view_helpers.rb
167
- homepage: https://github.com/CreativePublisher/rails_utilities
167
+ homepage: https://github.com/CreativePublisher/creative_rails_utilities
168
168
  licenses:
169
169
  - MIT
170
170
  metadata: {}