diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.rspec b/.rspec old mode 100644 new mode 100755 diff --git a/.specification b/.specification old mode 100644 new mode 100755 diff --git a/Gemfile b/Gemfile old mode 100644 new mode 100755 diff --git a/Gemfile.lock b/Gemfile.lock old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README b/README old mode 100644 new mode 100755 diff --git a/README.textile b/README.textile old mode 100644 new mode 100755 diff --git a/Rakefile b/Rakefile old mode 100644 new mode 100755 index 1bc84211..a0606ffb --- a/Rakefile +++ b/Rakefile @@ -12,16 +12,17 @@ require 'rake' require 'jeweler' Jeweler::Tasks.new do |gem| # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options - gem.name = "apn_on_rails" + gem.name = "fireinc-apn_on_rails" gem.summary = %Q{Apple Push Notifications on Rails} gem.description = %Q{APN on Rails is a Ruby on Rails gem that allows you to easily add Apple Push Notification (iPhone) support to your Rails application. +This version includes an association between an assumed User model and APN::Device } - gem.email = "tech-team@prx.org" - gem.homepage = "http://github.com/PRX/apn_on_rails" - gem.authors = ["markbates", "Rebecca Nesson"] + gem.email = "caleb@fire.coop" + gem.homepage = "http://github.com/calebhaye/apn_on_rails" + gem.authors = ["markbates", "Rebecca Nesson", "Caleb Adam Haye"] end #Jeweler::RubygemsDotOrgsTasks.new diff --git a/VERSION b/VERSION old mode 100644 new mode 100755 index 2b7c5ae0..73333c8a --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.4.2 +0.4.2.5 \ No newline at end of file diff --git a/autotest/discover.rb b/autotest/discover.rb old mode 100644 new mode 100755 diff --git a/fireinc-apn_on_rails.gemspec b/fireinc-apn_on_rails.gemspec new file mode 100755 index 00000000..c7c6a2a5 --- /dev/null +++ b/fireinc-apn_on_rails.gemspec @@ -0,0 +1,144 @@ +# Generated by jeweler +# DO NOT EDIT THIS FILE DIRECTLY +# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{fireinc-apn_on_rails} + s.version = "0.4.2.13" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["markbates", "Rebecca Nesson", "Caleb Adam Haye"] + s.date = %q{2011-11-31} + s.description = %q{APN on Rails is a Ruby on Rails gem that allows you to +easily add Apple Push Notification (iPhone) support to your Rails application. This version includes an association between an assumed User model and APN::Device +} + s.email = %q{caleb@fire.coop} + s.extra_rdoc_files = [ + "LICENSE", + "README", + "README.textile" + ] + s.files = [ + ".rspec", + ".specification", + "Gemfile", + "Gemfile.lock", + "LICENSE", + "README", + "README.textile", + "Rakefile", + "VERSION", + "fireinc-apn_on_rails.gemspec", + "autotest/discover.rb", + "generators/apn_migrations_generator.rb", + "generators/templates/apn_migrations/001_create_apn_devices.rb", + "generators/templates/apn_migrations/002_create_apn_notifications.rb", + "generators/templates/apn_migrations/003_alter_apn_devices.rb", + "generators/templates/apn_migrations/004_create_apn_apps.rb", + "generators/templates/apn_migrations/005_create_groups.rb", + "generators/templates/apn_migrations/006_alter_apn_groups.rb", + "generators/templates/apn_migrations/007_create_device_groups.rb", + "generators/templates/apn_migrations/008_create_apn_group_notifications.rb", + "generators/templates/apn_migrations/009_create_pull_notifications.rb", + "generators/templates/apn_migrations/010_alter_apn_notifications.rb", + "generators/templates/apn_migrations/011_make_device_token_index_nonunique.rb", + "generators/templates/apn_migrations/012_add_launch_notification_to_apn_pull_notifications.rb", + "lib/apn_on_rails.rb", + "lib/apn_on_rails/apn_on_rails.rb", + "lib/apn_on_rails/app/models/apn/app.rb", + "lib/apn_on_rails/app/models/apn/base.rb", + "lib/apn_on_rails/app/models/apn/device.rb", + "lib/apn_on_rails/app/models/apn/device_grouping.rb", + "lib/apn_on_rails/app/models/apn/group.rb", + "lib/apn_on_rails/app/models/apn/group_notification.rb", + "lib/apn_on_rails/app/models/apn/notification.rb", + "lib/apn_on_rails/app/models/apn/pull_notification.rb", + "lib/apn_on_rails/libs/connection.rb", + "lib/apn_on_rails/libs/feedback.rb", + "lib/apn_on_rails/tasks/apn.rake", + "lib/apn_on_rails/tasks/db.rake", + "lib/apn_on_rails_tasks.rb", + "spec/active_record/setup_ar.rb", + "spec/apn_on_rails/app/models/apn/app_spec.rb", + "spec/apn_on_rails/app/models/apn/device_spec.rb", + "spec/apn_on_rails/app/models/apn/group_notification_spec.rb", + "spec/apn_on_rails/app/models/apn/notification_spec.rb", + "spec/apn_on_rails/app/models/apn/pull_notification_spec.rb", + "spec/apn_on_rails/libs/connection_spec.rb", + "spec/apn_on_rails/libs/feedback_spec.rb", + "spec/extensions/string.rb", + "spec/factories/app_factory.rb", + "spec/factories/device_factory.rb", + "spec/factories/device_grouping_factory.rb", + "spec/factories/group_factory.rb", + "spec/factories/group_notification_factory.rb", + "spec/factories/notification_factory.rb", + "spec/factories/pull_notification_factory.rb", + "spec/fixtures/hexa.bin", + "spec/fixtures/message_for_sending.bin", + "spec/rails_root/config/apple_push_notification_development.pem", + "spec/spec_helper.rb" + ] + s.homepage = %q{http://github.com/calebhaye/apn_on_rails} + s.require_paths = ["lib"] + s.rubygems_version = %q{1.3.7} + s.summary = %q{Apple Push Notifications on Rails} + s.test_files = [ + "spec/active_record/setup_ar.rb", + "spec/apn_on_rails/app/models/apn/app_spec.rb", + "spec/apn_on_rails/app/models/apn/device_spec.rb", + "spec/apn_on_rails/app/models/apn/group_notification_spec.rb", + "spec/apn_on_rails/app/models/apn/notification_spec.rb", + "spec/apn_on_rails/app/models/apn/pull_notification_spec.rb", + "spec/apn_on_rails/libs/connection_spec.rb", + "spec/apn_on_rails/libs/feedback_spec.rb", + "spec/extensions/string.rb", + "spec/factories/app_factory.rb", + "spec/factories/device_factory.rb", + "spec/factories/device_grouping_factory.rb", + "spec/factories/group_factory.rb", + "spec/factories/group_notification_factory.rb", + "spec/factories/notification_factory.rb", + "spec/factories/pull_notification_factory.rb", + "spec/spec_helper.rb" + ] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then + s.add_runtime_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, [">= 2.0.0"]) + s.add_development_dependency(%q, ["~> 1.0.0"]) + s.add_development_dependency(%q, ["~> 1.5.0"]) + s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, ["~> 2.3.0"]) + s.add_development_dependency(%q, ["~> 2.3.0"]) + else + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 2.0.0"]) + s.add_dependency(%q, ["~> 1.0.0"]) + s.add_dependency(%q, ["~> 1.5.0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, ["~> 2.3.0"]) + s.add_dependency(%q, ["~> 2.3.0"]) + end + else + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 2.0.0"]) + s.add_dependency(%q, ["~> 1.0.0"]) + s.add_dependency(%q, ["~> 1.5.0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, ["~> 2.3.0"]) + s.add_dependency(%q, ["~> 2.3.0"]) + end +end + diff --git a/generators/apn_migrations_generator.rb b/generators/apn_migrations_generator.rb old mode 100644 new mode 100755 diff --git a/generators/templates/apn_migrations/001_create_apn_devices.rb b/generators/templates/apn_migrations/001_create_apn_devices.rb old mode 100644 new mode 100755 diff --git a/generators/templates/apn_migrations/002_create_apn_notifications.rb b/generators/templates/apn_migrations/002_create_apn_notifications.rb old mode 100644 new mode 100755 diff --git a/generators/templates/apn_migrations/003_alter_apn_devices.rb b/generators/templates/apn_migrations/003_alter_apn_devices.rb old mode 100644 new mode 100755 diff --git a/generators/templates/apn_migrations/004_create_apn_apps.rb b/generators/templates/apn_migrations/004_create_apn_apps.rb old mode 100644 new mode 100755 diff --git a/generators/templates/apn_migrations/005_create_groups.rb b/generators/templates/apn_migrations/005_create_groups.rb old mode 100644 new mode 100755 diff --git a/generators/templates/apn_migrations/006_alter_apn_groups.rb b/generators/templates/apn_migrations/006_alter_apn_groups.rb old mode 100644 new mode 100755 diff --git a/generators/templates/apn_migrations/007_create_device_groups.rb b/generators/templates/apn_migrations/007_create_device_groups.rb old mode 100644 new mode 100755 diff --git a/generators/templates/apn_migrations/008_create_apn_group_notifications.rb b/generators/templates/apn_migrations/008_create_apn_group_notifications.rb old mode 100644 new mode 100755 diff --git a/generators/templates/apn_migrations/009_create_pull_notifications.rb b/generators/templates/apn_migrations/009_create_pull_notifications.rb old mode 100644 new mode 100755 diff --git a/generators/templates/apn_migrations/010_alter_apn_notifications.rb b/generators/templates/apn_migrations/010_alter_apn_notifications.rb old mode 100644 new mode 100755 diff --git a/generators/templates/apn_migrations/011_make_device_token_index_nonunique.rb b/generators/templates/apn_migrations/011_make_device_token_index_nonunique.rb old mode 100644 new mode 100755 diff --git a/generators/templates/apn_migrations/012_add_launch_notification_to_apn_pull_notifications.rb b/generators/templates/apn_migrations/012_add_launch_notification_to_apn_pull_notifications.rb old mode 100644 new mode 100755 diff --git a/lib/apn_on_rails.rb b/lib/apn_on_rails.rb old mode 100644 new mode 100755 diff --git a/lib/apn_on_rails/apn_on_rails.rb b/lib/apn_on_rails/apn_on_rails.rb old mode 100644 new mode 100755 diff --git a/lib/apn_on_rails/app/models/apn/app.rb b/lib/apn_on_rails/app/models/apn/app.rb old mode 100644 new mode 100755 index a0927374..ecfafc8f --- a/lib/apn_on_rails/app/models/apn/app.rb +++ b/lib/apn_on_rails/app/models/apn/app.rb @@ -45,14 +45,15 @@ def self.send_notifications_for_cert(the_cert, app_id) conditions = ["app_id = ?", app_id] end begin - APN::Connection.open_for_delivery({:cert => the_cert}) do |conn, sock| - APN::Device.find_each(:conditions => conditions) do |dev| + APN::Device.find_each(:conditions => conditions) do |dev| + APN::Connection.open_for_delivery({:cert => the_cert}) do |conn, sock| dev.unsent_notifications.each do |noty| conn.write(noty.message_for_sending) noty.sent_at = Time.now noty.save end end + sleep(1) end rescue Exception => e log_connection_exception(e) @@ -144,7 +145,7 @@ def self.process_devices_for_cert(the_cert) protected - def log_connection_exception(ex) + def self.log_connection_exception(ex) puts ex.message end diff --git a/lib/apn_on_rails/app/models/apn/base.rb b/lib/apn_on_rails/app/models/apn/base.rb old mode 100644 new mode 100755 diff --git a/lib/apn_on_rails/app/models/apn/device.rb b/lib/apn_on_rails/app/models/apn/device.rb old mode 100644 new mode 100755 index 1864ca0a..c744dcfa --- a/lib/apn_on_rails/app/models/apn/device.rb +++ b/lib/apn_on_rails/app/models/apn/device.rb @@ -13,8 +13,9 @@ class APN::Device < APN::Base belongs_to :app, :class_name => 'APN::App' has_many :notifications, :class_name => 'APN::Notification' has_many :unsent_notifications, :class_name => 'APN::Notification', :conditions => 'sent_at is null' + belongs_to :user - validates_uniqueness_of :token, :scope => :app_id + validates_uniqueness_of :token, :scope => :artist_id validates_format_of :token, :with => /^[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}\s[a-z0-9]{8}$/ before_create :set_last_registered_at diff --git a/lib/apn_on_rails/app/models/apn/device_grouping.rb b/lib/apn_on_rails/app/models/apn/device_grouping.rb old mode 100644 new mode 100755 diff --git a/lib/apn_on_rails/app/models/apn/group.rb b/lib/apn_on_rails/app/models/apn/group.rb old mode 100644 new mode 100755 diff --git a/lib/apn_on_rails/app/models/apn/group_notification.rb b/lib/apn_on_rails/app/models/apn/group_notification.rb old mode 100644 new mode 100755 diff --git a/lib/apn_on_rails/app/models/apn/notification.rb b/lib/apn_on_rails/app/models/apn/notification.rb old mode 100644 new mode 100755 diff --git a/lib/apn_on_rails/app/models/apn/pull_notification.rb b/lib/apn_on_rails/app/models/apn/pull_notification.rb old mode 100644 new mode 100755 diff --git a/lib/apn_on_rails/libs/connection.rb b/lib/apn_on_rails/libs/connection.rb old mode 100644 new mode 100755 index c44f8a7e..a94c32d2 --- a/lib/apn_on_rails/libs/connection.rb +++ b/lib/apn_on_rails/libs/connection.rb @@ -59,7 +59,7 @@ def open(options = {}, &block) # :nodoc: ssl.connect yield ssl, sock if block_given? - + ensure ssl.close sock.close end diff --git a/lib/apn_on_rails/libs/feedback.rb b/lib/apn_on_rails/libs/feedback.rb old mode 100644 new mode 100755 diff --git a/lib/apn_on_rails/tasks/apn.rake b/lib/apn_on_rails/tasks/apn.rake old mode 100644 new mode 100755 diff --git a/lib/apn_on_rails/tasks/db.rake b/lib/apn_on_rails/tasks/db.rake old mode 100644 new mode 100755 diff --git a/lib/apn_on_rails_tasks.rb b/lib/apn_on_rails_tasks.rb old mode 100644 new mode 100755 diff --git a/apn_on_rails.gemspec b/presskit-apn_on_rails.gemspec old mode 100644 new mode 100755 similarity index 94% rename from apn_on_rails.gemspec rename to presskit-apn_on_rails.gemspec index b2d5b047..a719d8d3 --- a/apn_on_rails.gemspec +++ b/presskit-apn_on_rails.gemspec @@ -4,16 +4,16 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| - s.name = %q{apn_on_rails} - s.version = "0.4.2" + s.name = %q{presskit-apn_on_rails} + s.version = "0.1" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["markbates", "Rebecca Nesson"] - s.date = %q{2011-01-04} + s.authors = ["markbates", "Rebecca Nesson", "Caleb Adam Haye"] + s.date = %q{2011-11-31} s.description = %q{APN on Rails is a Ruby on Rails gem that allows you to -easily add Apple Push Notification (iPhone) support to your Rails application. +easily add Apple Push Notification (iPhone) support to your Rails application. This version includes an association between an assumed User model and APN::Device } - s.email = %q{tech-team@prx.org} + s.email = %q{caleb@fire.coop} s.extra_rdoc_files = [ "LICENSE", "README", @@ -29,7 +29,7 @@ easily add Apple Push Notification (iPhone) support to your Rails application. "README.textile", "Rakefile", "VERSION", - "apn_on_rails.gemspec", + "presskit-apn_on_rails.gemspec", "autotest/discover.rb", "generators/apn_migrations_generator.rb", "generators/templates/apn_migrations/001_create_apn_devices.rb", @@ -80,7 +80,7 @@ easily add Apple Push Notification (iPhone) support to your Rails application. "spec/rails_root/config/apple_push_notification_development.pem", "spec/spec_helper.rb" ] - s.homepage = %q{http://github.com/PRX/apn_on_rails} + s.homepage = %q{http://github.com/calebhaye/apn_on_rails} s.require_paths = ["lib"] s.rubygems_version = %q{1.3.7} s.summary = %q{Apple Push Notifications on Rails} diff --git a/spec/active_record/setup_ar.rb b/spec/active_record/setup_ar.rb old mode 100644 new mode 100755 diff --git a/spec/apn_on_rails/app/models/apn/app_spec.rb b/spec/apn_on_rails/app/models/apn/app_spec.rb old mode 100644 new mode 100755 diff --git a/spec/apn_on_rails/app/models/apn/device_spec.rb b/spec/apn_on_rails/app/models/apn/device_spec.rb old mode 100644 new mode 100755 diff --git a/spec/apn_on_rails/app/models/apn/group_notification_spec.rb b/spec/apn_on_rails/app/models/apn/group_notification_spec.rb old mode 100644 new mode 100755 diff --git a/spec/apn_on_rails/app/models/apn/notification_spec.rb b/spec/apn_on_rails/app/models/apn/notification_spec.rb old mode 100644 new mode 100755 diff --git a/spec/apn_on_rails/app/models/apn/pull_notification_spec.rb b/spec/apn_on_rails/app/models/apn/pull_notification_spec.rb old mode 100644 new mode 100755 diff --git a/spec/apn_on_rails/libs/connection_spec.rb b/spec/apn_on_rails/libs/connection_spec.rb old mode 100644 new mode 100755 diff --git a/spec/apn_on_rails/libs/feedback_spec.rb b/spec/apn_on_rails/libs/feedback_spec.rb old mode 100644 new mode 100755 diff --git a/spec/extensions/string.rb b/spec/extensions/string.rb old mode 100644 new mode 100755 diff --git a/spec/factories/app_factory.rb b/spec/factories/app_factory.rb old mode 100644 new mode 100755 diff --git a/spec/factories/device_factory.rb b/spec/factories/device_factory.rb old mode 100644 new mode 100755 diff --git a/spec/factories/device_grouping_factory.rb b/spec/factories/device_grouping_factory.rb old mode 100644 new mode 100755 diff --git a/spec/factories/group_factory.rb b/spec/factories/group_factory.rb old mode 100644 new mode 100755 diff --git a/spec/factories/group_notification_factory.rb b/spec/factories/group_notification_factory.rb old mode 100644 new mode 100755 diff --git a/spec/factories/notification_factory.rb b/spec/factories/notification_factory.rb old mode 100644 new mode 100755 diff --git a/spec/factories/pull_notification_factory.rb b/spec/factories/pull_notification_factory.rb old mode 100644 new mode 100755 diff --git a/spec/fixtures/hexa.bin b/spec/fixtures/hexa.bin old mode 100644 new mode 100755 diff --git a/spec/fixtures/message_for_sending.bin b/spec/fixtures/message_for_sending.bin old mode 100644 new mode 100755 diff --git a/spec/rails_root/config/apple_push_notification_development.pem b/spec/rails_root/config/apple_push_notification_development.pem old mode 100644 new mode 100755 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb old mode 100644 new mode 100755