merlin_gateway 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
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
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Manual design
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.
@@ -0,0 +1,20 @@
1
+ = MerlinGateway
2
+
3
+ ..is a client for the Aspiro Merlin SMS gateway.
4
+
5
+ == Installation
6
+
7
+ gem install merlin_gateway
8
+
9
+ == Usage example
10
+
11
+ require 'rubygems'
12
+ require 'merlin_gateway'
13
+
14
+ client = MerlinGateway::Client.new(:username => 'myusername', :password => 'mypassword')
15
+ message = client.new_message(4712345678, 'This is a test')
16
+ message.deliver!
17
+
18
+ == Copyright
19
+
20
+ Copyright (c) 2010 Manual design. See LICENSE for details.
@@ -0,0 +1,60 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "merlin_gateway"
8
+ gem.summary = %Q{Client for the Aspiro Merlin SMS gateway}
9
+ gem.description = %Q{Client for the Aspiro Merlin SMS gateway}
10
+ gem.email = "inge@manualdesign.no.no"
11
+ #gem.homepage = "http://github.com/elektronaut/merlin_gateway"
12
+ gem.authors = ["Inge Jørgensen"]
13
+ gem.add_dependency "builder", ">= 2.1.2"
14
+ gem.add_dependency "typhoeus", ">= 0.2.0"
15
+ #gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
16
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
21
+ end
22
+
23
+ require 'rake/testtask'
24
+ Rake::TestTask.new(:test) do |test|
25
+ test.libs << 'lib' << 'test'
26
+ test.pattern = 'test/**/test_*.rb'
27
+ test.verbose = true
28
+ end
29
+
30
+ begin
31
+ require 'rcov/rcovtask'
32
+ Rcov::RcovTask.new do |test|
33
+ test.libs << 'test'
34
+ test.pattern = 'test/**/test_*.rb'
35
+ test.verbose = true
36
+ end
37
+ rescue LoadError
38
+ task :rcov do
39
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
40
+ end
41
+ end
42
+
43
+ task :test => :check_dependencies
44
+
45
+ task :default => :test
46
+
47
+ require 'rake/rdoctask'
48
+ Rake::RDocTask.new do |rdoc|
49
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
50
+
51
+ rdoc.rdoc_dir = 'rdoc'
52
+ rdoc.title = "merlin_gateway #{version}"
53
+ rdoc.rdoc_files.include('README*')
54
+ rdoc.rdoc_files.include('lib/**/*.rb')
55
+ end
56
+
57
+ desc "Update code"
58
+ task :update_source do
59
+ `git pull --quiet origin master`
60
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.3
@@ -0,0 +1,12 @@
1
+ require 'rubygems'
2
+ require 'builder'
3
+ require 'typhoeus'
4
+ require 'pathname'
5
+
6
+ dir = Pathname(__FILE__).dirname.expand_path
7
+
8
+ require dir + 'merlin_gateway/client'
9
+ require dir + 'merlin_gateway/sms_message'
10
+
11
+ module MerlinGateway
12
+ end
@@ -0,0 +1,19 @@
1
+ module MerlinGateway
2
+
3
+ class Client
4
+ attr_accessor :username, :password, :access_number, :sender_number, :country
5
+
6
+ def initialize(options)
7
+ @username = options[:username]
8
+ @password = options[:password]
9
+ @access_number = options[:access_number] || '2210'
10
+ @sender_number = options[:sender_number] || @access_number
11
+ @country = options[:country] || 'NO'
12
+ end
13
+
14
+ def new_message(target_number, message, options={})
15
+ ::MerlinGateway::SmsMessage.new(target_number, message, options.merge({:client => self}))
16
+ end
17
+ end
18
+
19
+ end
@@ -0,0 +1,44 @@
1
+ module MerlinGateway
2
+
3
+ class SmsMessage
4
+ attr_accessor :target_number, :message, :price
5
+ attr_reader :client
6
+
7
+ def initialize(target_number, message, options={})
8
+ @target_number = target_number
9
+ @message = message
10
+ @client = options[:client]
11
+ @price = options[:price] || 0
12
+ end
13
+
14
+ def deliver!
15
+ xml_data = self.to_xml
16
+ response = Typhoeus::Request.post(
17
+ 'http://www.mobile-entry.com/gate/service',
18
+ #:method => :post,
19
+ :headers => {'Content-type' => 'text/xml'},
20
+ :username => client.username,
21
+ :password => client.password,
22
+ :body => xml_data
23
+ )
24
+ end
25
+
26
+ def to_xml
27
+ builder = Builder::XmlMarkup.new#(:indent=>2)
28
+ builder.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
29
+ xml_data = builder.gate do |gate|
30
+ gate.country client.country
31
+ gate.accessNumber client.access_number
32
+ gate.senderNumber client.sender_number
33
+ gate.targetNumber target_number
34
+ gate.price price
35
+ gate.sms do |sms|
36
+ sms.content do |content|
37
+ content.cdata! message
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ end
@@ -0,0 +1,58 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{merlin_gateway}
8
+ s.version = "0.1.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Inge J\303\270rgensen"]
12
+ s.date = %q{2011-06-08}
13
+ s.description = %q{Client for the Aspiro Merlin SMS gateway}
14
+ s.email = %q{inge@manualdesign.no.no}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/merlin_gateway.rb",
27
+ "lib/merlin_gateway/client.rb",
28
+ "lib/merlin_gateway/sms_message.rb",
29
+ "merlin_gateway.gemspec",
30
+ "test/helper.rb",
31
+ "test/test_merlin_gateway.rb"
32
+ ]
33
+ s.rdoc_options = ["--charset=UTF-8"]
34
+ s.require_paths = ["lib"]
35
+ s.rubygems_version = %q{1.3.7}
36
+ s.summary = %q{Client for the Aspiro Merlin SMS gateway}
37
+ s.test_files = [
38
+ "test/helper.rb",
39
+ "test/test_merlin_gateway.rb"
40
+ ]
41
+
42
+ if s.respond_to? :specification_version then
43
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
44
+ s.specification_version = 3
45
+
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ s.add_runtime_dependency(%q<builder>, [">= 2.1.2"])
48
+ s.add_runtime_dependency(%q<typhoeus>, [">= 0.2.0"])
49
+ else
50
+ s.add_dependency(%q<builder>, [">= 2.1.2"])
51
+ s.add_dependency(%q<typhoeus>, [">= 0.2.0"])
52
+ end
53
+ else
54
+ s.add_dependency(%q<builder>, [">= 2.1.2"])
55
+ s.add_dependency(%q<typhoeus>, [">= 0.2.0"])
56
+ end
57
+ end
58
+
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'merlin_gateway'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestMerlinGateway < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: merlin_gateway
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 3
10
+ version: 0.1.3
11
+ platform: ruby
12
+ authors:
13
+ - "Inge J\xC3\xB8rgensen"
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-06-08 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: builder
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 15
30
+ segments:
31
+ - 2
32
+ - 1
33
+ - 2
34
+ version: 2.1.2
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: typhoeus
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 23
46
+ segments:
47
+ - 0
48
+ - 2
49
+ - 0
50
+ version: 0.2.0
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ description: Client for the Aspiro Merlin SMS gateway
54
+ email: inge@manualdesign.no.no
55
+ executables: []
56
+
57
+ extensions: []
58
+
59
+ extra_rdoc_files:
60
+ - LICENSE
61
+ - README.rdoc
62
+ files:
63
+ - .document
64
+ - .gitignore
65
+ - LICENSE
66
+ - README.rdoc
67
+ - Rakefile
68
+ - VERSION
69
+ - lib/merlin_gateway.rb
70
+ - lib/merlin_gateway/client.rb
71
+ - lib/merlin_gateway/sms_message.rb
72
+ - merlin_gateway.gemspec
73
+ - test/helper.rb
74
+ - test/test_merlin_gateway.rb
75
+ has_rdoc: true
76
+ homepage:
77
+ licenses: []
78
+
79
+ post_install_message:
80
+ rdoc_options:
81
+ - --charset=UTF-8
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ hash: 3
99
+ segments:
100
+ - 0
101
+ version: "0"
102
+ requirements: []
103
+
104
+ rubyforge_project:
105
+ rubygems_version: 1.3.7
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: Client for the Aspiro Merlin SMS gateway
109
+ test_files:
110
+ - test/helper.rb
111
+ - test/test_merlin_gateway.rb