teliaxr 0.0.1

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/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ === 0.0.1 2009-10-23
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/Manifest.txt ADDED
@@ -0,0 +1,11 @@
1
+ History.txt
2
+ Manifest.txt
3
+ PostInstall.txt
4
+ README.rdoc
5
+ Rakefile
6
+ lib/teliaxr.rb
7
+ script/console
8
+ script/destroy
9
+ script/generate
10
+ test/test_helper.rb
11
+ test/test_teliaxr.rb
data/PostInstall.txt ADDED
@@ -0,0 +1,5 @@
1
+
2
+ For more information on teliaxr, see http://teliaxr.rubyforge.org
3
+
4
+
5
+
data/README.rdoc ADDED
@@ -0,0 +1,60 @@
1
+ = teliaxr
2
+
3
+ * http://github.com/renemendoza/teliaxr
4
+
5
+ == DESCRIPTION:
6
+
7
+ Unofficial ruby api to Teliax Dashboard, it will one day allow you to manage your teliax acct from
8
+
9
+
10
+ == FEATURES/PROBLEMS:
11
+ It doesnt do much at the time
12
+
13
+ Can login to your teliax account and list your numbers
14
+
15
+ Since it is unofficial and it relies on scrapping Teliax web sites it may broke if they change their website. YMMV
16
+
17
+
18
+ == SYNOPSIS:
19
+
20
+ teliax = Teliaxr::API.new(username, password)
21
+ teliax.login
22
+ teliax.numbers
23
+ teliax.numbers_list
24
+ 1234567890
25
+ 1234567891
26
+ 1234567892
27
+
28
+ == REQUIREMENTS:
29
+
30
+ mechanize 0.9.3
31
+ nokogiri
32
+
33
+ == INSTALL:
34
+
35
+ sudo gem install teliaxr
36
+
37
+ == LICENSE:
38
+
39
+ (The MIT License)
40
+
41
+ Copyright (c) 2009 Rene Mendoza
42
+
43
+ Permission is hereby granted, free of charge, to any person obtaining
44
+ a copy of this software and associated documentation files (the
45
+ 'Software'), to deal in the Software without restriction, including
46
+ without limitation the rights to use, copy, modify, merge, publish,
47
+ distribute, sublicense, and/or sell copies of the Software, and to
48
+ permit persons to whom the Software is furnished to do so, subject to
49
+ the following conditions:
50
+
51
+ The above copyright notice and this permission notice shall be
52
+ included in all copies or substantial portions of the Software.
53
+
54
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
55
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
56
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
57
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
58
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
59
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
60
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/teliaxr'
6
+
7
+ Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ # Hoe.plugin :cucumberfeatures
10
+
11
+ # Generate all the Rake tasks
12
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
+ $hoe = Hoe.spec 'teliaxr' do
14
+ self.developer 'Rene Mendoza', 'latiendamac@gmail.com'
15
+ self.post_install_message = 'Teliaxr' # TODO remove if post-install message not required
16
+ self.rubyforge_name = self.name # TODO this is default value
17
+ self.extra_deps = [['mechanize','>= 0.9.3']]
18
+
19
+ end
20
+
21
+ require 'newgem/tasks'
22
+ Dir['tasks/**/*.rake'].each { |t| load t }
23
+
24
+ # TODO - want other tests/tasks run by default? Add them to the list
25
+ # remove_task :default
26
+ # task :default => [:spec, :features]
data/lib/teliaxr.rb ADDED
@@ -0,0 +1,56 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ module Teliaxr
5
+ VERSION = '0.0.1'
6
+ require 'rubygems'
7
+ I_KNOW_I_AM_USING_AN_OLD_AND_BUGGY_VERSION_OF_LIBXML2=1
8
+ require 'mechanize'
9
+ require 'nokogiri'
10
+
11
+ class API
12
+ attr_reader :page
13
+ def initialize(username, password, url=nil)
14
+ @username = username
15
+ @password = password
16
+ @url = url
17
+ @url ||= "https://www.teliax.com"
18
+ @agent = WWW::Mechanize.new
19
+ get_main_page
20
+ end
21
+
22
+ def get_main_page
23
+ @page = @agent.get @url
24
+ end
25
+
26
+ def login
27
+ form = @page.forms.first
28
+ form['login'] = @username
29
+ form['password'] = @password
30
+ form.submit
31
+ @page = form.submit
32
+
33
+ end
34
+
35
+ def numbers
36
+ @page = @agent.click( @page.links.select {|l| l.text =~/Numbers/}.first )
37
+ end
38
+
39
+ def numbers_list
40
+ @page.search('div#site_content_container_center table tbody tr').each do |tr|
41
+ tr.search('td:nth-child(1)').each do |td|
42
+ puts td.content
43
+ end
44
+ end
45
+ end
46
+
47
+ def get_menu_links
48
+ @page.search('div#site_left_nav_content div').each do |nav|
49
+ nav.search('ul li a').each do |link|
50
+ puts link.content
51
+ end
52
+ end
53
+ end
54
+
55
+ end
56
+ end
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/teliaxr.rb'}"
9
+ puts "Loading teliaxr gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,3 @@
1
+ require 'stringio'
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/../lib/teliaxr'
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestTeliaxr < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def test_truth
9
+ assert true
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: teliaxr
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Rene Mendoza
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-23 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: mechanize
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.9.3
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: hoe
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.3.3
34
+ version:
35
+ description: Unofficial ruby api to Teliax Dashboard, it will one day allow you to manage your teliax acct from
36
+ email:
37
+ - latiendamac@gmail.com
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files:
43
+ - History.txt
44
+ - Manifest.txt
45
+ - PostInstall.txt
46
+ files:
47
+ - History.txt
48
+ - Manifest.txt
49
+ - PostInstall.txt
50
+ - README.rdoc
51
+ - Rakefile
52
+ - lib/teliaxr.rb
53
+ - script/console
54
+ - script/destroy
55
+ - script/generate
56
+ - test/test_helper.rb
57
+ - test/test_teliaxr.rb
58
+ has_rdoc: true
59
+ homepage: http://github.com/renemendoza/teliaxr
60
+ licenses: []
61
+
62
+ post_install_message: Teliaxr
63
+ rdoc_options:
64
+ - --main
65
+ - README.rdoc
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ version:
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ version:
80
+ requirements: []
81
+
82
+ rubyforge_project: teliaxr
83
+ rubygems_version: 1.3.3
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Unofficial ruby api to Teliax Dashboard, it will one day allow you to manage your teliax acct from
87
+ test_files:
88
+ - test/test_helper.rb
89
+ - test/test_teliaxr.rb