metrix_db 0.0.3 → 0.0.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.
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/metrix_db/version.rb +1 -1
- data/lib/metrix_db.rb +2 -2
- data/spec/metrix_db/field_spec.rb +3 -0
- data/spec/metrix_db/{where_spec.rb → first_spec.rb} +8 -8
- metadata +5 -5
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/metrix_db/version.rb
CHANGED
data/lib/metrix_db.rb
CHANGED
@@ -45,7 +45,7 @@ module MetrixDB
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
48
|
+
def first(conditions={})
|
49
49
|
return nil if @dataset.nil? || @fields.nil?
|
50
50
|
@dataset.each do |data|
|
51
51
|
conditions.each_pair do |k, v|
|
@@ -53,6 +53,6 @@ module MetrixDB
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
56
|
-
alias :on :
|
56
|
+
alias :on :first
|
57
57
|
end
|
58
58
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe MetrixDB do
|
4
|
-
context ".
|
4
|
+
context ".first" do
|
5
5
|
before do
|
6
6
|
dataset = [[1,2],[2,3]]
|
7
7
|
@dataset = dataset
|
@@ -14,26 +14,26 @@ describe MetrixDB do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it "find data from first col" do
|
17
|
-
@class.
|
18
|
-
@class.
|
17
|
+
@class.first(:col1 => 1).data.should == [1,2]
|
18
|
+
@class.first(:col1 => 2).data.should == [2,3]
|
19
19
|
end
|
20
20
|
|
21
21
|
it "find data from second col" do
|
22
|
-
@class.
|
23
|
-
@class.
|
22
|
+
@class.first(:col2 => 2).data.should == [1,2]
|
23
|
+
@class.first(:col2 => 3).data.should == [2,3]
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should initialize a instance" do
|
27
|
-
@class.
|
27
|
+
@class.first(:col2 => 2).should be_kind_of @class
|
28
28
|
end
|
29
29
|
|
30
30
|
it "newlly created instance should have instance methods according to field definition" do
|
31
|
-
inst = @class.
|
31
|
+
inst = @class.first(:col2 => 2)
|
32
32
|
inst.col1.should == 1
|
33
33
|
inst.col2.should == 2
|
34
34
|
end
|
35
35
|
|
36
|
-
it "should alias :on to :
|
36
|
+
it "should alias :on to :first" do
|
37
37
|
inst = @class.on(:col2 => 2)
|
38
38
|
inst.col1.should == 1
|
39
39
|
inst.col2.should == 2
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metrix_db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Allen Wei
|
@@ -68,7 +68,7 @@ files:
|
|
68
68
|
- metrix_db.gemspec
|
69
69
|
- spec/metrix_db/data_spec.rb
|
70
70
|
- spec/metrix_db/field_spec.rb
|
71
|
-
- spec/metrix_db/
|
71
|
+
- spec/metrix_db/first_spec.rb
|
72
72
|
- spec/metrix_db_spec.rb
|
73
73
|
- spec/spec_helper.rb
|
74
74
|
has_rdoc: true
|
@@ -108,6 +108,6 @@ summary: Simple DB base on Ruby Array
|
|
108
108
|
test_files:
|
109
109
|
- spec/metrix_db/data_spec.rb
|
110
110
|
- spec/metrix_db/field_spec.rb
|
111
|
-
- spec/metrix_db/
|
111
|
+
- spec/metrix_db/first_spec.rb
|
112
112
|
- spec/metrix_db_spec.rb
|
113
113
|
- spec/spec_helper.rb
|