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 CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- metrix_db (0.0.2)
4
+ metrix_db (0.0.3)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/README.md CHANGED
@@ -36,7 +36,7 @@ Options for field definition
36
36
  Query
37
37
  -----
38
38
 
39
- mydb = MyDB.where(:col1 => 1, :col2 => 2) # nil or instance of MyDB.
39
+ mydb = MyDB.first(:col1 => 1, :col2 => 2) # nil or instance of MyDB.
40
40
  mydb.col1 # => 1
41
41
  mydb.col2 # => 2
42
42
 
@@ -1,3 +1,3 @@
1
1
  module MetrixDb
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/metrix_db.rb CHANGED
@@ -45,7 +45,7 @@ module MetrixDB
45
45
  end
46
46
  end
47
47
 
48
- def where(conditions={})
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 :where
56
+ alias :on :first
57
57
  end
58
58
  end
@@ -45,6 +45,9 @@ describe MetrixDB do
45
45
  dataset [[1],[1]]
46
46
  }}.should_not raise_error
47
47
  end
48
+ end
49
+
50
+ context "" do
48
51
 
49
52
  end
50
53
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe MetrixDB do
4
- context ".where" do
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.where(:col1 => 1).data.should == [1,2]
18
- @class.where(:col1 => 2).data.should == [2,3]
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.where(:col2 => 2).data.should == [1,2]
23
- @class.where(:col2 => 3).data.should == [2,3]
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.where(:col2 => 2).should be_kind_of @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.where(:col2 => 2)
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 :where" do
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: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
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/where_spec.rb
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/where_spec.rb
111
+ - spec/metrix_db/first_spec.rb
112
112
  - spec/metrix_db_spec.rb
113
113
  - spec/spec_helper.rb