osu_term 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0f13bcb897569ab59d64f570c3143f08b881ebbbd2fd053e12a3fcd3de63e852
4
+ data.tar.gz: 724f5f9b981b1263223d4cc56a54c4e5b6cf3e6a71bb9d069b9520c3972196d2
5
+ SHA512:
6
+ metadata.gz: 42db3c17229956c50a1b75f466bc22fe4b4c361ef37b53e2f07d73977c6de862d4789c0bc02af7a43a2d17e931c1d5c6ac735925691a079138b77b732f744023
7
+ data.tar.gz: '0950b06a47b04fe442fcdb00a8354fb8e0c9c109666e3086df155d460cee9252c9f023139d70694fa3192aa0fc1b53ece1270792a21dbe006fcb47d6c78ae22e'
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
@@ -0,0 +1,44 @@
1
+ stages:
2
+ - build
3
+ - analysis
4
+ - test
5
+
6
+ variables: &vars
7
+ LANG: en_US.UTF-8
8
+ OSU_TERM: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
9
+ GIT_STRATEGY: none
10
+
11
+ osu_term:
12
+ stage: build
13
+ image: docker:latest
14
+ tags: [build]
15
+ script: docker build -t $OSU_TERM . && docker push $OSU_TERM
16
+ variables:
17
+ <<: *vars
18
+ GIT_STRATEGY: clone
19
+
20
+ .analysis: &analysis
21
+ stage: analysis
22
+ image: $OSU_TERM
23
+ tags: [test]
24
+ before_script:
25
+ - cd /app
26
+
27
+ bundle-audit:
28
+ <<: *analysis
29
+ script: bundle-audit check --update
30
+
31
+ rubocop:
32
+ <<: *analysis
33
+ except: [schedules]
34
+ script: rubocop
35
+
36
+ rubycritic:
37
+ <<: *analysis
38
+ script: rubycritic lib --no-browser -s 80
39
+
40
+ rspec:
41
+ stage: test
42
+ image: $OSU_TERM
43
+ tags: [test]
44
+ script: bundle exec rspec
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,3 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'spec/**/*'
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.0
7
+ before_install: gem install bundler -v 1.16.5
@@ -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 making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ 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 mueller.128@osu.edu. 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], version 1.4,
71
+ 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/
@@ -0,0 +1,13 @@
1
+ FROM code.osu.edu:5000/asctech/docker/ruby:2.5
2
+
3
+ ENV APP_ROOT=/app
4
+
5
+ RUN yum -y update && \
6
+ useradd --user-group deploy && \
7
+ mkdir -p ${APP_ROOT} && \
8
+ chown -R deploy:deploy ${APP_ROOT} /usr/local/bundle
9
+
10
+ USER deploy
11
+ WORKDIR ${APP_ROOT}
12
+ COPY --chown=deploy:deploy . ${APP_ROOT}
13
+ RUN bundle install
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in osu_term.gemspec
6
+ gemspec
@@ -0,0 +1,121 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ osu_term (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ addressable (2.5.2)
10
+ public_suffix (>= 2.0.2, < 4.0)
11
+ ast (2.4.0)
12
+ axiom-types (0.1.1)
13
+ descendants_tracker (~> 0.0.4)
14
+ ice_nine (~> 0.11.0)
15
+ thread_safe (~> 0.3, >= 0.3.1)
16
+ bundle-audit (0.1.0)
17
+ bundler-audit
18
+ bundler-audit (0.5.0)
19
+ bundler (~> 1.2)
20
+ thor (~> 0.18)
21
+ codeclimate-engine-rb (0.4.1)
22
+ virtus (~> 1.0)
23
+ coercible (1.0.0)
24
+ descendants_tracker (~> 0.0.1)
25
+ descendants_tracker (0.0.4)
26
+ thread_safe (~> 0.3, >= 0.3.1)
27
+ diff-lcs (1.3)
28
+ docile (1.3.1)
29
+ equalizer (0.0.11)
30
+ erubis (2.7.0)
31
+ flay (2.12.0)
32
+ erubis (~> 2.7.0)
33
+ path_expander (~> 1.0)
34
+ ruby_parser (~> 3.0)
35
+ sexp_processor (~> 4.0)
36
+ flog (4.6.2)
37
+ path_expander (~> 1.0)
38
+ ruby_parser (~> 3.1, > 3.1.0)
39
+ sexp_processor (~> 4.8)
40
+ ice_nine (0.11.2)
41
+ jaro_winkler (1.5.1-x86_64-darwin-17)
42
+ json (2.1.0)
43
+ launchy (2.4.3)
44
+ addressable (~> 2.3)
45
+ parallel (1.12.1)
46
+ parser (2.5.1.2)
47
+ ast (~> 2.4.0)
48
+ path_expander (1.0.3)
49
+ powerpack (0.1.2)
50
+ public_suffix (3.0.3)
51
+ rainbow (3.0.0)
52
+ rake (12.3.1)
53
+ reek (4.8.2)
54
+ codeclimate-engine-rb (~> 0.4.0)
55
+ parser (>= 2.5.0.0, < 2.6)
56
+ rainbow (>= 2.0, < 4.0)
57
+ rspec (3.8.0)
58
+ rspec-core (~> 3.8.0)
59
+ rspec-expectations (~> 3.8.0)
60
+ rspec-mocks (~> 3.8.0)
61
+ rspec-core (3.8.0)
62
+ rspec-support (~> 3.8.0)
63
+ rspec-expectations (3.8.1)
64
+ diff-lcs (>= 1.2.0, < 2.0)
65
+ rspec-support (~> 3.8.0)
66
+ rspec-mocks (3.8.0)
67
+ diff-lcs (>= 1.2.0, < 2.0)
68
+ rspec-support (~> 3.8.0)
69
+ rspec-support (3.8.0)
70
+ rubocop (0.58.1)
71
+ jaro_winkler (~> 1.5.1)
72
+ parallel (~> 1.10)
73
+ parser (>= 2.5, != 2.5.1.1)
74
+ powerpack (~> 0.1)
75
+ rainbow (>= 2.2.2, < 4.0)
76
+ ruby-progressbar (~> 1.7)
77
+ unicode-display_width (~> 1.0, >= 1.0.1)
78
+ ruby-progressbar (1.9.0)
79
+ ruby_parser (3.11.0)
80
+ sexp_processor (~> 4.9)
81
+ rubycritic (3.5.2)
82
+ flay (~> 2.8)
83
+ flog (~> 4.4)
84
+ launchy (= 2.4.3)
85
+ parser (~> 2.5.0)
86
+ rainbow (~> 3.0)
87
+ reek (~> 4.4)
88
+ ruby_parser (~> 3.8)
89
+ tty-which (~> 0.3.0)
90
+ virtus (~> 1.0)
91
+ sexp_processor (4.11.0)
92
+ simplecov (0.16.1)
93
+ docile (~> 1.1)
94
+ json (>= 1.8, < 3)
95
+ simplecov-html (~> 0.10.0)
96
+ simplecov-html (0.10.2)
97
+ thor (0.20.0)
98
+ thread_safe (0.3.6)
99
+ tty-which (0.3.0)
100
+ unicode-display_width (1.4.0)
101
+ virtus (1.0.5)
102
+ axiom-types (~> 0.1)
103
+ coercible (~> 1.0)
104
+ descendants_tracker (~> 0.0, >= 0.0.3)
105
+ equalizer (~> 0.0, >= 0.0.9)
106
+
107
+ PLATFORMS
108
+ ruby
109
+
110
+ DEPENDENCIES
111
+ bundle-audit
112
+ bundler (~> 1.16)
113
+ osu_term!
114
+ rake (~> 12.0)
115
+ rspec (~> 3.0)
116
+ rubocop
117
+ rubycritic
118
+ simplecov
119
+
120
+ BUNDLED WITH
121
+ 1.16.5
@@ -0,0 +1,77 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec feature)
6
+
7
+ ## Uncomment to clear the screen before every task
8
+ # clearing :on
9
+
10
+ ## Guard internally checks for changes in the Guardfile and exits.
11
+ ## If you want Guard to automatically start up again, run guard in a
12
+ ## shell loop, e.g.:
13
+ ##
14
+ ## $ while bundle exec guard; do echo "Restarting Guard..."; done
15
+ ##
16
+ ## Note: if you are using the `directories` clause above and you are not
17
+ ## watching the project directory ('.'), the you will want to move the Guardfile
18
+ ## to a watched dir and symlink it back, e.g.
19
+ #
20
+ # $ mkdir config
21
+ # $ mv Guardfile config/
22
+ # $ ln -s config/Guardfile .
23
+ #
24
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
25
+
26
+ # Note: The cmd option is now required due to the increasing number of ways
27
+ # rspec may be run, below are examples of the most common uses.
28
+ # * bundler: 'bundle exec rspec'
29
+ # * bundler binstubs: 'bin/rspec'
30
+ # * spring: 'bin/rspec' (This will use spring if running and you have
31
+ # installed the spring binstubs per the docs)
32
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
33
+ # * 'just' rspec: 'rspec'
34
+
35
+ guard :rspec, cmd: 'bundle exec rspec' do
36
+ require 'guard/rspec/dsl'
37
+ dsl = Guard::RSpec::Dsl.new(self)
38
+
39
+ # Feel free to open issues for suggestions and improvements
40
+
41
+ # RSpec files
42
+ rspec = dsl.rspec
43
+ watch(rspec.spec_helper) { rspec.spec_dir }
44
+ watch(rspec.spec_support) { rspec.spec_dir }
45
+ watch(rspec.spec_files)
46
+
47
+ # Ruby files
48
+ ruby = dsl.ruby
49
+ dsl.watch_spec_files_for(ruby.lib_files)
50
+
51
+ # Rails files
52
+ rails = dsl.rails(view_extensions: %w[erb haml slim])
53
+ dsl.watch_spec_files_for(rails.app_files)
54
+ dsl.watch_spec_files_for(rails.views)
55
+
56
+ watch(rails.controllers) do |m|
57
+ [
58
+ rspec.spec.call("routing/#{m[1]}_routing"),
59
+ rspec.spec.call("controllers/#{m[1]}_controller"),
60
+ rspec.spec.call("acceptance/#{m[1]}")
61
+ ]
62
+ end
63
+
64
+ # Rails config changes
65
+ watch(rails.spec_helper) { rspec.spec_dir }
66
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
67
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
68
+
69
+ # Capybara features specs
70
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
71
+
72
+ # Turnip features and steps
73
+ watch(%r{^spec/acceptance/(.+)\.feature$})
74
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
75
+ Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
76
+ end
77
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Kurt Mueller
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,65 @@
1
+ # OSU::Term
2
+
3
+ A simple utility gem for converting Ohio State's `strm`s into human readable
4
+ names, comparing strms to each other, and calculating the next strm.
5
+
6
+ To experiment with the code, run `bin/console` for an interactive prompt.
7
+
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'osu_term'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install osu_term
24
+
25
+ ## Usage
26
+
27
+ ```ruby
28
+ term = OSU::Term.new(strm: '1152')
29
+ term.year # => 2015
30
+ term.name # => "Spring"
31
+ term.to_s # => "Spring 2015"
32
+ term.quarter? # => false
33
+ term.semester? # => true
34
+ term.next_strm # => '1154'
35
+ term.next #=> #<OSU::Term @strm="1154">
36
+
37
+ term < term.next # => true
38
+ ```
39
+
40
+ The strm you pass in must be a string 4 digits in length.
41
+
42
+ - The 1st digit must be a 0 or a 1. This represents the century of the term. 0 =
43
+ 1900, 1 = 2000.
44
+ - The next two characters represent the last two digits of the year.
45
+ - If the strm is a quarter, the last digit must be 0 (Winter), 2 (Spring), 4 (Summer), or 8 (Autumn)
46
+ - If the strm is a semester, the last digit must be 2 (Spring), 4 (Summer), or 8 (Autumn)
47
+
48
+
49
+ ## Development
50
+
51
+ 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.
52
+
53
+ 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).
54
+
55
+ ## Contributing
56
+
57
+ Bug reports and pull requests are welcome on GitHub at https://code.osu.edu/asctech/osu_term. 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.
58
+
59
+ ## License
60
+
61
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
62
+
63
+ ## Code of Conduct
64
+
65
+ Everyone interacting in the OsuTerm project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://code.osu.edu/asctech/osu_term/blob/master/CODE_OF_CONDUCT.md).
@@ -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 'osu_term'
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(__FILE__)
@@ -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,268 @@
1
+ require 'osu_term/version'
2
+
3
+ module OSU
4
+ # A simple helper class to turn strms into readable human names. It can also
5
+ # determine if an strm took place during quarters, semesters, or during the
6
+ # quarter-to-semester transition. It can also calculate the next strm.
7
+ class Term
8
+ include Comparable
9
+
10
+ attr_reader :strm
11
+
12
+ # this strm was used to to transition from quarters to semesters
13
+ QUARTER_TO_SEMESTER_STRM = '1123'.freeze
14
+
15
+ # Initializes a new OsuTerm based on the strm passed in.
16
+ #
17
+ # @param args [Hash] A hash of arguments to pass into the constructor.
18
+ # @option args [String] :strm
19
+ #
20
+ # The osu term's strm number. This number has several requirements:
21
+ # 1. The strm must be a string that's 4 digits in length.
22
+ # 2. The first character must be 0 or 1. 0 = 1900-1999, 1 = 2000 and beyond
23
+ # 3. strm's 2nd and 3rd char represents last two digits of the year
24
+ # 4. the strm's last digit:
25
+ # - quarter: 0 (winter), 2 (Spring), 4 (Summer), or 8 (Autumn)
26
+ # - semester: 2 (Spring), 4 (Summer), or 8 (Autumn)
27
+ #
28
+ # For example, '1152' stands for "Spring 2015".
29
+ # 1 = 2000
30
+ # 15 = 2015
31
+ # 2 = Spring
32
+ #
33
+ # @return [OsuTerm] A new OSU::Term object.
34
+ # @raise [ArgumentError] Raised when the strm is malformed.
35
+ def initialize(strm:)
36
+ strm = strm.to_s
37
+ raise ArgumentError, 'strm must be 4 digits in length' unless FOUR_DIGITS.match?(strm)
38
+ raise ArgumentError, 'strm must start with 0 or 1' unless CENTURIES.match?(strm)
39
+
40
+ @strm = strm
41
+
42
+ if strm < QUARTER_TO_SEMESTER_STRM
43
+ extend(Quarter)
44
+ raise ArgumentError, 'strm must end in 0, 2, 4, or 8' unless Quarter::SEASONS.match?(strm)
45
+ elsif strm == QUARTER_TO_SEMESTER_STRM
46
+ extend(TransitionTerm)
47
+ else
48
+ extend(Semester)
49
+ raise ArgumentError, 'strm must end in 2, 4, or 8' unless Semester::SEASONS.match?(strm)
50
+ end
51
+ end
52
+
53
+ def name
54
+ names[season_number].fetch(:full)
55
+ end
56
+
57
+ def abbr_name
58
+ names[season_number].fetch(:abbr)
59
+ end
60
+
61
+ def abbr_year
62
+ strm[1..2]
63
+ end
64
+
65
+ def year
66
+ @year ||= "#{century}#{abbr_year}"
67
+ end
68
+
69
+ def description
70
+ @description ||= "#{name} #{year} #{type}"
71
+ end
72
+
73
+ def to_s
74
+ description
75
+ end
76
+
77
+ def abbreviated
78
+ @abbreviated ||= "#{abbr_name} '#{abbr_year} #{abbr_type}"
79
+ end
80
+
81
+ def <=>(other)
82
+ strm <=> other.strm
83
+ rescue NoMethodError
84
+ nil
85
+ end
86
+
87
+ def next_strm
88
+ if transition_semester?
89
+ '1124'
90
+ else
91
+ next_season_number = next_season.fetch(season_number)
92
+
93
+ case season_number
94
+ when 0, 2, 4
95
+ century_and_decade = strm[0..2]
96
+
97
+ "#{century_and_decade}#{next_season_number}"
98
+ when 8
99
+ century_indicator = strm[0].to_i
100
+ next_year = decade + 1
101
+
102
+ if next_year == 100
103
+ [century_indicator + 1, 0, 0, next_season_number].join
104
+ else
105
+ century_indicator.to_s + next_year.to_s.rjust(2, '0') + next_season_number.to_s
106
+ end
107
+ end
108
+ end
109
+ end
110
+
111
+ def next
112
+ self.class.new(strm: next_strm)
113
+ end
114
+
115
+ private
116
+
117
+ FOUR_DIGITS = /^\d{4}$/
118
+ CENTURIES = /(0|1)/
119
+
120
+ def season_number
121
+ @season_number ||= strm[-1].to_i
122
+ end
123
+
124
+ def century
125
+ @century ||= centuries[strm[0].to_i]
126
+ end
127
+
128
+ def decade
129
+ abbr_year.to_i
130
+ end
131
+ end
132
+
133
+ # Logic for OSU quarters
134
+ module Quarter
135
+ SEASONS = /(0|2|4|8)$/ # Winter, Spring, Summer, Autumn
136
+
137
+ def type
138
+ 'Quarter'
139
+ end
140
+
141
+ def abbr_type
142
+ 'Qtr'
143
+ end
144
+
145
+ def quarter?
146
+ true
147
+ end
148
+
149
+ def semester?
150
+ false
151
+ end
152
+
153
+ def transition_semester?
154
+ false
155
+ end
156
+
157
+ private
158
+
159
+ def names
160
+ {
161
+ 0 => { full: 'Winter', abbr: 'Wi' },
162
+ 2 => { full: 'Spring', abbr: 'Sp' },
163
+ 4 => { full: 'Summer', abbr: 'Su' },
164
+ 8 => { full: 'Autumn', abbr: 'Au' }
165
+ }
166
+ end
167
+
168
+ def centuries
169
+ {
170
+ 0 => '19',
171
+ 1 => '20'
172
+ }
173
+ end
174
+
175
+ def next_season
176
+ {
177
+ 0 => 2,
178
+ 2 => 4,
179
+ 4 => 8,
180
+ 8 => 0
181
+ }
182
+ end
183
+ end
184
+
185
+ # Logic for OSU transition terms
186
+ module TransitionTerm
187
+ SEASONS = /(3)$/ # Transition
188
+
189
+ def type
190
+ 'Semester Status Recalculation'
191
+ end
192
+
193
+ def abbr_type
194
+ 'Sem'
195
+ end
196
+
197
+ def quarter?
198
+ false
199
+ end
200
+
201
+ def semester?
202
+ true
203
+ end
204
+
205
+ def transition_semester?
206
+ true
207
+ end
208
+
209
+ private
210
+
211
+ def names
212
+ Hash.new(full: 'Spring', abbr: 'Sp')
213
+ end
214
+
215
+ def centuries
216
+ Hash.new('20')
217
+ end
218
+ end
219
+
220
+ # Logic for OSU semesters
221
+ module Semester
222
+ SEASONS = /(2|4|8)$/ # Spring, Summer, Autumn
223
+
224
+ def type
225
+ strm[-1] == SUMMER ? 'Term' : 'Semester'
226
+ end
227
+
228
+ def abbr_type
229
+ strm[-1] == SUMMER ? 'Trm' : 'Sem'
230
+ end
231
+
232
+ def quarter?
233
+ false
234
+ end
235
+
236
+ def semester?
237
+ true
238
+ end
239
+
240
+ def transition_semester?
241
+ false
242
+ end
243
+
244
+ private
245
+
246
+ SUMMER = '4'.freeze
247
+
248
+ def names
249
+ {
250
+ 2 => { full: 'Spring', abbr: 'Sp' },
251
+ 4 => { full: 'Summer', abbr: 'Su' },
252
+ 8 => { full: 'Autumn', abbr: 'Au' }
253
+ }
254
+ end
255
+
256
+ def centuries
257
+ Hash.new('20')
258
+ end
259
+
260
+ def next_season
261
+ {
262
+ 2 => 4,
263
+ 4 => 8,
264
+ 8 => 2
265
+ }
266
+ end
267
+ end
268
+ end
@@ -0,0 +1,3 @@
1
+ module OsuTerm
2
+ VERSION = '1.0.0'.freeze
3
+ end
@@ -0,0 +1,42 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'osu_term/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'osu_term'
7
+ spec.version = OsuTerm::VERSION
8
+ spec.authors = ['Kurt Mueller']
9
+ spec.email = ['mueller.128@osu.edu']
10
+
11
+ spec.summary = 'A simple gem for taking an OSU term\'s strm and turning it into useful information.'
12
+ spec.description = 'A simple gem for taking an OSU term\'s strm and turning it into useful information.'
13
+ spec.homepage = 'https://code.osu.edu/asctech/osu_term'
14
+ spec.license = 'MIT'
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
20
+ else
21
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
22
+ 'public gem pushes.'
23
+ end
24
+
25
+ # Specify which files should be added to the gem when it is released.
26
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
27
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
28
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
29
+ end
30
+ spec.bindir = 'exe'
31
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ['lib']
33
+
34
+ spec.add_development_dependency 'bundler', '~> 1.16'
35
+ spec.add_development_dependency 'rake', '~> 12.0'
36
+ spec.add_development_dependency 'rspec', '~> 3.0'
37
+
38
+ spec.add_development_dependency 'bundle-audit'
39
+ spec.add_development_dependency 'rubocop'
40
+ spec.add_development_dependency 'rubycritic'
41
+ spec.add_development_dependency 'simplecov'
42
+ end
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: osu_term
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Kurt Mueller
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-10-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '12.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '12.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundle-audit
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'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubycritic
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: A simple gem for taking an OSU term's strm and turning it into useful
112
+ information.
113
+ email:
114
+ - mueller.128@osu.edu
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - ".gitlab-ci.yml"
121
+ - ".rspec"
122
+ - ".rubocop.yml"
123
+ - ".travis.yml"
124
+ - CODE_OF_CONDUCT.md
125
+ - Dockerfile
126
+ - Gemfile
127
+ - Gemfile.lock
128
+ - Guardfile
129
+ - LICENSE.txt
130
+ - README.md
131
+ - Rakefile
132
+ - bin/console
133
+ - bin/setup
134
+ - lib/osu_term.rb
135
+ - lib/osu_term/version.rb
136
+ - osu_term.gemspec
137
+ homepage: https://code.osu.edu/asctech/osu_term
138
+ licenses:
139
+ - MIT
140
+ metadata:
141
+ allowed_push_host: https://rubygems.org
142
+ post_install_message:
143
+ rdoc_options: []
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 2.7.3
159
+ signing_key:
160
+ specification_version: 4
161
+ summary: A simple gem for taking an OSU term's strm and turning it into useful information.
162
+ test_files: []