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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 274989dcaa69f9b1c7d25faa5697bc9a645c43b1
4
- data.tar.gz: f2f827427f6fd76bfb0fa7fd871ac8a3bef99b9f
3
+ metadata.gz: f67069b2b76b03b8f982a941aa72cc93782d7e74
4
+ data.tar.gz: 784ab1f693a52dd86e367d27245412f331a7aa31
5
5
  SHA512:
6
- metadata.gz: 29d602aeb709c3564889119de0e6f2f850e62e4d8febfbdeaed197875d0f24867e15221e92464dac57f1b6cf208492384cd767933e61dd71cb9dc9e990e68586
7
- data.tar.gz: 2d0bb77811fe6f7dd17a67b06e9ce55251586dd82a6b9807e472d2fadec56785bf9ba8c6aebafaa5eae56a9092c04d139c6f061433e5c384ebb4ae10c5f991f3
6
+ metadata.gz: 25bbc17eb577715fef17102cf6a4338688caa49e61668296f2e954fea0ac4cfec083fa72146dc855658902624eacc70abc12dba47efe87295ee5d7f41b0f5e2a
7
+ data.tar.gz: ec319f73cada0e208b14768eadda97c72295d519560c4b1b04b7a152ac94282920225fd9fae67bffac7e903bb113cd3f21a33b91193c42f8d7897515a8f7b2d0
@@ -24,7 +24,7 @@ module Koromo
24
24
  return @slogger
25
25
  end
26
26
 
27
- helpers Helper, SQL
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
- setup_sql(Koromo.config)
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
@@ -3,9 +3,17 @@ require 'sequel'
3
3
 
4
4
  module Koromo
5
5
 
6
- module SQL
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 setup_sql(conf)
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]
@@ -1,5 +1,5 @@
1
1
  module Koromo
2
2
 
3
- Version = '0.0.1'
3
+ Version = '0.0.2'
4
4
 
5
5
  end
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.1
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-08 00:00:00.000000000 Z
11
+ date: 2016-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kajiki