pcr-ruby 0.0.1 → 0.0.2

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/.gitignore CHANGED
@@ -1,17 +1,22 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
1
+ token.dat
2
+ main.rb
3
+ *.gem
4
+ *.rbc
5
+ .bundle
6
+ .config
7
+ .yardoc
8
+ Gemfile.lock
9
+ InstalledFiles
10
+ _yardoc
11
+ coverage
12
+ doc/
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
20
+ instructors.txt
21
+ old
22
+ pcr-ruby
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in pcr-ruby.gemspec
4
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pcr-ruby.gemspec
4
+ gemspec
data/LICENSE CHANGED
@@ -1,22 +1,22 @@
1
- Copyright (c) 2012 parm289
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1
+ Copyright (c) 2012 parm289
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
22
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,29 +1,120 @@
1
- # Pcr::Ruby
2
-
3
- TODO: Write a gem description
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'pcr-ruby'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
- $ gem install pcr-ruby
18
-
19
- ## Usage
20
-
21
- TODO: Write usage instructions here
22
-
23
- ## Contributing
24
-
25
- 1. Fork it
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Added some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
1
+ # pcr-ruby: A Penn Course Review Ruby API Wrapper #
2
+
3
+ pcr-ruby is a simple, intuitive way to retrieve course data from the Penn Course Review API in Ruby. With pcr-ruby and a valid API token (which you can request [here](https://docs.google.com/spreadsheet/viewform?hl=en_US&formkey=dGZOZkJDaVkxdmc5QURUejAteFdBZGc6MQ#gid=0)), your Ruby project has access to reviews, ratings, and other information for all Penn courses.
4
+
5
+ ## How to use pcr-ruby #
6
+
7
+ *This section will change a lot as pcr-ruby is developed. As such, this section may not be fully accurate, but I will try to keep the instructions as current as possible.*
8
+
9
+ pcr-ruby follows the structure of the PCR API, with a few name changes to make object identities and roles clearer in your code. (Before using pcr-ruby, you should most definitely read the PCR API documentation, the link to which you should recieve upon being granted your API token.)
10
+
11
+ The PCR API essentially consists of four types of objects: 'Courses', 'Sections', 'Instructors', and 'Course Histories'. pcr-ruby aims to provide intuitive access to the data contained in these four object types while abstracting you and your user from background processing and unnecessary data. To that end, pcr-ruby (thus far) consists of two types of objects: 'Courses' and 'Sections' ('Instructors' coming soon).
12
+
13
+ ### 'Courses' in pcr-ruby ###
14
+
15
+ Course objects in the PCR API are essentially a group of that Course's Sections which were offered in a certain semester. Courses in pcr-ruby are different, and match up most directly with 'Course History' objects of the PCR API. It is my belief that when students think of a "course," they think of the entire history of the course and *not* the course offering for a specific semester. Therefore, pcr-ruby does not associate Courses with specific semesters -- rather, Courses exist across time and represent a single curriculum and course code.
16
+
17
+ To create a Course:
18
+ ```ruby
19
+ course = PCR::Course.new(:course_code => "DEPT-###")
20
+ ```
21
+ All other instance variables will auto-populate based on data from the PCR API.
22
+
23
+ pcr-ruby's Course objects have the following instance variables:
24
+ * **course_code** -- a string in the format "DEPT-###", where "DEPT" is the four-letter department code and "###" is the three-digit course code.
25
+ * **sections** -- an array of Section objects for the Course across all time. Useful for calculating average ratings and other cumulative statistics.
26
+ * **id** -- the Course's PCR API id. (Integer)
27
+ * **name** -- the Course's plain-English name. (String)
28
+ * **path** -- the PCR API sub-path leading to the Course (or, more accurately, the Course History). For example, "/coursehistories/1794/". Or, more generally: "/coursehistories/[id]/". (String)
29
+ * **reviews** -- an array of Hashes that contain review data for each of the Course's sections.
30
+
31
+ Courses have the following instance methods:
32
+ * **average(metric)** -- returns the average value, across all Sections, of "metric" as a Float. "Metric" must be a recognized rating in the PCR API. (Currently the names of these ratings are not intuitive, so I may provide plain-English access to rating names in the future.)
33
+ * **recent(metric)** -- returns the most recent value of "metric" as a Float. "Metric" must be a recognized rating in the PCR API. (Currently the names of these ratings are not intuitive, so I may provide plain-English access to rating names in the future.)
34
+
35
+ ### 'Sections' in pcr-ruby ###
36
+
37
+ In pcr-ruby, Sections are single offerings of a Course. Each Section is associated with a certain Instructor and semester -- think of a Section as the individual classes under the umbrella of the Course. Sections in the PCR API are treated similarly.
38
+
39
+ To create a Section:
40
+ ```ruby
41
+ section = PCR::Section.new(:instance_variable => value)
42
+ ```
43
+ Possible instance variables available for setting in the Section initialize method are: aliases, id, name, path, semester.
44
+
45
+ Sections have the following instance variables:
46
+ * **aliases** -- an array of the Section's course listings. Most of the time, a Section will only have one listing (the course code followed by a section code, like "-001"), but Sections that are cross-listed between departments may have multiple listings.
47
+ * **id** -- the Section's PCR API id. (Integer)
48
+ * **name** -- the plain-English name of the class. (String)
49
+ * **path** -- the PCR API sub-path that leads to the Section. Similar in format to Course.path. (String)
50
+ * **semester** -- the semester code for the semester in which the Section was offered. For example: "2011A". Semester codes are in the format "####X", where "####" represents a year and "X" represents a semester (A for Spring, B for Summer, C for Fall). (String)
51
+ * **description** -- a string containing the class description, which is written by the Section's Instructor and details the scope and characteristics of the class.
52
+ * **comments** -- a string containing PCR's comments about the Section. The comments are the most major part of the written review, and are sourced from student exit surveys.
53
+ * **ratings** -- a Hash of metrics and the ratings of the Section for each metric.
54
+ * **instructor** (to be developed) -- the Instructor object for the Section's professor.
55
+
56
+ Sections have the following instance methods:
57
+ * **reviews()** -- retrieves the Section's review data from PCR. Returns a Hash in the format {"comments" => @comments, "ratings" => @ratings}.
58
+
59
+ ### 'Instructors' in pcr-ruby ###
60
+
61
+ Instructors are arguably the most important part of PCR -- many students use PCR as a substitute for RateMyProfessor and base their course decisions on PCR professor ratings. The Instructor object represents a single professor through time. As of now, pcr-ruby allows you to retrieve both the average and most recent ratings of a professor; I may add the ability to look up ratings for specific courses/semesters taught in the future.
62
+
63
+ To create an Instructor:
64
+ ```ruby
65
+ instructor = PCR::Instructor.new(:id => id [, :name => name, :path => path, :sections => sections])
66
+ ```
67
+ (You really only need to pass the id argument, as pcr-ruby will automatically retrieve the other information from PCR.)
68
+
69
+ Insctructors have the following instance variables:
70
+ * **id** -- the Instructor's PCR id, a String in the form of "ID#-FIRST-M-LAST".
71
+ * **name** -- the Instructor's name, a String in the form of "FIRST-M-LAST".
72
+ * **path** -- the PCR sub-path that leads to the Instructor, a String in the form of "/instructors/id".
73
+ * **sections** -- a Hash of sections taught by Instructor.
74
+ * **reviews** -- a Hash of reviews of Instructor in JSON.
75
+
76
+ Instructors have the following instance methods:
77
+ * **getInfo** -- a utility method to fill in missing info in Instructor object (used to minimize unnecessary API hits)
78
+ * **getReviews** -- a utility method to get review info for Instructor object (used to minimize unnecessary API hits)
79
+ * **average(metric)** -- returns the average value, across all Sections taught by Instructor, of "metric" as a Float. "Metric" must be a recognized rating in the PCR API. (Currently the names of these ratings are not intuitive, so I may provide plain-English access to rating names in the future.)
80
+ * **recent(metric)** -- returns the average value of "metric" for the most recent semester in which the Instructor taught as a float. (For example, if the professor taught 3 classes in the most recent semester, this would return the average of "metric" over the three classes.) "Metric" must be a recognized rating in the PCR API. (Currently the names of these ratings are not intuitive, so I may provide plain-English access to rating names in the future.)
81
+
82
+ ## pcr-ruby Usage Examples ##
83
+
84
+ Here are some (hopefully very simple and intuitive) usage examples for pcr-ruby:
85
+
86
+ ### Get average course quality rating ###
87
+ Let's say we want to find the average course quality rating for Introduction to International Relations, PSCI-150:
88
+
89
+ ```ruby
90
+ require 'pcr.rb'
91
+ course_code = "PSCI-150"
92
+ course = PCR::Course.new(:course_code => course_code)
93
+ puts course.average("rCourseQuality") #=> 3.041
94
+ ```
95
+
96
+ Or, even more briefly:
97
+
98
+ ```ruby
99
+ require 'pcr.rb'
100
+ puts PCR::Course.new(:course_code => "PSCI-150").average("rCourseQuality") #=> 3.041
101
+ ```
102
+
103
+ ### Get most recent course difficulty rating ###
104
+ Finding the most recent section's course difficulty rating is just as easy:
105
+
106
+ ```ruby
107
+ require 'pcr.rb'
108
+ course = PCR::Course.new(:course_code => "PSCI-150")
109
+ puts course.recent("rDifficulty") #=> 2.5
110
+ ```
111
+
112
+ ### Get professor's average "ability to stimulate student interest" rating ###
113
+ ```ruby
114
+ require 'pcr.rb'
115
+ instructor = PCR::Instructor.new(:id => "1090-LINDA-H-ZHAO")
116
+ puts instructor.average("rStimulateInterest").round(2) #=> 1.7
117
+ ```
118
+
119
+ ## TODO ##
120
+ * Implement search by professor last/first name rather than by ID. ID is unintuitive. Will probably need to see if I can make a lookup method, or simply pull down a database of all instructors and do a search on that database.
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
- #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/lib/pcr-ruby.rb CHANGED
@@ -97,7 +97,7 @@ module PCR
97
97
  class API
98
98
  attr_accessor :token, :api_endpt
99
99
  def initialize()
100
- @token = File.open('token.dat', &:readline)
100
+ @token = File.open(File.join(File.dirname(__FILE__), '..', 'token.dat', &:readline)
101
101
  @api_endpt = "http://api.penncoursereview.com/v1/"
102
102
  end
103
103
  end
data/pcr-ruby.gemspec CHANGED
@@ -1,19 +1,19 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/pcr-ruby/version', __FILE__)
3
-
4
- Gem::Specification.new do |gem|
5
- gem.authors = "Matt Parmett"
6
- gem.email = "parm289@yahoo.com"
7
- gem.description = %q{Ruby wrapper for the Penn Course Review API}
8
- gem.summary = %q{Ruby wrapper for the Penn Course Review API}
9
- gem.homepage = ""
10
-
11
- gem.files = `git ls-files`.split($\)
12
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
- gem.name = "pcr-ruby"
15
- gem.require_paths = ["lib"]
16
- gem.version = Pcr::Ruby::VERSION
17
-
18
- gem.add_dependency "json"
19
- end
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/pcr-ruby/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = "Matt Parmett"
6
+ gem.email = "parm289@yahoo.com"
7
+ gem.description = %q{Ruby wrapper for the Penn Course Review API}
8
+ gem.summary = %q{Ruby wrapper for the Penn Course Review API}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "pcr-ruby"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Pcr::Ruby::VERSION
17
+
18
+ gem.add_dependency "json"
19
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pcr-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-04 00:00:00.000000000 Z
12
+ date: 2012-10-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -39,7 +39,6 @@ files:
39
39
  - README.md
40
40
  - Rakefile
41
41
  - lib/pcr-ruby.rb
42
- - lib/pcr-ruby/version.rb
43
42
  - pcr-ruby.gemspec
44
43
  homepage: ''
45
44
  licenses: []
@@ -1,5 +0,0 @@
1
- module Pcr
2
- module Ruby
3
- VERSION = "0.0.1"
4
- end
5
- end