clickatell 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/History.txt +4 -0
- data/Rakefile +95 -0
- data/lib/clickatell/utility/options.rb +5 -6
- data/lib/clickatell/version.rb +1 -1
- data/scripts/txt2html +67 -0
- data/spec/cli_options_test.rb +26 -0
- metadata +36 -27
data/.gitignore
ADDED
data/History.txt
CHANGED
data/Rakefile
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "rake/rdoctask"
|
3
|
+
require File.join(File.dirname(__FILE__), *%w[lib clickatell version])
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'jeweler'
|
7
|
+
|
8
|
+
Jeweler::Tasks.new do |gemspec|
|
9
|
+
gemspec.name = "clickatell"
|
10
|
+
gemspec.summary = "Ruby interface to the Clickatell SMS gateway service."
|
11
|
+
gemspec.email = "luke@lukeredpath.co.uk"
|
12
|
+
gemspec.homepage = "http://clickatell.rubyforge.org"
|
13
|
+
gemspec.authors = ["Luke Redpath"]
|
14
|
+
gemspec.executables = %w{sms}
|
15
|
+
gemspec.extra_rdoc_files = %w{RDOC_README.txt History.txt License.txt}
|
16
|
+
gemspec.has_rdoc = true
|
17
|
+
gemspec.rdoc_options = %w{--main RDOC_README.txt}
|
18
|
+
gemspec.version = Clickatell::VERSION
|
19
|
+
end
|
20
|
+
|
21
|
+
Jeweler::GemcutterTasks.new
|
22
|
+
|
23
|
+
rescue LoadError
|
24
|
+
puts "Jeweler not available. Install it with: gem install jeweler"
|
25
|
+
end
|
26
|
+
|
27
|
+
task :default => :spec
|
28
|
+
|
29
|
+
require "spec"
|
30
|
+
require "spec/rake/spectask"
|
31
|
+
|
32
|
+
Spec::Rake::SpecTask.new do |t|
|
33
|
+
t.spec_opts = %w(--format specdoc --colour)
|
34
|
+
t.libs = ["spec"]
|
35
|
+
end
|
36
|
+
|
37
|
+
Spec::Rake::SpecTask.new("spec_html") do |t|
|
38
|
+
t.spec_opts = %w(--format html)
|
39
|
+
t.libs = ["spec"]
|
40
|
+
end
|
41
|
+
|
42
|
+
# Rake::RDocTask.new do |rd|
|
43
|
+
# rd.main = "RDOC_README.txt"
|
44
|
+
# rd.rdoc_files.include("lib/**/*.rb", *$gemspec.extra_rdoc_files)
|
45
|
+
# rd.rdoc_dir = "rdoc"
|
46
|
+
# end
|
47
|
+
|
48
|
+
desc 'Generate website files'
|
49
|
+
task :website do
|
50
|
+
Dir['website/**/*.txt'].each do |txt|
|
51
|
+
sh %{ ruby scripts/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
|
52
|
+
end
|
53
|
+
sh "rake -s spec_html > website/specs.html"
|
54
|
+
end
|
55
|
+
|
56
|
+
desc 'Clear out RDoc and generated packages'
|
57
|
+
task :clean => [:clobber_rdoc, :clobber_package]
|
58
|
+
|
59
|
+
begin
|
60
|
+
require "rake/contrib/sshpublisher"
|
61
|
+
namespace :rubyforge do
|
62
|
+
|
63
|
+
desc "Release gem and RDoc documentation to RubyForge"
|
64
|
+
task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
|
65
|
+
|
66
|
+
namespace :release do
|
67
|
+
desc "Release a new version of this gem"
|
68
|
+
task :gem => [:package] do
|
69
|
+
require 'rubyforge'
|
70
|
+
rubyforge = RubyForge.new
|
71
|
+
rubyforge.configure
|
72
|
+
rubyforge.login
|
73
|
+
rubyforge.userconfig['release_notes'] = $gemspec.summary
|
74
|
+
path_to_gem = File.join(File.dirname(__FILE__), "pkg", "#{$gemspec.name}-#{$gemspec.version}.gem")
|
75
|
+
puts "Publishing #{$gemspec.name}-#{$gemspec.version.to_s} to Rubyforge..."
|
76
|
+
rubyforge.add_release($gemspec.rubyforge_project, $gemspec.name, $gemspec.version.to_s, path_to_gem)
|
77
|
+
end
|
78
|
+
|
79
|
+
desc "Publish RDoc to RubyForge."
|
80
|
+
task :docs => [:rdoc, :website] do
|
81
|
+
config = YAML.load(
|
82
|
+
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
83
|
+
)
|
84
|
+
|
85
|
+
host = "#{config['username']}@rubyforge.org"
|
86
|
+
remote_dir = "/var/www/gforge-projects/clickatell/"
|
87
|
+
|
88
|
+
Rake::SshDirPublisher.new(host, remote_dir, 'website').upload
|
89
|
+
Rake::SshDirPublisher.new(host, File.join(remote_dir, 'rdoc'), 'rdoc').upload
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
rescue LoadError
|
94
|
+
puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
|
95
|
+
end
|
@@ -6,7 +6,7 @@ module Clickatell
|
|
6
6
|
class Options #:nodoc:
|
7
7
|
class << self
|
8
8
|
|
9
|
-
def parse(args)
|
9
|
+
def parse(args)
|
10
10
|
@options = self.default_options
|
11
11
|
parser = OptionParser.new do |opts|
|
12
12
|
opts.banner = "Usage: sms [options] recipient(s) message"
|
@@ -64,18 +64,17 @@ module Clickatell
|
|
64
64
|
exit
|
65
65
|
end
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
|
+
@options.recipient = args[-2].split(',') rescue nil
|
69
|
+
@options.message = args[-1]
|
70
|
+
|
68
71
|
parser.parse!(args)
|
69
|
-
@options.recipient = ARGV[-2]
|
70
|
-
@options.message = ARGV[-1]
|
71
72
|
|
72
73
|
if (@options.message.nil? || @options.recipient.nil?) && send_message?
|
73
74
|
puts "You must specify a recipient and message!"
|
74
75
|
puts parser
|
75
76
|
exit
|
76
77
|
end
|
77
|
-
|
78
|
-
@options.recipient = @options.recipient.split(",")
|
79
78
|
|
80
79
|
return @options
|
81
80
|
|
data/lib/clickatell/version.rb
CHANGED
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/clickatell/version.rb'
|
8
|
+
|
9
|
+
version = Clickatell::VERSION::STRING
|
10
|
+
download = 'http://rubyforge.org/projects/clickatell'
|
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)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'shoulda'
|
3
|
+
require File.join(File.dirname(__FILE__), *%w[.. lib clickatell utility])
|
4
|
+
|
5
|
+
class CliOptionsTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
context "Sending a message" do
|
8
|
+
should "allow single recipients" do
|
9
|
+
options = Clickatell::Utility::Options.parse(%w{07944123456 testing})
|
10
|
+
assert_equal %w{07944123456}, options.recipient
|
11
|
+
end
|
12
|
+
|
13
|
+
should "allow multiple, comma-separated recipients" do
|
14
|
+
options = Clickatell::Utility::Options.parse(%w{07944123456,07944123457 testing})
|
15
|
+
assert_equal %w{07944123456 07944123457}, options.recipient
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "Checking balance" do
|
20
|
+
should "not require a recipient" do
|
21
|
+
options = Clickatell::Utility::Options.parse(%w{-b})
|
22
|
+
assert_nil options.recipient
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clickatell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Redpath
|
@@ -9,19 +9,10 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-12-01 00:00:00 +00:00
|
13
13
|
default_executable: sms
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
name: rspec
|
17
|
-
type: :development
|
18
|
-
version_requirement:
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: "0"
|
24
|
-
version:
|
14
|
+
dependencies: []
|
15
|
+
|
25
16
|
description:
|
26
17
|
email: luke@lukeredpath.co.uk
|
27
18
|
executables:
|
@@ -29,32 +20,45 @@ executables:
|
|
29
20
|
extensions: []
|
30
21
|
|
31
22
|
extra_rdoc_files:
|
32
|
-
- RDOC_README.txt
|
33
23
|
- History.txt
|
34
24
|
- License.txt
|
25
|
+
- RDOC_README.txt
|
35
26
|
files:
|
27
|
+
- .gitignore
|
36
28
|
- History.txt
|
37
29
|
- License.txt
|
38
30
|
- RDOC_README.txt
|
39
31
|
- README.textile
|
32
|
+
- Rakefile
|
40
33
|
- bin/sms
|
41
|
-
-
|
42
|
-
-
|
43
|
-
- spec/hash_ext_spec.rb
|
44
|
-
- spec/response_spec.rb
|
45
|
-
- spec/spec.opts
|
46
|
-
- spec/spec_helper.rb
|
34
|
+
- lib/clickatell.rb
|
35
|
+
- lib/clickatell/api.rb
|
47
36
|
- lib/clickatell/api/command.rb
|
48
37
|
- lib/clickatell/api/command_executor.rb
|
49
38
|
- lib/clickatell/api/error.rb
|
50
39
|
- lib/clickatell/api/message_status.rb
|
51
|
-
- lib/clickatell/api.rb
|
52
40
|
- lib/clickatell/response.rb
|
53
|
-
- lib/clickatell/utility/options.rb
|
54
41
|
- lib/clickatell/utility.rb
|
42
|
+
- lib/clickatell/utility/options.rb
|
55
43
|
- lib/clickatell/version.rb
|
56
|
-
- lib/clickatell.rb
|
57
44
|
- lib/core-ext/hash.rb
|
45
|
+
- scripts/txt2html
|
46
|
+
- spec/api_spec.rb
|
47
|
+
- spec/cli_options_test.rb
|
48
|
+
- spec/command_executor_spec.rb
|
49
|
+
- spec/hash_ext_spec.rb
|
50
|
+
- spec/response_spec.rb
|
51
|
+
- spec/spec.opts
|
52
|
+
- spec/spec_helper.rb
|
53
|
+
- website/images/footer_bg.gif
|
54
|
+
- website/index.txt
|
55
|
+
- website/javascripts/codehighlighter/code_highlighter.js
|
56
|
+
- website/javascripts/codehighlighter/ruby.js
|
57
|
+
- website/javascripts/rounded_corners_lite.inc.js
|
58
|
+
- website/stylesheets/limechoc.css
|
59
|
+
- website/stylesheets/rdoc.css
|
60
|
+
- website/stylesheets/screen.css
|
61
|
+
- website/template.rhtml
|
58
62
|
has_rdoc: true
|
59
63
|
homepage: http://clickatell.rubyforge.org
|
60
64
|
licenses: []
|
@@ -79,10 +83,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
83
|
version:
|
80
84
|
requirements: []
|
81
85
|
|
82
|
-
rubyforge_project:
|
86
|
+
rubyforge_project:
|
83
87
|
rubygems_version: 1.3.5
|
84
88
|
signing_key:
|
85
|
-
specification_version:
|
89
|
+
specification_version: 3
|
86
90
|
summary: Ruby interface to the Clickatell SMS gateway service.
|
87
|
-
test_files:
|
88
|
-
|
91
|
+
test_files:
|
92
|
+
- spec/api_spec.rb
|
93
|
+
- spec/cli_options_test.rb
|
94
|
+
- spec/command_executor_spec.rb
|
95
|
+
- spec/hash_ext_spec.rb
|
96
|
+
- spec/response_spec.rb
|
97
|
+
- spec/spec_helper.rb
|