little_sms 0.1.0
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.
- data/Gemfile +15 -0
- data/Gemfile.lock +22 -0
- data/LICENSE.txt +21 -0
- data/README.md +25 -0
- data/Rakefile +56 -0
- data/VERSION +1 -0
- data/lib/little_sms/component.rb +76 -0
- data/lib/little_sms/little_sms.rb +17 -0
- data/lib/little_sms/options.rb +32 -0
- data/lib/little_sms/ordering/contact.yaml +20 -0
- data/lib/little_sms/ordering/message.yaml +32 -0
- data/lib/little_sms/ordering/tag.yaml +9 -0
- data/lib/little_sms/ordering/task.yaml +6 -0
- data/lib/little_sms/ordering/user.yaml +6 -0
- data/lib/little_sms.rb +10 -0
- data/little_sms.gemspec +76 -0
- data/test/test_component.rb +26 -0
- data/test/test_little_sms.rb +27 -0
- data/test/test_options.rb +37 -0
- metadata +161 -0
data/Gemfile
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
source "http://rubygems.org"
|
|
2
|
+
# Add dependencies required to use your gem here.
|
|
3
|
+
# Example:
|
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
|
5
|
+
gem "json_pure"
|
|
6
|
+
|
|
7
|
+
# Add dependencies to develop your gem here.
|
|
8
|
+
# Include everything needed to run rake, tests, features, etc.
|
|
9
|
+
group :development do
|
|
10
|
+
gem "shoulda", ">= 0"
|
|
11
|
+
gem "bundler", "~> 1.0.0"
|
|
12
|
+
gem "jeweler", "~> 1.5.2"
|
|
13
|
+
gem "rcov", ">= 0"
|
|
14
|
+
end
|
|
15
|
+
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
GEM
|
|
2
|
+
remote: http://rubygems.org/
|
|
3
|
+
specs:
|
|
4
|
+
git (1.2.5)
|
|
5
|
+
jeweler (1.5.2)
|
|
6
|
+
bundler (~> 1.0.0)
|
|
7
|
+
git (>= 1.2.5)
|
|
8
|
+
rake
|
|
9
|
+
json_pure (1.4.6)
|
|
10
|
+
rake (0.8.7)
|
|
11
|
+
rcov (0.9.9)
|
|
12
|
+
shoulda (2.11.3)
|
|
13
|
+
|
|
14
|
+
PLATFORMS
|
|
15
|
+
ruby
|
|
16
|
+
|
|
17
|
+
DEPENDENCIES
|
|
18
|
+
bundler (~> 1.0.0)
|
|
19
|
+
jeweler (~> 1.5.2)
|
|
20
|
+
json_pure
|
|
21
|
+
rcov
|
|
22
|
+
shoulda
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Copyright (c) 2011 Artyom Bolshakov
|
|
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.
|
|
21
|
+
|
data/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# LittleSMS
|
|
2
|
+
This gem provides access to LittleSMS.ru API from ruby.
|
|
3
|
+
|
|
4
|
+
# Installation
|
|
5
|
+
$ gem install little_sms
|
|
6
|
+
|
|
7
|
+
# Usage
|
|
8
|
+
require "little_sms"
|
|
9
|
+
api = LittleSMS.new(:apiuser, :apikey)
|
|
10
|
+
api.message.send(:recipients => "112", :message => "Sos!")
|
|
11
|
+
|
|
12
|
+
Also you can pass a block to LittleSMS object:
|
|
13
|
+
|
|
14
|
+
LittleSMS.new(:apiuser, :apikey) do
|
|
15
|
+
msg = message.send(:recipients => "112", :message => "Sos!")
|
|
16
|
+
if msg[:status] == :success
|
|
17
|
+
messages_id = msg[:messages_id].join
|
|
18
|
+
status = message.status(:messages_id => messages_id)
|
|
19
|
+
puts "Message #{status[:messages][messages_id]}" if status[:status] == :success
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Copyright
|
|
24
|
+
Copyright © 2011 Artyom Bolshakov. See LICENSE.txt for details.
|
|
25
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'bundler'
|
|
3
|
+
begin
|
|
4
|
+
Bundler.setup(:default, :development)
|
|
5
|
+
rescue Bundler::BundlerError => e
|
|
6
|
+
$stderr.puts e.message
|
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
|
8
|
+
exit e.status_code
|
|
9
|
+
end
|
|
10
|
+
require 'rake'
|
|
11
|
+
|
|
12
|
+
require 'jeweler'
|
|
13
|
+
Jeweler::Tasks.new do |gem|
|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
|
15
|
+
gem.name = "little_sms"
|
|
16
|
+
gem.homepage = "http://github.com/TweeKane/little_sms"
|
|
17
|
+
gem.license = "MIT"
|
|
18
|
+
gem.summary = %Q{LittleSMS.ru API binding}
|
|
19
|
+
gem.description = %Q{LittleSMS.ru API binding}
|
|
20
|
+
gem.email = "tweekane@gmail.com"
|
|
21
|
+
gem.authors = ["Artyom Bolshakov"]
|
|
22
|
+
gem.files = `git ls-files`.split("\n")
|
|
23
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
24
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
|
25
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
|
26
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
|
27
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
|
28
|
+
end
|
|
29
|
+
Jeweler::RubygemsDotOrgTasks.new
|
|
30
|
+
|
|
31
|
+
require 'rake/testtask'
|
|
32
|
+
Rake::TestTask.new(:test) do |test|
|
|
33
|
+
test.libs << 'lib' << 'test'
|
|
34
|
+
test.pattern = 'test/**/test_*.rb'
|
|
35
|
+
test.verbose = true
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
require 'rcov/rcovtask'
|
|
39
|
+
Rcov::RcovTask.new do |test|
|
|
40
|
+
test.libs << 'test'
|
|
41
|
+
test.pattern = 'test/**/test_*.rb'
|
|
42
|
+
test.verbose = true
|
|
43
|
+
end
|
|
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 = "little_sms #{version}"
|
|
53
|
+
rdoc.rdoc_files.include('README*')
|
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
55
|
+
end
|
|
56
|
+
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.1.0
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
require "net/http"
|
|
3
|
+
require "net/https"
|
|
4
|
+
require 'digest/md5'
|
|
5
|
+
require 'digest/sha1'
|
|
6
|
+
|
|
7
|
+
class LittleSMS
|
|
8
|
+
class Component
|
|
9
|
+
# Conflict with message.send
|
|
10
|
+
undef :send
|
|
11
|
+
attr_reader :component
|
|
12
|
+
|
|
13
|
+
def initialize(component, api_user, api_key)
|
|
14
|
+
@api_uri = URI.parse("https://littlesms.ru:443/api/")
|
|
15
|
+
@auth = {:user => api_user, :key => api_key}
|
|
16
|
+
@component = component # Component name. E.g. message or user.
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def method_missing(name, *args)
|
|
20
|
+
request_api_method(name, args[0])
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
def request_api_method(method, options = {})
|
|
25
|
+
options ||= {}
|
|
26
|
+
options.merge!(@auth)
|
|
27
|
+
|
|
28
|
+
# Replace original sort method
|
|
29
|
+
options.extend(self.class::Options)
|
|
30
|
+
options.method_path = {:method => method, :component => @component }
|
|
31
|
+
|
|
32
|
+
options[:sign] = sign_request(options)
|
|
33
|
+
uri = @api_uri.merge("#{@component}/#{method}")
|
|
34
|
+
req = Net::HTTP::Post.new(uri.path)
|
|
35
|
+
req.set_form_data(options.delete_if {|k, v| k == :key})
|
|
36
|
+
|
|
37
|
+
uri.scheme, uri.port, use_ssl = if LittleSMS.use_ssl
|
|
38
|
+
['https', 443, true]
|
|
39
|
+
else
|
|
40
|
+
['http', 80, false]
|
|
41
|
+
end
|
|
42
|
+
res = Net::HTTP.new(uri.host, uri.port)
|
|
43
|
+
res.use_ssl = use_ssl
|
|
44
|
+
|
|
45
|
+
case res = res.start {|http| http.request(req) }
|
|
46
|
+
when Net::HTTPSuccess, Net::HTTPRedirection
|
|
47
|
+
return format_output(JSON.parse(res.body))
|
|
48
|
+
else
|
|
49
|
+
res.error!
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def sign_request(options)
|
|
54
|
+
Digest::MD5.hexdigest(
|
|
55
|
+
Digest::SHA1.hexdigest(options.sort.map {|e| e[1]}.join)
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Convert all strings keys to symbols
|
|
60
|
+
def format_output(hash)
|
|
61
|
+
format = lambda do |v|
|
|
62
|
+
if v.respond_to?(:map)
|
|
63
|
+
format_output(v)
|
|
64
|
+
else
|
|
65
|
+
v
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
if hash.kind_of? Hash
|
|
69
|
+
Hash[ hash.map { |k, v| [k.to_sym, format.call(v)] } ]
|
|
70
|
+
else
|
|
71
|
+
hash.map { |v| format.call(v) }
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class LittleSMS
|
|
2
|
+
class << self
|
|
3
|
+
attr_accessor :use_ssl
|
|
4
|
+
end
|
|
5
|
+
# Use ssl by default
|
|
6
|
+
self.use_ssl = true
|
|
7
|
+
|
|
8
|
+
def initialize(api_user, api_key, &block)
|
|
9
|
+
@api_user, @api_key = api_user, api_key
|
|
10
|
+
@components = {}
|
|
11
|
+
self.instance_eval &block if block_given?
|
|
12
|
+
end
|
|
13
|
+
def method_missing(name, *args)
|
|
14
|
+
@components[name] ||= Component.new(name, @api_user, @api_key)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require "yaml"
|
|
2
|
+
|
|
3
|
+
class LittleSMS
|
|
4
|
+
class Component
|
|
5
|
+
# This module should be mixed with request options hash.
|
|
6
|
+
# to overwite Hash#sort method
|
|
7
|
+
module Options
|
|
8
|
+
class NoMethodError < StandardError; end
|
|
9
|
+
class NoComponentError < StandardError; end
|
|
10
|
+
attr_accessor :method_path
|
|
11
|
+
def sort
|
|
12
|
+
order = load_order(@method_path[:component], @method_path[:method])
|
|
13
|
+
self.to_a.sort do |a,b|
|
|
14
|
+
order.find_index(a[0]) <=> order.find_index(b[0])
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
# load sorting order from yaml file
|
|
20
|
+
def load_order(component, method)
|
|
21
|
+
begin
|
|
22
|
+
order = YAML.load_file("#{File.dirname(__FILE__)}/ordering/#{component}.yaml")[method]
|
|
23
|
+
raise NoMethodError, "There is no such method in #{component} file: #{method}" if order.nil?
|
|
24
|
+
order
|
|
25
|
+
rescue Errno::ENOENT
|
|
26
|
+
raise NoComponentError, "There is no such file: #{component}"
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
:send:
|
|
3
|
+
- :user
|
|
4
|
+
- :recipients
|
|
5
|
+
- :message
|
|
6
|
+
- :sender
|
|
7
|
+
- :test
|
|
8
|
+
- :sign
|
|
9
|
+
- :key
|
|
10
|
+
:status:
|
|
11
|
+
- :user
|
|
12
|
+
- :sign
|
|
13
|
+
- :messages_id
|
|
14
|
+
- :key
|
|
15
|
+
:price:
|
|
16
|
+
- :user
|
|
17
|
+
- :sign
|
|
18
|
+
- :recipients
|
|
19
|
+
- :message
|
|
20
|
+
- :key
|
|
21
|
+
:history:
|
|
22
|
+
- :user
|
|
23
|
+
- :sign
|
|
24
|
+
- :history_id
|
|
25
|
+
- :recipient
|
|
26
|
+
- :sender
|
|
27
|
+
- :status
|
|
28
|
+
- :date_from
|
|
29
|
+
- :date_to
|
|
30
|
+
- :id
|
|
31
|
+
- :key
|
|
32
|
+
|
data/lib/little_sms.rb
ADDED
data/little_sms.gemspec
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Generated by jeweler
|
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
|
+
# -*- encoding: utf-8 -*-
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
s.name = %q{little_sms}
|
|
8
|
+
s.version = "0.1.0"
|
|
9
|
+
|
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
|
+
s.authors = ["Artyom Bolshakov"]
|
|
12
|
+
s.date = %q{2011-03-06}
|
|
13
|
+
s.description = %q{LittleSMS.ru API binding}
|
|
14
|
+
s.email = %q{tweekane@gmail.com}
|
|
15
|
+
s.extra_rdoc_files = [
|
|
16
|
+
"LICENSE.txt",
|
|
17
|
+
"README.md"
|
|
18
|
+
]
|
|
19
|
+
s.files = [
|
|
20
|
+
"Gemfile",
|
|
21
|
+
"Gemfile.lock",
|
|
22
|
+
"LICENSE.txt",
|
|
23
|
+
"README.md",
|
|
24
|
+
"Rakefile",
|
|
25
|
+
"VERSION",
|
|
26
|
+
"lib/little_sms.rb",
|
|
27
|
+
"lib/little_sms/component.rb",
|
|
28
|
+
"lib/little_sms/little_sms.rb",
|
|
29
|
+
"lib/little_sms/options.rb",
|
|
30
|
+
"lib/little_sms/ordering/contact.yaml",
|
|
31
|
+
"lib/little_sms/ordering/message.yaml",
|
|
32
|
+
"lib/little_sms/ordering/tag.yaml",
|
|
33
|
+
"lib/little_sms/ordering/task.yaml",
|
|
34
|
+
"lib/little_sms/ordering/user.yaml",
|
|
35
|
+
"little_sms.gemspec",
|
|
36
|
+
"test/test_component.rb",
|
|
37
|
+
"test/test_little_sms.rb",
|
|
38
|
+
"test/test_options.rb"
|
|
39
|
+
]
|
|
40
|
+
s.homepage = %q{http://github.com/TweeKane/little_sms}
|
|
41
|
+
s.licenses = ["MIT"]
|
|
42
|
+
s.require_paths = ["lib"]
|
|
43
|
+
s.rubygems_version = %q{1.3.7}
|
|
44
|
+
s.summary = %q{LittleSMS.ru API binding}
|
|
45
|
+
s.test_files = [
|
|
46
|
+
"test/test_component.rb",
|
|
47
|
+
"test/test_little_sms.rb",
|
|
48
|
+
"test/test_options.rb"
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
if s.respond_to? :specification_version then
|
|
52
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
53
|
+
s.specification_version = 3
|
|
54
|
+
|
|
55
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
56
|
+
s.add_runtime_dependency(%q<json_pure>, [">= 0"])
|
|
57
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
|
58
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
59
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
|
60
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
|
61
|
+
else
|
|
62
|
+
s.add_dependency(%q<json_pure>, [">= 0"])
|
|
63
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
|
64
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
65
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
|
66
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
|
67
|
+
end
|
|
68
|
+
else
|
|
69
|
+
s.add_dependency(%q<json_pure>, [">= 0"])
|
|
70
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
|
71
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
|
72
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
|
73
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'shoulda'
|
|
3
|
+
require 'lib/little_sms'
|
|
4
|
+
|
|
5
|
+
class ComponentTest < Test::Unit::TestCase
|
|
6
|
+
context "A LittleSMS::Component" do
|
|
7
|
+
def setup
|
|
8
|
+
@options = {:message=>"sos", :recipients=>"112", :user=>'free', :key=>'Jesus'}
|
|
9
|
+
@options.extend(LittleSMS::Component::Options)
|
|
10
|
+
@options.method_path = {:method => :send, :component => :message }
|
|
11
|
+
@component = LittleSMS::Component.new(:message, "Christ", "Jesus")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
should "should sign request" do
|
|
15
|
+
sign = @component.method(:sign_request).call(@options)
|
|
16
|
+
assert_equal "9ee9ac110901dae9ee9f97fde09f3268", sign
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
should "format output" do
|
|
20
|
+
out = {"recipients"=>["911", "112"], "messages_id"=>[], "count"=>1, "parts"=>1, "price"=>0.5, "balance"=>9, "test"=>1, "status"=>"success"}
|
|
21
|
+
formatted = {:recipients=>["911", "112"], :messages_id=>[], :count=>1, :parts=>1, :price=>0.5, :balance=>9, :test=>1, :status=>"success"}
|
|
22
|
+
assert_equal formatted, @component.instance_eval("format_output(#{out})")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'shoulda'
|
|
3
|
+
require 'lib/little_sms'
|
|
4
|
+
|
|
5
|
+
class LittleSMSTest < Test::Unit::TestCase
|
|
6
|
+
context "A LittleSMS" do
|
|
7
|
+
def setup
|
|
8
|
+
@api_user = :testapiuser
|
|
9
|
+
@api_key = :testapikeystring
|
|
10
|
+
@sms = LittleSMS.new @api_user, @api_key
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
should "create Component for unknown method" do
|
|
14
|
+
@sms.foo
|
|
15
|
+
assert_equal(@sms.instance_eval { @components[:foo].class }, LittleSMS::Component)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
should "accept block" do
|
|
19
|
+
mes = nil
|
|
20
|
+
LittleSMS.new @api_user, @api_key do
|
|
21
|
+
mes = message
|
|
22
|
+
end
|
|
23
|
+
assert_equal(LittleSMS::Component, mes.class)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'test/unit'
|
|
2
|
+
require 'shoulda'
|
|
3
|
+
require 'lib/little_sms'
|
|
4
|
+
|
|
5
|
+
class OptionsTest < Test::Unit::TestCase
|
|
6
|
+
context "A Options" do
|
|
7
|
+
def setup
|
|
8
|
+
@order = [:user, :recipients, :message, :sender, :test, :sign, :key]
|
|
9
|
+
@options = {:message=>"sos", :recipients=>"112"}
|
|
10
|
+
@options.extend(LittleSMS::Component::Options)
|
|
11
|
+
@options.method_path = {:method => :send, :component => :message }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
should "load order from file" do
|
|
15
|
+
assert_equal(@order, @options.instance_eval("load_order(:message, :send)"))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
should "sort with loaded order" do
|
|
19
|
+
assert_equal @options.sort, [[:recipients, "112"], [:message, "sos"]]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
should "fail if unknown method called" do
|
|
23
|
+
@options.method_path = {:method => :unknown, :component => :message }
|
|
24
|
+
assert_raise LittleSMS::Component::Options::NoMethodError do
|
|
25
|
+
@options.sort
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
should "fail if unknown component accessed" do
|
|
30
|
+
@options.method_path = {:method => :unknown, :component => :unknown }
|
|
31
|
+
assert_raise LittleSMS::Component::Options::NoComponentError do
|
|
32
|
+
@options.sort
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
metadata
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: little_sms
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 27
|
|
5
|
+
prerelease: false
|
|
6
|
+
segments:
|
|
7
|
+
- 0
|
|
8
|
+
- 1
|
|
9
|
+
- 0
|
|
10
|
+
version: 0.1.0
|
|
11
|
+
platform: ruby
|
|
12
|
+
authors:
|
|
13
|
+
- Artyom Bolshakov
|
|
14
|
+
autorequire:
|
|
15
|
+
bindir: bin
|
|
16
|
+
cert_chain: []
|
|
17
|
+
|
|
18
|
+
date: 2011-03-06 00:00:00 +03:00
|
|
19
|
+
default_executable:
|
|
20
|
+
dependencies:
|
|
21
|
+
- !ruby/object:Gem::Dependency
|
|
22
|
+
name: json_pure
|
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
24
|
+
none: false
|
|
25
|
+
requirements:
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
hash: 3
|
|
29
|
+
segments:
|
|
30
|
+
- 0
|
|
31
|
+
version: "0"
|
|
32
|
+
type: :runtime
|
|
33
|
+
prerelease: false
|
|
34
|
+
version_requirements: *id001
|
|
35
|
+
- !ruby/object:Gem::Dependency
|
|
36
|
+
name: shoulda
|
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
38
|
+
none: false
|
|
39
|
+
requirements:
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
hash: 3
|
|
43
|
+
segments:
|
|
44
|
+
- 0
|
|
45
|
+
version: "0"
|
|
46
|
+
type: :development
|
|
47
|
+
prerelease: false
|
|
48
|
+
version_requirements: *id002
|
|
49
|
+
- !ruby/object:Gem::Dependency
|
|
50
|
+
name: bundler
|
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
|
52
|
+
none: false
|
|
53
|
+
requirements:
|
|
54
|
+
- - ~>
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
hash: 23
|
|
57
|
+
segments:
|
|
58
|
+
- 1
|
|
59
|
+
- 0
|
|
60
|
+
- 0
|
|
61
|
+
version: 1.0.0
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: *id003
|
|
65
|
+
- !ruby/object:Gem::Dependency
|
|
66
|
+
name: jeweler
|
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
|
68
|
+
none: false
|
|
69
|
+
requirements:
|
|
70
|
+
- - ~>
|
|
71
|
+
- !ruby/object:Gem::Version
|
|
72
|
+
hash: 7
|
|
73
|
+
segments:
|
|
74
|
+
- 1
|
|
75
|
+
- 5
|
|
76
|
+
- 2
|
|
77
|
+
version: 1.5.2
|
|
78
|
+
type: :development
|
|
79
|
+
prerelease: false
|
|
80
|
+
version_requirements: *id004
|
|
81
|
+
- !ruby/object:Gem::Dependency
|
|
82
|
+
name: rcov
|
|
83
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
|
84
|
+
none: false
|
|
85
|
+
requirements:
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
hash: 3
|
|
89
|
+
segments:
|
|
90
|
+
- 0
|
|
91
|
+
version: "0"
|
|
92
|
+
type: :development
|
|
93
|
+
prerelease: false
|
|
94
|
+
version_requirements: *id005
|
|
95
|
+
description: LittleSMS.ru API binding
|
|
96
|
+
email: tweekane@gmail.com
|
|
97
|
+
executables: []
|
|
98
|
+
|
|
99
|
+
extensions: []
|
|
100
|
+
|
|
101
|
+
extra_rdoc_files:
|
|
102
|
+
- LICENSE.txt
|
|
103
|
+
- README.md
|
|
104
|
+
files:
|
|
105
|
+
- Gemfile
|
|
106
|
+
- Gemfile.lock
|
|
107
|
+
- LICENSE.txt
|
|
108
|
+
- README.md
|
|
109
|
+
- Rakefile
|
|
110
|
+
- VERSION
|
|
111
|
+
- lib/little_sms.rb
|
|
112
|
+
- lib/little_sms/component.rb
|
|
113
|
+
- lib/little_sms/little_sms.rb
|
|
114
|
+
- lib/little_sms/options.rb
|
|
115
|
+
- lib/little_sms/ordering/contact.yaml
|
|
116
|
+
- lib/little_sms/ordering/message.yaml
|
|
117
|
+
- lib/little_sms/ordering/tag.yaml
|
|
118
|
+
- lib/little_sms/ordering/task.yaml
|
|
119
|
+
- lib/little_sms/ordering/user.yaml
|
|
120
|
+
- little_sms.gemspec
|
|
121
|
+
- test/test_component.rb
|
|
122
|
+
- test/test_little_sms.rb
|
|
123
|
+
- test/test_options.rb
|
|
124
|
+
has_rdoc: true
|
|
125
|
+
homepage: http://github.com/TweeKane/little_sms
|
|
126
|
+
licenses:
|
|
127
|
+
- MIT
|
|
128
|
+
post_install_message:
|
|
129
|
+
rdoc_options: []
|
|
130
|
+
|
|
131
|
+
require_paths:
|
|
132
|
+
- lib
|
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
134
|
+
none: false
|
|
135
|
+
requirements:
|
|
136
|
+
- - ">="
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
hash: 3
|
|
139
|
+
segments:
|
|
140
|
+
- 0
|
|
141
|
+
version: "0"
|
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
|
+
none: false
|
|
144
|
+
requirements:
|
|
145
|
+
- - ">="
|
|
146
|
+
- !ruby/object:Gem::Version
|
|
147
|
+
hash: 3
|
|
148
|
+
segments:
|
|
149
|
+
- 0
|
|
150
|
+
version: "0"
|
|
151
|
+
requirements: []
|
|
152
|
+
|
|
153
|
+
rubyforge_project:
|
|
154
|
+
rubygems_version: 1.3.7
|
|
155
|
+
signing_key:
|
|
156
|
+
specification_version: 3
|
|
157
|
+
summary: LittleSMS.ru API binding
|
|
158
|
+
test_files:
|
|
159
|
+
- test/test_component.rb
|
|
160
|
+
- test/test_little_sms.rb
|
|
161
|
+
- test/test_options.rb
|