unm 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/unm.rb +7 -5
- data/lib/unm/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b59c5707c8826d1328fd3b5dc2a980457451f86
|
4
|
+
data.tar.gz: 76a4ebb55fad8ea4f36cd614a76dea93f8991f32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b2332ff7088d227478a6e98364446c460e7c6460b85a11f42f381942add6172a49d3f3b66ab2d4880a75d40aced234d512617d9b05503dd43c4166ca6e700d6
|
7
|
+
data.tar.gz: 163aa5c9d499467b70754729db438ab30d751e493a622365c748149e038fc95ee9120d2430ca428e93c5e913f73555fc9618fe1ef78d89ef0e6002782caf83d7
|
data/README.md
CHANGED
@@ -42,8 +42,8 @@ To get the course catalog, use `Unm::Courses.get`:
|
|
42
42
|
catalog = Unm::Courses.get
|
43
43
|
|
44
44
|
=> [{"Subject" =>
|
45
|
-
[{"name" => "Course Name", "description" => "Course Description"},
|
46
|
-
{"name" => "Course Name", "description" => "Course Description"},
|
45
|
+
[{"name" => "Course Name", "title" => "Course Title", "description" => "Course Description"},
|
46
|
+
{"name" => "Course Name", "title" => "Course Title", "description" => "Course Description"},
|
47
47
|
#...
|
48
48
|
]
|
49
49
|
]
|
data/lib/unm.rb
CHANGED
@@ -37,7 +37,7 @@ module Unm
|
|
37
37
|
raise "Please do not span more than one year" if to_date - from_date > 365
|
38
38
|
raise "to_date must be after from_date" if from_date > to_date
|
39
39
|
[from_date.strftime("%m%d%Y"), to_date.strftime("%m%d%Y")]
|
40
|
-
end
|
40
|
+
end
|
41
41
|
|
42
42
|
end
|
43
43
|
|
@@ -47,19 +47,21 @@ module Unm
|
|
47
47
|
|
48
48
|
class << self
|
49
49
|
|
50
|
-
def get
|
50
|
+
def get(catalog_year = 2017)
|
51
51
|
return @catalog if @catalog
|
52
|
-
|
52
|
+
catalog_year = catalog_year.to_s << "-" << catalog_year.next.to_s
|
53
|
+
subjects = HTTParty.get("http://catalog.unm.edu/catalogs/#{catalog_year}/subjects-and-courses.xml")["data"]["subjects"]["subject"]
|
53
54
|
@catalog = subjects.map do |subject|
|
54
55
|
courses = subject["course"]
|
55
56
|
name = subject["subjectName"]
|
56
57
|
{ name => [courses].flatten.map do |course|
|
57
58
|
course_name = name + " " + course["name"]
|
58
59
|
course_page = Nokogiri::HTML.parse(HTTParty.get(URI.escape course["path"])) rescue course["path"]
|
59
|
-
|
60
|
+
course_title = course_page.css('h1').first.text rescue "Error loading course title. Check #{course['path']}."
|
61
|
+
description = course_page.css('.content > p').first.text rescue "Error loading description. Check #{course["path"]}."
|
60
62
|
prerequisites = find_prerequisites(course_page) rescue "Error loading prerequisites. Check #{course["path"]}."
|
61
63
|
hours = course_page.css('b').text.match(/\(\D*(\d).*\)/)[1].to_i rescue "Error loading hours. Check #{course["path"]}."
|
62
|
-
{ "name" => course_name, "description" => description, "prerequisites" => prerequisites, "hours" => hours }
|
64
|
+
{ "name" => course_name, "title" => course_title, "description" => description, "prerequisites" => prerequisites, "hours" => hours }
|
63
65
|
end }
|
64
66
|
end
|
65
67
|
end
|
data/lib/unm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Piro-Rael
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -101,9 +101,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
version: '0'
|
102
102
|
requirements: []
|
103
103
|
rubyforge_project:
|
104
|
-
rubygems_version: 2.5.
|
104
|
+
rubygems_version: 2.5.2.2
|
105
105
|
signing_key:
|
106
106
|
specification_version: 4
|
107
107
|
summary: Utilities to interact with UNM Interfaces.
|
108
108
|
test_files: []
|
109
|
-
has_rdoc:
|