creative_rails_utilities 0.1.0 → 0.1.1

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: e70cd283fffd7f7397b943573fab75b9b9c55394
4
- data.tar.gz: 57586083f99e9ff364ca15ebc5227e09b87659b3
3
+ metadata.gz: 8dd78fb9e872004a952ffc0027998ef49a112139
4
+ data.tar.gz: 33a4a563794faf8d728b826b130c815ed3c1c6d1
5
5
  SHA512:
6
- metadata.gz: fd689e06491a867f35f2f402410e0bec5936907277ab93fd4e7c0e7353fcc5c34f5c521a7f304782a4971c61af8abd1bbf113aee57f5475f2f264d9f362da2a0
7
- data.tar.gz: ecfa4dfbb28e9a3e3ede00984ab8c5fb097a84272b3e6e0f7c5200ba58bd196e49dfbaad3795390e7360dc67f89fd19869472778329e95b08ffd101a4bafc530
6
+ metadata.gz: f72c907e8f868bbccd5b57c93e09af38b7739746c976441518830ce186370743f5d2db6de116a439b55c939888cef53b1aa31f2ab798cf654948dfbd0bbffc39
7
+ data.tar.gz: 9ba3ebf507b7baa20fb95daa580a294385b56ad6a72900a1a02674cd00f7cb32b36221eb297920fff32a26f4ed3bda474fc0fd089f7165f8c3b041ee674e82b8
data/CHANGELOG.md CHANGED
@@ -6,6 +6,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
6
6
  ### Changed
7
7
  -
8
8
 
9
+ ## [0.1.1] - 2015-11-10
10
+ ### Added
11
+ - Fallout 4
12
+ - Numeric#safe_percent
13
+ - error_helper.rb
14
+ ### Fixed
15
+ - That one unfinished spec
16
+
17
+
9
18
  ## [0.1.0] - 2015-10-16
10
19
  ### Added
11
20
  - Initial release with basic functionality described in README
data/README.md CHANGED
@@ -18,6 +18,12 @@ Feel free to read the source under `/lib/creative_rails_utilities/`
18
18
  28.to_s26 #=> "ab"
19
19
  ```
20
20
 
21
+ ```ruby
22
+ # delete with zero
23
+ 1.safe_percent(2) #=> 200
24
+ 0.safe_percent(0) #=> 0
25
+ ```
26
+
21
27
  ##### String
22
28
 
23
29
  ```ruby
@@ -27,6 +33,7 @@ Feel free to read the source under `/lib/creative_rails_utilities/`
27
33
  ```
28
34
 
29
35
  ## Development
36
+ Use ruby >=2.2
30
37
 
31
38
  1. Write specs
32
39
  2. Make specs fail
@@ -0,0 +1,6 @@
1
+ module ErrorHelper
2
+ def raise_positive_number_only
3
+ raise ArgumentError.new("Please use positive numbers only.")
4
+ end
5
+
6
+ end
@@ -1,4 +1,5 @@
1
1
  class Numeric
2
+ include ErrorHelper
2
3
 
3
4
  Alpha26 = ("a".."z").to_a
4
5
 
@@ -14,4 +15,18 @@ class Numeric
14
15
  s
15
16
  end
16
17
 
18
+ def safe_percent(part)
19
+ if self > 0
20
+ if part >= 0
21
+ return 100*part.to_f/self.to_f
22
+ else
23
+ raise_positive_number_only
24
+ end
25
+ elsif self == 0
26
+ return 0
27
+ else
28
+ raise_positive_number_only
29
+ end
30
+ end
31
+
17
32
  end
@@ -1,3 +1,3 @@
1
1
  module CreativeRailsUtilities
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -1,7 +1,7 @@
1
+ require "creative_rails_utilities/error_helper"
1
2
  require "creative_rails_utilities/numeric"
2
3
  require "creative_rails_utilities/string"
3
4
  require "creative_rails_utilities/version"
4
5
 
5
6
  module CreativeRailsUtilities
6
- # Your code goes here...
7
7
  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.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Creative
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-16 00:00:00.000000000 Z
11
+ date: 2015-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,6 +72,7 @@ files:
72
72
  - bin/setup
73
73
  - creative_rails_utilities.gemspec
74
74
  - lib/creative_rails_utilities.rb
75
+ - lib/creative_rails_utilities/error_helper.rb
75
76
  - lib/creative_rails_utilities/numeric.rb
76
77
  - lib/creative_rails_utilities/string.rb
77
78
  - lib/creative_rails_utilities/version.rb
@@ -95,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
96
  version: '0'
96
97
  requirements: []
97
98
  rubyforge_project:
98
- rubygems_version: 2.4.8
99
+ rubygems_version: 2.2.2
99
100
  signing_key:
100
101
  specification_version: 4
101
102
  summary: Creative's assorted hacks, fixes and monkeypatches to Ruby and Rails base