vidibus-core_extensions 0.3.16 → 0.3.17

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source :rubygems
2
2
 
3
3
  group :development do
4
- gem "rspec", "~> 2.0.0.beta.20"
4
+ gem "rspec"
5
5
  gem "rr"
6
6
  gem "relevance-rcov"
7
7
  end
data/Gemfile.lock CHANGED
@@ -4,16 +4,14 @@ GEM
4
4
  diff-lcs (1.1.2)
5
5
  relevance-rcov (0.9.2.1)
6
6
  rr (1.0.2)
7
- rspec (2.0.1)
8
- rspec-core (~> 2.0.1)
9
- rspec-expectations (~> 2.0.1)
10
- rspec-mocks (~> 2.0.1)
11
- rspec-core (2.0.1)
12
- rspec-expectations (2.0.1)
13
- diff-lcs (>= 1.1.2)
14
- rspec-mocks (2.0.1)
15
- rspec-core (~> 2.0.1)
16
- rspec-expectations (~> 2.0.1)
7
+ rspec (2.5.0)
8
+ rspec-core (~> 2.5.0)
9
+ rspec-expectations (~> 2.5.0)
10
+ rspec-mocks (~> 2.5.0)
11
+ rspec-core (2.5.1)
12
+ rspec-expectations (2.5.0)
13
+ diff-lcs (~> 1.1.2)
14
+ rspec-mocks (2.5.0)
17
15
 
18
16
  PLATFORMS
19
17
  ruby
@@ -21,4 +19,4 @@ PLATFORMS
21
19
  DEPENDENCIES
22
20
  relevance-rcov
23
21
  rr
24
- rspec (~> 2.0.0.beta.20)
22
+ rspec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.16
1
+ 0.3.17
@@ -131,6 +131,33 @@ class Array
131
131
  ordered.compact
132
132
  end
133
133
 
134
+ # Deletes items from self and nested arrays that are equal to obj.
135
+ # If any items are found, returns obj. If the item is not found, returns nil.
136
+ # If the optional code block is given, returns the result of block if the
137
+ # item is not found.
138
+ #
139
+ # Examples:
140
+ #
141
+ # list = ["one", "two", ["one"]]
142
+ # list.delete_rec("one") #=> "one"
143
+ # list #=> ["two", []]
144
+ #
145
+ def delete_rec(obj, &block)
146
+ out = nil
147
+ _self = self
148
+ _self.each do |item|
149
+ _out = nil
150
+ if item.class == Array
151
+ _out = item.delete_rec(obj, &block)
152
+ else
153
+ _out = _self.delete(obj, &block)
154
+ end
155
+ out ||= _out
156
+ end
157
+ self.replace(_self)
158
+ out
159
+ end
160
+
134
161
  private
135
162
 
136
163
  # Returns predecessor of given needle from haystack.
@@ -188,4 +188,12 @@ describe "Array" do
188
188
  list.sort_by_map(map).should eql(["one", "two", "three"])
189
189
  end
190
190
  end
191
+
192
+ describe "#delete_rec" do
193
+ it "should remove a given item from self" do
194
+ list = ["one", "two", ["one"]]
195
+ list.delete_rec("one").should eql("one")
196
+ list.should eql(["two", []])
197
+ end
198
+ end
191
199
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{vidibus-core_extensions}
8
- s.version = "0.3.16"
8
+ s.version = "0.3.17"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andre Pankratz"]
12
- s.date = %q{2011-02-02}
12
+ s.date = %q{2011-02-25}
13
13
  s.description = %q{Provides some extensions to the ruby core.}
14
14
  s.email = %q{andre@vidibus.com}
15
15
  s.extra_rdoc_files = [
@@ -60,16 +60,16 @@ Gem::Specification.new do |s|
60
60
  s.specification_version = 3
61
61
 
62
62
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
63
- s.add_development_dependency(%q<rspec>, ["~> 2.0.0.beta.20"])
63
+ s.add_development_dependency(%q<rspec>, [">= 0"])
64
64
  s.add_development_dependency(%q<rr>, [">= 0"])
65
65
  s.add_development_dependency(%q<relevance-rcov>, [">= 0"])
66
66
  else
67
- s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.20"])
67
+ s.add_dependency(%q<rspec>, [">= 0"])
68
68
  s.add_dependency(%q<rr>, [">= 0"])
69
69
  s.add_dependency(%q<relevance-rcov>, [">= 0"])
70
70
  end
71
71
  else
72
- s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.20"])
72
+ s.add_dependency(%q<rspec>, [">= 0"])
73
73
  s.add_dependency(%q<rr>, [">= 0"])
74
74
  s.add_dependency(%q<relevance-rcov>, [">= 0"])
75
75
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vidibus-core_extensions
3
3
  version: !ruby/object:Gem::Version
4
- hash: 51
4
+ hash: 49
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 16
10
- version: 0.3.16
9
+ - 17
10
+ version: 0.3.17
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andre Pankratz
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-02 00:00:00 +01:00
18
+ date: 2011-02-25 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -25,16 +25,12 @@ dependencies:
25
25
  version_requirements: &id001 !ruby/object:Gem::Requirement
26
26
  none: false
27
27
  requirements:
28
- - - ~>
28
+ - - ">="
29
29
  - !ruby/object:Gem::Version
30
- hash: 62196427
30
+ hash: 3
31
31
  segments:
32
- - 2
33
32
  - 0
34
- - 0
35
- - beta
36
- - 20
37
- version: 2.0.0.beta.20
33
+ version: "0"
38
34
  requirement: *id001
39
35
  - !ruby/object:Gem::Dependency
40
36
  type: :development