koromo 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/koromo/server.rb +4 -4
- data/lib/koromo/sql.rb +10 -16
- data/lib/koromo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f67069b2b76b03b8f982a941aa72cc93782d7e74
|
4
|
+
data.tar.gz: 784ab1f693a52dd86e367d27245412f331a7aa31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25bbc17eb577715fef17102cf6a4338688caa49e61668296f2e954fea0ac4cfec083fa72146dc855658902624eacc70abc12dba47efe87295ee5d7f41b0f5e2a
|
7
|
+
data.tar.gz: ec319f73cada0e208b14768eadda97c72295d519560c4b1b04b7a152ac94282920225fd9fae67bffac7e903bb113cd3f21a33b91193c42f8d7897515a8f7b2d0
|
data/lib/koromo/server.rb
CHANGED
@@ -24,7 +24,7 @@ module Koromo
|
|
24
24
|
return @slogger
|
25
25
|
end
|
26
26
|
|
27
|
-
helpers Helper
|
27
|
+
helpers Helper
|
28
28
|
|
29
29
|
configure do
|
30
30
|
set :environment, :production
|
@@ -35,11 +35,11 @@ module Koromo
|
|
35
35
|
before do
|
36
36
|
# @jsonp_callback = params[:callback]
|
37
37
|
halt 401 unless valid_token?(params[:auth])
|
38
|
-
|
38
|
+
Koromo.sql.setup(Koromo.config)
|
39
39
|
end
|
40
40
|
|
41
41
|
get '/:resource' do |r|
|
42
|
-
result = get_resource(r, params: params)
|
42
|
+
result = Koromo.sql.get_resource(r, params: params)
|
43
43
|
if result
|
44
44
|
json_with_object(result)
|
45
45
|
else
|
@@ -49,7 +49,7 @@ module Koromo
|
|
49
49
|
|
50
50
|
get '/:resource/:id' do |r, id|
|
51
51
|
fail Sinatra::NotFound if /\W/ =~ id
|
52
|
-
result = get_resource(r, id: id, params: params)
|
52
|
+
result = Koromo.sql.get_resource(r, id: id, params: params)
|
53
53
|
if result
|
54
54
|
json_with_object(result)
|
55
55
|
else
|
data/lib/koromo/sql.rb
CHANGED
@@ -3,9 +3,17 @@ require 'sequel'
|
|
3
3
|
|
4
4
|
module Koromo
|
5
5
|
|
6
|
-
|
6
|
+
def self.sql
|
7
|
+
SQL.shared_instance
|
8
|
+
end
|
9
|
+
|
10
|
+
class SQL
|
11
|
+
|
12
|
+
def self.shared_instance
|
13
|
+
@sql ||= SQL.new
|
14
|
+
end
|
7
15
|
|
8
|
-
def
|
16
|
+
def setup(conf)
|
9
17
|
@config = conf
|
10
18
|
# Sequel connection setup
|
11
19
|
# Sequel.application_timezone = :local
|
@@ -37,20 +45,6 @@ module Koromo
|
|
37
45
|
@models[name]
|
38
46
|
end
|
39
47
|
|
40
|
-
def run_query(query)
|
41
|
-
result = mssql.execute(query)
|
42
|
-
records = []
|
43
|
-
result.each(cache_rows: false) do |row|
|
44
|
-
record = {}
|
45
|
-
row.each { |k, v| record[k] = convert_value(v) }
|
46
|
-
records.push record
|
47
|
-
end
|
48
|
-
records
|
49
|
-
# rescue => e
|
50
|
-
# puts e.message
|
51
|
-
# raise
|
52
|
-
end
|
53
|
-
|
54
48
|
def get_resource(name, **args)
|
55
49
|
return nil unless model = model_for_resource(name)
|
56
50
|
p args[:params]
|
data/lib/koromo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: koromo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken J.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kajiki
|