Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added `highline/import`. (Vic's suggestion)

  • Loading branch information...
commit 732eea7080d323ecdc50e8f36e16fe61256e1154 1 parent 8075fe0
@ashbb authored
View
18 Countries/all_courses.rb
@@ -3,11 +3,15 @@
require 'hpricot'
require 'mechanize'
+require 'highline/import'
-courses = %W(FORPC101-10C FORPC101-9C POIRPTDDC101-1I POIRPWMC101-2I
- POIRPWSC101-3I FORPC101-3 FORPC101-4 FORPC101-5C FORPC101-6C
- FORPC101-7C FORPC101-8C POIRPC101-1I POIRPWDC101-1I POIRPWMC101-1I
- POIRPWSC101-1I POIRPWSC101-2I POJRPC101-1) << 'Teachers Lounge'
+courses = %W(FOFXR101-1I FOGGHC101-3L FORPC101-10C
+ FORPC101-11C FORPC101-12C FOUTWRC101-1I POIRPWMC101-3I
+ POIRPWSC101-3I POIRPWSC101-4I POIRPWSC101-4I POIRSC101-1I
+ FOGGHC101-1L FOGGHC101-2L FORPC101-3 FORPC101-4
+ FORPC101-5C FORPC101-6C FORPC101-7C FORPC101-8C
+ FORPC101-9C POIRPWMC101-1I POIRPWMC101-2I
+ POIRPWSC101-1I POIRPWSC101-2I) << 'Teachers Lounge'
lists, countries, htmls = [], [], []
@@ -17,11 +21,11 @@
login_page = agent.get("http://rubylearning.org/class/login/index.php")
login_form = login_page.forms.first
-login_form['username'] = "your username"
-login_form['password'] = "your password"
+login_form['username'] = ask('Username: '){|q|q.echo = true}
+login_form['password'] = ask('Password: '){|q|q.echo = '*'}
agent.submit(login_form)
-main_page = agent.get('http://rubylearning.org/class/course/index.php')
+main_page = agent.get('http://rubylearning.org/class/')
courses.each do |course|
course_link = main_page.link_with(:text => course)
View
5 Countries/ruby_launcher.rb
@@ -3,14 +3,15 @@
# Mechanize compliant version: 0.9.0
require 'mechanize'
+require 'highline/import'
agent = WWW::Mechanize.new
login_page = agent.get("http://rubylearning.org/class/login/index.php")
login_form = login_page.forms.first
-login_form['username'] = "your username"
-login_form['password'] = "your password"
+login_form['username'] = ask('Username: '){|q|q.echo = true}
+login_form['password'] = ask('Password: '){|q|q.echo = '*'}
main_page = agent.submit(login_form)
#course_link = main_page.links.text(ARGV[0].upcase)
View
20 Countries/ruby_launcher2.rb
@@ -2,11 +2,15 @@
# Mechanize compliant version: 0.9.0
require 'mechanize'
+require 'highline/import'
-courses = %W(FORPC101-10C FORPC101-9C POIRPTDDC101-1I POIRPWMC101-2I
- POIRPWSC101-3I FORPC101-3 FORPC101-4 FORPC101-5C FORPC101-6C
- FORPC101-7C FORPC101-8C POIRPC101-1I POIRPWDC101-1I POIRPWMC101-1I
- POIRPWSC101-1I POIRPWSC101-2I POJRPC101-1) << 'Teachers Lounge'
+courses = %W(FOFXR101-1I FOGGHC101-3L FORPC101-10C
+ FORPC101-11C FORPC101-12C FOUTWRC101-1I POIRPWMC101-3I
+ POIRPWSC101-3I POIRPWSC101-4I POIRPWSC101-4I POIRSC101-1I
+ FOGGHC101-1L FOGGHC101-2L FORPC101-3 FORPC101-4
+ FORPC101-5C FORPC101-6C FORPC101-7C FORPC101-8C
+ FORPC101-9C POIRPWMC101-1I POIRPWMC101-2I
+ POIRPWSC101-1I POIRPWSC101-2I) << 'Teachers Lounge'
agent = WWW::Mechanize.new
#agent.set_proxy('proxy server name', 'port', 'userid', 'password')
@@ -14,11 +18,11 @@
login_page = agent.get("http://rubylearning.org/class/login/index.php")
login_form = login_page.forms.first
-login_form['username'] = "your username"
-login_form['password'] = "your password"
+login_form['username'] = ask('Username: '){|q|q.echo = true}
+login_form['password'] = ask('Password: '){|q|q.echo = '*'}
agent.submit(login_form)
-main_page = agent.get('http://rubylearning.org/class/course/index.php')
+main_page = agent.get('http://rubylearning.org/class/')
courses.each do |course|
course_link = main_page.link_with(:text => course)
@@ -35,4 +39,4 @@
open(course + '.html', 'w'){|f| f.puts show_all_page.body}
end
-%x(ruby shoes_all_courses.rb)
+%x(ruby shoes_all_courses.rb)
View
11 Countries/shoes_all_courses.rb
@@ -4,10 +4,13 @@
require 'hpricot'
-courses = %W(FORPC101-10C FORPC101-9C POIRPTDDC101-1I POIRPWMC101-2I
- POIRPWSC101-3I FORPC101-3 FORPC101-4 FORPC101-5C FORPC101-6C
- FORPC101-7C FORPC101-8C POIRPC101-1I POIRPWDC101-1I POIRPWMC101-1I
- POIRPWSC101-1I POIRPWSC101-2I POJRPC101-1) << 'Teachers Lounge'
+courses = %W(FOFXR101-1I FOGGHC101-3L FORPC101-10C
+ FORPC101-11C FORPC101-12C FOUTWRC101-1I POIRPWMC101-3I
+ POIRPWSC101-3I POIRPWSC101-4I POIRPWSC101-4I POIRSC101-1I
+ FOGGHC101-1L FOGGHC101-2L FORPC101-3 FORPC101-4
+ FORPC101-5C FORPC101-6C FORPC101-7C FORPC101-8C
+ FORPC101-9C POIRPWMC101-1I POIRPWMC101-2I
+ POIRPWSC101-1I POIRPWSC101-2I) << 'Teachers Lounge'
list, countries = [], []
View
9 README.txt
@@ -12,15 +12,11 @@ Requirement:
gem install mechanize
Usage:
-- replace your username and password
- + line 12 and 13 of ruby_launcher.rb
- + line 17 and 18 of ruby_launcher2.rb
- + line 20 and 21 of all_courses.rb
- select the courses
+ ruby_launcher.rb : give it as an argument
- + ruby_launcher2.rb : edit line 6, 7, 8, 9
- + all_courses.rb : edit line 7, 8, 9, 10
+ + ruby_launcher2.rb : edit line 7-13
+ + all_courses.rb : edit line 8-14
- run the Ruby program
+ C:\> ruby ruby_launcher.rb <course name>
@@ -28,6 +24,7 @@ Usage:
+ C:\> ruby all_courses.rb
Change log:
+06th Apr: Added `highline/import`. (Vic's suggestion)
25th Feb: Fixed a few typos
12th Feb: Merged RLGGHC's pull-request.
28th Jan: Added two new tools, ruby_launcher2.rb and all_courses.rb, which output a total of all courses.
Please sign in to comment.
Something went wrong with that request. Please try again.