powerpack 0.0.3 → 0.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5ae47f06545fa305812faece61d4a22a32f29cf
4
- data.tar.gz: ffc7a033f26e64169194bd31fd0e0d3a97ddb145
3
+ metadata.gz: d33e4476c5faccdafe8e8065366f11e4a65478e7
4
+ data.tar.gz: 5c592ba39bcd2d5e57210e17e27138d245e4420e
5
5
  SHA512:
6
- metadata.gz: ea7099ee760815ad0b5257690a2cc48925c677956f7b51f9a974fe1d19f31b3cd4fcadd9b6ac09b7f57815923d71774ccca763a234785ed34495c48377d8609a
7
- data.tar.gz: 298cd5779cd56510d5089f85c23b8cc7b74920cd0be906682c6b214af047c7786d72f4410dc0c017f9931bc2137b17096ebb1222b16d548790b89f2a21997431
6
+ metadata.gz: c7d594c9deaabc166e4f9030c7f2efd13d9598d810b3abe784b1ed63a673a3fc9c7da18a2c60f75aa0e3b5a1ea4f8d70bedfa3464a361b4b887239d4933d7e71
7
+ data.tar.gz: d0c5b207e0111a33ad38d64551561b0dc65f7330246924119185348479bfdbe5d6cc31cd64d7a8adf9a35a3658dbafbe99573c06b4fe73d93ba84dbb50cadf2f
data/README.md CHANGED
@@ -23,6 +23,9 @@ Or install it yourself as:
23
23
 
24
24
  * [Hash](http://rdoc.info/github/bbatsov/powerpack/Hash)
25
25
  * [#symbolize_keys](http://rdoc.info/github/bbatsov/powerpack/Hash#symbolize_keys-instance_method)
26
+ * [Numeric](http://rdoc.info/github/bbatsov/powerpack/Numeric)
27
+ * [#pos?](http://rdoc.info/github/bbatsov/powerpack/Numeric#pos?-instance_method)
28
+ * [#neg?](http://rdoc.info/github/bbatsov/powerpack/Numeric#neg?-instance_method)
26
29
  * [String](http://rdoc.info/github/bbatsov/powerpack/String)
27
30
  * [#blank?](http://rdoc.info/github/bbatsov/powerpack/String#blank?-instance_method)
28
31
  * [#format](http://rdoc.info/github/bbatsov/powerpack/String#format-instance_method)
data/Rakefile CHANGED
@@ -1 +1,6 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+ require 'yard'
3
+
4
+ YARD::Rake::YardocTask.new do |t|
5
+ t.files = ['lib/**/*.rb']
6
+ end
@@ -2,4 +2,6 @@ require 'powerpack/version'
2
2
 
3
3
  require 'powerpack/hash'
4
4
 
5
+ require 'powerpack/numeric'
6
+
5
7
  require 'powerpack/string'
@@ -2,7 +2,7 @@ unless Hash.method_defined? :symbolize_keys
2
2
  class Hash
3
3
  # Converts the keys of the hash to symbols.
4
4
  #
5
- # @return [Hash] a copy of the original hash with its keys converted to symbols.
5
+ # @return [Hash] a copy of the original hash with its keys converted to symbols
6
6
  #
7
7
  # @example
8
8
  # { 'one' => 1, 'two' => 2 }.symbolize_keys #=> { :one => 1, :two => 2 }
@@ -0,0 +1,2 @@
1
+ require_relative 'numeric/neg'
2
+ require_relative 'numeric/pos'
@@ -0,0 +1,19 @@
1
+ unless Numeric.method_defined? :neg?
2
+ class Numeric
3
+ # Checks whether a number is negative.
4
+ #
5
+ # @return [Boolean] true is the number is negative, false otherwise
6
+ #
7
+ # @example
8
+ # 5.neg? #=> false
9
+ #
10
+ # @example
11
+ # -0.5.neg? #=> true
12
+ #
13
+ # @example
14
+ # 0.neg? #=> false
15
+ def neg?
16
+ self < 0
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ unless Numeric.method_defined? :pos?
2
+ class Numeric
3
+ # Checks whether a number is positive.
4
+ #
5
+ # @return [Boolean] true is the number is positive, false otherwise
6
+ #
7
+ # @example
8
+ # 5.pos? #=> true
9
+ #
10
+ # @example
11
+ # -0.5.pos? #=> false
12
+ #
13
+ # @example
14
+ # 0.pos? #=> false
15
+ def pos?
16
+ self > 0
17
+ end
18
+ end
19
+ end
@@ -1,9 +1,9 @@
1
1
  unless String.method_defined? :blank?
2
2
  class String
3
- # Checks whether a string is blank.
3
+ # Checks whether a string is blank. A string is considered blank if it
4
+ # is either empty or contains only whitespace characters.
4
5
  #
5
- # @return [String] `true` is the string is empty or contains only
6
- # whitespace, `false` otherwise
6
+ # @return [Boolean] true is the string is blank, false otherwise
7
7
  #
8
8
  # @example
9
9
  # ''.blank? #=> true
@@ -1,6 +1,6 @@
1
1
  unless String.method_defined? :format
2
2
  class String
3
- # A nicer alternative to `Kernel#sprintf` and `String#%`.
3
+ # A nicer alternative to Kernel#sprintf and String#%.
4
4
  #
5
5
  # @return [String] the formatted string
6
6
  #
@@ -2,8 +2,8 @@ unless String.method_defined? :squish
2
2
  class String
3
3
  # Strips leading and trailing whitespace and squashes internal whitespace.
4
4
  #
5
- # @return [String] a string with not leading and traling whitespace and no
6
- # consecutive whitespace characters inside it
5
+ # @return [String] a string with no leading and traling whitespace and no
6
+ # consecutive whitespace characters inside it
7
7
  #
8
8
  # @example
9
9
  # ' Peter Parker'.squish #=> 'Peter Parker'
@@ -1,3 +1,3 @@
1
1
  module Powerpack
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Numeric#neg?' do
4
+ it 'returns false for positive integer' do
5
+ expect(1.neg?).to be_false
6
+ end
7
+
8
+ it 'returns false for positive float' do
9
+ expect(0.1.neg?).to be_false
10
+ end
11
+
12
+ it 'returns true for negative integer' do
13
+ expect(-1.neg?).to be_true
14
+ end
15
+
16
+ it 'returns true for negative float' do
17
+ expect(-0.01.neg?).to be_true
18
+ end
19
+
20
+ it 'returns false for 0' do
21
+ expect(0.neg?).to be_false
22
+ expect(0.0.neg?).to be_false
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Numeric#pos?' do
4
+ it 'returns true for positive integer' do
5
+ expect(1.pos?).to be_true
6
+ end
7
+
8
+ it 'returns true for positive float' do
9
+ expect(0.1.pos?).to be_true
10
+ end
11
+
12
+ it 'returns false for negative integer' do
13
+ expect(-1.pos?).to be_false
14
+ end
15
+
16
+ it 'returns false for negative float' do
17
+ expect(-0.01.pos?).to be_false
18
+ end
19
+
20
+ it 'returns false for 0' do
21
+ expect(0.pos?).to be_false
22
+ expect(0.0.pos?).to be_false
23
+ end
24
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: powerpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-09 00:00:00.000000000 Z
11
+ date: 2013-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -83,6 +83,9 @@ files:
83
83
  - lib/powerpack.rb
84
84
  - lib/powerpack/hash.rb
85
85
  - lib/powerpack/hash/symbolize_keys.rb
86
+ - lib/powerpack/numeric.rb
87
+ - lib/powerpack/numeric/neg.rb
88
+ - lib/powerpack/numeric/pos.rb
86
89
  - lib/powerpack/string.rb
87
90
  - lib/powerpack/string/blank.rb
88
91
  - lib/powerpack/string/format.rb
@@ -92,6 +95,8 @@ files:
92
95
  - lib/powerpack/version.rb
93
96
  - powerpack.gemspec
94
97
  - spec/powerpack/hash/symbolize_keys_spec.rb
98
+ - spec/powerpack/numeric/neg_spec.rb
99
+ - spec/powerpack/numeric/pos_spec.rb
95
100
  - spec/powerpack/string/blank_spec.rb
96
101
  - spec/powerpack/string/format_spec.rb
97
102
  - spec/powerpack/string/squish_spec.rb
@@ -124,6 +129,8 @@ specification_version: 4
124
129
  summary: A few useful extensions to core Ruby classes.
125
130
  test_files:
126
131
  - spec/powerpack/hash/symbolize_keys_spec.rb
132
+ - spec/powerpack/numeric/neg_spec.rb
133
+ - spec/powerpack/numeric/pos_spec.rb
127
134
  - spec/powerpack/string/blank_spec.rb
128
135
  - spec/powerpack/string/format_spec.rb
129
136
  - spec/powerpack/string/squish_spec.rb