efo_nelfo 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7cd36136a8426da58c3b6c2ce3c4bf4c877d8909
4
- data.tar.gz: a4d291f32bd8dcf424ee8838210c4630fa2f6d03
3
+ metadata.gz: bc150385ebc532a1ce0a57b768e06fa4e4a58a26
4
+ data.tar.gz: 65a4ced11a05a2276172feab4660ac930675b15b
5
5
  SHA512:
6
- metadata.gz: 4058a0deb87c886511770d283a52117bac37400d939b5cb93b9a3e26c98fe1904f183b785e64b14ceba37facfea22f5ef7dbe543e2413979d5ba22c6cdc8d2ce
7
- data.tar.gz: 94e3115db5dece52aa977f7b9338dc78f4e52fdefcdba0fcd411af77287177d6f6a5b27747e870f9ca579a1af18c068f4a18a4b79a2c9eab93955c3165b523ea
6
+ metadata.gz: 7a89ef9514bef3958804325c47b53e4f7d86a723f4ae88fa9be96ecfe66fa3b7b536b52793a78febe89c9e20f659c9a200b158918e0f67f92c7e086fd6455cec
7
+ data.tar.gz: 8f12faf70709eece907240b69dd733211a0df98c34fba5e8a8aeb0f59466c7f29628a77edfb31e65fd315c67f1e0ef0eaa906f092d0db83b7337ba20a39c12c7
@@ -0,0 +1,9 @@
1
+ {
2
+ "folders":
3
+ [
4
+ {
5
+ "follow_symlinks": true,
6
+ "path": "."
7
+ }
8
+ ]
9
+ }
@@ -26,10 +26,20 @@ module EfoNelfo
26
26
  @list << obj
27
27
  end
28
28
 
29
+ def delete(index)
30
+ @list.delete_at index
31
+ end
32
+
29
33
  def to_a
30
34
  map(&:to_a).flatten(1)
31
35
  end
32
36
 
37
+ # find_by property_name: 'test'
38
+ def find_by(args)
39
+ key = args.keys.first; value = args.values.first
40
+ @list.select { |l| l.respond_to?(key) && l.public_send(key) == value }
41
+ end
42
+
33
43
  private
34
44
  attr_reader :list
35
45
 
@@ -1,3 +1,3 @@
1
1
  module EfoNelfo
2
- VERSION = "1.4.0"
2
+ VERSION = "1.5.0"
3
3
  end
@@ -1,6 +1,21 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe EfoNelfo::Collection do
4
+ module EfoNelfo
5
+ module V21
6
+ class MyType < EfoNelfo::PostType
7
+ property :whatever
8
+ property :version
9
+ end
10
+
11
+ class BT < EfoNelfo::PostType
12
+ property :post_type
13
+ property :whatever
14
+ property :version
15
+ end
16
+ end
17
+ end
18
+
4
19
  Owner = Class.new do
5
20
  def self.version_from_class
6
21
  '21'
@@ -15,21 +30,13 @@ describe EfoNelfo::Collection do
15
30
  array.post_type.must_equal "BT"
16
31
  end
17
32
 
33
+ it ".delete removes the element at given position" do
34
+ array << { post_type: "BT", whatever: 'blah' }
35
+ array.delete(0)
36
+ array.size.must_equal 0
37
+ end
38
+
18
39
  describe "<<" do
19
- module EfoNelfo
20
- module V21
21
- class MyType < EfoNelfo::PostType
22
- property :whatever
23
- property :version
24
- end
25
-
26
- class BT < EfoNelfo::PostType
27
- property :post_type
28
- property :whatever
29
- property :version
30
- end
31
- end
32
- end
33
40
 
34
41
  describe "passing a hash" do
35
42
  let(:hash) {
@@ -65,4 +72,25 @@ describe EfoNelfo::Collection do
65
72
  end
66
73
  end
67
74
 
75
+ describe "#find_by" do
76
+ before do
77
+ array << { post_type: 'BT', whatever: 'foo' }
78
+ array << { post_type: 'BT', whatever: 'bar' }
79
+ end
80
+
81
+ it "returns the matching rows" do
82
+ array.find_by(whatever: 'foo').must_be_instance_of Array
83
+ array.find_by(whatever: 'foo').first.must_be_instance_of EfoNelfo::V21::BT
84
+ end
85
+
86
+ it "returns empty array when no rows could be found" do
87
+ array.find_by(whatever: 'barr').must_be_empty
88
+ end
89
+
90
+ it "returns empty array when trying to search for a key that doesn't exist" do
91
+ array.find_by(blue_dragon_breath: 'wtf').must_be_empty
92
+ end
93
+
94
+ end
95
+
68
96
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: efo_nelfo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gudleik Rasch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-10 00:00:00.000000000 Z
11
+ date: 2013-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -122,6 +122,7 @@ files:
122
122
  - README.md
123
123
  - Rakefile
124
124
  - efo_nelfo.gemspec
125
+ - efonelfo.sublime-project
125
126
  - lib/efo_nelfo.rb
126
127
  - lib/efo_nelfo/collection.rb
127
128
  - lib/efo_nelfo/errors.rb
@@ -186,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
187
  version: '0'
187
188
  requirements: []
188
189
  rubyforge_project:
189
- rubygems_version: 2.0.3
190
+ rubygems_version: 2.1.5
190
191
  signing_key:
191
192
  specification_version: 4
192
193
  summary: Parser for EFONELFO format