rubyuw 0.99.15 → 0.99.16

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,3 +2,5 @@ pkg/*
2
2
  test/password.rb
3
3
  .yardoc
4
4
  doc/*
5
+ test.rb
6
+ .bundle/*
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem "rake"
7
+ gem "jeweler", "1.4.0"
8
+ end
@@ -0,0 +1,31 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rubyuw (0.99.16)
5
+ mechanize (>= 0.9.3)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ gemcutter (0.6.1)
11
+ git (1.2.5)
12
+ jeweler (1.4.0)
13
+ gemcutter (>= 0.1.0)
14
+ git (>= 1.2.5)
15
+ rubyforge (>= 2.0.0)
16
+ json_pure (1.4.6)
17
+ mechanize (1.0.0)
18
+ nokogiri (>= 1.2.1)
19
+ nokogiri (1.4.3.1)
20
+ rake (0.8.7)
21
+ rubyforge (2.0.4)
22
+ json_pure (>= 1.1.7)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ jeweler (= 1.4.0)
29
+ mechanize (>= 0.9.3)
30
+ rake
31
+ rubyuw!
data/Rakefile CHANGED
@@ -1,3 +1,6 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+
1
4
  begin
2
5
  require 'jeweler'
3
6
  Jeweler::Tasks.new do |gemspec|
@@ -42,4 +45,4 @@ namespace :test do
42
45
  task :run_live do
43
46
  run_tests(Dir[File.join(File.dirname(__FILE__), 'test', 'live', '**', '*.rb')])
44
47
  end
45
- end
48
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.99.15
1
+ 0.99.16
@@ -18,7 +18,7 @@ module RubyUW
18
18
  # See allow_concurrency=
19
19
  @@allow_concurrency = false
20
20
 
21
- class <<self
21
+ class << self
22
22
  # Authenticate with MyUW. This method sets up and verifies
23
23
  # a session with MyUW. Every feature of RubyUW which requires
24
24
  # authentication (as of writing this documentation this is
@@ -152,4 +152,4 @@ module RubyUW
152
152
  end
153
153
  end
154
154
  end
155
- end
155
+ end
@@ -19,7 +19,7 @@ module RubyUW
19
19
  # the array access notation common to ruby. This access returns
20
20
  # a {RubyUW::SLN} object.
21
21
  class CurriculumEnrollment
22
- class <<self
22
+ class << self
23
23
  # Pulls data about a specific curriculum. The SLN data is pulled
24
24
  # directly from the MyUW curriculum information page. Authentication
25
25
  # is required prior to use.
@@ -29,47 +29,57 @@ module RubyUW
29
29
  def find(curriculum, term)
30
30
  raise Errors::NotLoggedInError.new unless Base.authenticated?
31
31
 
32
- page = Base.connection.get("https://sdb.admin.washington.edu/timeschd/uwnetid/tsstat.asp?QTRYR=#{term}&CURRIC=#{curriculum}")
32
+ url = "https://sdb.admin.washington.edu/timeschd/uwnetid/tsstat.asp?QTRYR=#{term}&CURRIC=#{curriculum}"
33
+
34
+ page = Base.connection.get(url)
35
+ if page.form_with(:name => "relay")
36
+ # Strange thing UW began implementing 08/31/2010. This is to
37
+ # get around it.
38
+ page = Base.connection.goto(url).
39
+ submit_form('relay').
40
+ submit_form('relay').execute!
41
+ end
42
+
33
43
  raise Errors::CurriculumDoesNotExistError.new if !curriculum_exists?(page)
34
-
44
+
35
45
  extract_courses(page, term)
36
46
  rescue WWW::Mechanize::ResponseCodeError
37
47
  raise Errors::CurriculumDoesNotExistError.new
38
48
  end
39
-
49
+
40
50
  protected
41
51
 
42
52
  def curriculum_exists?(page)
43
53
  !(page.body.to_s =~ /No sections found for (.+?)/i)
44
54
  end
45
-
55
+
46
56
  def extract_courses(page, term)
47
57
  course_nodes = page.search('//table//tr[count(th)>1 and @bgcolor="#d0d0d0"]//following-sibling::tr')
48
-
58
+
49
59
  results = {}
50
- course_nodes.each { |node|
60
+ course_nodes.each { |node|
51
61
  sln, data = extract_course(node)
52
62
  results[sln] = RubyUW::SLN.new(sln, term, data)
53
63
  }
54
-
64
+
55
65
  results
56
66
  end
57
-
67
+
58
68
  def extract_course(node)
59
69
  data_keys = [:sln, :course, :section, :type, :title, :current_enrollment, :limit_enrollment,
60
70
  :room_capacity, :space_available, nil, :notes]
61
71
 
62
72
  results = Base.extract(node, './/td | .//th', data_keys)
63
73
  results[:sln].gsub!(/^>/, '') # Strips leading '>' off of quiz sections
64
-
74
+
65
75
  [results[:sln], results]
66
76
  end
67
77
  end
68
78
  end
69
-
79
+
70
80
  module Errors
71
81
  # An error indicating that the curriclum requesting does not
72
82
  # exist.
73
83
  class CurriculumDoesNotExistError < Error; end
74
84
  end
75
- end
85
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rubyuw}
8
- s.version = "0.99.15"
8
+ s.version = "0.99.16"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mitchell Hashimoto"]
12
- s.date = %q{2010-04-20}
12
+ s.date = %q{2010-08-31}
13
13
  s.description = %q{Library which provides a ruby interface to the University of Washington student portal.}
14
14
  s.email = %q{mitchell.hashimoto@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -17,6 +17,8 @@ Gem::Specification.new do |s|
17
17
  ]
18
18
  s.files = [
19
19
  ".gitignore",
20
+ "Gemfile",
21
+ "Gemfile.lock",
20
22
  "README.md",
21
23
  "Rakefile",
22
24
  "VERSION",
@@ -76,7 +78,7 @@ Gem::Specification.new do |s|
76
78
  s.homepage = %q{http://github.com/mitchellh/rubyuw}
77
79
  s.rdoc_options = ["--charset=UTF-8"]
78
80
  s.require_paths = ["lib"]
79
- s.rubygems_version = %q{1.3.6}
81
+ s.rubygems_version = %q{1.3.7}
80
82
  s.summary = %q{Library which provides a ruby interface to the University of Washington student portal.}
81
83
  s.test_files = [
82
84
  "test/live/curriculum_enrollment_test.rb",
@@ -97,7 +99,7 @@ Gem::Specification.new do |s|
97
99
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
98
100
  s.specification_version = 3
99
101
 
100
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
102
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
101
103
  s.add_runtime_dependency(%q<mechanize>, [">= 0.9.3"])
102
104
  else
103
105
  s.add_dependency(%q<mechanize>, [">= 0.9.3"])
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyuw
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 435
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 99
8
- - 15
9
- version: 0.99.15
9
+ - 16
10
+ version: 0.99.16
10
11
  platform: ruby
11
12
  authors:
12
13
  - Mitchell Hashimoto
@@ -14,23 +15,25 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-04-20 00:00:00 -07:00
18
+ date: 2010-08-31 00:00:00 -07:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
- name: mechanize
22
+ type: :runtime
22
23
  prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ name: mechanize
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
26
+ none: false
24
27
  requirements:
25
28
  - - ">="
26
29
  - !ruby/object:Gem::Version
30
+ hash: 61
27
31
  segments:
28
32
  - 0
29
33
  - 9
30
34
  - 3
31
35
  version: 0.9.3
32
- type: :runtime
33
- version_requirements: *id001
36
+ requirement: *id001
34
37
  description: Library which provides a ruby interface to the University of Washington student portal.
35
38
  email: mitchell.hashimoto@gmail.com
36
39
  executables: []
@@ -41,6 +44,8 @@ extra_rdoc_files:
41
44
  - README.md
42
45
  files:
43
46
  - .gitignore
47
+ - Gemfile
48
+ - Gemfile.lock
44
49
  - README.md
45
50
  - Rakefile
46
51
  - VERSION
@@ -106,23 +111,27 @@ rdoc_options:
106
111
  require_paths:
107
112
  - lib
108
113
  required_ruby_version: !ruby/object:Gem::Requirement
114
+ none: false
109
115
  requirements:
110
116
  - - ">="
111
117
  - !ruby/object:Gem::Version
118
+ hash: 3
112
119
  segments:
113
120
  - 0
114
121
  version: "0"
115
122
  required_rubygems_version: !ruby/object:Gem::Requirement
123
+ none: false
116
124
  requirements:
117
125
  - - ">="
118
126
  - !ruby/object:Gem::Version
127
+ hash: 3
119
128
  segments:
120
129
  - 0
121
130
  version: "0"
122
131
  requirements: []
123
132
 
124
133
  rubyforge_project:
125
- rubygems_version: 1.3.6
134
+ rubygems_version: 1.3.7
126
135
  signing_key:
127
136
  specification_version: 3
128
137
  summary: Library which provides a ruby interface to the University of Washington student portal.