flexible_api_server 0.0.13 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,11 +13,18 @@ class ActiveRecord::Base
13
13
  end
14
14
  end
15
15
 
16
+
17
+
16
18
  module FlexibleApiServer
17
19
 
18
20
  class App < Sinatra::Base
19
-
21
+ # to allow periods in parameters without it being a MIME type, respondto tries to replace all periods, so we intercept before
22
+ before do
23
+ request.path_info = request.path_info.sub(/\.(?=([.*\)]))/, '\period')
24
+ end
25
+
20
26
  register Sinatra::RespondTo
27
+
21
28
  mime_type :jsonp, 'application/javascript'
22
29
  mime_type :js, 'application/json'
23
30
  mime_type :xml, 'application/xml'
@@ -203,14 +210,19 @@ module FlexibleApiServer
203
210
 
204
211
  DEFAULT_LIMIT = 50
205
212
 
213
+ # override this method to allow backspace (%5C) escaping commas, parentheses, and backspaces in params
206
214
  def add_scopes(query, scope_param)
207
215
  scopes = []
208
216
  scopes.concat scope_param.split ':' unless scope_param.nil?
209
217
  scopes.concat params[:scopes] if params[:scopes].is_a?(Array)
210
218
  scopes.each do |scope|
211
- # TODO remove this ugliness
212
- method, arg_string = scope.split '('
213
- if !arg_string.nil? && args = arg_string.chop.split(',').map(&:strip)
219
+ method, arg_string = scope.split(/(?<=[^\\])\(/)
220
+ if !arg_string.nil?
221
+ arg_string = arg_string.chop.gsub(/\\\\/, "\\backspace").gsub(/\\period/, '.')
222
+ # split on non-escaped commas
223
+ args = arg_string.split(/(?<=[^\\]),/).map(&:strip)
224
+ # map escaped characters to normal values
225
+ args = args.map {|arg| arg.gsub(/\\,/, ',')}.map {|arg| arg.gsub(/\\\(/, '(')}.map {|arg| arg.gsub(/\\backspace/, '\\')}
214
226
  query = query.send method.to_sym, *args
215
227
  else
216
228
  query = query.send method.to_sym
@@ -1,5 +1,5 @@
1
1
  module FlexibleApiServer
2
2
 
3
- VERSION = '0.0.13'
3
+ VERSION = '0.1.0'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,146 +1,137 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: flexible_api_server
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
4
5
  prerelease:
5
- version: 0.0.13
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - John Crepezzi
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-06-20 00:00:00 -04:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2011-10-07 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: rspec
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70236559424220 !ruby/object:Gem::Requirement
20
17
  none: false
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
24
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
25
22
  type: :development
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: sqlite3
29
23
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70236559424220
25
+ - !ruby/object:Gem::Dependency
26
+ name: sqlite3
27
+ requirement: &70236559423520 !ruby/object:Gem::Requirement
31
28
  none: false
32
- requirements:
33
- - - ">="
34
- - !ruby/object:Gem::Version
35
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
36
33
  type: :development
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: rack-test
40
34
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *70236559423520
36
+ - !ruby/object:Gem::Dependency
37
+ name: rack-test
38
+ requirement: &70236559422400 !ruby/object:Gem::Requirement
42
39
  none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
47
44
  type: :development
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
- name: flexible_api
51
45
  prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *70236559422400
47
+ - !ruby/object:Gem::Dependency
48
+ name: flexible_api
49
+ requirement: &70236559421440 !ruby/object:Gem::Requirement
53
50
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: 0.0.7
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.1.0
58
55
  type: :runtime
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
61
- name: json
62
56
  prerelease: false
63
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *70236559421440
58
+ - !ruby/object:Gem::Dependency
59
+ name: json
60
+ requirement: &70236559420920 !ruby/object:Gem::Requirement
64
61
  none: false
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: "0"
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
69
66
  type: :runtime
70
- version_requirements: *id005
71
- - !ruby/object:Gem::Dependency
72
- name: activerecord
73
67
  prerelease: false
74
- requirement: &id006 !ruby/object:Gem::Requirement
68
+ version_requirements: *70236559420920
69
+ - !ruby/object:Gem::Dependency
70
+ name: activerecord
71
+ requirement: &70236559409220 !ruby/object:Gem::Requirement
75
72
  none: false
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- version: "0"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
80
77
  type: :runtime
81
- version_requirements: *id006
82
- - !ruby/object:Gem::Dependency
83
- name: sinatra
84
78
  prerelease: false
85
- requirement: &id007 !ruby/object:Gem::Requirement
79
+ version_requirements: *70236559409220
80
+ - !ruby/object:Gem::Dependency
81
+ name: sinatra
82
+ requirement: &70236559407680 !ruby/object:Gem::Requirement
86
83
  none: false
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- version: "0"
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
91
88
  type: :runtime
92
- version_requirements: *id007
93
- - !ruby/object:Gem::Dependency
94
- name: sinatra-respond_to
95
89
  prerelease: false
96
- requirement: &id008 !ruby/object:Gem::Requirement
90
+ version_requirements: *70236559407680
91
+ - !ruby/object:Gem::Dependency
92
+ name: sinatra-respond_to
93
+ requirement: &70236559406900 !ruby/object:Gem::Requirement
97
94
  none: false
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- version: "0"
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
102
99
  type: :runtime
103
- version_requirements: *id008
100
+ prerelease: false
101
+ version_requirements: *70236559406900
104
102
  description: Server for exposing Flexible APIs
105
103
  email: john.crepezzi@gmail.com
106
104
  executables: []
107
-
108
105
  extensions: []
109
-
110
106
  extra_rdoc_files: []
111
-
112
- files:
107
+ files:
113
108
  - lib/flexible_api_server/version.rb
114
109
  - lib/flexible_api_server.rb
115
110
  - views/doc_index.html.erb
116
111
  - spec/spec_helper.rb
117
- has_rdoc: false
118
112
  homepage: http://github.com/seejohnrun/flexible_api_server
119
113
  licenses: []
120
-
121
114
  post_install_message:
122
115
  rdoc_options: []
123
-
124
- require_paths:
116
+ require_paths:
125
117
  - lib
126
- required_ruby_version: !ruby/object:Gem::Requirement
118
+ required_ruby_version: !ruby/object:Gem::Requirement
127
119
  none: false
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: "0"
132
- required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
125
  none: false
134
- requirements:
135
- - - ">="
136
- - !ruby/object:Gem::Version
137
- version: "0"
126
+ requirements:
127
+ - - ! '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
138
130
  requirements: []
139
-
140
131
  rubyforge_project: flexible_api_server
141
- rubygems_version: 1.6.2
132
+ rubygems_version: 1.8.10
142
133
  signing_key:
143
134
  specification_version: 3
144
135
  summary: Server for exposing Flexible APIs created by FlexibleAPI
145
- test_files:
136
+ test_files:
146
137
  - spec/spec_helper.rb