ki 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/Gemfile.lock +75 -45
- data/README.rdoc +0 -17
- data/VERSION +1 -1
- data/ki.gemspec +8 -5
- data/lib/model.rb +1 -6
- data/lib/{extensions/mail.rb → modules/email.rb} +4 -10
- data/lib/req.rb +9 -1
- data/lib/resp.rb +8 -2
- data/lib/static_file.rb +4 -1
- data/spec/{extensions/mail_spec.rb → modules/email_spec.rb} +3 -10
- metadata +22 -6
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,81 +1,110 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
addressable (2.3.5)
|
5
|
+
bson (1.9.2)
|
6
|
+
bson_ext (1.9.2)
|
7
|
+
bson (~> 1.9.2)
|
8
|
+
builder (3.2.2)
|
9
|
+
coderay (1.0.9)
|
8
10
|
coffee-script (2.2.0)
|
9
11
|
coffee-script-source
|
10
12
|
execjs
|
11
|
-
coffee-script-source (1.
|
13
|
+
coffee-script-source (1.6.3)
|
12
14
|
daemons (1.1.9)
|
13
|
-
diff-lcs (1.
|
14
|
-
eventmachine (1.0.
|
15
|
-
execjs (
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
diff-lcs (1.2.4)
|
16
|
+
eventmachine (1.0.3)
|
17
|
+
execjs (2.0.0)
|
18
|
+
faraday (0.8.8)
|
19
|
+
multipart-post (~> 1.2.0)
|
20
|
+
ffi (1.9.0)
|
21
|
+
formatador (0.2.4)
|
22
|
+
git (1.2.6)
|
23
|
+
github_api (0.10.1)
|
24
|
+
addressable
|
25
|
+
faraday (~> 0.8.1)
|
26
|
+
hashie (>= 1.2)
|
27
|
+
multi_json (~> 1.4)
|
28
|
+
nokogiri (~> 1.5.2)
|
29
|
+
oauth2
|
30
|
+
guard (1.7.0)
|
31
|
+
formatador (>= 0.2.4)
|
20
32
|
listen (>= 0.6.0)
|
21
33
|
lumberjack (>= 1.0.2)
|
22
34
|
pry (>= 0.9.10)
|
23
|
-
terminal-table (>= 1.4.3)
|
24
35
|
thor (>= 0.14.6)
|
25
|
-
guard-rspec (2.4
|
36
|
+
guard-rspec (2.5.4)
|
26
37
|
guard (>= 1.1)
|
27
38
|
rspec (~> 2.11)
|
28
|
-
haml (
|
29
|
-
|
30
|
-
|
39
|
+
haml (4.0.3)
|
40
|
+
tilt
|
41
|
+
hashie (2.0.5)
|
42
|
+
highline (1.6.19)
|
43
|
+
httpauth (0.2.0)
|
44
|
+
jeweler (1.8.7)
|
45
|
+
builder
|
31
46
|
bundler (~> 1.0)
|
32
47
|
git (>= 1.2.5)
|
48
|
+
github_api (= 0.10.1)
|
49
|
+
highline (>= 1.6.15)
|
50
|
+
nokogiri (= 1.5.10)
|
33
51
|
rake
|
34
52
|
rdoc
|
35
|
-
json (1.
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
53
|
+
json (1.8.0)
|
54
|
+
jwt (0.1.8)
|
55
|
+
multi_json (>= 1.5)
|
56
|
+
listen (0.7.3)
|
57
|
+
lumberjack (1.0.4)
|
58
|
+
mail (2.5.4)
|
40
59
|
mime-types (~> 1.16)
|
41
60
|
treetop (~> 1.4.8)
|
42
|
-
method_source (0.8.
|
43
|
-
mime-types (1.
|
44
|
-
mongo (1.
|
45
|
-
bson (~> 1.
|
46
|
-
multi_json (1.
|
61
|
+
method_source (0.8.2)
|
62
|
+
mime-types (1.24)
|
63
|
+
mongo (1.9.2)
|
64
|
+
bson (~> 1.9.2)
|
65
|
+
multi_json (1.7.9)
|
66
|
+
multi_xml (0.5.5)
|
67
|
+
multipart-post (1.2.0)
|
68
|
+
nokogiri (1.5.10)
|
69
|
+
oauth2 (0.9.2)
|
70
|
+
faraday (~> 0.8)
|
71
|
+
httpauth (~> 0.2)
|
72
|
+
jwt (~> 0.1.4)
|
73
|
+
multi_json (~> 1.0)
|
74
|
+
multi_xml (~> 0.5)
|
75
|
+
rack (~> 1.2)
|
47
76
|
polyglot (0.3.3)
|
48
|
-
pry (0.9.
|
77
|
+
pry (0.9.12.2)
|
49
78
|
coderay (~> 1.0.5)
|
50
79
|
method_source (~> 0.8)
|
51
80
|
slop (~> 3.4)
|
52
|
-
rack (1.5.
|
53
|
-
rake (10.0
|
81
|
+
rack (1.5.2)
|
82
|
+
rake (10.1.0)
|
54
83
|
rb-inotify (0.8.8)
|
55
84
|
ffi (>= 0.5.0)
|
56
|
-
rdoc (
|
85
|
+
rdoc (4.0.1)
|
57
86
|
json (~> 1.4)
|
58
|
-
rspec (2.
|
59
|
-
rspec-core (~> 2.
|
60
|
-
rspec-expectations (~> 2.
|
61
|
-
rspec-mocks (~> 2.
|
62
|
-
rspec-core (2.
|
63
|
-
rspec-expectations (2.
|
64
|
-
diff-lcs (
|
65
|
-
rspec-mocks (2.
|
66
|
-
sass (3.2.
|
87
|
+
rspec (2.14.1)
|
88
|
+
rspec-core (~> 2.14.0)
|
89
|
+
rspec-expectations (~> 2.14.0)
|
90
|
+
rspec-mocks (~> 2.14.0)
|
91
|
+
rspec-core (2.14.5)
|
92
|
+
rspec-expectations (2.14.2)
|
93
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
94
|
+
rspec-mocks (2.14.3)
|
95
|
+
sass (3.2.10)
|
67
96
|
simplecov (0.7.1)
|
68
97
|
multi_json (~> 1.0)
|
69
98
|
simplecov-html (~> 0.7.1)
|
70
99
|
simplecov-html (0.7.1)
|
71
|
-
slop (3.4.
|
72
|
-
|
73
|
-
thin (1.5.0)
|
100
|
+
slop (3.4.6)
|
101
|
+
thin (1.5.1)
|
74
102
|
daemons (>= 1.0.9)
|
75
103
|
eventmachine (>= 0.12.6)
|
76
104
|
rack (>= 1.0.0)
|
77
|
-
thor (0.
|
78
|
-
|
105
|
+
thor (0.18.1)
|
106
|
+
tilt (1.4.1)
|
107
|
+
treetop (1.4.15)
|
79
108
|
polyglot
|
80
109
|
polyglot (>= 0.3.1)
|
81
110
|
|
@@ -89,6 +118,7 @@ DEPENDENCIES
|
|
89
118
|
guard-rspec
|
90
119
|
haml
|
91
120
|
jeweler
|
121
|
+
json
|
92
122
|
mail
|
93
123
|
mongo
|
94
124
|
rack
|
data/README.rdoc
CHANGED
@@ -1,20 +1,3 @@
|
|
1
1
|
= ki
|
2
2
|
|
3
|
-
Description goes here.
|
4
|
-
|
5
|
-
== Contributing to ki
|
6
|
-
|
7
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
-
* Fork the project.
|
10
|
-
* Start a feature/bugfix branch.
|
11
|
-
* Commit and push until you are happy with your contribution.
|
12
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
-
|
15
3
|
http://openclipart.org/detail/97081/polar-bear-by-aguasas
|
16
|
-
|
17
|
-
== Copyright
|
18
|
-
|
19
|
-
Copyright (c) 2013 Cristian Mircea Messel. See LICENSE.txt for
|
20
|
-
further details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.3
|
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.3.
|
8
|
+
s.version = "0.3.3"
|
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-
|
12
|
+
s.date = "2013-09-02"
|
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"]
|
@@ -41,13 +41,13 @@ Gem::Specification.new do |s|
|
|
41
41
|
"ki_wrap.rb",
|
42
42
|
"lib/conf.rb",
|
43
43
|
"lib/db.rb",
|
44
|
-
"lib/extensions/mail.rb",
|
45
44
|
"lib/helpers.rb",
|
46
45
|
"lib/ki.rb",
|
47
46
|
"lib/ki_cli.rb",
|
48
47
|
"lib/mockreq.rb",
|
49
48
|
"lib/model.rb",
|
50
49
|
"lib/modules/callbacks.rb",
|
50
|
+
"lib/modules/email.rb",
|
51
51
|
"lib/modules/model_helpers.rb",
|
52
52
|
"lib/modules/query_interface.rb",
|
53
53
|
"lib/modules/restrictions.rb",
|
@@ -61,11 +61,11 @@ Gem::Specification.new do |s|
|
|
61
61
|
"lib/views/layout.haml",
|
62
62
|
"spec/conf_spec.rb",
|
63
63
|
"spec/db_spec.rb",
|
64
|
-
"spec/extensions/mail_spec.rb",
|
65
64
|
"spec/integration/integration_spec.rb",
|
66
65
|
"spec/ki_spec.rb",
|
67
66
|
"spec/model_spec.rb",
|
68
67
|
"spec/modules/callbacks_spec.rb",
|
68
|
+
"spec/modules/email_spec.rb",
|
69
69
|
"spec/modules/query_interface_spec.rb",
|
70
70
|
"spec/modules/restrictions_spec.rb",
|
71
71
|
"spec/performance/performance.sh",
|
@@ -76,7 +76,7 @@ Gem::Specification.new do |s|
|
|
76
76
|
s.homepage = "http://github.com/mess110/ki"
|
77
77
|
s.licenses = ["MIT"]
|
78
78
|
s.require_paths = ["lib"]
|
79
|
-
s.rubygems_version = "1.8.
|
79
|
+
s.rubygems_version = "1.8.23"
|
80
80
|
s.summary = "Prototyping noSQL RESTful API cloud database"
|
81
81
|
|
82
82
|
if s.respond_to? :specification_version then
|
@@ -92,6 +92,7 @@ Gem::Specification.new do |s|
|
|
92
92
|
s.add_runtime_dependency(%q<coffee-script>, [">= 0"])
|
93
93
|
s.add_runtime_dependency(%q<thin>, [">= 0"])
|
94
94
|
s.add_runtime_dependency(%q<mail>, [">= 0"])
|
95
|
+
s.add_runtime_dependency(%q<json>, [">= 0"])
|
95
96
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
96
97
|
s.add_development_dependency(%q<guard-rspec>, [">= 0"])
|
97
98
|
s.add_development_dependency(%q<rb-inotify>, ["~> 0.8.8"])
|
@@ -109,6 +110,7 @@ Gem::Specification.new do |s|
|
|
109
110
|
s.add_dependency(%q<coffee-script>, [">= 0"])
|
110
111
|
s.add_dependency(%q<thin>, [">= 0"])
|
111
112
|
s.add_dependency(%q<mail>, [">= 0"])
|
113
|
+
s.add_dependency(%q<json>, [">= 0"])
|
112
114
|
s.add_dependency(%q<rspec>, [">= 0"])
|
113
115
|
s.add_dependency(%q<guard-rspec>, [">= 0"])
|
114
116
|
s.add_dependency(%q<rb-inotify>, ["~> 0.8.8"])
|
@@ -127,6 +129,7 @@ Gem::Specification.new do |s|
|
|
127
129
|
s.add_dependency(%q<coffee-script>, [">= 0"])
|
128
130
|
s.add_dependency(%q<thin>, [">= 0"])
|
129
131
|
s.add_dependency(%q<mail>, [">= 0"])
|
132
|
+
s.add_dependency(%q<json>, [">= 0"])
|
130
133
|
s.add_dependency(%q<rspec>, [">= 0"])
|
131
134
|
s.add_dependency(%q<guard-rspec>, [">= 0"])
|
132
135
|
s.add_dependency(%q<rb-inotify>, ["~> 0.8.8"])
|
data/lib/model.rb
CHANGED
@@ -2,8 +2,7 @@ require 'modules/callbacks'
|
|
2
2
|
require 'modules/restrictions'
|
3
3
|
require 'modules/query_interface'
|
4
4
|
require 'modules/model_helpers'
|
5
|
-
|
6
|
-
require 'extensions/mail'
|
5
|
+
require 'modules/email'
|
7
6
|
|
8
7
|
module Ki
|
9
8
|
class Model
|
@@ -108,8 +107,4 @@ module Ki
|
|
108
107
|
raise "invalid id format: #{params['id']}"
|
109
108
|
end
|
110
109
|
end
|
111
|
-
|
112
|
-
class Site < Model
|
113
|
-
respond_to :html
|
114
|
-
end
|
115
110
|
end
|
@@ -2,14 +2,7 @@ require 'mail'
|
|
2
2
|
require 'net/smtp'
|
3
3
|
|
4
4
|
module Ki
|
5
|
-
|
6
|
-
# Include it in a Ki::Model to load its send_mail method
|
7
|
-
#
|
8
|
-
# === Example
|
9
|
-
# class Article < Ki::Model
|
10
|
-
# include Ki::EMail
|
11
|
-
# end
|
12
|
-
module EMail
|
5
|
+
module Email
|
13
6
|
def valid_mail? s
|
14
7
|
return false if s == '' || s.nil?
|
15
8
|
r = /^[a-z0-9\+\-\.]+@[a-z0-9]+\.[a-z0-9\.\-]+$/i =~ s
|
@@ -22,10 +15,10 @@ module Ki
|
|
22
15
|
if params.length != 4
|
23
16
|
raise 'params missing'
|
24
17
|
end
|
25
|
-
|
18
|
+
|
26
19
|
params.each do |elem|
|
27
20
|
if !self.class.required_attributes.include? elem
|
28
|
-
raise "invalid attribute #{elem.to_s}"
|
21
|
+
raise "invalid attribute #{elem.to_s}"
|
29
22
|
end
|
30
23
|
end
|
31
24
|
|
@@ -53,5 +46,6 @@ module Ki
|
|
53
46
|
smtp.send_message msgstr, f, t
|
54
47
|
end
|
55
48
|
end
|
49
|
+
|
56
50
|
end
|
57
51
|
end
|
data/lib/req.rb
CHANGED
@@ -18,7 +18,11 @@ module Ki
|
|
18
18
|
def route
|
19
19
|
@klass = Util.base(path).to_class
|
20
20
|
@format = content_type == 'application/json' ? :json : Util.format(path)
|
21
|
-
@
|
21
|
+
if @klass || path == '/' || has_view?
|
22
|
+
@code = 200
|
23
|
+
else
|
24
|
+
@code = 404
|
25
|
+
end
|
22
26
|
end
|
23
27
|
|
24
28
|
def json?
|
@@ -40,6 +44,10 @@ module Ki
|
|
40
44
|
}[@format]
|
41
45
|
end
|
42
46
|
|
47
|
+
def has_view?
|
48
|
+
File.exists?(Util.root_view_path(Util.base(path)))
|
49
|
+
end
|
50
|
+
|
43
51
|
private
|
44
52
|
|
45
53
|
def static_path_requested?
|
data/lib/resp.rb
CHANGED
@@ -13,6 +13,8 @@ module Ki
|
|
13
13
|
}
|
14
14
|
|
15
15
|
# TODO think of a way to clean this up
|
16
|
+
# here be dragons. don't try to understand this because it is a nested mess
|
17
|
+
# it is my duty to clean it. one day
|
16
18
|
klass = @req.klass
|
17
19
|
if klass.responds_to_formats.include? @req.format
|
18
20
|
if @req.code == 404
|
@@ -21,9 +23,13 @@ module Ki
|
|
21
23
|
if @req.index?
|
22
24
|
body = @req.html? ? partial('index') : { :index => 200 }
|
23
25
|
else
|
24
|
-
klass_view = Util.root_view_path(klass.to_s.downcase)
|
25
26
|
if @req.html?
|
26
|
-
|
27
|
+
if klass == nil # if route is /ruby it means ruby.haml exists in views
|
28
|
+
body = Util.render_partial Util.base(@req.path), { 'env' => @req.env }, 'layout'
|
29
|
+
else
|
30
|
+
klass_view = Util.root_view_path(klass.to_s.downcase)
|
31
|
+
body = File.exists?(klass_view) ? partial(klass.to_s.downcase) : partial('index')
|
32
|
+
end
|
27
33
|
else
|
28
34
|
begin
|
29
35
|
interpret_json_params
|
data/lib/static_file.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
module Ki
|
2
|
+
# serve files from public folder
|
3
|
+
# and compile them if they are coffee of sass
|
2
4
|
class StaticFile < Rack::File
|
3
5
|
attr_reader :env
|
4
6
|
|
@@ -55,7 +57,8 @@ module Ki
|
|
55
57
|
|
56
58
|
def self.coffee_to_js coffee_path, js_path
|
57
59
|
if File.exists? coffee_path
|
58
|
-
|
60
|
+
coffee_file = File.read(coffee_path)
|
61
|
+
cont = CoffeeScript.compile(coffee_file)
|
59
62
|
File.open(js_path, 'w') do |f|
|
60
63
|
f.puts cont
|
61
64
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
|
-
describe Ki::
|
4
|
-
it "should validate
|
5
|
-
extend Ki::
|
3
|
+
describe Ki::Email do
|
4
|
+
it "should validate email properly" do
|
5
|
+
extend Ki::Email
|
6
6
|
|
7
7
|
valid_mail?('asd').should be_false
|
8
8
|
valid_mail?('asd.asd').should be_false
|
@@ -16,11 +16,4 @@ describe Ki::EMail do
|
|
16
16
|
valid_mail?('cool@gmail.co.uk').should be_true
|
17
17
|
valid_mail?('cool+beans@gmail.com').should be_true
|
18
18
|
end
|
19
|
-
|
20
|
-
it "should also work as instance method" do
|
21
|
-
class CoolMail
|
22
|
-
include Ki::EMail
|
23
|
-
end
|
24
|
-
CoolMail.new.valid_mail?('cool@gmail.com').should be_true
|
25
|
-
end
|
26
19
|
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.3.
|
4
|
+
version: 0.3.3
|
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-
|
12
|
+
date: 2013-09-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -155,6 +155,22 @@ dependencies:
|
|
155
155
|
- - ! '>='
|
156
156
|
- !ruby/object:Gem::Version
|
157
157
|
version: '0'
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: json
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ! '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :runtime
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
158
174
|
- !ruby/object:Gem::Dependency
|
159
175
|
name: rspec
|
160
176
|
requirement: !ruby/object:Gem::Requirement
|
@@ -300,13 +316,13 @@ files:
|
|
300
316
|
- ki_wrap.rb
|
301
317
|
- lib/conf.rb
|
302
318
|
- lib/db.rb
|
303
|
-
- lib/extensions/mail.rb
|
304
319
|
- lib/helpers.rb
|
305
320
|
- lib/ki.rb
|
306
321
|
- lib/ki_cli.rb
|
307
322
|
- lib/mockreq.rb
|
308
323
|
- lib/model.rb
|
309
324
|
- lib/modules/callbacks.rb
|
325
|
+
- lib/modules/email.rb
|
310
326
|
- lib/modules/model_helpers.rb
|
311
327
|
- lib/modules/query_interface.rb
|
312
328
|
- lib/modules/restrictions.rb
|
@@ -320,11 +336,11 @@ files:
|
|
320
336
|
- lib/views/layout.haml
|
321
337
|
- spec/conf_spec.rb
|
322
338
|
- spec/db_spec.rb
|
323
|
-
- spec/extensions/mail_spec.rb
|
324
339
|
- spec/integration/integration_spec.rb
|
325
340
|
- spec/ki_spec.rb
|
326
341
|
- spec/model_spec.rb
|
327
342
|
- spec/modules/callbacks_spec.rb
|
343
|
+
- spec/modules/email_spec.rb
|
328
344
|
- spec/modules/query_interface_spec.rb
|
329
345
|
- spec/modules/restrictions_spec.rb
|
330
346
|
- spec/performance/performance.sh
|
@@ -346,7 +362,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
346
362
|
version: '0'
|
347
363
|
segments:
|
348
364
|
- 0
|
349
|
-
hash:
|
365
|
+
hash: 4153304961759907564
|
350
366
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
351
367
|
none: false
|
352
368
|
requirements:
|
@@ -355,7 +371,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
355
371
|
version: '0'
|
356
372
|
requirements: []
|
357
373
|
rubyforge_project:
|
358
|
-
rubygems_version: 1.8.
|
374
|
+
rubygems_version: 1.8.23
|
359
375
|
signing_key:
|
360
376
|
specification_version: 3
|
361
377
|
summary: Prototyping noSQL RESTful API cloud database
|