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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/lib/unm.rb +7 -5
  4. data/lib/unm/version.rb +1 -1
  5. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3b9891a5baa7fe357166ffc7721f46bd28a763a
4
- data.tar.gz: 10be1fb2f5f464827694e1b5130731dd35f8758a
3
+ metadata.gz: 0b59c5707c8826d1328fd3b5dc2a980457451f86
4
+ data.tar.gz: 76a4ebb55fad8ea4f36cd614a76dea93f8991f32
5
5
  SHA512:
6
- metadata.gz: 4cab3388816d1e7599a5ad91f9d4d31d2505d361d452635714742c0a3822faea7e0e58cddce6585b3956bef034c6e78d5fb655f264155f54604cc52dc7755319
7
- data.tar.gz: 9777c6f21d0de5e6e0af3a2cf0e3f46365ed0421469a18619e6c2fc1d83a1d6cab108e108a7259b69b7042c138f5e5d6fcad98792aca722f3f3131b733268d9f
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
- subjects = HTTParty.get("http://catalog.unm.edu/catalogs/2016-2017/subjects-and-courses.xml")["data"]["subjects"]["subject"]
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
- description = course_page.css('.content > p').first.text rescue "Error loading description. Check #{course["path"]}."
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
@@ -1,3 +1,3 @@
1
1
  module Unm
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
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.0
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: 2016-07-25 00:00:00.000000000 Z
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.1
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: