sinatra-backstage 0.2.2 → 0.2.3

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: 874df067c1f31e0fa5c8913f9968b5d375eeb4a3
4
- data.tar.gz: f985613fd20fc61bc2ee0e01910288500b116411
3
+ metadata.gz: 207a05ebdc4fa45edc961167ba323bbd40e4d6ee
4
+ data.tar.gz: 7f963a8aaf072e820201b2b940070852c4516598
5
5
  SHA512:
6
- metadata.gz: e9ee548654babda6cea1d9ba5f7849ecd03485d1c35974c997140f4b3cf89ff21b1f5ddb2d9a4e69526ff87a170f947e39301291d776efd6340920cb8cb2d828
7
- data.tar.gz: f68d0ee1bb05a71d7929b7131193ef08dabb1b3b41f2aae85587b77dcd2e1050319f3d8bb191a9335240b3993fafb49a18d282d30015a1c8cca7bd07a688dd9b
6
+ metadata.gz: e8e6a92c8f69cfd140447ff1f0e5c3cfb6054af6c8635f66bba7534f382cd21bc14393fcb8a0b25d0b78c24d2ccea8ede931adb1d841e2638cefb3f0fcf12197
7
+ data.tar.gz: 52ab702b62853ed6140febac73a3aafbe2e8a0147bb0e4dc088a01d3528aa99aef7591ff5a233861f1aeef1d89bf76c5ebc82ce8b30f52905222ba32af25faf9
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'dm-serializer'
2
2
 
3
3
  module Sinatra
4
4
  module Backstage
@@ -14,15 +14,31 @@ module Sinatra
14
14
  ## Routes
15
15
  ### get list
16
16
  get namespace do
17
- @objects = rest_get_all klass, params
18
- request.accept.each do |type|
19
- # puts "type.to_s = #{type.to_s}"
20
- case type.to_s
21
- when 'text/html'
22
- halt eval "#{settings.render_engine} '#{demodulize(klass).downcase}/list'"
23
- when 'text/json', 'application/json'
24
- halt @objects.to_a.to_json
17
+ ## get format
18
+ # puts "-- REST.Routing get namespace ( params = #{params})"
19
+ format = params.delete('format') || 'html'
20
+ # puts "-- REST.Routing get namespace after format ( params = #{params})"
21
+ format = 'json' if request.accept.include?('text/json') || request.accept.include?('application/json')
22
+ ## get json options
23
+ json_opts = params.delete('json_opts')
24
+ json_opts = json_opts.inject({}) do |hash_sym, (key, val)|
25
+ hash_sym[key.to_sym] = val.map do |el|
26
+ el.to_sym
25
27
  end
28
+ hash_sym
29
+ end
30
+ ## get objects
31
+ @objects = rest_get_all klass, params
32
+ # puts "-- REST.Routing get namespace ( @objects = #{@objects})"
33
+ # puts "-- REST.Routing get namespace ( @objects.to_a = #{@objects.to_a})"
34
+ # puts "-- REST.Routing get namespace ( @objects.to_json = #{@objects.to_json})"
35
+ # puts "-- REST.Routing get namespace ( @objects.to_a.to_json = #{@objects.to_a.to_json})"
36
+ ## return
37
+ case format
38
+ when 'html'
39
+ halt eval "#{settings.render_engine} '#{demodulize(klass).downcase}/list'"
40
+ when 'json'
41
+ halt @objects.to_json(json_opts)
26
42
  end
27
43
  error 406
28
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-backstage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Popov
@@ -9,105 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2015-05-25 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: sinatra
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1'
27
- - !ruby/object:Gem::Dependency
28
- name: sinatra-contrib
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1'
41
- - !ruby/object:Gem::Dependency
42
- name: sinatra-conditions
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: dm-core
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1'
69
- - !ruby/object:Gem::Dependency
70
- name: dm-types
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '1'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '1'
83
- - !ruby/object:Gem::Dependency
84
- name: dm-validations
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '1'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '1'
97
- - !ruby/object:Gem::Dependency
98
- name: dm-timestamps
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '1'
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '1'
12
+ dependencies: []
111
13
  description: Sinatra-Backstage simplifies the use of the basic routes and models for
112
14
  Sinatra and DataMapper. Currently it includes REST and User.
113
15
  email: alex.wayfer@gmail.com