fwt_push_notification_server 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +34 -0
- data/app/assets/images/fw-logo.png +0 -0
- data/app/assets/javascripts/fwt_push_notification_server/application.js +13 -0
- data/app/assets/javascripts/fwt_push_notification_server/device_tokens.js +2 -0
- data/app/assets/stylesheets/fwt_push_notification_server/application.css.scss +192 -0
- data/app/assets/stylesheets/fwt_push_notification_server/device_tokens.css +4 -0
- data/app/assets/stylesheets/fwt_push_notification_server/jquery-ui-timepicker-addon.css +10 -0
- data/app/assets/stylesheets/fwt_push_notification_server/jquery-ui.css +474 -0
- data/app/assets/stylesheets/fwt_push_notification_server/jquery.ui.theme.css +248 -0
- data/app/controllers/fwt_push_notification_server/application_controller.rb +9 -0
- data/app/controllers/fwt_push_notification_server/device_tokens_controller.rb +51 -0
- data/app/helpers/fwt_push_notification_server/application_helper.rb +6 -0
- data/app/helpers/fwt_push_notification_server/device_tokens_helper.rb +6 -0
- data/app/models/fwt_push_notification_server/device_token.rb +9 -0
- data/app/models/fwt_push_notification_server/user.rb +7 -0
- data/app/views/fwt_push_notification_server/application/_empty_view.html.erb +1 -0
- data/app/views/fwt_push_notification_server/device_tokens/index.html.erb +35 -0
- data/app/views/layouts/fwt_push_notification_server/_messages.html.erb +6 -0
- data/app/views/layouts/fwt_push_notification_server/application.html.erb +30 -0
- data/config/initializers/devise.rb +27 -0
- data/config/locales/devise.en.yml +60 -0
- data/config/routes.rb +11 -0
- data/lib/fwt_push_notification_server/engine.rb +16 -0
- data/lib/fwt_push_notification_server/version.rb +3 -0
- data/lib/fwt_push_notification_server.rb +48 -0
- data/lib/generators/fwt_push_notification_server/install/install_generator.rb +49 -0
- data/lib/generators/fwt_push_notification_server/install/templates/create_fwt_push_notification_server_device_tokens.rb +14 -0
- data/lib/generators/fwt_push_notification_server/install/templates/devise_create_fwt_push_notification_server_users.rb +31 -0
- data/lib/generators/fwt_push_notification_server/install/templates/initializer.rb +20 -0
- data/lib/generators/fwt_push_notification_server/install/templates/seeds.rb +5 -0
- data/lib/tasks/fwt_push_notification_server_tasks.rake +4 -0
- data/test/controllers/fwt_push_notification_server/device_tokens_controller_test.rb +51 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/fwt_push_notification_server.rb +19 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20130918095820_create_fwt_push_notification_server_device_tokens.rb +14 -0
- data/test/dummy/db/migrate/20130918095821_devise_create_fwt_push_notification_server_users.rb +31 -0
- data/test/dummy/db/schema.rb +43 -0
- data/test/dummy/db/seeds.rb +5 -0
- data/test/dummy/log/development.log +16238 -0
- data/test/dummy/log/test.log +10 -0
- data/test/dummy/public/404.html +58 -0
- data/test/dummy/public/422.html +58 -0
- data/test/dummy/public/500.html +57 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/12c8e9505bddaa133e5fb349c2a5686f5ceccada/bootstrap.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_accordion.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_alerts.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_breadcrumbs.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_button-groups.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_buttons.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_carousel.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_close.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_code.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_component-animations.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_dropdowns.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_forms.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_grid.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_hero-unit.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_labels-badges.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_layouts.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_media.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_mixins.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_modals.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_navbar.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_navs.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_pager.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_pagination.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_popovers.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_progress-bars.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_reset.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_scaffolding.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_sprites.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_tables.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_thumbnails.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_tooltip.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_type.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_utilities.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_variables.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/_wells.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/7c851c8cce3147a485a2e36f9c2ea3624eca398d/bootstrap.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sass/dd375f805d06ad6efb1710787bd24bcab705b025/application.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/018e8124fa401e10da2a0f8d089b1467 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/04f93e7cd5f3c6bd6c26ea15acf03144 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/1e51677f9d96bb542510a33f91cbd9b6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/23bb189d596dce443600523c2af2f418 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/375c78da06e45aab2bc0723f291620f6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/3bebeefd5ffe6a58fb03bf1f37ac9163 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/40525813aeb4df11bbc7934420765970 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/4809faed3f3c49e4f0069d90c42db9fa +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/4837e9658be5fa714ededd423bec6394 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/4930f39005ca20c14fe5b6ff5e3462c5 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/4edaf8d607c191a1d04f54ceafa27f34 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/525db6dca24b08bdb1073bd610b641fa +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/52fc34b303a5058c0f82e03f5e49be15 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/53a6a8c806fb66ef100dcdec2c14667f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5d48cbe0eb7f4d2a888760672ebcd0b5 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5dbf4424a551546c8ca2ea3693f57aad +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/63e1b63a0601a563b63be1b6cb6f14e8 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7525085b7df71dd698c4ddd96818b178 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7c0cc261ea34e01a60b85decd619d572 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/807b74c8c0f4286940e0f072e71dbf48 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/86b51d868b31f8ec21eab714b70f25c8 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/871bed79442dc4d0f7e860539e548c11 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/873e96cc154ed7b8f89ae6ebd6330d76 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9266b6839c460333f8fabb33531b0aa5 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9619769a83bc4c96187fad84dd44f662 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/984da49c74b19af286bd6da0be3b7f41 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b3329085a217fc47138d40e542cbab29 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b49ac435bde8ad5725858653ed8c96b0 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c88406e714c83dc7a8eba7dfc687b9be +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/db1758582caea75d451566fa655186d1 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ee6e9c40abd892aaef0bbbf0bd11c5e0 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f0e74746290141cd77d8e42db2047501 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f301640fffe07f12598645f72b673e29 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f3f906a5c3f8d16aaa9833a07d5f87dc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f6db10193f0119f139b2d45d263ed768 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/fa7addf7e35b3a6bfcff34dc107fad07 +0 -0
- data/test/fixtures/fwt_push_notification_server/device_tokens.yml +13 -0
- data/test/fixtures/fwt_push_notification_server/users.yml +11 -0
- data/test/fwt_push_notification_server_test.rb +9 -0
- data/test/helpers/fwt_push_notification_server/device_tokens_helper_test.rb +6 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/models/fwt_push_notification_server/device_token_test.rb +9 -0
- data/test/models/fwt_push_notification_server/user_test.rb +9 -0
- data/test/test_helper.rb +15 -0
- metadata +481 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
|
2
|
+
|
3
|
+
en:
|
4
|
+
devise:
|
5
|
+
confirmations:
|
6
|
+
confirmed: "Your account was successfully confirmed. Please sign in."
|
7
|
+
confirmed_and_signed_in: "Your account was successfully confirmed. You are now signed in."
|
8
|
+
send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes."
|
9
|
+
send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes."
|
10
|
+
failure:
|
11
|
+
already_authenticated: "You are already signed in."
|
12
|
+
inactive: "Your account is not activated yet."
|
13
|
+
invalid: "Invalid email or password."
|
14
|
+
invalid_token: "Invalid authentication token."
|
15
|
+
locked: "Your account is locked."
|
16
|
+
not_found_in_database: "Invalid email or password."
|
17
|
+
timeout: "Your session expired. Please sign in again to continue."
|
18
|
+
unauthenticated: "You need to sign in or sign up before continuing."
|
19
|
+
unconfirmed: "You have to confirm your account before continuing."
|
20
|
+
mailer:
|
21
|
+
confirmation_instructions:
|
22
|
+
subject: "Confirmation instructions"
|
23
|
+
reset_password_instructions:
|
24
|
+
subject: "Reset password instructions"
|
25
|
+
unlock_instructions:
|
26
|
+
subject: "Unlock Instructions"
|
27
|
+
omniauth_callbacks:
|
28
|
+
failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
|
29
|
+
success: "Successfully authenticated from %{kind} account."
|
30
|
+
passwords:
|
31
|
+
no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
|
32
|
+
send_instructions: "You will receive an email with instructions about how to reset your password in a few minutes."
|
33
|
+
send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
|
34
|
+
updated: "Your password was changed successfully. You are now signed in."
|
35
|
+
updated_not_active: "Your password was changed successfully."
|
36
|
+
registrations:
|
37
|
+
destroyed: "Bye! Your account was successfully cancelled. We hope to see you again soon."
|
38
|
+
signed_up: "Welcome! You have signed up successfully."
|
39
|
+
signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
|
40
|
+
signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
|
41
|
+
signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please open the link to activate your account."
|
42
|
+
update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
|
43
|
+
updated: "You updated your account successfully."
|
44
|
+
sessions:
|
45
|
+
signed_in: "Signed in successfully."
|
46
|
+
signed_out: "Signed out successfully."
|
47
|
+
unlocks:
|
48
|
+
send_instructions: "You will receive an email with instructions about how to unlock your account in a few minutes."
|
49
|
+
send_paranoid_instructions: "If your account exists, you will receive an email with instructions about how to unlock it in a few minutes."
|
50
|
+
unlocked: "Your account has been unlocked successfully. Please sign in to continue."
|
51
|
+
errors:
|
52
|
+
messages:
|
53
|
+
already_confirmed: "was already confirmed, please try signing in"
|
54
|
+
confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
|
55
|
+
expired: "has expired, please request a new one"
|
56
|
+
not_found: "not found"
|
57
|
+
not_locked: "was not locked"
|
58
|
+
not_saved:
|
59
|
+
one: "1 error prohibited this %{resource} from being saved:"
|
60
|
+
other: "%{count} errors prohibited this %{resource} from being saved:"
|
data/config/routes.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "kaminari-bootstrap"
|
2
|
+
require "bootstrap-sass"
|
3
|
+
require "sass-rails"
|
4
|
+
require "devise"
|
5
|
+
require "cancan"
|
6
|
+
require "simple_form"
|
7
|
+
require "rails_bootstrap_navbar"
|
8
|
+
require "coffee-rails"
|
9
|
+
|
10
|
+
module FwtPushNotificationServer
|
11
|
+
|
12
|
+
class Engine < ::Rails::Engine
|
13
|
+
isolate_namespace FwtPushNotificationServer
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "fwt_push_notification_server/engine"
|
2
|
+
require 'active_support/core_ext/hash/slice'
|
3
|
+
require "devise"
|
4
|
+
require "grocer"
|
5
|
+
|
6
|
+
module FwtPushNotificationServer
|
7
|
+
|
8
|
+
mattr_accessor :config
|
9
|
+
|
10
|
+
def self.apns_config
|
11
|
+
config.slice(:gateway, :certificate, :passphrase)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.send_notification_to_all(alert)
|
15
|
+
devices = DeviceToken.where(:is_valid => true).all
|
16
|
+
send_notification(alert, devices)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.send_notification(alert, device_tokens)
|
20
|
+
|
21
|
+
alert = alert.byteslice(0, 232)
|
22
|
+
alert += '...' if alert.bytesize > 232
|
23
|
+
|
24
|
+
config = self.apns_config
|
25
|
+
|
26
|
+
pusher = Grocer.pusher(config)
|
27
|
+
|
28
|
+
device_tokens = [device_tokens] unless device_tokens.is_a?(Array)
|
29
|
+
|
30
|
+
device_tokens.each do |device|
|
31
|
+
if device.is_valid
|
32
|
+
token = device.token
|
33
|
+
n = Grocer::Notification.new(device_token: token, alert: alert)
|
34
|
+
pusher.push n
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
feedback = Grocer.feedback(config)
|
39
|
+
feedback.each do |attempt|
|
40
|
+
token = attempt.device_token
|
41
|
+
device_token = DeviceToken.find_by_token(token)
|
42
|
+
device_token.update_attribute("is_valid", false) unless device_token.nil?
|
43
|
+
puts "Device #{token} failed at #{attempt.timestamp}"
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'rails/generators/migration'
|
2
|
+
|
3
|
+
module FwtPushNotificationServer
|
4
|
+
module Generators
|
5
|
+
|
6
|
+
class InstallGenerator < ::Rails::Generators::Base
|
7
|
+
|
8
|
+
include Rails::Generators::Migration
|
9
|
+
|
10
|
+
source_root File.expand_path('../templates', __FILE__)
|
11
|
+
|
12
|
+
desc "Add the migrations"
|
13
|
+
|
14
|
+
def self.next_migration_number(path)
|
15
|
+
unless @prev_migration_nr
|
16
|
+
@prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
|
17
|
+
else
|
18
|
+
@prev_migration_nr += 1
|
19
|
+
end
|
20
|
+
@prev_migration_nr.to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
def copy_migrations
|
24
|
+
migration_template "create_fwt_push_notification_server_device_tokens.rb", "db/migrate/create_fwt_push_notification_server_device_tokens.rb"
|
25
|
+
migration_template "devise_create_fwt_push_notification_server_users.rb", "db/migrate/devise_create_fwt_push_notification_server_users.rb"
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "Add initializer"
|
29
|
+
|
30
|
+
def copy_initializer_file
|
31
|
+
copy_file "initializer.rb", "config/initializers/#{app_name}.rb"
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "Add seeds"
|
35
|
+
|
36
|
+
def append_seeds
|
37
|
+
seeds = File.read(File.join(File.dirname(__FILE__), "templates/seeds.rb"))
|
38
|
+
append_file "db/seeds.rb", seeds
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
def app_name
|
43
|
+
"fwt_push_notification_server"
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateFwtPushNotificationServerDeviceTokens < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def change
|
4
|
+
create_table :fwt_push_notification_server_device_tokens do |t|
|
5
|
+
t.string :token
|
6
|
+
t.string :device_id
|
7
|
+
t.string :device_name
|
8
|
+
t.boolean :is_valid, :default => true
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class DeviseCreateFwtPushNotificationServerUsers < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def change
|
4
|
+
create_table(:fwt_push_notification_server_users) do |t|
|
5
|
+
## Database authenticatable
|
6
|
+
t.string :email, :null => false, :default => ""
|
7
|
+
t.string :encrypted_password, :null => false, :default => ""
|
8
|
+
|
9
|
+
## Recoverable
|
10
|
+
t.string :reset_password_token
|
11
|
+
t.datetime :reset_password_sent_at
|
12
|
+
|
13
|
+
## Rememberable
|
14
|
+
t.datetime :remember_created_at
|
15
|
+
|
16
|
+
## Trackable
|
17
|
+
t.integer :sign_in_count, :default => 0, :null => false
|
18
|
+
t.datetime :current_sign_in_at
|
19
|
+
t.datetime :last_sign_in_at
|
20
|
+
t.string :current_sign_in_ip
|
21
|
+
t.string :last_sign_in_ip
|
22
|
+
|
23
|
+
t.timestamps
|
24
|
+
end
|
25
|
+
|
26
|
+
add_index :fwt_push_notification_server_users, :email, :unique => true, :name => "fwt_users_email_index"
|
27
|
+
add_index :fwt_push_notification_server_users, :reset_password_token, :unique => true, :name => "fwt_users_reset_password_token_index"
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#development (sandbox)
|
2
|
+
FwtPushNotificationServer.config = {
|
3
|
+
|
4
|
+
:api_key => 'YOUR-DEVELOPMENT-KEY-HERE',
|
5
|
+
:certificate => File.join(Rails.root, 'config', 'APNSDevelopment.pem'),
|
6
|
+
:passphrase => 'PASSPHRASE',
|
7
|
+
:gateway => 'gateway.sandbox.push.apple.com',
|
8
|
+
:title => 'FWT Push Notifications'
|
9
|
+
};
|
10
|
+
|
11
|
+
#production
|
12
|
+
# FwtPushNotificationServer.config = {
|
13
|
+
|
14
|
+
# :api_key => 'YOUR-PRODUCTION-KEY-HERE',
|
15
|
+
# :certificate => File.join(Rails.root, 'config', 'APNSProduction.pem'),
|
16
|
+
# :passphrase => 'PASSPHRASE',
|
17
|
+
# :gateway => 'gateway.push.apple.com',
|
18
|
+
# :title => 'FWT Push Notifications'
|
19
|
+
|
20
|
+
# };
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module FwtPushNotificationServer
|
4
|
+
class DeviceTokensControllerTest < ActionController::TestCase
|
5
|
+
setup do
|
6
|
+
@device_token = device_tokens(:one)
|
7
|
+
end
|
8
|
+
|
9
|
+
test "should get index" do
|
10
|
+
get :index
|
11
|
+
assert_response :success
|
12
|
+
assert_not_nil assigns(:device_tokens)
|
13
|
+
end
|
14
|
+
|
15
|
+
test "should get new" do
|
16
|
+
get :new
|
17
|
+
assert_response :success
|
18
|
+
end
|
19
|
+
|
20
|
+
test "should create device_token" do
|
21
|
+
assert_difference('DeviceToken.count') do
|
22
|
+
post :create, device_token: { device_id: @device_token.device_id, device_name: @device_token.device_name, is_valid: @device_token.is_valid, token: @device_token.token }
|
23
|
+
end
|
24
|
+
|
25
|
+
assert_redirected_to device_token_path(assigns(:device_token))
|
26
|
+
end
|
27
|
+
|
28
|
+
test "should show device_token" do
|
29
|
+
get :show, id: @device_token
|
30
|
+
assert_response :success
|
31
|
+
end
|
32
|
+
|
33
|
+
test "should get edit" do
|
34
|
+
get :edit, id: @device_token
|
35
|
+
assert_response :success
|
36
|
+
end
|
37
|
+
|
38
|
+
test "should update device_token" do
|
39
|
+
patch :update, id: @device_token, device_token: { device_id: @device_token.device_id, device_name: @device_token.device_name, is_valid: @device_token.is_valid, token: @device_token.token }
|
40
|
+
assert_redirected_to device_token_path(assigns(:device_token))
|
41
|
+
end
|
42
|
+
|
43
|
+
test "should destroy device_token" do
|
44
|
+
assert_difference('DeviceToken.count', -1) do
|
45
|
+
delete :destroy, id: @device_token
|
46
|
+
end
|
47
|
+
|
48
|
+
assert_redirected_to device_tokens_path
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
data/test/dummy/bin/rake
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require(*Rails.groups)
|
6
|
+
require "fwt_push_notification_server"
|
7
|
+
|
8
|
+
module Dummy
|
9
|
+
class Application < Rails::Application
|
10
|
+
# Settings in config/environments/* take precedence over those specified here.
|
11
|
+
# Application configuration should go into files in config/initializers
|
12
|
+
# -- all .rb files in that directory are automatically loaded.
|
13
|
+
|
14
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
15
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
16
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
17
|
+
|
18
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
19
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
20
|
+
# config.i18n.default_locale = :de
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
6
|
+
development:
|
7
|
+
adapter: sqlite3
|
8
|
+
database: db/development.sqlite3
|
9
|
+
pool: 5
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
# Warning: The database defined as "test" will be erased and
|
13
|
+
# re-generated from your development database when you run "rake".
|
14
|
+
# Do not set this db to the same as development or production.
|
15
|
+
test:
|
16
|
+
adapter: sqlite3
|
17
|
+
database: db/test.sqlite3
|
18
|
+
pool: 5
|
19
|
+
timeout: 5000
|
20
|
+
|
21
|
+
production:
|
22
|
+
adapter: sqlite3
|
23
|
+
database: db/production.sqlite3
|
24
|
+
pool: 5
|
25
|
+
timeout: 5000
|