ruby_extendsions 0.1.3 → 0.1.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.
@@ -13,6 +13,15 @@ module RubyExtendsions
13
13
  def fill_nil!(val)
14
14
  self.each_index { |i| self[i] ||= val }
15
15
  end
16
+
17
+ #change [[1,2,3][4,5,6]] to ('1','2','3'),('4','5','6')
18
+ #be used with mess insert mysql
19
+ def format_mess_insert
20
+ self.inject('') do |s,i|
21
+ t = i.inject('(') { |x, n| x << "'#{n}'," }.chop
22
+ s << t << '),'
23
+ end.chop
24
+ end
16
25
  end#InstanceMethods
17
26
 
18
27
  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.3"
5
+ s.version = "0.1.4"
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ["blackanger"]
8
8
  s.email = ["blackanger.z@gmail.com"]
@@ -0,0 +1,24 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "RubyExtend::ArrayExtendsions" do
4
+ before(:each) do
5
+ @arr1 = [1, 2, 3, nil, nil, nil]
6
+ @arr2 = [[1,2,3,nil,4],[4,5,6,nil,nil]]
7
+ end
8
+
9
+ it "A array data should have not fill_nil method if havn't use ruby_extend " do
10
+ @arr1.respond_to?("fill_nil").should eql false
11
+ end
12
+
13
+ it "A array include nil object data should be fill value" do
14
+ require 'ruby_extendsions'
15
+ @arr1.fill_nil!('')
16
+ @arr1.should eql([1,2,3,'','',''])
17
+ end
18
+
19
+ it "format_mess_insert should be successful!" do
20
+ require 'ruby_extendsions'
21
+ @arr2.format_mess_insert.should eql("('1','2','3','','4'),('4','5','6','','')")
22
+ end
23
+
24
+ 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: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
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-29 00:00:00 +08:00
18
+ date: 2010-12-30 00:00:00 +08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -68,6 +68,7 @@ files:
68
68
  - lib/ruby_extendsions/array_extendsions.rb
69
69
  - lib/ruby_extendsions/hash_extendsions.rb
70
70
  - ruby_extendsions.gemspec
71
+ - spec/array_spec.rb
71
72
  - spec/hash_spec.rb
72
73
  - spec/spec_helper.rb
73
74
  has_rdoc: true