tropo_message 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,21 +1,3 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in tropo_message.gemspec
4
+ gemspec
data/Rakefile CHANGED
@@ -1,53 +1,2 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "tropo_message"
8
- gem.summary = "A tiny wrapper for creating a Tropo message"
9
- gem.description = "A tiny wrapper for creating a Tropo message"
10
- gem.email = "dwilkie@gmail.com"
11
- gem.homepage = "http://github.com/dwilkie/tropo_message"
12
- gem.authors = ["David Wilkie"]
13
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
- end
15
- Jeweler::GemcutterTasks.new
16
- rescue LoadError
17
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
18
- end
19
-
20
- require 'rake/testtask'
21
- Rake::TestTask.new(:test) do |test|
22
- test.libs << 'lib' << 'test'
23
- test.pattern = 'test/**/test_*.rb'
24
- test.verbose = true
25
- end
26
-
27
- begin
28
- require 'rcov/rcovtask'
29
- Rcov::RcovTask.new do |test|
30
- test.libs << 'test'
31
- test.pattern = 'test/**/test_*.rb'
32
- test.verbose = true
33
- end
34
- rescue LoadError
35
- task :rcov do
36
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
- end
38
- end
39
-
40
- task :test => :check_dependencies
41
-
42
- task :default => :test
43
-
44
- require 'rake/rdoctask'
45
- Rake::RDocTask.new do |rdoc|
46
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
-
48
- rdoc.rdoc_dir = 'rdoc'
49
- rdoc.title = "tropo_message #{version}"
50
- rdoc.rdoc_files.include('README*')
51
- rdoc.rdoc_files.include('lib/**/*.rb')
52
- end
53
-
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/lib/tropo_message.rb CHANGED
@@ -47,7 +47,7 @@ module Tropo
47
47
  # # <token>1234512345</token>
48
48
  # # <var name="to" value="44122782474"/>
49
49
  # # <var name="text" value="Hi+John%2C+how+r+u+today%3F"/>
50
- # # </sessions>"
50
+ # # </sessions>"
51
51
  #
52
52
  def request_xml
53
53
  request_params = @params.dup
@@ -109,19 +109,19 @@ module Tropo
109
109
 
110
110
  # Getter/Setter methods
111
111
  def action
112
- params["action"] || tropo_parameters["action"]
112
+ params["action"] || unescape(tropo_parameters["action"])
113
113
  end
114
114
 
115
115
  def answer_on_media
116
- params["answer_on_media"] || tropo_parameters["answer_on_media"]
116
+ params["answer_on_media"] || unescape(tropo_parameters["answer_on_media"])
117
117
  end
118
118
 
119
119
  def channel
120
- params["channel"] || tropo_parameters["channel"] || "TEXT"
120
+ params["channel"] || unescape(tropo_parameters["channel"]) || "TEXT"
121
121
  end
122
122
 
123
123
  def from
124
- params["from"] || tropo_parameters["from"]
124
+ params["from"] || unescape(tropo_parameters["from"])
125
125
  end
126
126
 
127
127
  def from=(value)
@@ -129,19 +129,19 @@ module Tropo
129
129
  end
130
130
 
131
131
  def headers
132
- params["headers"] || tropo_parameters["headers"]
132
+ params["headers"] || unescape(tropo_parameters["headers"])
133
133
  end
134
134
 
135
135
  def network
136
- params["network"] || tropo_parameters["network"] || "SMS"
136
+ params["network"] || unescape(tropo_parameters["network"]) || "SMS"
137
137
  end
138
138
 
139
139
  def recording
140
- params["recording"] || tropo_parameters["recording"]
140
+ params["recording"] || unescape(tropo_parameters["recording"])
141
141
  end
142
142
 
143
143
  def text
144
- params["text"] || tropo_parameters["text"]
144
+ params["text"] || unescape(tropo_parameters["text"])
145
145
  end
146
146
 
147
147
  def text=(value)
@@ -149,11 +149,11 @@ module Tropo
149
149
  end
150
150
 
151
151
  def timeout
152
- params["timeout"] || tropo_parameters["timeout"]
152
+ params["timeout"] || unescape(tropo_parameters["timeout"])
153
153
  end
154
154
 
155
155
  def to
156
- params["to"] || tropo_parameters["to"]
156
+ params["to"] || unescape(tropo_parameters["to"])
157
157
  end
158
158
 
159
159
  def to=(value)
@@ -184,6 +184,13 @@ module Tropo
184
184
  }.tr(' ', '+')
185
185
  end
186
186
 
187
+ # Unescapes a URI escaped string. (Stolen from Camping).
188
+ def unescape(s)
189
+ s.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n){
190
+ [$1.delete('%')].pack('H*')
191
+ } if s
192
+ end
193
+
187
194
  # Return the bytesize of String; uses String#length under Ruby 1.8 and
188
195
  # String#bytesize under 1.9.
189
196
  if ''.respond_to?(:bytesize)
@@ -0,0 +1,4 @@
1
+ module TropoMessage
2
+ VERSION = "0.1.0"
3
+ end
4
+
@@ -13,16 +13,16 @@ describe Tropo::Message do
13
13
  "call_id"=>nil,
14
14
  "parameters"=>{
15
15
  "token" => "123451234512345123451234512345123451234512345",
16
- "text"=>"Hi%2C+how+r+u+today+%3A+my+friend+%3Cyour+name",
17
- "to"=>"612382211234",
18
- "from" => "661213433198",
19
- "channel" => "SomeChannel",
20
- "network" => "SomeNetwork",
21
- "action" => "SomeAction",
22
- "timeout" => "SomeTimeout",
23
- "answer_on_media" => "Phone",
24
- "headers" => "MyCustomHeaders",
25
- "recording" => "MyRecording"
16
+ "text"=>"Hi%2C+how+r+u+today+%3A+my+friend+%3Cyour+name%3E",
17
+ "to"=>"%2B612382211234",
18
+ "from" => "%2B661213433198",
19
+ "channel" => "Some%2BChannel",
20
+ "network" => "Some%2BNetwork",
21
+ "action" => "Some%2BAction",
22
+ "timeout" => "Some%2BTimeout",
23
+ "answer_on_media" => "The%2BPhone",
24
+ "headers" => "My%2BCustom%2BHeaders",
25
+ "recording" => "My%2BRecording"
26
26
  }
27
27
  }
28
28
  }
@@ -84,14 +84,14 @@ describe Tropo::Message do
84
84
  it "should include all the required and optional parameters" do
85
85
  tropo_message.parse(tropo_session)
86
86
  tropo_message.response_params.should == {
87
- "to" => "612382211234",
88
- "channel" => "SomeChannel",
89
- "network" => "SomeNetwork",
90
- "from" => "661213433198",
91
- "timeout" => "SomeTimeout",
92
- "answer_on_media" => "Phone",
93
- "headers" => "MyCustomHeaders",
94
- "recording" => "MyRecording"
87
+ "to" => "+612382211234",
88
+ "channel" => "Some+Channel",
89
+ "network" => "Some+Network",
90
+ "from" => "+661213433198",
91
+ "timeout" => "Some+Timeout",
92
+ "answer_on_media" => "The+Phone",
93
+ "headers" => "My+Custom+Headers",
94
+ "recording" => "My+Recording"
95
95
  }
96
96
  end
97
97
  end
@@ -103,7 +103,7 @@ describe Tropo::Message do
103
103
  it "should include all the required parameters" do
104
104
  tropo_message.parse(tropo_session)
105
105
  tropo_message.response_params.should == {
106
- "to" => "612382211234",
106
+ "to" => "+612382211234",
107
107
  "channel" => "TEXT",
108
108
  "network" => "SMS",
109
109
  }
@@ -136,9 +136,9 @@ describe Tropo::Message do
136
136
  end
137
137
  end
138
138
  context "responding to tropo" do
139
- it "should return the receiver from the session parameters" do
139
+ it "should return the receiver (unescapted) from the session parameters" do
140
140
  tropo_message.parse(tropo_session)
141
- tropo_message.to.should == "612382211234"
141
+ tropo_message.to.should == "+612382211234"
142
142
  end
143
143
  end
144
144
  end
@@ -153,7 +153,7 @@ describe Tropo::Message do
153
153
  context "responding to tropo" do
154
154
  it "should return the sender from the session parameters" do
155
155
  tropo_message.parse(tropo_session)
156
- tropo_message.from.should == "661213433198"
156
+ tropo_message.from.should == "+661213433198"
157
157
  end
158
158
  end
159
159
  end
@@ -168,7 +168,7 @@ describe Tropo::Message do
168
168
  context "responding to tropo" do
169
169
  it "should return the text from the session parameters" do
170
170
  tropo_message.parse(tropo_session)
171
- tropo_message.text.should == "Hi%2C+how+r+u+today+%3A+my+friend+%3Cyour+name"
171
+ tropo_message.text.should == "Hi, how r u today : my friend <your name>"
172
172
  end
173
173
  end
174
174
  end
@@ -186,7 +186,7 @@ describe Tropo::Message do
186
186
  context "'channel' is in the session parameters" do
187
187
  it "should return the channel from the session parameters" do
188
188
  tropo_message.parse(tropo_session)
189
- tropo_message.channel.should == "SomeChannel"
189
+ tropo_message.channel.should == "Some+Channel"
190
190
  end
191
191
  end
192
192
  context "'channel' is not in the session parameters" do
@@ -212,7 +212,7 @@ describe Tropo::Message do
212
212
  context "'network' is in the session parameters" do
213
213
  it "should return the network from the session parameters" do
214
214
  tropo_message.parse(tropo_session)
215
- tropo_message.network.should == "SomeNetwork"
215
+ tropo_message.network.should == "Some+Network"
216
216
  end
217
217
  end
218
218
  context "'network' is not in the session parameters" do
@@ -239,7 +239,7 @@ describe Tropo::Message do
239
239
  context "'action' is in the session parameters" do
240
240
  it "should return the action from the session parameters" do
241
241
  tropo_message.parse(tropo_session)
242
- tropo_message.action.should == "SomeAction"
242
+ tropo_message.action.should == "Some+Action"
243
243
  end
244
244
  end
245
245
  context "'action' is not in the session parameters" do
@@ -265,7 +265,7 @@ describe Tropo::Message do
265
265
  context "'timeout' is in the session parameters" do
266
266
  it "should return the timeout from the session parameters" do
267
267
  tropo_message.parse(tropo_session)
268
- tropo_message.timeout.should == "SomeTimeout"
268
+ tropo_message.timeout.should == "Some+Timeout"
269
269
  end
270
270
  end
271
271
  context "'timeout' is not in the session parameters" do
@@ -291,7 +291,7 @@ describe Tropo::Message do
291
291
  context "'answer_on_media' is in the session parameters" do
292
292
  it "should return 'answer_on_media' from the session parameters" do
293
293
  tropo_message.parse(tropo_session)
294
- tropo_message.answer_on_media.should == "Phone"
294
+ tropo_message.answer_on_media.should == "The+Phone"
295
295
  end
296
296
  end
297
297
  context "'answer_on_media' is not in the session parameters" do
@@ -317,7 +317,7 @@ describe Tropo::Message do
317
317
  context "'headers' is in the session parameters" do
318
318
  it "should return the headers from the session parameters" do
319
319
  tropo_message.parse(tropo_session)
320
- tropo_message.headers.should == "MyCustomHeaders"
320
+ tropo_message.headers.should == "My+Custom+Headers"
321
321
  end
322
322
  end
323
323
  context "'headers' is not in the session parameters" do
@@ -343,7 +343,7 @@ describe Tropo::Message do
343
343
  context "'recording' is in the session parameters" do
344
344
  it "should return the recording from the session parameters" do
345
345
  tropo_message.parse(tropo_session)
346
- tropo_message.recording.should == "MyRecording"
346
+ tropo_message.recording.should == "My+Recording"
347
347
  end
348
348
  end
349
349
  context "'recording' is not in the session parameters" do
@@ -1,51 +1,22 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "tropo_message/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{tropo_message}
8
- s.version = "0.0.5"
6
+ s.name = "tropo_message"
7
+ s.version = TropoMessage::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["David Wilkie"]
10
+ s.email = ["dwilkie@gmail.com"]
11
+ s.homepage = "https://github.com/dwilkie/tropo_message"
12
+ s.summary = %q{Simplifies sending messages with Tropo}
13
+ s.description = %q{Makes it easier to send a message using Tropo}
9
14
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["David Wilkie"]
12
- s.date = %q{2010-10-15}
13
- s.description = %q{A tiny wrapper for creating a Tropo message}
14
- s.email = %q{dwilkie@gmail.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.markdown"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".gitignore",
22
- "LICENSE",
23
- "README.markdown",
24
- "Rakefile",
25
- "VERSION",
26
- "lib/tropo_message.rb",
27
- "spec/spec_helper.rb",
28
- "spec/tropo_messsage_spec.rb",
29
- "tropo_message.gemspec"
30
- ]
31
- s.homepage = %q{http://github.com/dwilkie/tropo_message}
32
- s.rdoc_options = ["--charset=UTF-8"]
33
- s.require_paths = ["lib"]
34
- s.rubygems_version = %q{1.3.7}
35
- s.summary = %q{A tiny wrapper for creating a Tropo message}
36
- s.test_files = [
37
- "spec/tropo_messsage_spec.rb",
38
- "spec/spec_helper.rb"
39
- ]
40
-
41
- if s.respond_to? :specification_version then
42
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
43
- s.specification_version = 3
15
+ s.rubyforge_project = "tropo_message"
44
16
 
45
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
- else
47
- end
48
- else
49
- end
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
50
21
  end
51
22
 
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
+ - 1
7
8
  - 0
8
- - 5
9
- version: 0.0.5
9
+ version: 0.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - David Wilkie
@@ -14,37 +14,38 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-15 00:00:00 +07:00
17
+ date: 2010-11-15 00:00:00 +07:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
21
- description: A tiny wrapper for creating a Tropo message
22
- email: dwilkie@gmail.com
21
+ description: Makes it easier to send a message using Tropo
22
+ email:
23
+ - dwilkie@gmail.com
23
24
  executables: []
24
25
 
25
26
  extensions: []
26
27
 
27
- extra_rdoc_files:
28
- - LICENSE
29
- - README.markdown
28
+ extra_rdoc_files: []
29
+
30
30
  files:
31
31
  - .document
32
32
  - .gitignore
33
+ - Gemfile
33
34
  - LICENSE
34
35
  - README.markdown
35
36
  - Rakefile
36
- - VERSION
37
37
  - lib/tropo_message.rb
38
+ - lib/tropo_message/version.rb
38
39
  - spec/spec_helper.rb
39
40
  - spec/tropo_messsage_spec.rb
40
41
  - tropo_message.gemspec
41
42
  has_rdoc: true
42
- homepage: http://github.com/dwilkie/tropo_message
43
+ homepage: https://github.com/dwilkie/tropo_message
43
44
  licenses: []
44
45
 
45
46
  post_install_message:
46
- rdoc_options:
47
- - --charset=UTF-8
47
+ rdoc_options: []
48
+
48
49
  require_paths:
49
50
  - lib
50
51
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -65,11 +66,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
66
  version: "0"
66
67
  requirements: []
67
68
 
68
- rubyforge_project:
69
+ rubyforge_project: tropo_message
69
70
  rubygems_version: 1.3.7
70
71
  signing_key:
71
72
  specification_version: 3
72
- summary: A tiny wrapper for creating a Tropo message
73
- test_files:
74
- - spec/tropo_messsage_spec.rb
75
- - spec/spec_helper.rb
73
+ summary: Simplifies sending messages with Tropo
74
+ test_files: []
75
+
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.5