data247 0.2.0 → 0.3.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/VERSION +1 -1
- data/lib/data247.rb +15 -2
- data/spec/data247_spec.rb +9 -5
- metadata +8 -9
- data/.gitignore +0 -22
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/data247.rb
CHANGED
@@ -54,14 +54,27 @@ class Data247
|
|
54
54
|
new(:status=>"Timeout from Data24-7")
|
55
55
|
end
|
56
56
|
|
57
|
+
# When using FakeWeb for testing (which you should), use this to setup a fake response that returns the data you want.
|
58
|
+
#
|
59
|
+
# Required parameters:
|
60
|
+
# * :msisdn
|
61
|
+
#
|
62
|
+
# Optional parameters:
|
63
|
+
# * :status (defaults to "OK")
|
64
|
+
# * :username (defaults to Data247.username)
|
65
|
+
# * :password (defaults to Data247.password)
|
66
|
+
# * :operator (defaults to "T-Mobile")
|
67
|
+
# * :result (operator code, defaults to "123345", the T-Mobile operator code)
|
57
68
|
def setup_fakeweb_response(options={})
|
58
69
|
raise "FakeWeb is not defined. Please require 'fakeweb' and make sure the fakeweb rubygem is installed." unless defined?(FakeWeb)
|
59
70
|
raise ArgumentError.new("Option missing: :msisdn") unless options[:msisdn]
|
60
|
-
options[:status]
|
71
|
+
options[:status] ||= "OK"
|
61
72
|
options[:username]||= self.username
|
62
73
|
options[:password]||= self.password
|
74
|
+
options[:operator] ||= "T-Mobile"
|
75
|
+
options[:result] ||= "123345"
|
63
76
|
FakeWeb.register_uri :get, "http://api.data24-7.com/carrier.php?username=#{options[:username]}&password=#{options[:password]}&p1=#{options[:msisdn]}", :body=> <<-MSG
|
64
|
-
<?xml version="1.0"?><response><results><result item="1"><status>#{options[:status]}</status><number>#{options[:msisdn]}</number><wless>y</wless><carrier_name
|
77
|
+
<?xml version="1.0"?><response><results><result item="1"><status>#{options[:status]}</status><number>#{options[:msisdn]}</number><wless>y</wless><carrier_name>#{options[:operator]}</carrier_name><carrier_id>#{options[:result]}</carrier_id><sms_address>#{options[:msisdn]}@tmomail.net</sms_address><mms_address>#{options[:msisdn]}@tmomail.net</mms_address></result></results><balance>21.5000</balance></response>
|
65
78
|
MSG
|
66
79
|
end
|
67
80
|
end
|
data/spec/data247_spec.rb
CHANGED
@@ -21,16 +21,20 @@ describe "Data247" do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
describe "the returned Data247 instance" do
|
24
|
-
|
25
|
-
@data247 = Data247.detect("31612345678")
|
26
|
-
end
|
24
|
+
let(:data247) { Data247.detect("31612345678") }
|
27
25
|
|
28
26
|
it "should contain the returned operator code" do
|
29
|
-
|
27
|
+
data247.operator_code.should == "12345"
|
30
28
|
end
|
31
29
|
|
32
30
|
it "should contain the returned msisdn" do
|
33
|
-
|
31
|
+
data247.msisdn.should == "31612345678"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should contain the operator name" do
|
35
|
+
Data247.setup_fakeweb_response(:msisdn=>"31612345679", :status=>"OK", :result => 130730, :operator=>"KPN")
|
36
|
+
data = Data247.detect("31612345679")
|
37
|
+
data.operator_name.should == "KPN"
|
34
38
|
end
|
35
39
|
end
|
36
40
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: data247
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 19
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 3
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Gerard de Brieder
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-07-19 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -58,7 +58,6 @@ extra_rdoc_files:
|
|
58
58
|
- LICENSE
|
59
59
|
- README.rdoc
|
60
60
|
files:
|
61
|
-
- .gitignore
|
62
61
|
- LICENSE
|
63
62
|
- README.rdoc
|
64
63
|
- Rakefile
|
@@ -71,8 +70,8 @@ homepage: http://github.com/smeevil/data247
|
|
71
70
|
licenses: []
|
72
71
|
|
73
72
|
post_install_message:
|
74
|
-
rdoc_options:
|
75
|
-
|
73
|
+
rdoc_options: []
|
74
|
+
|
76
75
|
require_paths:
|
77
76
|
- lib
|
78
77
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -96,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
95
|
requirements: []
|
97
96
|
|
98
97
|
rubyforge_project:
|
99
|
-
rubygems_version: 1.
|
98
|
+
rubygems_version: 1.6.2
|
100
99
|
signing_key:
|
101
100
|
specification_version: 3
|
102
101
|
summary: Wrapper class for Data24-7 mobile operator detection based on msisdn.
|