Skip to content
Browse files

revamped project structure courtesy of newgem

  • Loading branch information...
1 parent 1f9d180 commit 619f1b86c2c576a0fc2f52a485c7e47644ccaa1b @bpoweski committed
View
4 History.txt
@@ -0,0 +1,4 @@
+=== 0.0.1 2009-09-10
+
+* 1 major enhancement:
+ * Initial release
View
23 Manifest.txt
@@ -0,0 +1,23 @@
+History.txt
+Manifest.txt
+PostInstall.txt
+README
+README.rdoc
+Rakefile
+bin/apns
+bin/apnserverd
+lib/apnserver.rb
+lib/apnserver/client.rb
+lib/apnserver/notification.rb
+lib/apnserver/payload.rb
+lib/apnserver/server.rb
+script/console
+script/console.cmd
+script/destroy
+script/destroy.cmd
+script/generate
+script/generate.cmd
+test/notification_test.rb
+test/payload_test.rb
+test/test_apnserver.rb
+test/test_helper.rb
View
7 PostInstall.txt
@@ -0,0 +1,7 @@
+
+For more information on apnserver, see http://apnserver.rubyforge.org
+
+NOTE: Change this information in PostInstall.txt
+You can also delete it if you don't want it.
+
+
View
48 README.rdoc
@@ -0,0 +1,48 @@
+= apnserver
+
+* http://github.com/#{github_username}/#{project_name}
+
+== DESCRIPTION:
+
+FIX (describe your package)
+
+== FEATURES/PROBLEMS:
+
+* FIX (list of features or problems)
+
+== SYNOPSIS:
+
+ FIX (code sample of usage)
+
+== REQUIREMENTS:
+
+* FIX (list of requirements)
+
+== INSTALL:
+
+* FIX (sudo gem install, anything else)
+
+== LICENSE:
+
+(The MIT License)
+
+Copyright (c) 2009 FIXME full name
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
29 Rakefile
@@ -1,9 +1,26 @@
-require 'rake/testtask'
+require 'rubygems'
+gem 'hoe', '>= 2.1.0'
+require 'hoe'
+require 'fileutils'
+require './lib/apnserver'
+
+Hoe.plugin :newgem
+# Hoe.plugin :website
+# Hoe.plugin :cucumberfeatures
+
+# Generate all the Rake tasks
+# Run 'rake -T' to see list of generated tasks (from gem root directory)
+$hoe = Hoe.spec 'apnserver' do
+ self.developer 'FIXME full name', 'FIXME email'
+ self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
+ self.rubyforge_name = self.name # TODO this is default value
+ # self.extra_deps = [['activesupport','>= 2.0.2']]
-Rake::TestTask.new do |t|
- t.libs << "test"
- t.test_files = FileList['test/*_test.rb']
- t.verbose = true
end
-task :default => [:test]
+require 'newgem/tasks'
+Dir['tasks/**/*.rake'].each { |t| load t }
+
+# TODO - want other tests/tasks run by default? Add them to the list
+# remove_task :default
+# task :default => [:spec, :features]
View
10 lib/apnserver.rb
@@ -1 +1,9 @@
-require 'apnserver/notification'
+$:.unshift(File.dirname(__FILE__)) unless
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
+
+
+module Apnserver
+ VERSION = '0.0.1'
+end
+
+require 'apnserver/notification'
View
37 lib/apnserver/client.rb
@@ -0,0 +1,37 @@
+class ApnsClient
+
+ attr_accessor :certificate, :key, :host, :port
+
+ def initialize(certificate, key, host = 'gateway.push.apple.com', port = 2195)
+ @certificate, @key, @host, @port = certificate, path, host, port
+ end
+
+ def connect!
+ raise "The path to your pem file is not set." unless self.pem
+ raise "The path to your pem file does not exist!" unless File.exist?(self.pem)
+
+ @context = OpenSSL::SSL::SSLContext.new
+ @context.cert = OpenSSL::X509::Certificate.new(File.read(self.pem))
+ @context.key = OpenSSL::PKey::RSA.new(File.read(self.pem), self.pass)
+
+ @sock = TCPSocket.new(self.host, self.port)
+ @ssl = OpenSSL::SSL::SSLSocket.new(@sock, @context)
+ @ssl.connect
+
+ return @sock, @ssl
+ end
+
+ def disconnect!
+ @ssl.close
+ @sock.close
+ end
+
+ def write(bytes)
+ @ssl.write(bytes)
+ end
+
+ def connected?
+ @ssl
+ end
+
+end
View
39 lib/apnserver/server.rb
@@ -27,45 +27,6 @@ def receive_data(data)
end
end
-class ApnsClient
-
- attr_accessor :certificate, :key, :host, :port
-
-
- def intialize(certificate, key, host = 'gateway.push.apple.com', port = 2195)
- @certificate, @key, @host, @port = certificate, path, host, port
- end
-
- def connect!
- raise "The path to your pem file is not set." unless self.pem
- raise "The path to your pem file does not exist!" unless File.exist?(self.pem)
-
- @context = OpenSSL::SSL::SSLContext.new
- @context.cert = OpenSSL::X509::Certificate.new(File.read(self.pem))
- @context.key = OpenSSL::PKey::RSA.new(File.read(self.pem), self.pass)
-
- @sock = TCPSocket.new(self.host, self.port)
- @ssl = OpenSSL::SSL::SSLSocket.new(@sock, @context)
- @ssl.connect
-
- return @sock, @ssl
- end
-
- def disconnect!
- @ssl.close
- @sock.close
- end
-
- def write(bytes)
- @ssl.write(bytes)
- end
-
- def connected?
- @ssl
- end
-
-end
-
EventMachine::run do
puts "Starting APN Server: #{Time.now}"
View
10 script/console
@@ -0,0 +1,10 @@
+#!/usr/bin/env ruby
+# File: script/console
+irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
+
+libs = " -r irb/completion"
+# Perhaps use a console_lib to store any extra methods I may want available in the cosole
+# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
+libs << " -r #{File.dirname(__FILE__) + '/../lib/apnserver.rb'}"
+puts "Loading apnserver gem"
+exec "#{irb} #{libs} --simple-prompt"
View
1 script/console.cmd
@@ -0,0 +1 @@
+@ruby script/console %*
View
14 script/destroy
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
+
+begin
+ require 'rubigen'
+rescue LoadError
+ require 'rubygems'
+ require 'rubigen'
+end
+require 'rubigen/scripts/destroy'
+
+ARGV.shift if ['--help', '-h'].include?(ARGV[0])
+RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
+RubiGen::Scripts::Destroy.new.run(ARGV)
View
1 script/destroy.cmd
@@ -0,0 +1 @@
+@ruby script/destroy %*
View
14 script/generate
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
+
+begin
+ require 'rubigen'
+rescue LoadError
+ require 'rubygems'
+ require 'rubigen'
+end
+require 'rubigen/scripts/generate'
+
+ARGV.shift if ['--help', '-h'].include?(ARGV[0])
+RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
+RubiGen::Scripts::Generate.new.run(ARGV)
View
1 script/generate.cmd
@@ -0,0 +1 @@
+@ruby script/generate %*
View
11 test/test_apnserver.rb
@@ -0,0 +1,11 @@
+require File.dirname(__FILE__) + '/test_helper.rb'
+
+class TestApnserver < Test::Unit::TestCase
+
+ def setup
+ end
+
+ def test_truth
+ assert true
+ end
+end
View
5 test/test_helper.rb
@@ -1,2 +1,3 @@
-require 'rubygems'
-require 'test/unit'
+require 'stringio'
+require 'test/unit'
+require File.dirname(__FILE__) + '/../lib/apnserver'
View
3 test/notification_test.rb → test/test_notification.rb
@@ -1,5 +1,4 @@
-require 'test_helper'
-require 'apnserver/notification'
+require File.dirname(__FILE__) + '/test_helper.rb'
class NotificationTest < Test::Unit::TestCase
include ApnServer
View
3 test/payload_test.rb → test/test_payload.rb
@@ -1,5 +1,4 @@
-require 'apnserver/payload'
-require 'test_helper'
+require File.dirname(__FILE__) + '/test_helper.rb'
class NotificationTest < Test::Unit::TestCase
include ApnServer::Payload

0 comments on commit 619f1b8

Please sign in to comment.
Something went wrong with that request. Please try again.