metrix_db 0.0.8 → 0.0.9
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/lib/metrix_db.rb +3 -1
- data/lib/metrix_db/version.rb +1 -1
- data/spec/metrix_db/query_spec.rb +6 -0
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/lib/metrix_db.rb
CHANGED
@@ -58,11 +58,13 @@ module MetrixDB
|
|
58
58
|
def on(conditions={})
|
59
59
|
return nil if @dataset.nil? || @fields.nil?
|
60
60
|
@dataset.each_with_index do |data, index|
|
61
|
+
hash = {}
|
61
62
|
conditions.each_pair do |k, v|
|
62
63
|
if data[@fields[k.to_sym]] == v
|
63
|
-
|
64
|
+
hash[k.to_sym] = v
|
64
65
|
end
|
65
66
|
end
|
67
|
+
return get_from_cache(index) if hash == conditions
|
66
68
|
end
|
67
69
|
return nil
|
68
70
|
end
|
data/lib/metrix_db/version.rb
CHANGED
@@ -23,6 +23,12 @@ describe MetrixDB do
|
|
23
23
|
@class.on(:col2 => 3).data.should == [2,3]
|
24
24
|
end
|
25
25
|
|
26
|
+
it "use two conditions" do
|
27
|
+
@class.on(:col1 => 2, :col2 => 3).data.should == [2,3]
|
28
|
+
@class.on(:col1 => 1, :col2 => 2).data.should == [1,2]
|
29
|
+
end
|
30
|
+
|
31
|
+
|
26
32
|
it "should initialize a instance" do
|
27
33
|
@class.on(:col2 => 2).should be_kind_of @class
|
28
34
|
end
|
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: 13
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 9
|
10
|
+
version: 0.0.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Allen Wei
|