ruby_extendsions 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,6 +22,16 @@ module RubyExtendsions
22
22
  s << t << '),'
23
23
  end.chop
24
24
  end
25
+
26
+ #whether the array is all nil item
27
+ # like arr = [nil,nil,nil,nil]
28
+ # arr.is_nil_all? #=> true
29
+ def is_nil_all?
30
+ b = true
31
+ self.each {|i| b = false if !i.nil? }
32
+ return b
33
+ end
34
+
25
35
  end#InstanceMethods
26
36
 
27
37
  module ClassMethods
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "ruby_extendsions"
5
- s.version = "0.1.4"
5
+ s.version = "0.1.5"
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ["blackanger"]
8
8
  s.email = ["blackanger.z@gmail.com"]
data/spec/array_spec.rb CHANGED
@@ -4,10 +4,14 @@ describe "RubyExtend::ArrayExtendsions" do
4
4
  before(:each) do
5
5
  @arr1 = [1, 2, 3, nil, nil, nil]
6
6
  @arr2 = [[1,2,3,nil,4],[4,5,6,nil,nil]]
7
+ @arr3 = [nil,nil,nil,nil]
8
+ @arr4 = [nil,nil,1,nil,nil]
7
9
  end
8
10
 
9
11
  it "A array data should have not fill_nil method if havn't use ruby_extend " do
10
12
  @arr1.respond_to?("fill_nil").should eql false
13
+ @arr2.respond_to?("format_mess_insert").should eql false
14
+ @arr2.respond_to?("is_nil_all?").should eql false
11
15
  end
12
16
 
13
17
  it "A array include nil object data should be fill value" do
@@ -21,4 +25,10 @@ describe "RubyExtend::ArrayExtendsions" do
21
25
  @arr2.format_mess_insert.should eql("('1','2','3','','4'),('4','5','6','','')")
22
26
  end
23
27
 
28
+ it "whether the Array is all nil item" do
29
+ require 'ruby_extendsions'
30
+ @arr3.is_nil_all?.should eql true
31
+ @arr4.is_nil_all?.should eql false
32
+ end
33
+
24
34
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_extendsions
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
9
+ - 5
10
+ version: 0.1.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - blackanger
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-30 00:00:00 +08:00
18
+ date: 2011-01-04 00:00:00 +08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency