ruby_extendsions 0.1.8 → 0.1.8.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,3 +2,4 @@ source :gemcutter
2
2
 
3
3
  # Specify your gem's dependencies in ruby_extend.gemspec
4
4
  gemspec
5
+
@@ -1,3 +1,4 @@
1
+ require 'set'
1
2
  require 'ruby_extendsions/hash_extendsions'
2
3
  require 'ruby_extendsions/array_extendsions'
3
4
 
@@ -1,10 +1,11 @@
1
1
  module RubyExtendsions
2
2
  module ArrayExtendsions
3
- def self.included(base)
4
- base.send :include, InstanceMethods
5
- base.send :extend, ClassMethods
6
- end
7
-
3
+ # def self.included(base)
4
+ # base.send :include, InstanceMethods
5
+ # base.send :extend, ClassMethods
6
+ # end
7
+ extend ActiveSupport::Concern
8
+
8
9
  module InstanceMethods
9
10
  def fill_nil(val)
10
11
  self.inject([]) {|s, a| s << (a.nil? ? a=val : a)}
@@ -48,13 +49,21 @@ module RubyExtendsions
48
49
  return if l>u
49
50
  m=(l+u)/2
50
51
  return if !(e.class == self[m].class)
51
- (e < self[m] ? u=m-1 : l=m+1)
52
+ e < self[m] ? u=m-1 : l=m+1
52
53
  e == self[m] ? m : binary_search_index(e,l,u)
53
54
  end
55
+
54
56
  # 基于二分查找的include?
55
- def b_include?(e)
57
+ def b_include? e
56
58
  !self.binary_search_index(e).nil?
57
59
  end
60
+
61
+ #比较两个数组内容相同
62
+ def compare_content com_arr
63
+ arr = Set.new self
64
+ com_arr = Set.new com_arr
65
+ return arr == com_arr
66
+ end
58
67
 
59
68
  end#InstanceMethods
60
69
 
@@ -2,18 +2,19 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "ruby_extendsions"
5
- s.version = "0.1.8"
5
+ s.version = "0.1.8.1"
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ["blackanger"]
8
8
  s.email = ["blackanger.z@gmail.com"]
9
9
  s.homepage = "http://rubygems.org/gems/ruby_extendsions"
10
10
  s.summary = "Ruby Extendsions For Hash"
11
- s.description = "Ruby Extendsions"
11
+ s.description = "Ruby Extendsions for rails 3.0.5+"
12
12
 
13
13
  s.required_rubygems_version = ">= 1.3.6"
14
14
  s.rubyforge_project = "ruby_extendsions"
15
15
  s.add_development_dependency "bundler", ">= 1.0.0"
16
16
  s.add_development_dependency "rspec"
17
+ s.add_development_dependency "rails", ">=3.0.5"
17
18
 
18
19
  s.files = `git ls-files`.split("\n")
19
20
  s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
data/spec/array_spec.rb CHANGED
@@ -45,4 +45,12 @@ describe "RubyExtend::ArrayExtendsions" do
45
45
  arr.b_include?(9999).should be_true
46
46
  end
47
47
 
48
+ it "should be compare the elements between the two Array objects" do
49
+ arr, brr = [1,2,3], [3,2,1]
50
+ foo, bar = [1,2,3], [3,2,1,4]
51
+ arr.compare_content(brr).should be_true
52
+ foo.compare_content(bar).should be_false
53
+ (arr == brr ).should be_false
54
+ end
55
+
48
56
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_extendsions
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 101
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
9
  - 8
10
- version: 0.1.8
10
+ - 1
11
+ version: 0.1.8.1
11
12
  platform: ruby
12
13
  authors:
13
14
  - blackanger
@@ -48,7 +49,23 @@ dependencies:
48
49
  version: "0"
49
50
  type: :development
50
51
  version_requirements: *id002
51
- description: Ruby Extendsions
52
+ - !ruby/object:Gem::Dependency
53
+ name: rails
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 13
61
+ segments:
62
+ - 3
63
+ - 0
64
+ - 5
65
+ version: 3.0.5
66
+ type: :development
67
+ version_requirements: *id003
68
+ description: Ruby Extendsions for rails 3.0.5+
52
69
  email:
53
70
  - blackanger.z@gmail.com
54
71
  executables: []