fireinc-apn_on_rails 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/.rspec +2 -0
  2. data/.specification +80 -0
  3. data/Gemfile +19 -0
  4. data/Gemfile.lock +47 -0
  5. data/LICENSE +21 -0
  6. data/README +179 -0
  7. data/README.textile +209 -0
  8. data/Rakefile +49 -0
  9. data/VERSION +1 -0
  10. data/apn_on_rails.gemspec +144 -0
  11. data/autotest/discover.rb +1 -0
  12. data/generators/apn_migrations_generator.rb +31 -0
  13. data/generators/templates/apn_migrations/001_create_apn_devices.rb +13 -0
  14. data/generators/templates/apn_migrations/002_create_apn_notifications.rb +23 -0
  15. data/generators/templates/apn_migrations/003_alter_apn_devices.rb +25 -0
  16. data/generators/templates/apn_migrations/004_create_apn_apps.rb +18 -0
  17. data/generators/templates/apn_migrations/005_create_groups.rb +23 -0
  18. data/generators/templates/apn_migrations/006_alter_apn_groups.rb +11 -0
  19. data/generators/templates/apn_migrations/007_create_device_groups.rb +27 -0
  20. data/generators/templates/apn_migrations/008_create_apn_group_notifications.rb +23 -0
  21. data/generators/templates/apn_migrations/009_create_pull_notifications.rb +16 -0
  22. data/generators/templates/apn_migrations/010_alter_apn_notifications.rb +21 -0
  23. data/generators/templates/apn_migrations/011_make_device_token_index_nonunique.rb +11 -0
  24. data/generators/templates/apn_migrations/012_add_launch_notification_to_apn_pull_notifications.rb +9 -0
  25. data/lib/apn_on_rails.rb +4 -0
  26. data/lib/apn_on_rails/apn_on_rails.rb +81 -0
  27. data/lib/apn_on_rails/app/models/apn/app.rb +151 -0
  28. data/lib/apn_on_rails/app/models/apn/base.rb +9 -0
  29. data/lib/apn_on_rails/app/models/apn/device.rb +50 -0
  30. data/lib/apn_on_rails/app/models/apn/device_grouping.rb +16 -0
  31. data/lib/apn_on_rails/app/models/apn/group.rb +12 -0
  32. data/lib/apn_on_rails/app/models/apn/group_notification.rb +79 -0
  33. data/lib/apn_on_rails/app/models/apn/notification.rb +93 -0
  34. data/lib/apn_on_rails/app/models/apn/pull_notification.rb +28 -0
  35. data/lib/apn_on_rails/libs/connection.rb +70 -0
  36. data/lib/apn_on_rails/libs/feedback.rb +39 -0
  37. data/lib/apn_on_rails/tasks/apn.rake +30 -0
  38. data/lib/apn_on_rails/tasks/db.rake +19 -0
  39. data/lib/apn_on_rails_tasks.rb +3 -0
  40. data/spec/active_record/setup_ar.rb +19 -0
  41. data/spec/apn_on_rails/app/models/apn/app_spec.rb +230 -0
  42. data/spec/apn_on_rails/app/models/apn/device_spec.rb +60 -0
  43. data/spec/apn_on_rails/app/models/apn/group_notification_spec.rb +66 -0
  44. data/spec/apn_on_rails/app/models/apn/notification_spec.rb +71 -0
  45. data/spec/apn_on_rails/app/models/apn/pull_notification_spec.rb +100 -0
  46. data/spec/apn_on_rails/libs/connection_spec.rb +40 -0
  47. data/spec/apn_on_rails/libs/feedback_spec.rb +43 -0
  48. data/spec/extensions/string.rb +10 -0
  49. data/spec/factories/app_factory.rb +27 -0
  50. data/spec/factories/device_factory.rb +29 -0
  51. data/spec/factories/device_grouping_factory.rb +22 -0
  52. data/spec/factories/group_factory.rb +27 -0
  53. data/spec/factories/group_notification_factory.rb +22 -0
  54. data/spec/factories/notification_factory.rb +22 -0
  55. data/spec/factories/pull_notification_factory.rb +22 -0
  56. data/spec/fixtures/hexa.bin +1 -0
  57. data/spec/fixtures/message_for_sending.bin +0 -0
  58. data/spec/rails_root/config/apple_push_notification_development.pem +19 -0
  59. data/spec/spec_helper.rb +55 -0
  60. metadata +283 -0
@@ -0,0 +1,22 @@
1
+ module DeviceGroupingFactory
2
+
3
+ class << self
4
+
5
+ def new(options = {})
6
+ device = APN::Device.first
7
+ group = APN::Group.first
8
+ options = {:device_id => device.id, :group_id => group.id}.merge(options)
9
+ return APN::DeviceGrouping.new(options)
10
+ end
11
+
12
+ def create(options = {})
13
+ device_grouping = DeviceGroupingFactory.new(options)
14
+ device_grouping.save
15
+ return device_grouping
16
+ end
17
+
18
+ end
19
+
20
+ end
21
+
22
+ DeviceGroupingFactory.create
@@ -0,0 +1,27 @@
1
+ module GroupFactory
2
+
3
+ class << self
4
+
5
+ def new(options = {})
6
+ app = APN::App.first
7
+ options = {:app_id => app.id, :name => GroupFactory.random_name}.merge(options)
8
+ return APN::Group.new(options)
9
+ end
10
+
11
+ def create(options = {})
12
+ group = GroupFactory.new(options)
13
+ group.save
14
+ return group
15
+ end
16
+
17
+ def random_name
18
+ tok = []
19
+ tok << String.randomize(8)
20
+ tok.join(' ').downcase
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+
27
+ GroupFactory.create
@@ -0,0 +1,22 @@
1
+ module GroupNotificationFactory
2
+
3
+ class << self
4
+
5
+ def new(options = {})
6
+ group = APN::Group.first
7
+ options = {:group_id => group.id, :sound => 'my_sound.aiff',
8
+ :badge => 5, :alert => 'Hello!', :custom_properties => {'typ' => 1}}.merge(options)
9
+ return APN::GroupNotification.new(options)
10
+ end
11
+
12
+ def create(options = {})
13
+ notification = GroupNotificationFactory.new(options)
14
+ notification.save
15
+ return notification
16
+ end
17
+
18
+ end
19
+
20
+ end
21
+
22
+ GroupNotificationFactory.create
@@ -0,0 +1,22 @@
1
+ module NotificationFactory
2
+
3
+ class << self
4
+
5
+ def new(options = {})
6
+ device = APN::Device.first
7
+ options = {:device_id => device.id, :sound => 'my_sound.aiff',
8
+ :badge => 5, :alert => 'Hello!', :custom_properties => {'typ' => 1}}.merge(options)
9
+ return APN::Notification.new(options)
10
+ end
11
+
12
+ def create(options = {})
13
+ notification = NotificationFactory.new(options)
14
+ notification.save
15
+ return notification
16
+ end
17
+
18
+ end
19
+
20
+ end
21
+
22
+ NotificationFactory.create
@@ -0,0 +1,22 @@
1
+ module PullNotificationFactory
2
+
3
+ class << self
4
+
5
+ def new(options = {})
6
+ app = APN::App.first
7
+ options = {:app_id => app.id, :title => 'Pull Notification Title',
8
+ :content => 'blah blah blah', :link => 'http://www.prx.org', :launch_notification => false}.merge(options)
9
+ return APN::PullNotification.new(options)
10
+ end
11
+
12
+ def create(options = {})
13
+ noty = PullNotificationFactory.new(options)
14
+ noty.save
15
+ return noty
16
+ end
17
+
18
+ end
19
+
20
+ end
21
+
22
+ PullNotificationFactory.create
@@ -0,0 +1 @@
1
+ P�&cmVS��`�0tϬɵ]�GC�r-E�;�
@@ -0,0 +1,19 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDDDCCAfSgAwIBAgIBATANBgkqhkiG9w0BAQUFADA8MQswCQYDVQQGEwJVUzEN
3
+ MAsGA1UECgwEaG9tZTERMA8GA1UECwwIbWFjYmF0ZXMxCzAJBgNVBAMMAkNBMB4X
4
+ DTA5MDIyMjE5MDUyOVoXDTEwMDIyMjE5MDUyOVowUzELMAkGA1UEBhMCVVMxDTAL
5
+ BgNVBAoMBGhvbWUxETAPBgNVBAsMCG1hY2JhdGVzMQswCQYDVQQLDAJDQTEVMBMG
6
+ A1UEAwwMaGVsbG8tc2VydmVyMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCr
7
+ LhTbcQc6hpYVeB8O94JzWnS41wZTaHReYe2mAxkIH9gF11Gm/Tejdfy7TboVsVtD
8
+ FZ+vrVYPFnnVZG2UNDUkfBvkbCBrFQ8glnAHGRYtDxdFjrLDxm0BOfC58wEtV2cM
9
+ hZhiLqjHFuSjHuAlAUshfCfWmKbEeDVtFSDxUMa6iQIDAQABo4GFMIGCMAwGA1Ud
10
+ EwEB/wQCMAAwMQYJYIZIAYb4QgENBCQWIlJ1YnkvT3BlblNTTCBHZW5lcmF0ZWQg
11
+ Q2VydGlmaWNhdGUwHQYDVR0OBBYEFEIBIEcdhFKPB+QILbsupdz3uD6YMAsGA1Ud
12
+ DwQEAwIFoDATBgNVHSUEDDAKBggrBgEFBQcDATANBgkqhkiG9w0BAQUFAAOCAQEA
13
+ dOKP/y/hsdnn2cbYpu2I6r8Lzql52XKa+jOaOT0TyPhmUAz0bFUgA53a202MDhbS
14
+ KDVhIkC88KTjyyRwVNnwsrS5JD/IOXIJw/vy9VX14aCymPkup0TQR6ZIicKrjcMS
15
+ yhmU5I0+fmsUN4PnayOuT/tJ0giy/x+1L/pgMicS47TvyNLB0vl34FplgmH6zlXv
16
+ nS/5phroEJm71DPyDNNzoohZo54YHpGmvEDqjLc6DB+Ihu6/sghmd5dlSPNqsubO
17
+ sBQeOyNuscbXo6MXI8uDYrZ/PqAtdzPXBjB7LXvVs69YT4KT7BaO3rqobgfJ0kNU
18
+ e7roqj04VUJGmU47qrMLBg==
19
+ -----END CERTIFICATE-----
@@ -0,0 +1,55 @@
1
+ require 'rspec'
2
+ require 'action_view'
3
+
4
+ Dir.glob(File.join(File.dirname(__FILE__), 'extensions', '*.rb')).sort.each do |f|
5
+ require f
6
+ end
7
+
8
+ require File.join(File.dirname(__FILE__), 'active_record', 'setup_ar.rb')
9
+
10
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'apn_on_rails')
11
+
12
+ Dir.glob(File.join(File.dirname(__FILE__), 'factories', '*.rb')).sort.each do |f|
13
+ require f
14
+ end
15
+
16
+ configatron.apn.cert = File.expand_path(File.join(File.dirname(__FILE__), 'rails_root', 'config', 'apple_push_notification_development.pem'))
17
+
18
+ RSpec.configure do |config|
19
+
20
+ config.before(:all) do
21
+
22
+ end
23
+
24
+ config.after(:all) do
25
+
26
+ end
27
+
28
+ config.before(:each) do
29
+
30
+ end
31
+
32
+ config.after(:each) do
33
+
34
+ end
35
+
36
+ end
37
+
38
+ def fixture_path(*name)
39
+ return File.join(File.dirname(__FILE__), 'fixtures', *name)
40
+ end
41
+
42
+ def fixture_value(*name)
43
+ return File.read(fixture_path(*name))
44
+ end
45
+
46
+ def write_fixture(name, value)
47
+ File.open(fixture_path(*name), 'w') {|f| f.write(value)}
48
+ end
49
+
50
+ def apn_cert
51
+ File.read(File.join(File.dirname(__FILE__), 'rails_root', 'config', 'apple_push_notification_development.pem'))
52
+ end
53
+
54
+ class BlockRan < StandardError
55
+ end
metadata ADDED
@@ -0,0 +1,283 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fireinc-apn_on_rails
3
+ version: !ruby/object:Gem::Version
4
+ hash: 11
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 4
9
+ - 2
10
+ version: 0.4.2
11
+ platform: ruby
12
+ authors:
13
+ - markbates
14
+ - Rebecca Nesson
15
+ - Caleb Adam Haye
16
+ autorequire:
17
+ bindir: bin
18
+ cert_chain: []
19
+
20
+ date: 2011-03-21 00:00:00 -07:00
21
+ default_executable:
22
+ dependencies:
23
+ - !ruby/object:Gem::Dependency
24
+ name: configatron
25
+ prerelease: false
26
+ requirement: &id001 !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ hash: 3
32
+ segments:
33
+ - 0
34
+ version: "0"
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: autotest
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :development
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: sqlite3-ruby
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ type: :development
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: rspec
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 15
74
+ segments:
75
+ - 2
76
+ - 0
77
+ - 0
78
+ version: 2.0.0
79
+ type: :development
80
+ version_requirements: *id004
81
+ - !ruby/object:Gem::Dependency
82
+ name: bundler
83
+ prerelease: false
84
+ requirement: &id005 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ hash: 23
90
+ segments:
91
+ - 1
92
+ - 0
93
+ - 0
94
+ version: 1.0.0
95
+ type: :development
96
+ version_requirements: *id005
97
+ - !ruby/object:Gem::Dependency
98
+ name: jeweler
99
+ prerelease: false
100
+ requirement: &id006 !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ~>
104
+ - !ruby/object:Gem::Version
105
+ hash: 3
106
+ segments:
107
+ - 1
108
+ - 5
109
+ - 0
110
+ version: 1.5.0
111
+ type: :development
112
+ version_requirements: *id006
113
+ - !ruby/object:Gem::Dependency
114
+ name: rcov
115
+ prerelease: false
116
+ requirement: &id007 !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ hash: 3
122
+ segments:
123
+ - 0
124
+ version: "0"
125
+ type: :development
126
+ version_requirements: *id007
127
+ - !ruby/object:Gem::Dependency
128
+ name: actionpack
129
+ prerelease: false
130
+ requirement: &id008 !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ~>
134
+ - !ruby/object:Gem::Version
135
+ hash: 3
136
+ segments:
137
+ - 2
138
+ - 3
139
+ - 0
140
+ version: 2.3.0
141
+ type: :development
142
+ version_requirements: *id008
143
+ - !ruby/object:Gem::Dependency
144
+ name: activerecord
145
+ prerelease: false
146
+ requirement: &id009 !ruby/object:Gem::Requirement
147
+ none: false
148
+ requirements:
149
+ - - ~>
150
+ - !ruby/object:Gem::Version
151
+ hash: 3
152
+ segments:
153
+ - 2
154
+ - 3
155
+ - 0
156
+ version: 2.3.0
157
+ type: :development
158
+ version_requirements: *id009
159
+ description: |
160
+ APN on Rails is a Ruby on Rails gem that allows you to
161
+ easily add Apple Push Notification (iPhone) support to your Rails application. This version includes an association between an assumed User model and APN::Device
162
+
163
+ email: caleb@fire.coop
164
+ executables: []
165
+
166
+ extensions: []
167
+
168
+ extra_rdoc_files:
169
+ - LICENSE
170
+ - README
171
+ - README.textile
172
+ files:
173
+ - .rspec
174
+ - .specification
175
+ - Gemfile
176
+ - Gemfile.lock
177
+ - LICENSE
178
+ - README
179
+ - README.textile
180
+ - Rakefile
181
+ - VERSION
182
+ - apn_on_rails.gemspec
183
+ - autotest/discover.rb
184
+ - generators/apn_migrations_generator.rb
185
+ - generators/templates/apn_migrations/001_create_apn_devices.rb
186
+ - generators/templates/apn_migrations/002_create_apn_notifications.rb
187
+ - generators/templates/apn_migrations/003_alter_apn_devices.rb
188
+ - generators/templates/apn_migrations/004_create_apn_apps.rb
189
+ - generators/templates/apn_migrations/005_create_groups.rb
190
+ - generators/templates/apn_migrations/006_alter_apn_groups.rb
191
+ - generators/templates/apn_migrations/007_create_device_groups.rb
192
+ - generators/templates/apn_migrations/008_create_apn_group_notifications.rb
193
+ - generators/templates/apn_migrations/009_create_pull_notifications.rb
194
+ - generators/templates/apn_migrations/010_alter_apn_notifications.rb
195
+ - generators/templates/apn_migrations/011_make_device_token_index_nonunique.rb
196
+ - generators/templates/apn_migrations/012_add_launch_notification_to_apn_pull_notifications.rb
197
+ - lib/apn_on_rails.rb
198
+ - lib/apn_on_rails/apn_on_rails.rb
199
+ - lib/apn_on_rails/app/models/apn/app.rb
200
+ - lib/apn_on_rails/app/models/apn/base.rb
201
+ - lib/apn_on_rails/app/models/apn/device.rb
202
+ - lib/apn_on_rails/app/models/apn/device_grouping.rb
203
+ - lib/apn_on_rails/app/models/apn/group.rb
204
+ - lib/apn_on_rails/app/models/apn/group_notification.rb
205
+ - lib/apn_on_rails/app/models/apn/notification.rb
206
+ - lib/apn_on_rails/app/models/apn/pull_notification.rb
207
+ - lib/apn_on_rails/libs/connection.rb
208
+ - lib/apn_on_rails/libs/feedback.rb
209
+ - lib/apn_on_rails/tasks/apn.rake
210
+ - lib/apn_on_rails/tasks/db.rake
211
+ - lib/apn_on_rails_tasks.rb
212
+ - spec/active_record/setup_ar.rb
213
+ - spec/apn_on_rails/app/models/apn/app_spec.rb
214
+ - spec/apn_on_rails/app/models/apn/device_spec.rb
215
+ - spec/apn_on_rails/app/models/apn/group_notification_spec.rb
216
+ - spec/apn_on_rails/app/models/apn/notification_spec.rb
217
+ - spec/apn_on_rails/app/models/apn/pull_notification_spec.rb
218
+ - spec/apn_on_rails/libs/connection_spec.rb
219
+ - spec/apn_on_rails/libs/feedback_spec.rb
220
+ - spec/extensions/string.rb
221
+ - spec/factories/app_factory.rb
222
+ - spec/factories/device_factory.rb
223
+ - spec/factories/device_grouping_factory.rb
224
+ - spec/factories/group_factory.rb
225
+ - spec/factories/group_notification_factory.rb
226
+ - spec/factories/notification_factory.rb
227
+ - spec/factories/pull_notification_factory.rb
228
+ - spec/fixtures/hexa.bin
229
+ - spec/fixtures/message_for_sending.bin
230
+ - spec/rails_root/config/apple_push_notification_development.pem
231
+ - spec/spec_helper.rb
232
+ has_rdoc: true
233
+ homepage: http://github.com/calebhaye/apn_on_rails
234
+ licenses: []
235
+
236
+ post_install_message:
237
+ rdoc_options: []
238
+
239
+ require_paths:
240
+ - lib
241
+ required_ruby_version: !ruby/object:Gem::Requirement
242
+ none: false
243
+ requirements:
244
+ - - ">="
245
+ - !ruby/object:Gem::Version
246
+ hash: 3
247
+ segments:
248
+ - 0
249
+ version: "0"
250
+ required_rubygems_version: !ruby/object:Gem::Requirement
251
+ none: false
252
+ requirements:
253
+ - - ">="
254
+ - !ruby/object:Gem::Version
255
+ hash: 3
256
+ segments:
257
+ - 0
258
+ version: "0"
259
+ requirements: []
260
+
261
+ rubyforge_project:
262
+ rubygems_version: 1.6.2
263
+ signing_key:
264
+ specification_version: 3
265
+ summary: Apple Push Notifications on Rails
266
+ test_files:
267
+ - spec/active_record/setup_ar.rb
268
+ - spec/apn_on_rails/app/models/apn/app_spec.rb
269
+ - spec/apn_on_rails/app/models/apn/device_spec.rb
270
+ - spec/apn_on_rails/app/models/apn/group_notification_spec.rb
271
+ - spec/apn_on_rails/app/models/apn/notification_spec.rb
272
+ - spec/apn_on_rails/app/models/apn/pull_notification_spec.rb
273
+ - spec/apn_on_rails/libs/connection_spec.rb
274
+ - spec/apn_on_rails/libs/feedback_spec.rb
275
+ - spec/extensions/string.rb
276
+ - spec/factories/app_factory.rb
277
+ - spec/factories/device_factory.rb
278
+ - spec/factories/device_grouping_factory.rb
279
+ - spec/factories/group_factory.rb
280
+ - spec/factories/group_notification_factory.rb
281
+ - spec/factories/notification_factory.rb
282
+ - spec/factories/pull_notification_factory.rb
283
+ - spec/spec_helper.rb