rubyuw 0.99.13 → 0.99.14

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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/rubyuw/base.rb +21 -21
  3. data/rubyuw.gemspec +3 -3
  4. metadata +20 -9
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.99.13
1
+ 0.99.14
@@ -1,6 +1,6 @@
1
1
  module RubyUW
2
2
  # The base class for RubyUW. As a developer using RubyUW, you'll
3
- # most likely only use this class to authenticate a connection to
3
+ # most likely only use this class to authenticate a connection to
4
4
  # MyUW and to verify the connection.
5
5
  #
6
6
  # The base connection is shared by all other portions of RubyUW.
@@ -14,7 +14,7 @@ module RubyUW
14
14
  # RubyUW::Base.authenticate("uwnetid", "password")
15
15
  class Base
16
16
  @@connection = nil
17
-
17
+
18
18
  # See allow_concurrency=
19
19
  @@allow_concurrency = false
20
20
 
@@ -31,10 +31,10 @@ module RubyUW
31
31
  def authenticate(netid, password)
32
32
  # Clear pre-existing session information first
33
33
  logout
34
-
34
+
35
35
  # Log in
36
36
  results = connection.goto("http://myuw.washington.edu").
37
- verify("//input[@type='submit' and @value='Log in with your UW NetID']").
37
+ verify("//input[@type='submit' and @name='defbut']").
38
38
  submit_form('f').
39
39
  submit_form('relay').
40
40
  submit_form('query', {
@@ -42,14 +42,14 @@ module RubyUW
42
42
  :pass => password
43
43
  }).
44
44
  execute!
45
-
45
+
46
46
  relay_form = results.form_with(:name => 'relay')
47
47
  return false unless results.form_with(:name => 'query').nil?
48
48
  relay_form.submit()
49
-
49
+
50
50
  true
51
51
  end
52
-
52
+
53
53
  # Checks whether authentication is still valid. This method
54
54
  # goes to the MyUW portal and checks to verify that the
55
55
  # previous authentication is valid. If no authentication was
@@ -60,17 +60,17 @@ module RubyUW
60
60
  results = connection.goto("http://myuw.washington.edu").
61
61
  submit_form('f').
62
62
  execute!
63
-
63
+
64
64
  !results.search("//div[@class='main_search']").empty?
65
65
  end
66
-
66
+
67
67
  # Log out from MyUW. This method clears the cookies of the
68
68
  # connection, also cleraing out any session data. This effectively
69
69
  # logs a user out of anything.
70
70
  def logout
71
71
  connection.cookie_jar.clear!
72
72
  end
73
-
73
+
74
74
  # Determines whether RubyUW will be thread-safe. If set to true,
75
75
  # each thread will have its own individual connection object.
76
76
  # This also means that each thread is expected to authenticate
@@ -84,16 +84,16 @@ module RubyUW
84
84
  # already (which you shouldn't), you'll have to reauthenticate.
85
85
  def allow_concurrency=(value)
86
86
  return if @@allow_concurrency == !!value
87
-
87
+
88
88
  # Reset all connections so we don't have any dangling
89
89
  reset_connection!
90
-
90
+
91
91
  # Forcing boolean value
92
92
  @@allow_concurrency = !!value
93
93
  end
94
-
94
+
95
95
  def allow_concurrency; @@allow_concurrency; end
96
-
96
+
97
97
  # Returns the connection object. Used by other portions of RubyUW
98
98
  # to browse the pages, authenticate, and more. This method will
99
99
  # typically *never* be called by non-internal systems.
@@ -107,24 +107,24 @@ module RubyUW
107
107
  # Workaround to avoid frozen object error SSL pages
108
108
  browser.keep_alive = false
109
109
 
110
- # Do not keep any history, which is otherwise a
110
+ # Do not keep any history, which is otherwise a
111
111
  # surefire way to grow memory usage without bound.
112
112
  browser.max_history = 0
113
-
113
+
114
114
  # Force parsing with Nokogiri. Strange bug introduced
115
115
  # in 0.9.3 of WWW::Mechanize defaults to nil.
116
116
  # http://github.com/tenderlove/mechanize/issues#issue/5
117
117
  browser.html_parser = Nokogiri::HTML
118
118
  end
119
119
  end
120
-
120
+
121
121
  # Resets the connection by clearing out the old. This way,
122
122
  # when connection is next called, it will recreate the object.
123
123
  def reset_connection!
124
124
  connection_thread[:connection] = nil
125
125
  self
126
126
  end
127
-
127
+
128
128
  # Runs an xpath on a page, mapping the results to a hash map.
129
129
  # This method should never have to be called outside the core library
130
130
  # code. It is purely a conveniance method supplied to other parts
@@ -140,12 +140,12 @@ module RubyUW
140
140
  break if i >= keys.length
141
141
  data[keys[i]] = node.inner_text.strip.gsub("\302\240", "") unless keys[i].nil?
142
142
  end
143
-
143
+
144
144
  data
145
145
  end
146
-
146
+
147
147
  protected
148
-
148
+
149
149
  # Returns the thread on which to store the connections
150
150
  def connection_thread
151
151
  allow_concurrency ? Thread.current : Thread.main
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rubyuw}
8
- s.version = "0.99.13"
8
+ s.version = "0.99.14"
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-02-20}
12
+ s.date = %q{2010-04-03}
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 = [
@@ -76,7 +76,7 @@ Gem::Specification.new do |s|
76
76
  s.homepage = %q{http://github.com/mitchellh/rubyuw}
77
77
  s.rdoc_options = ["--charset=UTF-8"]
78
78
  s.require_paths = ["lib"]
79
- s.rubygems_version = %q{1.3.5}
79
+ s.rubygems_version = %q{1.3.6}
80
80
  s.summary = %q{Library which provides a ruby interface to the University of Washington student portal.}
81
81
  s.test_files = [
82
82
  "test/live/curriculum_enrollment_test.rb",
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyuw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.99.13
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 99
8
+ - 14
9
+ version: 0.99.14
5
10
  platform: ruby
6
11
  authors:
7
12
  - Mitchell Hashimoto
@@ -9,19 +14,23 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-20 00:00:00 -08:00
17
+ date: 2010-04-03 00:00:00 -07:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: mechanize
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 9
30
+ - 3
23
31
  version: 0.9.3
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  description: Library which provides a ruby interface to the University of Washington student portal.
26
35
  email: mitchell.hashimoto@gmail.com
27
36
  executables: []
@@ -100,18 +109,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
100
109
  requirements:
101
110
  - - ">="
102
111
  - !ruby/object:Gem::Version
112
+ segments:
113
+ - 0
103
114
  version: "0"
104
- version:
105
115
  required_rubygems_version: !ruby/object:Gem::Requirement
106
116
  requirements:
107
117
  - - ">="
108
118
  - !ruby/object:Gem::Version
119
+ segments:
120
+ - 0
109
121
  version: "0"
110
- version:
111
122
  requirements: []
112
123
 
113
124
  rubyforge_project:
114
- rubygems_version: 1.3.5
125
+ rubygems_version: 1.3.6
115
126
  signing_key:
116
127
  specification_version: 3
117
128
  summary: Library which provides a ruby interface to the University of Washington student portal.