ispusage 0.3.0 → 0.4.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/ispusage/fetchers/au_translink.rb +26 -0
- data/lib/ispusage/fetchers.rb +2 -1
- data/lib/ispusage/usage_period.rb +23 -5
- data/lib/ispusage.rb +14 -6
- data/spec/fetchers/au_translink_spec.rb +24 -0
- data/spec/fetchers/fetcher_spec.rb +1 -1
- data/spec/fixtures/au_translink/logon.html +190 -0
- data/spec/fixtures/au_translink/summary.html +328 -0
- data/spec/usage_period_spec.rb +57 -3
- metadata +7 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'mechanize'
|
3
|
+
|
4
|
+
class IspUsage
|
5
|
+
class Fetchers
|
6
|
+
class AUTranslink < Fetcher
|
7
|
+
def initialize(options)
|
8
|
+
super(options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def fetch_usage
|
12
|
+
agent = Mechanize.new
|
13
|
+
page = agent.get('https://www.seqits.com.au/webtix/')
|
14
|
+
login_form = page.form('form2')
|
15
|
+
login_form['cardNum'] = self.username
|
16
|
+
login_form.pass = self.password
|
17
|
+
page = agent.submit(login_form, login_form.buttons.first)
|
18
|
+
|
19
|
+
usage = UsagePeriod.new(:type => :balance)
|
20
|
+
self.usage_periods << usage
|
21
|
+
|
22
|
+
usage.used = page.search('.results_table/tr[2]/td[2]').text.match(/\d+\.\d+/)[0].to_f
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/ispusage/fetchers.rb
CHANGED
@@ -2,4 +2,5 @@ require 'ispusage/fetchers/fetcher'
|
|
2
2
|
require 'ispusage/fetchers/au_optus'
|
3
3
|
require 'ispusage/fetchers/au_three'
|
4
4
|
require 'ispusage/fetchers/iinet'
|
5
|
-
require 'ispusage/fetchers/internode'
|
5
|
+
require 'ispusage/fetchers/internode'
|
6
|
+
require 'ispusage/fetchers/au_translink'
|
@@ -1,9 +1,12 @@
|
|
1
1
|
class IspUsage
|
2
2
|
class UsagePeriod
|
3
3
|
attr_accessor :quota, :used, :label
|
4
|
+
attr_reader :type
|
4
5
|
def initialize(options = {})
|
5
6
|
self.label = 'No Label Set'
|
6
|
-
|
7
|
+
self.type = :meter
|
8
|
+
|
9
|
+
auto_setters = [:quota, :used, :label, :type]
|
7
10
|
options.each do |key, value|
|
8
11
|
if auto_setters.include?(key)
|
9
12
|
self.send(key.to_s + '=', value)
|
@@ -12,6 +15,7 @@ class IspUsage
|
|
12
15
|
end
|
13
16
|
|
14
17
|
def total
|
18
|
+
return nil if quota.nil? || used.nil?
|
15
19
|
if quota > used
|
16
20
|
return quota
|
17
21
|
else
|
@@ -20,12 +24,26 @@ class IspUsage
|
|
20
24
|
end
|
21
25
|
|
22
26
|
def to_hash
|
23
|
-
{
|
24
|
-
:quota => quota,
|
27
|
+
hash = {
|
25
28
|
:used => used,
|
26
|
-
:
|
27
|
-
:
|
29
|
+
:label => label,
|
30
|
+
:type => type
|
28
31
|
}
|
32
|
+
|
33
|
+
hash.merge!({
|
34
|
+
:quota => quota,
|
35
|
+
:total => total,
|
36
|
+
}) if type == :meter
|
37
|
+
|
38
|
+
hash
|
39
|
+
end
|
40
|
+
|
41
|
+
def type=(typ)
|
42
|
+
if [:balance, :meter].include?(typ)
|
43
|
+
@type = typ
|
44
|
+
else
|
45
|
+
raise IspUsage::InvalidUsagePeriodType
|
46
|
+
end
|
29
47
|
end
|
30
48
|
end
|
31
49
|
end
|
data/lib/ispusage.rb
CHANGED
@@ -5,12 +5,14 @@ require 'pp'
|
|
5
5
|
require 'json'
|
6
6
|
|
7
7
|
class IspUsage
|
8
|
-
|
8
|
+
class InvalidUsagePeriodType < StandardError; end
|
9
|
+
|
9
10
|
ISPS = [
|
10
|
-
'AUIinet',
|
11
|
-
'AUInternode',
|
12
|
-
'AUOptus',
|
13
|
-
'AUThree'
|
11
|
+
{:class => 'AUIinet', :name => 'iiNet'},
|
12
|
+
{:class => 'AUInternode', :name => 'Internode'},
|
13
|
+
{:class => 'AUOptus', :name => 'Optus'},
|
14
|
+
{:class => 'AUThree', :name => 'Three'},
|
15
|
+
{:class => 'AUTranslink', :name => 'Translink'}
|
14
16
|
]
|
15
17
|
|
16
18
|
class Cli
|
@@ -23,10 +25,16 @@ class IspUsage
|
|
23
25
|
opts.on('-p', '--password password', 'Password') {|p| options[:password] = p}
|
24
26
|
opts.on('-q', '--pin ', 'PIN') {|pin| options[:pin] = pin}
|
25
27
|
opts.on('-j', '--json', 'JSON Output') {|j| options[:output] = :json}
|
28
|
+
opts.on('--list-isps', 'List ISP classes available') {|opt| options[:list_isps] = true}
|
26
29
|
end
|
27
30
|
optparse.parse!
|
28
31
|
|
29
|
-
|
32
|
+
if options[:list_isps]
|
33
|
+
puts ISPS.to_json
|
34
|
+
return 0
|
35
|
+
end
|
36
|
+
|
37
|
+
unless ISPS.map{|i| i[:class]}.include?(options[:isp])
|
30
38
|
puts 'Unknown ISP: ' + options[:isp]
|
31
39
|
return 1
|
32
40
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe IspUsage::Fetchers::AUTranslink do
|
4
|
+
describe "single usage period" do
|
5
|
+
before do
|
6
|
+
signon = File.read(File.dirname(__FILE__) + '/../fixtures/au_translink/logon.html')
|
7
|
+
FakeWeb.register_uri(:get, 'https://www.seqits.com.au/webtix/', :response => signon)
|
8
|
+
usage = File.read(File.dirname(__FILE__) + '/../fixtures/au_translink/summary.html')
|
9
|
+
FakeWeb.register_uri(:post, 'https://www.seqits.com.au/webtix/welcome/welcome.do', :response => usage)
|
10
|
+
|
11
|
+
options = {:username => '0160123412341234', :password => 'password'}
|
12
|
+
@usage = IspUsage::Fetchers::AUTranslink.new(options)
|
13
|
+
@usage.fetch_usage
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return usage correctly" do
|
17
|
+
@usage.usage_periods.first.used.should == 24.63
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should set the usage type to balance" do
|
21
|
+
@usage.usage_periods.first.type.should == :balance
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -5,7 +5,7 @@ describe IspUsage::Fetchers::Fetcher do
|
|
5
5
|
@usage = IspUsage::Fetchers::Fetcher.new(:username => 'bob', :password => 'xkcd')
|
6
6
|
@usage.usage_periods << IspUsage::UsagePeriod.new(:used => 500, :quota => 1000, :label => 'All Day')
|
7
7
|
@usage.to_hash.should == {
|
8
|
-
:usage_periods => [{:used => 500, :quota => 1000, :total => 1000, :label => 'All Day'}],
|
8
|
+
:usage_periods => [{:used => 500, :quota => 1000, :total => 1000, :label => 'All Day', :type => :meter}],
|
9
9
|
:isp => 'Fetcher',
|
10
10
|
:username => 'bob'
|
11
11
|
}
|
@@ -0,0 +1,190 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Content-Type: text/html; charset=iso-8859-1
|
3
|
+
|
4
|
+
|
5
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
<html>
|
16
|
+
<head>
|
17
|
+
|
18
|
+
<link rel="icon" type="image/x-icon" href="/webtix/media/favicon.ico" />
|
19
|
+
<link rel="shortcut icon" type="image/x-icon" href="/webtix/media/favicon.ico" />
|
20
|
+
|
21
|
+
<title>TransLink - my go card</title>
|
22
|
+
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
|
23
|
+
|
24
|
+
|
25
|
+
<link rel="stylesheet" type="text/css" href="/webtix/css/my_styles.css?version=1259037761000"/>
|
26
|
+
<script type="text/javascript" src="/webtix/script/common.js?version=1259037761000"></script>
|
27
|
+
</head>
|
28
|
+
|
29
|
+
<body onload="init()" onunload="loadCookie();">
|
30
|
+
<map name="headerImgMap">
|
31
|
+
<area href="http://www.translink.com.au"
|
32
|
+
title="TransLink"
|
33
|
+
shape="rect"
|
34
|
+
coords="20,25,220,64"/>
|
35
|
+
</map>
|
36
|
+
|
37
|
+
<div class="mainTable">
|
38
|
+
<div><img id="headerImage" src="/webtix/media/banner.jpg" usemap="#headerImgMap" title="go card banner"/></div>
|
39
|
+
|
40
|
+
<!-- BODY -->
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
<script type="text/javascript" src="/webtix/script/welcome.js?version=1259037761000"></script>
|
48
|
+
|
49
|
+
<div class="welcome_page">
|
50
|
+
<div id="top_nav_bar">
|
51
|
+
<span id="navText"></span>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
|
55
|
+
<div id="contentWell">
|
56
|
+
<noscript>
|
57
|
+
<div id="javascript_required_msg" style="text-align: center;">
|
58
|
+
JavaScript is required to use this site. View our
|
59
|
+
<a href="http://www.translink.com.au/help.php" target="_blank">help section</a>
|
60
|
+
for more information.
|
61
|
+
</div>
|
62
|
+
</noscript>
|
63
|
+
|
64
|
+
|
65
|
+
<script type="text/javascript">
|
66
|
+
function customInitFunction() {
|
67
|
+
|
68
|
+
}
|
69
|
+
</script>
|
70
|
+
|
71
|
+
<div id="ncs_down_msg_zone" class="error"></div>
|
72
|
+
|
73
|
+
<table cellpadding="3" cellspacing="3">
|
74
|
+
<tr>
|
75
|
+
<td valign="top">
|
76
|
+
<div class="contentBox" id="topLeftContentBox">
|
77
|
+
<div class="section_header"> I would like to</div>
|
78
|
+
|
79
|
+
<form name="form1" method="post" action="/webtix/welcome/welcome.do">
|
80
|
+
<div id="buyCardOption">
|
81
|
+
<input type="radio" name="cardOps" value="buy" id="buyCard" onclick="update();" />
|
82
|
+
<label for="buyCard">Buy a registered <b><i>go</i></b> card</label>
|
83
|
+
</div>
|
84
|
+
<div id="registerCardOption">
|
85
|
+
<input type="radio" name="cardOps" value="register" id="registerCard" onclick="update();" />
|
86
|
+
<label for="registerCard">Register my <b><i>go</i></b> card</label>
|
87
|
+
</div>
|
88
|
+
<div id="nextButtonDiv">
|
89
|
+
<input class="go_btn_disabled" type="submit" value="Next" id="gobtn1" disabled="disabled" onclick="return validate(this.form);" />
|
90
|
+
</div>
|
91
|
+
</form>
|
92
|
+
</div>
|
93
|
+
</td>
|
94
|
+
|
95
|
+
<td valign="top">
|
96
|
+
<div class="contentBox" id="topRightContentBox">
|
97
|
+
<div class="section_header"> Manage my <b><i>go</i></b> card</div>
|
98
|
+
<div id="msg_zone" class="error"> </div>
|
99
|
+
|
100
|
+
|
101
|
+
<form name="form2" method="post" action="/webtix/welcome/welcome.do">
|
102
|
+
<input type="hidden" name="cardOps" value="Display"/>
|
103
|
+
|
104
|
+
<table cellpadding="0" cellspacing="1" id="form_table">
|
105
|
+
<tr>
|
106
|
+
<td width="25%" align="right"> <b><i>go</i></b> card no:</td>
|
107
|
+
<td width="40%"><input type="text" name="cardNum" id="serial" size="25" maxlength="24"/></td>
|
108
|
+
<td id="card_no_hint"> (last 16 digits)</td>
|
109
|
+
</tr>
|
110
|
+
<tr>
|
111
|
+
<td align="right"> Password:</td>
|
112
|
+
<td><input name="pass" type="password" id="passwd" size="25" maxlength="24"/></td>
|
113
|
+
<td> </td>
|
114
|
+
</tr>
|
115
|
+
<tr>
|
116
|
+
<td colspan="2" id="forgot_pswd">
|
117
|
+
<a href="#" onclick="alert('Call 13 12 30 to reset your password.');">Forgot your password?</a>
|
118
|
+
</td>
|
119
|
+
<td colspan="1" id="go_btn_cell">
|
120
|
+
<input class="go_btn" type="submit" value="Login" id="gobtn2" onclick="return validate(this.form);" />
|
121
|
+
</td>
|
122
|
+
</tr>
|
123
|
+
</table>
|
124
|
+
</form>
|
125
|
+
</div>
|
126
|
+
</td>
|
127
|
+
</tr>
|
128
|
+
|
129
|
+
|
130
|
+
<tr>
|
131
|
+
<td id="go_card_img">
|
132
|
+
<img src="/webtix/media/cc_go_card.jpg" title="go card image"/>
|
133
|
+
</td>
|
134
|
+
<td>
|
135
|
+
<div class="contentBox" id="bottomRightContentBox">
|
136
|
+
<div class="section_header">Welcome to <b><i>go</i></b> card online</div>
|
137
|
+
<div id="faqSectionWelcome">
|
138
|
+
<P>If your <em>go</em> card is registered you can login to top-up your balance, set up auto top-up, view your transactions or change your account details.</P><P>If you don't have an online password you can register your card now or call TransLink on 13 12 30.</P><P>You can change your password online any time.</P><P>If you need more information about <em>go</em> card please read our <a href="http://www.translink.com.au/go_faq.php" target="_blank">frequently asked questions.</A></P><P>TransLink is committed to protecting your privacy. View the <em>go</em> card <a href="http://www.translink.com.au/privacy_go.php" target="_blank">privacy statement</A> for more information.</P>
|
139
|
+
</div>
|
140
|
+
</div>
|
141
|
+
</td>
|
142
|
+
</tr>
|
143
|
+
</table>
|
144
|
+
</div>
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
<!-- FOOTER -->
|
151
|
+
<div class="footer_table">
|
152
|
+
<span id="contactText" style="visibility: visible;">
|
153
|
+
<span id="contact1">
|
154
|
+
<a id="crLink" href="http://www.translink.com.au/copyright_go.php" target="_blank">Copyright</a> |
|
155
|
+
<a id="diLink" href="http://www.translink.com.au/disclaimer.php" target="_blank">Disclaimer</a> |
|
156
|
+
<a id="prLink" href="http://www.translink.com.au/privacy_go.php" target="_blank">Privacy</a> |
|
157
|
+
<a id="otLink" href="http://www.qld.gov.au/languages" target="_blank">Other languages</a><br/>
|
158
|
+
</span>
|
159
|
+
<span id="contact2">
|
160
|
+
|
161
|
+
</span>
|
162
|
+
</span>
|
163
|
+
</div>
|
164
|
+
</div>
|
165
|
+
</div>
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
<script type="text/javascript">
|
173
|
+
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
174
|
+
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
175
|
+
</script>
|
176
|
+
<script type="text/javascript">
|
177
|
+
try {
|
178
|
+
var pageTracker = _gat._getTracker("UA-12682799-1");
|
179
|
+
pageTracker._setDomainName(".seqits.com.au");
|
180
|
+
pageTracker._trackPageview();
|
181
|
+
} catch(err) {}</script>
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
</body>
|
189
|
+
</html>
|
190
|
+
|
@@ -0,0 +1,328 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Content-Type: text/html; charset=iso-8859-1
|
3
|
+
|
4
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
<html>
|
15
|
+
<head>
|
16
|
+
|
17
|
+
<link rel="icon" type="image/x-icon" href="/webtix/media/favicon.ico" />
|
18
|
+
<link rel="shortcut icon" type="image/x-icon" href="/webtix/media/favicon.ico" />
|
19
|
+
|
20
|
+
<title>TransLink - my go card</title>
|
21
|
+
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
|
22
|
+
|
23
|
+
<meta http-equiv="Refresh" content="900;url=https://www.seqits.com.au:443/webtix/welcome/welcome.do?logout=true"/>
|
24
|
+
|
25
|
+
|
26
|
+
<link rel="stylesheet" type="text/css" href="/webtix/css/my_styles.css?version=1259037761000"/>
|
27
|
+
<script type="text/javascript" src="/webtix/script/common.js?version=1259037761000"></script>
|
28
|
+
</head>
|
29
|
+
|
30
|
+
<body onload="init()" onunload="loadCookie();">
|
31
|
+
<map name="headerImgMap">
|
32
|
+
<area href="http://www.translink.com.au"
|
33
|
+
title="TransLink"
|
34
|
+
shape="rect"
|
35
|
+
coords="20,25,220,64"/>
|
36
|
+
</map>
|
37
|
+
|
38
|
+
<div class="mainTable">
|
39
|
+
<div><img id="headerImage" src="/webtix/media/banner.jpg" usemap="#headerImgMap" title="go card banner"/></div>
|
40
|
+
|
41
|
+
<!-- BODY -->
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
<script type="text/javascript">
|
51
|
+
var reload_info_text = 'The top-up amounts listed have been processed and will be downloaded to your card within 48 hours. You must touch on within 60 days from the transaction date, or the top-up amount will be cancelled.';
|
52
|
+
var recurringReload_info_text = 'The amount shown will be transferred from your nominated account to your card when your card balance reaches $5.00.';
|
53
|
+
|
54
|
+
function topUpRemoveButtonClicked(thrAutoId) {
|
55
|
+
var agree = confirm('Are you sure you want to remove this auto top-up?', 'Removal Confirmation');
|
56
|
+
if (agree == false) {
|
57
|
+
return false;
|
58
|
+
}
|
59
|
+
window.location = 'modifyCard.do?modifyAction=removeThresholdAutoload&thrAutoId='+thrAutoId;
|
60
|
+
}
|
61
|
+
|
62
|
+
function topUpUpdateButtonClicked(removeButtonId) {
|
63
|
+
document.getElementById('topUpUpdateButton').style.display = 'none';
|
64
|
+
document.getElementById('topUpUpdateInputButtons').style.display = '';
|
65
|
+
document.getElementById(removeButtonId).style.display = 'none';
|
66
|
+
document.getElementById('msg_zone').innerHTML = '';
|
67
|
+
|
68
|
+
|
69
|
+
document.getElementById('thresholdAutoloadUpdateValueId').style.background = 'white';
|
70
|
+
document.getElementById('thresholdAutoloadUpdateValueId').focus();
|
71
|
+
|
72
|
+
}
|
73
|
+
|
74
|
+
function topUpUpdateInputButtonsCancelClicked(removeButtonId) {
|
75
|
+
document.getElementById('topUpUpdateButton').style.display = '';
|
76
|
+
document.getElementById('topUpUpdateInputButtons').style.display = 'none';
|
77
|
+
document.getElementById(removeButtonId).style.display = '';
|
78
|
+
|
79
|
+
|
80
|
+
document.getElementById('thresholdAutoloadUpdateValueId').value = '';
|
81
|
+
|
82
|
+
}
|
83
|
+
|
84
|
+
function topUpUpdateInputButtonsUpdateClicked(form) {
|
85
|
+
var valid = validate();
|
86
|
+
|
87
|
+
if (valid == false) {
|
88
|
+
return false;
|
89
|
+
}
|
90
|
+
|
91
|
+
document.getElementById('msg_zone').innerHTML = '';
|
92
|
+
form.submit();
|
93
|
+
}
|
94
|
+
</script>
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
<div class="mc_summary_page">
|
100
|
+
<div id="top_nav_bar">
|
101
|
+
<span id="navText">Summary of my card</span>
|
102
|
+
<span id="logoutText" style="visibility: visible;"><a href="../welcome/welcome.do?logout=true" class="link_btn">Logout</a></span>
|
103
|
+
</div>
|
104
|
+
|
105
|
+
|
106
|
+
<div class="NavSpacer"><span class="boldFont"><b><i>go</i></b> card number:</span> 0160 1234 1234 1234</div>
|
107
|
+
<div class="listBG">
|
108
|
+
<ul id="nav">
|
109
|
+
<li id="current">
|
110
|
+
<a href="../cardinfo/summary.do">Summary</a></li>
|
111
|
+
<li id="nav2">
|
112
|
+
<a href="../cardinfo/history.do">History</a></li>
|
113
|
+
<li id="nav4">
|
114
|
+
<a href="../cardinfo/updateContactInfoDisplay.do?ciTab=true">Contact Info</a></li>
|
115
|
+
<li id="nav5">
|
116
|
+
<a href="../cardinfo/updateBillingInfoDisplay.do">Billing Account</a></li>
|
117
|
+
</ul>
|
118
|
+
</div>
|
119
|
+
<div class="content_table">
|
120
|
+
|
121
|
+
|
122
|
+
<div id="contentWell">
|
123
|
+
<table width="720">
|
124
|
+
<tr>
|
125
|
+
<td align="right" class="boldFont">Passenger Type:</td>
|
126
|
+
<td width="40%">Adult</td>
|
127
|
+
<td align="right" class="boldFont">Issued Date:</td>
|
128
|
+
<td>30-Mar-2008</td>
|
129
|
+
</tr>
|
130
|
+
<tr>
|
131
|
+
<td align="right" class="boldFont">Status:</td>
|
132
|
+
<td width="40%">
|
133
|
+
In-use
|
134
|
+
</td>
|
135
|
+
<td align="right" class="boldFont">Expiry Date:</td>
|
136
|
+
|
137
|
+
|
138
|
+
<td >
|
139
|
+
30-Mar-2018
|
140
|
+
</td>
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
</tr>
|
145
|
+
</table>
|
146
|
+
|
147
|
+
<div id="state_info"></div>
|
148
|
+
<table cellpadding="0" cellspacing="0">
|
149
|
+
<tr>
|
150
|
+
<td class="scroll_pane">
|
151
|
+
<table width="720" cellspacing="1" class="results_table">
|
152
|
+
<tr>
|
153
|
+
<th width="50%">As Of</th>
|
154
|
+
<th>Card Balance</th>
|
155
|
+
</tr>
|
156
|
+
<tr>
|
157
|
+
<td>02-Mar-10 07:49:01 AM</td>
|
158
|
+
<td>$24.63</td>
|
159
|
+
</tr>
|
160
|
+
</table>
|
161
|
+
</td>
|
162
|
+
</tr>
|
163
|
+
</table>
|
164
|
+
|
165
|
+
<br />
|
166
|
+
<table>
|
167
|
+
<tr>
|
168
|
+
<td class="boldFont">
|
169
|
+
Pending top-up Amounts
|
170
|
+
<img src="../media/info_small.gif" alt="info"
|
171
|
+
onmouseover="area=document.getElementById('reload_info');area.innerHTML=reload_info_text; area.className='info_section';"
|
172
|
+
onmouseout="area=document.getElementById('reload_info');area.innerHTML='';area.className='';" />
|
173
|
+
</td>
|
174
|
+
</tr>
|
175
|
+
<tr>
|
176
|
+
<td id="reload_info"></td>
|
177
|
+
</tr>
|
178
|
+
<tr>
|
179
|
+
<td class="scroll_pane" width="720">
|
180
|
+
<table id="resultsTable1_1" cellspacing="1" width="100%" class="results_table">
|
181
|
+
<tr>
|
182
|
+
<th width="30%">Transaction Date</th>
|
183
|
+
<th width="20%">Action</th>
|
184
|
+
<th width="30%">Top-up amount</th>
|
185
|
+
<th width="20%">Expires</th>
|
186
|
+
</tr>
|
187
|
+
</table>
|
188
|
+
|
189
|
+
<table id="resultsTable1_2" cellspacing="0" cellpadding="0" width="100%">
|
190
|
+
<tr>
|
191
|
+
<td id="reloads_info"></td>
|
192
|
+
</tr>
|
193
|
+
</table>
|
194
|
+
|
195
|
+
<div id="resultsDiv1" style="width: 100%; overflow: auto">
|
196
|
+
<table id="resultsTable1_3" cellspacing="1" width="100%" class="results_table">
|
197
|
+
|
198
|
+
</table>
|
199
|
+
</div>
|
200
|
+
</td>
|
201
|
+
</tr>
|
202
|
+
</table>
|
203
|
+
|
204
|
+
<br />
|
205
|
+
<table>
|
206
|
+
<tr>
|
207
|
+
<td class="boldFont">
|
208
|
+
Auto top-up
|
209
|
+
<img src="../media/info_small.gif" alt="info"
|
210
|
+
onmouseover="area=document.getElementById('recurringReload_info');area.innerHTML=recurringReload_info_text;area.className='info_section';"
|
211
|
+
onmouseout="area=document.getElementById('recurringReload_info');area.innerHTML='';area.className='';" />
|
212
|
+
</td>
|
213
|
+
</tr>
|
214
|
+
<tr>
|
215
|
+
<td id="recurringReload_info"></td>
|
216
|
+
</tr>
|
217
|
+
<tr>
|
218
|
+
<td class="scroll_pane" width="720">
|
219
|
+
<table id="resultsTable2_1" cellspacing="1" width="100%" class="results_table">
|
220
|
+
<tr>
|
221
|
+
<th width="20%">Effective Date</th>
|
222
|
+
<th width="20%">Status <img src="../media/info_small.gif" alt="info" onmouseover="area=document.getElementById('reloads_info1');area.innerHTML='<i>Processing Pending</i>: Your auto top-up request is being processed<br /><i>Pending</i>: An auto top-up request is being processed<br /><i>Active</i>: Auto top-up on your <b><i>go</i></b> card has been activated<br /><i>Remove Pending</i>: Your request to remove auto top-up is being processed<br /><i>Remove Pending (Expired)</i>: Your request to remove auto top-up has expired. Try again.<br /><i>';area.className='info_section';" onmouseout="area=document.getElementById('reloads_info1');area.innerHTML='';area.className='';" /></th>
|
223
|
+
<th width="20%">Top-up amount</th>
|
224
|
+
<th width="40%">Action <img src="../media/info_small.gif" alt="info" onmouseover="area=document.getElementById('reloads_info1');area.innerHTML='<i>Remove</i>: Cancel auto top-up.<br/> <i>Update Value</i>: Change your auto top-up amount.';area.className='info_section';" onmouseout="area=document.getElementById('reloads_info1');area.innerHTML='';area.className='';" /></th>
|
225
|
+
</tr>
|
226
|
+
</table>
|
227
|
+
|
228
|
+
<table id="resultsTable2_2" cellspacing="0" cellpadding="0" width="100%">
|
229
|
+
<tr>
|
230
|
+
<td id="reloads_info1"></td>
|
231
|
+
</tr>
|
232
|
+
</table>
|
233
|
+
|
234
|
+
<div id="resultsDiv2" style="width: 100%; overflow: auto">
|
235
|
+
<table id="resultsTable2_3" cellspacing="1" width="100%" class="results_table">
|
236
|
+
|
237
|
+
</table>
|
238
|
+
</div>
|
239
|
+
</td>
|
240
|
+
</tr>
|
241
|
+
</table>
|
242
|
+
|
243
|
+
<div class="info_section" style="margin-bottom: 3px; margin-top: 15px; width: 710px;">
|
244
|
+
<img src="../media/info.gif" alt="info" />
|
245
|
+
Funds added to your <b><i>go</i></b> card using the online 'Top-up' facility may take up to 24 hours to appear on your account summary.
|
246
|
+
<span id="view_txn_hist_msg">To view your transaction history click on the History tab.</span>
|
247
|
+
</div>
|
248
|
+
</div>
|
249
|
+
|
250
|
+
</div>
|
251
|
+
|
252
|
+
<script type="text/javascript">
|
253
|
+
setTableHeight(1);
|
254
|
+
setTableHeight(2);
|
255
|
+
|
256
|
+
function setTableHeight(id) {
|
257
|
+
if (getNumRows('resultsDiv'+id) > 4) {
|
258
|
+
var height = getHeightOf4Rows('resultsDiv'+id);
|
259
|
+
var adjusted = setMaxHeight('resultsDiv'+id, height+2);
|
260
|
+
if (adjusted) {
|
261
|
+
document.getElementById('resultsTable'+id+'_1').style.width = '700px';
|
262
|
+
document.getElementById('resultsTable'+id+'_2').style.width = '700px';
|
263
|
+
document.getElementById('resultsTable'+id+'_3').style.width = '700px';
|
264
|
+
}
|
265
|
+
}
|
266
|
+
}
|
267
|
+
|
268
|
+
function getNumRows(divId) {
|
269
|
+
var div = document.getElementById(divId);
|
270
|
+
var tr = div.getElementsByTagName('tr');
|
271
|
+
if (!tr) {
|
272
|
+
return 0;
|
273
|
+
}
|
274
|
+
return tr.length;
|
275
|
+
}
|
276
|
+
|
277
|
+
function getHeightOf4Rows(divId) {
|
278
|
+
var div = document.getElementById(divId);
|
279
|
+
var table = div.getElementsByTagName('table');
|
280
|
+
var tr = div.getElementsByTagName('tr');
|
281
|
+
var offsets = getElementOffsets(tr[4], table[0]);
|
282
|
+
return offsets["top"];
|
283
|
+
}
|
284
|
+
</script>
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
<!-- FOOTER -->
|
289
|
+
<div class="footer_table">
|
290
|
+
<span id="contactText" style="visibility: visible;">
|
291
|
+
<span id="contact1">
|
292
|
+
<a id="crLink" href="http://www.translink.com.au/copyright_go.php" target="_blank">Copyright</a> |
|
293
|
+
<a id="diLink" href="http://www.translink.com.au/disclaimer.php" target="_blank">Disclaimer</a> |
|
294
|
+
<a id="prLink" href="http://www.translink.com.au/privacy_go.php" target="_blank">Privacy</a> |
|
295
|
+
<a id="otLink" href="http://www.qld.gov.au/languages" target="_blank">Other languages</a><br/>
|
296
|
+
</span>
|
297
|
+
<span id="contact2">
|
298
|
+
|
299
|
+
</span>
|
300
|
+
</span>
|
301
|
+
</div>
|
302
|
+
</div>
|
303
|
+
</div>
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
<script type="text/javascript">
|
311
|
+
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
312
|
+
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
313
|
+
</script>
|
314
|
+
<script type="text/javascript">
|
315
|
+
try {
|
316
|
+
var pageTracker = _gat._getTracker("UA-12682799-1");
|
317
|
+
pageTracker._setDomainName(".seqits.com.au");
|
318
|
+
pageTracker._trackPageview();
|
319
|
+
} catch(err) {}</script>
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
</body>
|
327
|
+
</html>
|
328
|
+
|
data/spec/usage_period_spec.rb
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe IspUsage::UsagePeriod do
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
describe "should return hash for usage period" do
|
5
|
+
it "should describe a meter" do
|
6
|
+
@usage_period = IspUsage::UsagePeriod.new(:quota => 1000, :used => 500, :label => 'All Day', :type => :meter)
|
7
|
+
@usage_period.to_hash.should == {:quota => 1000, :used => 500, :total => 1000, :label => 'All Day', :type => :meter}
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should describe a balance" do
|
11
|
+
@usage_period = IspUsage::UsagePeriod.new(:used => 500, :label => 'Freezone', :type => :balance)
|
12
|
+
@usage_period.to_hash.should == {:used => 500, :label => 'Freezone', :type => :balance}
|
13
|
+
end
|
7
14
|
end
|
8
15
|
|
9
16
|
describe "calculate totals" do
|
@@ -16,5 +23,52 @@ describe IspUsage::UsagePeriod do
|
|
16
23
|
@usage_period = IspUsage::UsagePeriod.new(:quota => 1000, :used => 1500)
|
17
24
|
@usage_period.total.should == 1500
|
18
25
|
end
|
26
|
+
|
27
|
+
it "when its a balance" do
|
28
|
+
@usage_period = IspUsage::UsagePeriod.new(:used => 1500, :type => :balance)
|
29
|
+
@usage_period.total.should be_nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "type" do
|
34
|
+
before do
|
35
|
+
@usage_period = IspUsage::UsagePeriod.new(:quota => 500, :used => 250)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should set type correctly in initialize" do
|
39
|
+
usage_period = IspUsage::UsagePeriod.new(:type => :balance)
|
40
|
+
usage_period.type.should == :balance
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should default to meter" do
|
44
|
+
@usage_period.type.should == :meter
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should allow balance type" do
|
48
|
+
lambda{@usage_period.type = :balance}.should_not raise_error
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should allow meter type" do
|
52
|
+
lambda{@usage_period.type = :meter}.should_not raise_error
|
53
|
+
end
|
54
|
+
|
55
|
+
it "shouldn't allow nil" do
|
56
|
+
lambda{@usage_period.type = nil}.should raise_error(IspUsage::InvalidUsagePeriodType)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "shouldn't allow a non valid entry" do
|
60
|
+
lambda{@usage_period.type = :blah}.should raise_error(IspUsage::InvalidUsagePeriodType)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should set type meter correct in to_hash" do
|
64
|
+
@usage_period.type = :meter
|
65
|
+
@usage_period.to_hash[:type].should == :meter
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should set type meter correct in to_hash" do
|
69
|
+
@usage_period.type = :balance
|
70
|
+
@usage_period.to_hash[:type].should == :balance
|
71
|
+
end
|
72
|
+
|
19
73
|
end
|
20
74
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ispusage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alan Harper
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-03-05 00:00:00 +10:00
|
13
13
|
default_executable: ispusage
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -73,12 +73,14 @@ files:
|
|
73
73
|
- lib/ispusage/fetchers.rb
|
74
74
|
- lib/ispusage/fetchers/au_optus.rb
|
75
75
|
- lib/ispusage/fetchers/au_three.rb
|
76
|
+
- lib/ispusage/fetchers/au_translink.rb
|
76
77
|
- lib/ispusage/fetchers/fetcher.rb
|
77
78
|
- lib/ispusage/fetchers/iinet.rb
|
78
79
|
- lib/ispusage/fetchers/internode.rb
|
79
80
|
- lib/ispusage/usage_period.rb
|
80
81
|
- spec/fetchers/au_optus_spec.rb
|
81
82
|
- spec/fetchers/au_three_spec.rb
|
83
|
+
- spec/fetchers/au_translink_spec.rb
|
82
84
|
- spec/fetchers/fetcher_spec.rb
|
83
85
|
- spec/fetchers/iinet_spec.rb
|
84
86
|
- spec/fetchers/internode_spec.rb
|
@@ -92,6 +94,8 @@ files:
|
|
92
94
|
- spec/fixtures/au_three/pin.html
|
93
95
|
- spec/fixtures/au_three/signon.html
|
94
96
|
- spec/fixtures/au_three/usage.html
|
97
|
+
- spec/fixtures/au_translink/logon.html
|
98
|
+
- spec/fixtures/au_translink/summary.html
|
95
99
|
- spec/ispusage_spec.rb
|
96
100
|
- spec/spec.opts
|
97
101
|
- spec/spec_helper.rb
|
@@ -127,6 +131,7 @@ summary: Fetch ISP quota Usage
|
|
127
131
|
test_files:
|
128
132
|
- spec/fetchers/au_optus_spec.rb
|
129
133
|
- spec/fetchers/au_three_spec.rb
|
134
|
+
- spec/fetchers/au_translink_spec.rb
|
130
135
|
- spec/fetchers/fetcher_spec.rb
|
131
136
|
- spec/fetchers/iinet_spec.rb
|
132
137
|
- spec/fetchers/internode_spec.rb
|