unm 0.0.2 → 0.0.3
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 +17 -5
- data/lib/unm/version.rb +1 -1
- data/lib/unm.rb +22 -0
- data/unm-0.0.2.gem +0 -0
- data/unm.gemspec +1 -0
- metadata +17 -3
- data/unm-0.0.1.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae471835e0e73af3eec77b67aa3e856b32518086
|
4
|
+
data.tar.gz: 35617e934c13280acd386916d59cb56a0c8a36ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1742d5d0dd545260dbc468e2f844b7403087aad239578214d6025b298521e16fe39f6a6c41ea21ce9b15510aec87be10ffde38ad71c26712cce608b0e8d9ee1
|
7
|
+
data.tar.gz: e6bfa678176fb1f5f701bb6563215b56aafa97d21791e82ee0f31cf9f021279a653a07aec9b8b032c71b4901ad2005b668fc0d186bab75556dbdeabdf14271c1
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Unm
|
2
2
|
|
3
3
|
This gem interacts with UNM interfaces. Currently it only works with the events
|
4
|
-
calendar.
|
4
|
+
calendar and course catalog.
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
|
@@ -21,22 +21,34 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
## Usage
|
23
23
|
|
24
|
-
To use the
|
24
|
+
To use the calendar, first create a new `Unm::Calendar` object by passing it a start
|
25
25
|
and end date, and a format (defaults to CSV, other options are ICAL and XML):
|
26
26
|
|
27
27
|
```ruby
|
28
28
|
calendar = Unm::Calendar.new(Date.today, Date.today + 365, "ICAL")
|
29
29
|
```
|
30
30
|
|
31
|
-
Then perform the request (returns
|
32
|
-
retrieve raw string):
|
31
|
+
Then perform the request (returns the request body):
|
33
32
|
|
34
33
|
```ruby
|
35
34
|
request = calendar.get
|
36
|
-
puts
|
35
|
+
puts request
|
37
36
|
# Probably outputs some super long iCalendar string
|
38
37
|
```
|
39
38
|
|
39
|
+
To get the course catalog, use `Unm::Courses.get`:
|
40
|
+
|
41
|
+
``` ruby
|
42
|
+
catalog = Unm::Courses.get
|
43
|
+
|
44
|
+
=> [{"Subject" =>
|
45
|
+
[{"name" => "Course Name", "description" => "Course Description"},
|
46
|
+
{"name" => "Course Name", "description" => "Course Description"},
|
47
|
+
#...
|
48
|
+
]
|
49
|
+
]
|
50
|
+
```
|
51
|
+
|
40
52
|
## Contributing
|
41
53
|
|
42
54
|
1. Fork it ( https://github.com/[my-github-username]/unm/fork )
|
data/lib/unm/version.rb
CHANGED
data/lib/unm.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require "unm/version"
|
2
2
|
require 'httparty'
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'singleton'
|
3
5
|
module Unm
|
4
6
|
|
5
7
|
class Calendar
|
@@ -39,4 +41,24 @@ module Unm
|
|
39
41
|
|
40
42
|
end
|
41
43
|
|
44
|
+
class Courses
|
45
|
+
|
46
|
+
include Singleton
|
47
|
+
|
48
|
+
def self.get
|
49
|
+
return @catalog if @catalog
|
50
|
+
subjects = HTTParty.get("http://catalog.unm.edu/catalogs/2014-2015/subjects-and-courses.xml")["data"]["subjects"]["subject"]
|
51
|
+
@catalog = subjects.map do |subject|
|
52
|
+
courses = subject["course"]
|
53
|
+
name = subject["subjectName"]
|
54
|
+
{ name => [courses].flatten.map do |course|
|
55
|
+
course_name = name + " " + course["name"]
|
56
|
+
course_description = Nokogiri::HTML.parse(HTTParty.get(course["path"])).css('.content > p').first.text rescue course["path"]
|
57
|
+
{ "name" => course_name, "description" => course_description }
|
58
|
+
end }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
42
64
|
end
|
data/unm-0.0.2.gem
ADDED
Binary file
|
data/unm.gemspec
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.0.
|
4
|
+
version: 0.0.3
|
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: 2015-
|
11
|
+
date: 2015-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: nokogiri
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: Curently only works with the calendar.
|
56
70
|
email:
|
57
71
|
- fdisk@fdisk.co
|
@@ -66,7 +80,7 @@ files:
|
|
66
80
|
- Rakefile
|
67
81
|
- lib/unm.rb
|
68
82
|
- lib/unm/version.rb
|
69
|
-
- unm-0.0.
|
83
|
+
- unm-0.0.2.gem
|
70
84
|
- unm.gemspec
|
71
85
|
homepage: ''
|
72
86
|
licenses:
|
data/unm-0.0.1.gem
DELETED
File without changes
|