activesms 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 0.0.2 2007-07-26
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/License.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2007 Robert Cottrell
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,16 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ lib/activesms.rb
7
+ lib/activesms/version.rb
8
+ scripts/txt2html
9
+ setup.rb
10
+ test/test_activesms.rb
11
+ test/test_helper.rb
12
+ website/index.html
13
+ website/index.txt
14
+ website/javascripts/rounded_corners_lite.inc.js
15
+ website/stylesheets/screen.css
16
+ website/template.rhtml
data/README.txt ADDED
@@ -0,0 +1,52 @@
1
+ = Active SMS -- A framework for sending and receiving SMS messages.
2
+
3
+ Active SMS is a collection of classes and templates for easily sending and
4
+ receiving SMS messages from within a Ruby on Rails application. It is
5
+ modeled on the standard Action Mailer package for sending emails to provide
6
+ a familiar framework with which to send messages.
7
+
8
+ == Supported Gateways
9
+
10
+ Active SMS will require a valid account from a third party SMS gateway to
11
+ send or receive SMS messages. The following gateways are currently supported:
12
+
13
+ * BulkSMS[http://www.bulksms.com]
14
+ * Clickatell[http://www.clickatell.com]
15
+ * Simplewire[http://www.simplewire.com] (requires jruby)
16
+
17
+ Not all features are supported by all gateways.
18
+
19
+ == License
20
+
21
+ Active SMS is released under the MIT license.
22
+
23
+ == Download
24
+
25
+ The latest version of Active SMS can be found at
26
+
27
+ * http://rubyforge.org/frs/?group_id=2923
28
+
29
+ == Installation
30
+
31
+ The preferred method of installing Active SMS is through its GEM file.
32
+ You will need to have RubyGems[http://rubygems.rubyforge.org/wiki/wiki.pl]
33
+ installed for that, though.
34
+
35
+ % [sudo] gem install activesms
36
+
37
+ == Simplewire Configuration
38
+
39
+ * Make sure you are using jruby
40
+ * Make sure swsms.jar is in your classpath (Download at: http://www.simplewire.com/developers/sdk/java/)
41
+ * Add the following configuration code to the rails environment.
42
+
43
+ ActiveSms::Base.establish_connection(
44
+ :adapter => "simplewire",
45
+ :subscriber_id => "id",
46
+ :subscriber_password => "password"
47
+ )
48
+
49
+ == Support
50
+
51
+ The Active SMS homepage is http://activesms.rubyforge.org. You can find the
52
+ Active SMS RubyForge page at http://rubyforge.org/projects/activesms.
data/Rakefile ADDED
@@ -0,0 +1,133 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/clean'
4
+ require 'rake/testtask'
5
+ require 'rake/packagetask'
6
+ require 'rake/gempackagetask'
7
+ require 'rake/rdoctask'
8
+ require 'rake/contrib/rubyforgepublisher'
9
+ require 'fileutils'
10
+
11
+ # Need to add this hack for hoe to work with jruby
12
+ if RUBY_PLATFORM =~ /java/
13
+ OLD_RUBY_PLATFORM = RUBY_PLATFORM
14
+ RUBY_PLATFORM = "win32"
15
+ require 'hoe'
16
+ Hoe::DIFF = "diff"
17
+ RUBY_PLATFORM = OLD_RUBY_PLATFORM
18
+ else
19
+ require 'hoe'
20
+ end
21
+
22
+ include FileUtils
23
+ require File.join(File.dirname(__FILE__), 'lib', 'activesms', 'version')
24
+
25
+ AUTHOR = ['Robert Cottrell', 'Ben Curren', 'Dean Mao'] # can also be an array of Authors
26
+ EMAIL = ['rgcottrell@rubyforge.org', 'ben@esomnie.com', 'dean@esomnie.com']
27
+ DESCRIPTION = "Active SMS is a framework for sending and receiving SMS messages"
28
+ GEM_NAME = 'activesms' # what ppl will type to install your gem
29
+
30
+ @config_file = "~/.rubyforge/user-config.yml"
31
+ @config = nil
32
+ def rubyforge_username
33
+ unless @config
34
+ begin
35
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
36
+ rescue
37
+ puts <<-EOS
38
+ ERROR: No rubyforge config file found: #{@config_file}"
39
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
40
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
41
+ EOS
42
+ exit
43
+ end
44
+ end
45
+ @rubyforge_username ||= @config["username"]
46
+ end
47
+
48
+ RUBYFORGE_PROJECT = 'activesms' # The unix name for your project
49
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
50
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
51
+
52
+ NAME = "activesms"
53
+ REV = nil
54
+ # UNCOMMENT IF REQUIRED:
55
+ # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
56
+ VERS = ActiveSms::VERSION::STRING + (REV ? ".#{REV}" : "")
57
+ CLEAN.include ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store']
58
+ RDOC_OPTS = ['--quiet', '--title', 'activesms documentation',
59
+ "--opname", "index.html",
60
+ "--line-numbers",
61
+ "--main", "README",
62
+ "--inline-source"]
63
+
64
+ class Hoe
65
+ def extra_deps
66
+ @extra_deps.reject { |x| Array(x).first == 'hoe' }
67
+ end
68
+ end
69
+
70
+ # Generate all the Rake tasks
71
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
72
+ hoe = Hoe.new(GEM_NAME, VERS) do |p|
73
+ p.author = AUTHOR
74
+ p.description = DESCRIPTION
75
+ p.email = EMAIL
76
+ p.summary = DESCRIPTION
77
+ p.url = HOMEPATH
78
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
79
+ p.test_globs = ["test/**/test_*.rb"]
80
+ p.clean_globs |= CLEAN #An array of file patterns to delete on clean.
81
+
82
+ # == Optional
83
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
84
+ p.extra_deps = [['activesupport', '>=1.3.1'], ['actionpack', '>=1.12.5']] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
85
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
86
+ end
87
+
88
+ CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\n\n")
89
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
90
+ hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
91
+
92
+ desc 'Generate website files'
93
+ task :website_generate do
94
+ Dir['website/**/*.txt'].each do |txt|
95
+ sh %{ ruby scripts/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
96
+ end
97
+ end
98
+
99
+ desc 'Upload website files to rubyforge'
100
+ task :website_upload do
101
+ host = "#{rubyforge_username}@rubyforge.org"
102
+ remote_dir = "/var/www/gforge-projects/#{PATH}/"
103
+ local_dir = 'website'
104
+ sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
105
+ end
106
+
107
+ desc 'Generate and upload website files'
108
+ task :website => [:website_generate, :website_upload, :publish_docs]
109
+
110
+ desc 'Release the website and new gem version'
111
+ task :deploy => [:check_version, :website, :release] do
112
+ puts "Remember to create SVN tag:"
113
+ puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
114
+ "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
115
+ puts "Suggested comment:"
116
+ puts "Tagging release #{CHANGES}"
117
+ end
118
+
119
+ desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
120
+ task :local_deploy => [:website_generate, :install_gem]
121
+
122
+ task :check_version do
123
+ unless ENV['VERSION']
124
+ puts 'Must pass a VERSION=x.y.z release version'
125
+ exit
126
+ end
127
+ unless ENV['VERSION'] == VERS
128
+ puts "Please update your version.rb to match the release version, currently #{VERS}"
129
+ exit
130
+ end
131
+ end
132
+
133
+
@@ -0,0 +1,9 @@
1
+ module ActiveSms #:nodoc:
2
+ module VERSION #:nodoc:
3
+ MAJOR = 0
4
+ MINOR = 0
5
+ TINY = 2
6
+
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
8
+ end
9
+ end
data/lib/activesms.rb ADDED
@@ -0,0 +1,60 @@
1
+ #
2
+ # Copyright (c) 2007 Robert Cottrell
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ $:.unshift(File.dirname(__FILE__))
25
+
26
+ # Require ActiveSupport for standard Rails extensions.
27
+ unless defined?(ActiveSupport)
28
+ begin
29
+ require 'active_support'
30
+ rescue LoadError
31
+ require 'rubygems'
32
+ require_gem 'activesupport'
33
+ end
34
+ end
35
+
36
+ # Require ActionController for access to UrlWriter in ActiveSms::Base senders.
37
+ unless defined?(ActionController)
38
+ begin
39
+ require 'action_controller'
40
+ rescue LoadError
41
+ require 'rubygems'
42
+ require_gem 'actionpack', '>= 1.12.5'
43
+ end
44
+ end
45
+
46
+ # Require base classes.
47
+ require 'activesms/version'
48
+ require 'activesms/base'
49
+ require 'activesms/connections'
50
+ require 'activesms/exceptions'
51
+ require 'activesms/version'
52
+
53
+ # Require the supported gateways connection adapters.
54
+ require 'activesms/connection_adapters/abstract_adapter'
55
+ require 'activesms/connection_adapters/bulk_sms_adapter'
56
+ require 'activesms/connection_adapters/clickatell_adapter'
57
+ # Simplewire requires jruby
58
+ if RUBY_PLATFORM =~ /java/
59
+ require 'activesms/connection_adapters/simplewire_adapter'
60
+ end
data/scripts/txt2html ADDED
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'redcloth'
5
+ require 'syntax/convertors/html'
6
+ require 'erb'
7
+ require File.dirname(__FILE__) + '/../lib/activesms/version.rb'
8
+
9
+ version = ActiveSms::VERSION::STRING
10
+ download = 'http://rubyforge.org/projects/activesms'
11
+
12
+ class Fixnum
13
+ def ordinal
14
+ # teens
15
+ return 'th' if (10..19).include?(self % 100)
16
+ # others
17
+ case self % 10
18
+ when 1: return 'st'
19
+ when 2: return 'nd'
20
+ when 3: return 'rd'
21
+ else return 'th'
22
+ end
23
+ end
24
+ end
25
+
26
+ class Time
27
+ def pretty
28
+ return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
29
+ end
30
+ end
31
+
32
+ def convert_syntax(syntax, source)
33
+ return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
34
+ end
35
+
36
+ if ARGV.length >= 1
37
+ src, template = ARGV
38
+ template ||= File.dirname(__FILE__) + '/../website/template.rhtml'
39
+
40
+ else
41
+ puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
42
+ exit!
43
+ end
44
+
45
+ template = ERB.new(File.open(template).read)
46
+
47
+ title = nil
48
+ body = nil
49
+ File.open(src) do |fsrc|
50
+ title_text = fsrc.readline
51
+ body_text = fsrc.read
52
+ syntax_items = []
53
+ body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</>!m){
54
+ ident = syntax_items.length
55
+ element, syntax, source = $1, $2, $3
56
+ syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
57
+ "syntax-temp-#{ident}"
58
+ }
59
+ title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
60
+ body = RedCloth.new(body_text).to_html
61
+ body.gsub!(%r!(?:<pre><code>)?syntax-temp-(d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
62
+ end
63
+ stat = File.stat(src)
64
+ created = stat.ctime
65
+ modified = stat.mtime
66
+
67
+ $stdout << template.result(binding)