ki 0.1.1 → 0.1.2
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/VERSION +1 -1
- data/examples/northpole/Gemfile.lock +1 -1
- data/examples/northpole/app.rb +3 -0
- data/ki.gemspec +2 -2
- data/lib/model.rb +8 -2
- data/spec/model_spec.rb +22 -7
- metadata +3 -3
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.
|
|
1
|
+
0.1.2
|
data/examples/northpole/app.rb
CHANGED
data/ki.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = "ki"
|
|
8
|
-
s.version = "0.1.
|
|
8
|
+
s.version = "0.1.2"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Cristian Mircea Messel"]
|
|
12
|
-
s.date = "2013-02-
|
|
12
|
+
s.date = "2013-02-10"
|
|
13
13
|
s.description = "Fuck setting up a database for your prototypes. Some call it an ORM with a RESTful interface. Some say its for prototyping."
|
|
14
14
|
s.email = "mess110@gmail.com"
|
|
15
15
|
s.executables = ["ki"]
|
data/lib/model.rb
CHANGED
|
@@ -26,9 +26,15 @@ module Ki
|
|
|
26
26
|
|
|
27
27
|
def find
|
|
28
28
|
raise 'params missing' unless @req.params
|
|
29
|
-
raise 'param _id missing' unless @req.params['_id']
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
if @req.params['_id']
|
|
31
|
+
unless @req.params.length == 1
|
|
32
|
+
raise 'no other params allowed when querying _id'
|
|
33
|
+
end
|
|
34
|
+
@hash = @db.find(class_name, @req.params['_id'])
|
|
35
|
+
else
|
|
36
|
+
@hash = @db.find_by(class_name, @req.params)
|
|
37
|
+
end
|
|
32
38
|
raise "#{class_name} not found" if @hash.nil?
|
|
33
39
|
end
|
|
34
40
|
|
data/spec/model_spec.rb
CHANGED
|
@@ -27,16 +27,31 @@ describe Ki::Model do
|
|
|
27
27
|
Zoidberg.new(get).hash['name'].should == 'homer'
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
it "should
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
it "should find objects depending on params" do
|
|
31
|
+
@db.create 'zoidberg', { :name => 'homer', :valid => true }
|
|
32
|
+
@db.create 'zoidberg', { :name => 'bart', :valid => true }
|
|
33
|
+
@db.create 'zoidberg', { :name => 'batman', :valid => false, :cool => true }
|
|
34
|
+
@db.create 'zoidberg', { :name => 'joker', :valid => false, :cool => true }
|
|
35
|
+
@db.create 'zoidberg', { :name => 'joker', :valid => false, :cool => false }
|
|
36
|
+
|
|
37
|
+
r = Zoidberg.new(ReqFactory.new(:get, { :name => 'homer' })).hash
|
|
38
|
+
r[0]['name'].should == 'homer'
|
|
39
|
+
|
|
40
|
+
r = Zoidberg.new(ReqFactory.new(:get, { :valid => true })).hash
|
|
41
|
+
r.length.should == 2
|
|
42
|
+
|
|
43
|
+
r.collect { |z|
|
|
44
|
+
z['valid'].should be_true
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
r = Zoidberg.new(ReqFactory.new(:get, { :valid => false, :cool => true })).hash
|
|
48
|
+
r.length.should == 2
|
|
34
49
|
end
|
|
35
50
|
|
|
36
|
-
it "should raise error
|
|
51
|
+
it "should raise error when _id and other params are given. it should be _id only" do
|
|
37
52
|
expect {
|
|
38
|
-
Zoidberg.new(ReqFactory.new(:
|
|
39
|
-
}.to raise_error
|
|
53
|
+
Zoidberg.new(ReqFactory.new(:get, { '_id' => 'hi', 'foo' => 'bar'}))
|
|
54
|
+
}.to raise_error 'no other params allowed when querying _id'
|
|
40
55
|
end
|
|
41
56
|
|
|
42
57
|
it "should only accept valid object ids" do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ki
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-02-
|
|
12
|
+
date: 2013-02-10 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rack
|
|
@@ -293,7 +293,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
293
293
|
version: '0'
|
|
294
294
|
segments:
|
|
295
295
|
- 0
|
|
296
|
-
hash: -
|
|
296
|
+
hash: -3381699098757723557
|
|
297
297
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
298
298
|
none: false
|
|
299
299
|
requirements:
|