umd 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 86745c0e6eaed649177f9ccd604052018bf94c9f
4
+ data.tar.gz: 75ddf91acfd01f8b7724109301c76198054ad015
5
+ SHA512:
6
+ metadata.gz: 68886b7081fa38091fc3cbceab13da59028231fc5981ca8cb975263950a883309e05417f912ebb9dee397e01df5e7f404ac2743b7d4b77a60874cf04014d5477
7
+ data.tar.gz: 18bd39353ba040e5991bbcb4dc2022bd5d615833dff4abc248e86aeca8c90705f1a7d371d2d9fa2e11cd3eb467cc9fff46cd4e44f78025b2a23ed545525775f3
Binary file
Binary file
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.13.7
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to the best of our ability to make
7
+ participation in our project and our community a harassment-free experience for
8
+ everyone, regardless of age, body size, disability, ethnicity, gender identity
9
+ and expression, level of experience, nationality, personal appearance, race,
10
+ religion, political belief, and sexual identity or orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at jp@jpteti.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
71
+ version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in umd.gemspec
4
+ gemspec
@@ -0,0 +1,25 @@
1
+ The ABRMS License (ABRMS)
2
+
3
+ Copyright (c) 2017 J-P Teti
4
+
5
+ This software is licensed under the "Anyone But Richard M Stallman"
6
+ (ABRMS) license, described below. No other licenses may apply.
7
+
8
+ --------------------------------------------
9
+ The "Anyone But Richard M Stallman" license
10
+ --------------------------------------------
11
+
12
+ Do anything you want with this program, with the exceptions listed
13
+ below under "EXCEPTIONS".
14
+
15
+ THIS SOFTWARE IS PROVIDED "AS IS" WITH NO WARRANTY OF ANY KIND.
16
+
17
+ In the unlikely event that you happen to make a zillion bucks off of
18
+ this, then good for you; consider buying a homeless person a meal.
19
+
20
+
21
+ EXCEPTIONS
22
+ ----------
23
+
24
+ Richard M Stallman (the guy behind GNU, etc.) may not make use of or
25
+ redistribute this program or any of its derivatives.
@@ -0,0 +1,53 @@
1
+ # UMD
2
+
3
+ This is a wrapper for the [umd.io](http://umd.io) API for data about the University of Maryland, College Park. Currently it's basically just some
4
+ niceties through [HTTParty](https://github.com/jnunemaker/httparty). Relying on this right now is a *bad* idea, as it's under development and there
5
+ almost certainly will be API-breaking changes.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'umd'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install umd
22
+
23
+ ## Usage
24
+
25
+ TODO: Write this up.
26
+
27
+ ## Security details
28
+
29
+ UMD is cryptographically signed. To be sure the gem you install hasn’t been tampered with:
30
+
31
+ Add my public key (if you haven’t already) as a trusted certificate
32
+
33
+ `gem cert --add <(curl -Ls https://raw.github.com/jpteti/umd/master/certs/jpteti.pem)`
34
+
35
+ `gem install umd -P MediumSecurity`
36
+
37
+ The MediumSecurity trust profile will verify signed gems, but allow the installation of unsigned dependencies.
38
+ This is necessary because not all of UMD's dependencies are signed, so we cannot use HighSecurity.
39
+
40
+ ## Development
41
+
42
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
43
+
44
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
45
+
46
+ ## Contributing
47
+
48
+ Bug reports and pull requests are welcome on GitHub at https://github.com/jpteti/umd. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
49
+
50
+
51
+ ## License
52
+
53
+ The gem is available as open source under the terms of the [ABRMS License](http://www.dadhacker.com/blog/?p=2106#comments). In short, you can do whatever you'd like with this software, as long as you're not Richard M. Stallman.
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "umd"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,20 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDXDCCAkSgAwIBAgIBATANBgkqhkiG9w0BAQUFADA6MQswCQYDVQQDDAJqcDEW
3
+ MBQGCgmSJomT8ixkARkWBmpwdGV0aTETMBEGCgmSJomT8ixkARkWA2NvbTAeFw0x
4
+ NzAzMjUxNTUzNTFaFw0xODAzMjUxNTUzNTFaMDoxCzAJBgNVBAMMAmpwMRYwFAYK
5
+ CZIm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+ require "umd/constants"
3
+ require "httparty"
4
+
5
+ module Umd
6
+ class UMD
7
+ include HTTParty
8
+ base_uri(Umd::API_V0_ROOT)
9
+
10
+ def self.corrected_options_hash(opts)
11
+ options_hash = opts
12
+
13
+ if options_hash[:departments].is_a?(Array)
14
+ options_hash[:departments] = options_hash[:departments].join(',')
15
+ end
16
+
17
+ # This must remain beneath the flattening of the array into a string
18
+ if options_hash[:departments].is_a?(String)
19
+ options_hash[:departments].upcase!
20
+ end
21
+
22
+ if options_hash[:sort]
23
+ options_hash[:sort] = self.formatted_sort_hash(options_hash[:sort])
24
+ end
25
+
26
+ options_hash
27
+ end
28
+
29
+ def self.formatted_sort_hash(sort_hash)
30
+ final_string = ""
31
+
32
+ if sort_hash[:asc]
33
+ final_string = sort_hash[:asc].map { |attribute| attribute.to_s }.join(',') + ","
34
+ end
35
+
36
+ if sort_hash[:desc]
37
+ final_string = final_string + sort_hash[:desc].map { |attribute| "-#{attribute}" }.join(',')
38
+ end
39
+
40
+ final_string
41
+ end
42
+
43
+ # def self.courses
44
+ # self.courses(nil)
45
+ # end
46
+ #
47
+ # # def self.courses(options = {})
48
+ # # final_options = corrected_options_hash(options)
49
+ # #
50
+ # # self.get('/courses', {query: final_options})
51
+ # # end
52
+
53
+ def self.courses(course_ids=nil, options={})
54
+ if course_ids.is_a?(Hash)
55
+ options = course_ids
56
+ course_ids = nil
57
+ end
58
+
59
+ final_options = corrected_options_hash(options)
60
+
61
+ path = '/courses'
62
+
63
+ if !course_ids.nil?
64
+ path = '/courses/'
65
+
66
+ if course_ids.is_a?(Array)
67
+ path = path + course_ids.map { |s| s.to_s.downcase }.join(',')
68
+ else
69
+ path = path + course_ids.downcase
70
+ end
71
+ end
72
+
73
+ self.get(path, {query: final_options})
74
+ end
75
+
76
+ def self.course_list(options={})
77
+ final_options = corrected_options_hash(options)
78
+
79
+ self.get('/courses/list', {query: final_options})
80
+ end
81
+
82
+ def self.sections(section_ids, options={})
83
+ final_options = corrected_options_hash(options)
84
+
85
+ path = '/sections/'
86
+
87
+ if section_ids.is_a?(Array)
88
+ path = path + section_ids.map { |s| s.to_s.downcase }.join(',')
89
+ else
90
+ path = path + section_ids.downcase
91
+ end
92
+
93
+ self.get(path, {query: final_options})
94
+ end
95
+
96
+ def self.departments(options={})
97
+ self.get('/courses/departments', {query: corrected_options_hash(options)})
98
+ end
99
+
100
+ def self.professors(options={})
101
+ final_options = corrected_options_hash(options)
102
+
103
+ self.get('/professors', {query: final_options})
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,3 @@
1
+ module Umd
2
+ API_V0_ROOT = "http://api.umd.io/v0"
3
+ end
@@ -0,0 +1,3 @@
1
+ module Umd
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'umd/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "umd"
8
+ spec.version = Umd::VERSION
9
+ spec.authors = ["J-P Teti"]
10
+ spec.email = ["jp@jpteti.com"]
11
+
12
+ spec.summary = %q{Ruby API wrapper for umd.io.}
13
+ spec.description = %q{A Ruby API wrapper for umd.io}
14
+ spec.homepage = "https://github.com/jpteti/umd"
15
+ spec.license = "Nonstandard"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+ spec.cert_chain = ['certs/jpteti.pem']
24
+ spec.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.13"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rspec", "~> 3.0"
29
+ spec.add_development_dependency "httparty", "~> 0.14.0"
30
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: umd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - J-P Teti
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDXDCCAkSgAwIBAgIBATANBgkqhkiG9w0BAQUFADA6MQswCQYDVQQDDAJqcDEW
14
+ MBQGCgmSJomT8ixkARkWBmpwdGV0aTETMBEGCgmSJomT8ixkARkWA2NvbTAeFw0x
15
+ NzAzMjUxNTUzNTFaFw0xODAzMjUxNTUzNTFaMDoxCzAJBgNVBAMMAmpwMRYwFAYK
16
+ CZImiZPyLGQBGRYGanB0ZXRpMRMwEQYKCZImiZPyLGQBGRYDY29tMIIBIjANBgkq
17
+ hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv7x0rNoQqBZq9/LEwEKN/8277Criv7C5
18
+ P6+z1MCmeLNlYIKgKjhexVbm+Ghkhocd285blqXSZwANDHNY5+WJ7v+pITcMdTWk
19
+ IRWXMAdruOde3yVumMxpcUJcTPbSK41UFINMeN3pmM/DluhI6R8y++1ODkH23lzX
20
+ 8Y8YbCKR7OW1TsxtMTzR3mOy0VPZTpx1dFB4HDVVx2YKhpWt5lp0h911bvvMwjgM
21
+ 8BdllcdA9ZVX7c2aPVkXKBvrJcGvcPrzb5nPSGkoSJ36aJBpdGFdi0eDIstZLQFI
22
+ ooc76icn35wybWkuUxqcF04cnWHW3UVUbDM1z1E26dvxKja/HjlJeQIDAQABo20w
23
+ azAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU03U/S5NN9gwp+aRO
24
+ HOWxLryJEE8wGAYDVR0RBBEwD4ENanBAanB0ZXRpLmNvbTAYBgNVHRIEETAPgQ1q
25
+ cEBqcHRldGkuY29tMA0GCSqGSIb3DQEBBQUAA4IBAQC7kDLIMB9yUNaEYmfQIKbb
26
+ JyXc9BXy4YBWyzQIhim0P0h5nSakYssH780Ck8e9Kt5TEQJ+R+Dke/QcuqLGQMG3
27
+ /TVLWUAoJpy49cJxA5c6xKUL3ru7MBEok7oSsFDdj6W0vhCGop96DiTFMmFfThRD
28
+ lcd2lqANIwXG3GcPOlsFI7E7k3EP2ufNaLtPg2SW4gXHF6KePR6z/y0VyK+N4kec
29
+ zR3zJSO7GY2ZbHOT+25MKH4TeMngbqaXhGTq+fLliXrDw/Ty3/L976alxPs0IXga
30
+ gB9NVl7Y7VVZBfE0ENaw43MAPflZI84j4uWLxShgDDh0OIXWEpckNOEHzhuRTtY/
31
+ -----END CERTIFICATE-----
32
+ date: 2017-03-25 00:00:00.000000000 Z
33
+ dependencies:
34
+ - !ruby/object:Gem::Dependency
35
+ name: bundler
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.13'
41
+ type: :development
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.13'
48
+ - !ruby/object:Gem::Dependency
49
+ name: rake
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ type: :development
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ - !ruby/object:Gem::Dependency
77
+ name: httparty
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.14.0
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.14.0
90
+ description: A Ruby API wrapper for umd.io
91
+ email:
92
+ - jp@jpteti.com
93
+ executables: []
94
+ extensions: []
95
+ extra_rdoc_files: []
96
+ files:
97
+ - ".gitignore"
98
+ - ".rspec"
99
+ - ".travis.yml"
100
+ - CODE_OF_CONDUCT.md
101
+ - Gemfile
102
+ - LICENSE.txt
103
+ - README.md
104
+ - Rakefile
105
+ - bin/console
106
+ - bin/setup
107
+ - certs/jpteti.pem
108
+ - lib/umd.rb
109
+ - lib/umd/constants.rb
110
+ - lib/umd/version.rb
111
+ - umd.gemspec
112
+ homepage: https://github.com/jpteti/umd
113
+ licenses:
114
+ - Nonstandard
115
+ metadata: {}
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ requirements: []
131
+ rubyforge_project:
132
+ rubygems_version: 2.5.1
133
+ signing_key:
134
+ specification_version: 4
135
+ summary: Ruby API wrapper for umd.io.
136
+ test_files: []
Binary file