flexible_api_server 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module FlexibleApiServer
2
2
 
3
- VERSION = '0.0.2'
3
+ VERSION = '0.0.3'
4
4
 
5
5
  end
@@ -26,6 +26,7 @@ module FlexibleApiServer
26
26
  set :views, File.dirname(__FILE__) + '/../views'
27
27
 
28
28
  FILTERED_COLUMNS = [:password, :password_confirmation]
29
+ ALLOWED_FORMATS = [:js, :xml]
29
30
 
30
31
  def assign(k, v)
31
32
  @assign ||= {}
@@ -33,13 +34,14 @@ module FlexibleApiServer
33
34
  nil
34
35
  end
35
36
 
36
- def free_render(code, hash)
37
+ def free_render(code, hash = '') # blank by default, not nil
37
38
  status code
38
39
  # Filter some things out
39
40
  FILTERED_COLUMNS.each do |column|
40
41
  hash[column] = '[filtered]' if hash.has_key?(column)
41
42
  end if hash.is_a?(Hash)
42
43
  # and respond
44
+ format :js unless ALLOWED_FORMATS.include? format
43
45
  respond_to do |wants|
44
46
  wants.js { hash.to_json }
45
47
  wants.xml { hash.to_xml }
@@ -65,6 +67,11 @@ module FlexibleApiServer
65
67
  free_render 404, :message => "Unknown method '#{request.env['sinatra.error'].name}' on #{params[:model]}"
66
68
  end
67
69
 
70
+ get '/favicon' do
71
+ headers['Cache-Control'] = 'public, max-age=7776000'
72
+ free_render 404
73
+ end
74
+
68
75
  post '/:model' do
69
76
  model_klass = params[:model].singularize.camelize.constantize
70
77
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flexible_api_server
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - John Crepezzi
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-28 00:00:00 +01:00
18
+ date: 2011-03-29 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency