ki 0.2.4 → 0.2.5
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/ki.gemspec +2 -2
- data/lib/model.rb +4 -0
- data/lib/modules/model_helpers.rb +4 -0
- data/lib/modules/restrictions.rb +15 -0
- data/lib/resp.rb +1 -1
- data/lib/util.rb +11 -2
- data/spec/modules/restrictions_spec.rb +13 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.5
|
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.2.
|
8
|
+
s.version = "0.2.5"
|
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-23"
|
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
@@ -16,6 +16,8 @@ module Ki
|
|
16
16
|
attr_accessor :hash
|
17
17
|
attr_accessor :req
|
18
18
|
|
19
|
+
layout :layout
|
20
|
+
|
19
21
|
def initialize req
|
20
22
|
@hash = {}
|
21
23
|
@db = Db.instance
|
@@ -100,6 +102,8 @@ module Ki
|
|
100
102
|
send m.to_sym
|
101
103
|
send "after_#{m.to_s}".to_sym
|
102
104
|
after_all
|
105
|
+
rescue BSON::InvalidObjectId
|
106
|
+
raise "invalid _id format: #{params['_id']}"
|
103
107
|
end
|
104
108
|
end
|
105
109
|
|
data/lib/modules/restrictions.rb
CHANGED
@@ -59,5 +59,20 @@ module Ki
|
|
59
59
|
attributes
|
60
60
|
end
|
61
61
|
end
|
62
|
+
|
63
|
+
def selected_layout
|
64
|
+
:layout
|
65
|
+
end
|
66
|
+
|
67
|
+
def layout l
|
68
|
+
send :define_method, :selected_layout do
|
69
|
+
l
|
70
|
+
end
|
71
|
+
|
72
|
+
eigen_class = class << self; self; end
|
73
|
+
eigen_class.send(:define_method, :selected_layout) do
|
74
|
+
l
|
75
|
+
end
|
76
|
+
end
|
62
77
|
end
|
63
78
|
end
|
data/lib/resp.rb
CHANGED
data/lib/util.rb
CHANGED
@@ -2,6 +2,10 @@ class NilClass
|
|
2
2
|
def responds_to_formats
|
3
3
|
[:json, :html]
|
4
4
|
end
|
5
|
+
|
6
|
+
def selected_layout
|
7
|
+
:layout
|
8
|
+
end
|
5
9
|
end
|
6
10
|
|
7
11
|
class String
|
@@ -71,9 +75,14 @@ module Ki
|
|
71
75
|
File.basename(root)
|
72
76
|
end
|
73
77
|
|
74
|
-
def self.render_partial s, hash={}
|
78
|
+
def self.render_partial s, hash={}, l=:layout
|
75
79
|
contents = file_contents(s)
|
76
|
-
|
80
|
+
case l
|
81
|
+
when :none
|
82
|
+
layout_contents = "= yield"
|
83
|
+
else
|
84
|
+
layout_contents = file_contents(l.to_s)
|
85
|
+
end
|
77
86
|
|
78
87
|
haml(layout_contents).render do
|
79
88
|
haml(contents).render(Object.new(), hash)
|
@@ -85,4 +85,17 @@ describe Ki::Restrictions do
|
|
85
85
|
Bar.new(ReqFactory.new(:post, { 'foo' => 'bar'}))
|
86
86
|
}.to raise_error 'foo not unique'
|
87
87
|
end
|
88
|
+
|
89
|
+
it "should default to :layout" do
|
90
|
+
class Foo < Ki::Model
|
91
|
+
end
|
92
|
+
Foo.selected_layout.should == :layout
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should chage default layout" do
|
96
|
+
class Foo < Ki::Model
|
97
|
+
layout :none
|
98
|
+
end
|
99
|
+
Foo.selected_layout.should == :none
|
100
|
+
end
|
88
101
|
end
|
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.2.
|
4
|
+
version: 0.2.5
|
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-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -343,7 +343,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
343
343
|
version: '0'
|
344
344
|
segments:
|
345
345
|
- 0
|
346
|
-
hash:
|
346
|
+
hash: -2281689135110628816
|
347
347
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
348
348
|
none: false
|
349
349
|
requirements:
|