rack-push-notification 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rack-push-notification (0.1.2)
5
- bootstrap-sass (~> 2.1)
4
+ rack-push-notification (0.2.0)
5
+ bootstrap-sass (~> 2.1.0)
6
6
  coffee-script (~> 2.2)
7
7
  compass (~> 0.11)
8
8
  eco (~> 1.0)
@@ -25,7 +25,7 @@ GEM
25
25
  coffee-script (2.2.0)
26
26
  coffee-script-source
27
27
  execjs
28
- coffee-script-source (1.4.0)
28
+ coffee-script-source (1.6.1)
29
29
  commander (4.1.3)
30
30
  highline (~> 1.6.11)
31
31
  compass (0.12.2)
@@ -39,31 +39,31 @@ GEM
39
39
  eco-source (1.1.0.rc.1)
40
40
  execjs (1.4.0)
41
41
  multi_json (~> 1.0)
42
- fssm (0.2.9)
43
- haml (3.1.7)
42
+ fssm (0.2.10)
43
+ haml (3.1.8)
44
44
  highline (1.6.15)
45
45
  hike (1.2.1)
46
46
  houston (0.1.1)
47
47
  commander (~> 4.1.2)
48
48
  json (~> 1.7.3)
49
- json (1.7.6)
50
- multi_json (1.5.0)
51
- rack (1.4.4)
49
+ json (1.7.7)
50
+ multi_json (1.6.1)
51
+ rack (1.5.2)
52
52
  rack-contrib (1.1.0)
53
53
  rack (>= 0.9.1)
54
- rack-protection (1.3.2)
54
+ rack-protection (1.4.0)
55
55
  rack
56
56
  rake (0.9.2.2)
57
57
  rspec (0.6.4)
58
- sass (3.2.5)
59
- sequel (3.37.0)
60
- sinatra (1.3.3)
61
- rack (~> 1.3, >= 1.3.6)
62
- rack-protection (~> 1.2)
58
+ sass (3.2.6)
59
+ sequel (3.45.0)
60
+ sinatra (1.3.5)
61
+ rack (~> 1.4)
62
+ rack-protection (~> 1.3)
63
63
  tilt (~> 1.3, >= 1.3.3)
64
64
  sinatra-param (0.1.2)
65
65
  sinatra (~> 1.3)
66
- sprockets (2.8.2)
66
+ sprockets (2.9.0)
67
67
  hike (~> 1.2)
68
68
  multi_json (~> 1.0)
69
69
  rack (~> 1.0)
@@ -71,7 +71,7 @@ GEM
71
71
  sprockets-sass (0.9.1)
72
72
  sprockets (~> 2.0)
73
73
  tilt (~> 1.1)
74
- tilt (1.3.3)
74
+ tilt (1.3.4)
75
75
 
76
76
  PLATFORMS
77
77
  ruby
@@ -34,23 +34,34 @@ module Rack
34
34
 
35
35
  get '/devices/?' do
36
36
  param :q, String
37
- param :offset, Integer, default: 0
38
- param :limit, Integer, max: 100, min: 1, default: 25
39
-
40
- @devices = ::Rack::PushNotification::Device.dataset
41
- @devices = @devices.filter("tsv @@ to_tsquery('english', ?)", "#{params[:q]}:*") if params[:q] and not params[:q].empty?
42
-
43
- {
44
- devices: @devices.limit(params[:limit], params[:offset]),
45
- total: @devices.count
46
- }.to_json
37
+
38
+ devices = ::Rack::PushNotification::Device.dataset
39
+ devices = devices.filter("tsv @@ to_tsquery('english', ?)", "#{params[:q]}:*") if params[:q] and not params[:q].empty?
40
+
41
+ if params[:page] or params[:per_page]
42
+ param :page, Integer, default: 1, min: 1
43
+ param :per_page, Integer, default: 100, in: (1..100)
44
+
45
+ {
46
+ devices: devices.limit(params[:per_page], (params[:page] - 1) * params[:per_page]),
47
+ page: params[:page],
48
+ total: klass.count
49
+ }.to_json
50
+ else
51
+ param :limit, Integer, default: 100, in: (1..100)
52
+ param :offset, Integer, default: 0, min: 0
53
+
54
+ {
55
+ devices: devices.limit(params[:limit], params[:offset])
56
+ }.to_json
57
+ end
47
58
  end
48
59
 
49
60
  get '/devices/:token/?' do
50
- @record = ::Rack::PushNotification::Device.find(token: params[:token])
61
+ record = ::Rack::PushNotification::Device.find(token: params[:token])
51
62
 
52
- if @record
53
- @record.to_json
63
+ if record
64
+ {device: record}.to_json
54
65
  else
55
66
  status 404
56
67
  end
@@ -22,6 +22,7 @@ class RPN.Collections.Devices extends Backbone.Paginator.requestPager
22
22
  parse: (response) ->
23
23
  @total = response.total
24
24
  @totalPages = Math.ceil(@total / @perPage)
25
+ console.log(response)
25
26
  response.devices
26
27
 
27
28
  comparator: (database) ->
@@ -27,12 +27,12 @@ class RPN.Views.Compose extends Backbone.View
27
27
  @updatePreview()
28
28
  @updateTime()
29
29
 
30
- $.ajax "/message"
30
+ $.ajax("/message"
31
31
  type: "HEAD"
32
32
 
33
33
  error: (data, status) =>
34
34
  @disable()
35
-
35
+ )
36
36
  @
37
37
 
38
38
  submit: ->
@@ -44,13 +44,14 @@ class RPN.Views.Compose extends Backbone.View
44
44
  if $("input[name='recipients']:checked").val() == "specified"
45
45
  tokens = [$form.find("#tokens").val()]
46
46
 
47
- $.ajax "/message"
47
+ $.ajax("/message"
48
48
  type: "POST"
49
49
  dataType: "json"
50
50
  data: {
51
51
  tokens: tokens,
52
52
  payload: payload
53
53
  }
54
+ )
54
55
 
55
56
  beforeSend: =>
56
57
  @$el.find(".alert-error, .alert-success").remove()
@@ -170,8 +170,8 @@ div.CodeMirror span
170
170
  color: #839496
171
171
  div.CodeMirror-selected
172
172
  background: #586e75
173
- .CodeMirror-gutter
174
- .CodeMirror-gutter-text
173
+ .CodeMirror-gutter,
174
+ .CodeMirror-gutter-text,
175
175
  .CodeMirror-cursor
176
176
  border-left: 1px solid #839496
177
177
  span
@@ -3,7 +3,6 @@
3
3
  $btnPrimaryBackground: #f00
4
4
  @import "bootstrap"
5
5
 
6
-
7
6
  @mixin helvetica-font-stack
8
7
  font-family: "Helvetica Neue", Helvetica, Arial, Geneva, sans-serif
9
8
 
@@ -19,7 +18,7 @@ html body
19
18
  -webkit-background-clip: padding-box
20
19
 
21
20
  & > header
22
- @extend .navbar
21
+ @extend .navbar
23
22
  @extend .navbar-static-top
24
23
 
25
24
  nav
@@ -33,8 +32,6 @@ html body
33
32
  & > header
34
33
  @extend .page-header
35
34
 
36
- h1
37
-
38
35
  aside
39
36
  float: right
40
37
 
@@ -62,7 +59,7 @@ form#compose
62
59
 
63
60
  li
64
61
  @extend .control-group
65
-
62
+
66
63
  input[type="radio"], label
67
64
  display: inline-block
68
65
 
@@ -83,7 +80,7 @@ form#compose
83
80
  clear: both
84
81
  width: 100%
85
82
  margin-top: 5em
86
-
83
+
87
84
  button
88
85
  @extend .btn
89
86
  @extend .btn-large
@@ -107,5 +104,5 @@ form.filter
107
104
  margin-bottom: 0
108
105
 
109
106
  input[type="text"]
110
- @extend .input-medium
107
+ @extend .input-medium
111
108
  @extend .search-query
@@ -4,12 +4,10 @@ module Rack
4
4
  class PushNotification::Device < Sequel::Model
5
5
  self.dataset = :devices
6
6
 
7
- Sequel::Migrator.run(self.db, ::File.join(::File.dirname(__FILE__), "migrations"))
8
-
9
7
  self.strict_param_setting = false
10
8
  self.raise_on_save_failure = false
11
9
 
12
- plugin :json_serializer, naked: true, except: :id
10
+ plugin :json_serializer, naked: true
13
11
  plugin :validation_helpers
14
12
  plugin :timestamps, force: true
15
13
  plugin :schema
@@ -29,5 +27,7 @@ module Rack
29
27
  def normalize_token!
30
28
  self.token = self.token.strip.gsub(/[<\s>]/, '')
31
29
  end
30
+
31
+ Sequel::Migrator.run(self.db, ::File.join(::File.dirname(__FILE__), "migrations")) rescue false
32
32
  end
33
33
  end
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class PushNotification
3
- VERSION = '0.1.2'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
@@ -26,14 +26,14 @@ module Rack
26
26
  param :languages, Array
27
27
  param :tags, Array
28
28
 
29
- @record = Device.find(token: params[:token]) || Device.new
30
- @record.set(params)
29
+ record = Device.find(token: params[:token]) || Device.new
30
+ record.set(params)
31
31
 
32
- code = @record.new? ? 201 : 200
32
+ code = record.new? ? 201 : 200
33
33
 
34
- if @record.save
34
+ if record.save
35
35
  status code
36
- @record.to_json
36
+ {device: record}.to_json
37
37
  else
38
38
  status 406
39
39
  {errors: @record.errors}.to_json
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.add_dependency "eco", "~> 1.0"
24
24
  s.add_dependency "haml", "~> 3.1"
25
25
  s.add_dependency "sass", "~> 3.2"
26
- s.add_dependency "bootstrap-sass", "~> 2.1"
26
+ s.add_dependency "bootstrap-sass", "~> 2.1.0"
27
27
  s.add_dependency "compass", "~> 0.11"
28
28
  s.add_dependency "sprockets", "~> 2.8"
29
29
  s.add_dependency "sprockets-sass", "~> 0.9"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-push-notification
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-21 00:00:00.000000000 Z
12
+ date: 2013-03-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70327362806500 !ruby/object:Gem::Requirement
16
+ requirement: &70243365178400 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.6.1
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70327362806500
24
+ version_requirements: *70243365178400
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70327362806000 !ruby/object:Gem::Requirement
27
+ requirement: &70243365177680 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.9.2
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70327362806000
35
+ version_requirements: *70243365177680
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rack
38
- requirement: &70327362805540 !ruby/object:Gem::Requirement
38
+ requirement: &70243365176960 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '1.4'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70327362805540
46
+ version_requirements: *70243365176960
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rack-contrib
49
- requirement: &70327362805080 !ruby/object:Gem::Requirement
49
+ requirement: &70243365176280 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '1.1'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70327362805080
57
+ version_requirements: *70243365176280
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: sequel
60
- requirement: &70327362804620 !ruby/object:Gem::Requirement
60
+ requirement: &70243365175480 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '3.37'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70327362804620
68
+ version_requirements: *70243365175480
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: sinatra
71
- requirement: &70327362804160 !ruby/object:Gem::Requirement
71
+ requirement: &70243365174540 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.3.2
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70327362804160
79
+ version_requirements: *70243365174540
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: sinatra-param
82
- requirement: &70327362803700 !ruby/object:Gem::Requirement
82
+ requirement: &70243365173800 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0.1'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70327362803700
90
+ version_requirements: *70243365173800
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: coffee-script
93
- requirement: &70327362803240 !ruby/object:Gem::Requirement
93
+ requirement: &70243365173320 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '2.2'
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *70327362803240
101
+ version_requirements: *70243365173320
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: eco
104
- requirement: &70327362802760 !ruby/object:Gem::Requirement
104
+ requirement: &70243365172840 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '1.0'
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *70327362802760
112
+ version_requirements: *70243365172840
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: haml
115
- requirement: &70327362802300 !ruby/object:Gem::Requirement
115
+ requirement: &70243365172340 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '3.1'
121
121
  type: :runtime
122
122
  prerelease: false
123
- version_requirements: *70327362802300
123
+ version_requirements: *70243365172340
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: sass
126
- requirement: &70327362801840 !ruby/object:Gem::Requirement
126
+ requirement: &70243365171860 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ~>
@@ -131,21 +131,21 @@ dependencies:
131
131
  version: '3.2'
132
132
  type: :runtime
133
133
  prerelease: false
134
- version_requirements: *70327362801840
134
+ version_requirements: *70243365171860
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: bootstrap-sass
137
- requirement: &70327362801380 !ruby/object:Gem::Requirement
137
+ requirement: &70243365171380 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ~>
141
141
  - !ruby/object:Gem::Version
142
- version: '2.1'
142
+ version: 2.1.0
143
143
  type: :runtime
144
144
  prerelease: false
145
- version_requirements: *70327362801380
145
+ version_requirements: *70243365171380
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: compass
148
- requirement: &70327362800920 !ruby/object:Gem::Requirement
148
+ requirement: &70243365170900 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ~>
@@ -153,10 +153,10 @@ dependencies:
153
153
  version: '0.11'
154
154
  type: :runtime
155
155
  prerelease: false
156
- version_requirements: *70327362800920
156
+ version_requirements: *70243365170900
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: sprockets
159
- requirement: &70327362800460 !ruby/object:Gem::Requirement
159
+ requirement: &70243365170440 !ruby/object:Gem::Requirement
160
160
  none: false
161
161
  requirements:
162
162
  - - ~>
@@ -164,10 +164,10 @@ dependencies:
164
164
  version: '2.8'
165
165
  type: :runtime
166
166
  prerelease: false
167
- version_requirements: *70327362800460
167
+ version_requirements: *70243365170440
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: sprockets-sass
170
- requirement: &70327362800000 !ruby/object:Gem::Requirement
170
+ requirement: &70243365169980 !ruby/object:Gem::Requirement
171
171
  none: false
172
172
  requirements:
173
173
  - - ~>
@@ -175,10 +175,10 @@ dependencies:
175
175
  version: '0.9'
176
176
  type: :runtime
177
177
  prerelease: false
178
- version_requirements: *70327362800000
178
+ version_requirements: *70243365169980
179
179
  - !ruby/object:Gem::Dependency
180
180
  name: houston
181
- requirement: &70327362799540 !ruby/object:Gem::Requirement
181
+ requirement: &70243365169520 !ruby/object:Gem::Requirement
182
182
  none: false
183
183
  requirements:
184
184
  - - ~>
@@ -186,7 +186,7 @@ dependencies:
186
186
  version: 0.1.1
187
187
  type: :runtime
188
188
  prerelease: false
189
- version_requirements: *70327362799540
189
+ version_requirements: *70243365169520
190
190
  description: Generate a REST API for registering and querying push notification device
191
191
  tokens.
192
192
  email: m@mattt.me
@@ -228,8 +228,6 @@ files:
228
228
  - ./lib/rack/push-notification/version.rb
229
229
  - ./lib/rack/push-notification.rb
230
230
  - ./LICENSE
231
- - ./rack-push-notification-0.1.0.gem
232
- - ./rack-push-notification-0.1.1.gem
233
231
  - ./rack-push-notification.gemspec
234
232
  - ./Rakefile
235
233
  - ./README.md
@@ -247,7 +245,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
247
245
  version: '0'
248
246
  segments:
249
247
  - 0
250
- hash: 2419482738763005983
248
+ hash: -324249567493366905
251
249
  required_rubygems_version: !ruby/object:Gem::Requirement
252
250
  none: false
253
251
  requirements:
@@ -256,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
256
254
  version: '0'
257
255
  segments:
258
256
  - 0
259
- hash: 2419482738763005983
257
+ hash: -324249567493366905
260
258
  requirements: []
261
259
  rubyforge_project:
262
260
  rubygems_version: 1.8.15
Binary file
Binary file