wurst 0.0.1 → 0.0.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: 555f2a5dc91b8d3e73f6df0763ea13b1069a5552
4
- data.tar.gz: 37f81445cf937e9e322906ef92ec5b74f46ad443
3
+ metadata.gz: bfe6de8e5bf7b64113eddef6e542b3c02ab699e9
4
+ data.tar.gz: 2c37731cec40c66e0abc3a9f4d25a206436e93fb
5
5
  SHA512:
6
- metadata.gz: 6ec04850fa8bba150f3e0bd4ba649921df6ceebd06e1c8d5a33b1f90c7f1e1cf898bd91af3e61626022a799c63fbea9d269293a4adc6f1cf966c1ad493922122
7
- data.tar.gz: 2f9dbc628ca0cb806b3c5b525d20cb95b260f110681ef04d73432e621dda1cf88ee1d8b18c318e3beadc72aff1dd96478b5df07f179ef1036722ad56ed3c3afb
6
+ metadata.gz: 04b1d6e584f8e4179c1d23cc2c63a0a718c33130456972474a9d78c72120b538587ffe3bb4480117626346fd617c7cc4107a3c97822123fa4080c45c3c720d96
7
+ data.tar.gz: 1c0207c4f73a50f0f377e8819f0e32933fd9ae2e326d7b51359374d770bce0c43c0a38ba4b3acce2d53ddce57bf8d5be3aca796cb1f65c1c5affb0c19faad079
@@ -46,11 +46,10 @@ module ZWResources
46
46
  Tilt::ERBTemplate.new{@@models_js_template}.render
47
47
  end
48
48
 
49
- Dir.glob(File.join('..', 'assets')) do |file|
50
- # TODO cross-platform? probably not.
51
- base.send :get, file.split('/').last do
49
+ %w(handlebars-v1.3.0.js ember.js ember-data.js).each do |filename|
50
+ base.send :get, "/#{filename}" do
52
51
  content_type :js, :charset => 'utf-8'
53
- send_file file
52
+ File.read File.join(File.dirname(File.expand_path(__FILE__)), "../assets/#{filename}")
54
53
  end
55
54
  end
56
55
  end
@@ -70,6 +69,14 @@ module ZWResources
70
69
  puts "***"
71
70
  puts router.routes.inspect
72
71
 
72
+ # Parse JSON payload
73
+ # http://stackoverflow.com/a/17049683
74
+ before do
75
+ request.body.rewind
76
+ request_body = request.body.read
77
+ @request_payload = JSON.parse(request_body, :symbolize_names => true) unless request_body.empty?
78
+ end
79
+
73
80
  # Find
74
81
  get "/#{model_name_string}/:id" do |id|
75
82
  content_type :json, :charset => 'utf-8'
@@ -94,11 +101,11 @@ module ZWResources
94
101
  put "/#{model_name_string}/:id" do |id|
95
102
  content_type :json, :charset => 'utf-8'
96
103
  if router.has_route? :update
97
- {post: router.update(id, params)}.to_json
104
+ {post: router.update(id, @request_payload[:post])}.to_json
98
105
  else
99
106
  param_names = model.properties.select{ |prop| prop.class != DataMapper::Property::Serial }.map{ |prop| prop.name }
100
107
  m = model.get(id)
101
- m.update(params.select{ |k,v| param_names.include? k.to_sym })
108
+ m.update(@request_payload[:post].select{ |k,v| param_names.include? k.to_sym })
102
109
  {post: m}.to_json
103
110
  end
104
111
  end
@@ -107,10 +114,10 @@ module ZWResources
107
114
  post "/#{model_name_string}" do
108
115
  content_type :json, :charset => 'utf-8'
109
116
  if router.has_route? :create
110
- {post: router.create(params)}.to_json
117
+ {post: router.create(@request_payload[:post])}.to_json
111
118
  else
112
119
  param_names = model.properties.select{ |prop| prop.class != DataMapper::Property::Serial }.map{ |prop| prop.name }
113
- m = model.create(params.select{ |k,v| param_names.include? k.to_sym })
120
+ m = model.create(@request_payload[:post].select{ |k,v| param_names.include? k.to_sym })
114
121
  {post: m}.to_json
115
122
  end
116
123
  end
@@ -1,3 +1,3 @@
1
1
  module Wurst
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wurst
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - cdn64
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-12-16 00:00:00.000000000 Z
13
+ date: 2015-01-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler