dbc_today 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 166ada7b9c0a52ddc044c8faf53ff31428e8b28f
4
+ data.tar.gz: 8173b06f881ffbe05a164fb5df0ebcc1c9c5e8f6
5
+ SHA512:
6
+ metadata.gz: c592ae1a4452603f5769fb457df9bf191c01ea55aeb40d86780ba93bfb3943e863f9908e1dfafbf8572c75261f7f98903ddfa5569bf77533016fb5ff9596e760
7
+ data.tar.gz: 41d0683308ff86522a2ff74d9f1f549dcae118a9ec425655e64dd2d8c5b1986fc5b387913877173a47ed2a10f64281e4c4662aaca94f4ff100b3e890b82496dc
data/.gitignore ADDED
@@ -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/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ before_install: gem install bundler -v 1.11.2
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at TODO: Write your email address. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in dbc_today.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Mark Stewart
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.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # DbcToday
2
+
3
+ ## Purpose
4
+
5
+ To print out the events on the schedule for a particular phase, during a particular day and week of that phase.
6
+
7
+ ## Installation
8
+
9
+ $ gem install dbc_today
10
+
11
+ ## Usage
12
+
13
+ `dbctoday [phase number] [week number] [day number (optional; defaults to current day number)]`
14
+
15
+ Examples:
16
+
17
+ `dbctoday 1 1 1` for phase 1, week 1, day 1 schedule
18
+ `dbctoday 1 1` for phase 1, week 1 schedule for today's day of the week
19
+
20
+ ## Development
21
+
22
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
23
+
24
+ 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).
25
+
26
+ ## Contributing
27
+
28
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/dbc_today. 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.
29
+
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
34
+
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "dbc_today"
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
data/bin/setup ADDED
@@ -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
data/dbc_today.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dbc_today/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "dbc_today"
8
+ spec.version = DbcToday::VERSION
9
+ spec.authors = ["Mark Stewart"]
10
+ spec.email = ["mark.stewart@devbootcamp.com"]
11
+
12
+ spec.summary = %q{A console app for checking today's schedule at DBC.}
13
+ spec.description = %q{Also serves as a demo for console MVC style}
14
+ spec.homepage = "https://github.com/Devbootcamp/dbc_today"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.11"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "minitest", "~> 5.0"
25
+ spec.add_development_dependency "colorizer", ">= 0.0.2"
26
+ end
data/exe/dbctoday ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ # ^ The above comment tells the system
3
+ # to read this file like a ruby file
4
+ require_relative '../lib/dbc_today/controller'
5
+
6
+ phase = ARGV[0]
7
+ week = ARGV[1]
8
+ day = ARGV[2] || Date.today.wday.to_s
9
+
10
+ controller = Controller.new
11
+
12
+ controller.show_schedule(phase, week, day)
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ ruby '2.3'
4
+
5
+ gem 'colorize'
@@ -0,0 +1,16 @@
1
+ require 'date'
2
+ require_relative 'view'
3
+ require_relative 'event'
4
+
5
+ class Controller
6
+ attr_reader :view
7
+
8
+ def initialize
9
+ @view = View.new
10
+ end
11
+
12
+ def show_schedule(phase, week, day)
13
+ events = Event.where(phase: phase, week: week, day: day)
14
+ view.show_events(events)
15
+ end
16
+ end
@@ -0,0 +1,75 @@
1
+ require_relative 'timeable'
2
+ require 'csv'
3
+
4
+ class Event
5
+ include Timeable
6
+ attr_reader :phase, :week, :day, :description, :start_time, :end_time
7
+
8
+ def initialize(attributes)
9
+ @phase = attributes.fetch(:phase)
10
+ @week = attributes.fetch(:week)
11
+ @day = attributes.fetch(:day)
12
+ @description = attributes.fetch(:description, nil)
13
+ @start_time = attributes.fetch(:start_time, nil)
14
+ @end_time = attributes.fetch(:end_time, nil)
15
+ end
16
+
17
+ def all_day?
18
+ start_time.downcase == 'all day' ||
19
+ (starts_at_day_start? &&
20
+ ends_at_day_end?)
21
+ end
22
+
23
+ def moment?
24
+ start_time == end_time ||
25
+ end_time.nil?
26
+ end
27
+
28
+ def start_time_military
29
+ in_military(start_time)
30
+ end
31
+
32
+ def self.all
33
+ list = []
34
+
35
+ CSV.foreach(
36
+ "#{current_directory}/schedule.csv",
37
+ headers: true,
38
+ header_converters: :symbol,
39
+ skip_blanks: true
40
+ ) do |row|
41
+ list << Event.new(row)
42
+ end
43
+
44
+ list
45
+ end
46
+
47
+ def self.where(phase:, week:, day:)
48
+ all.select { |event|
49
+ nil_or_match(event.phase, phase) &&
50
+ nil_or_match(event.week, week) &&
51
+ nil_or_match(event.day, day)
52
+ }.sort_by { |e| e.start_time_military }
53
+ end
54
+
55
+ private
56
+
57
+ def starts_at_day_start?
58
+ start_time.start_with?('9:00a') ||
59
+ start_time.start_with?('9a')
60
+ end
61
+
62
+ def ends_at_day_end?
63
+ end_time&.start_with?('6:00p') ||
64
+ end_time&.start_with?('6p')
65
+ end
66
+
67
+ def self.nil_or_match(attribute_value, value_to_match)
68
+ attribute_value.nil? ||
69
+ attribute_value.include?(value_to_match)
70
+ end
71
+
72
+ def self.current_directory
73
+ File.expand_path File.dirname(__FILE__)
74
+ end
75
+ end
@@ -0,0 +1,28 @@
1
+ phase,week,day,description,start_time,end_time
2
+ ,,,begin day,9am,
3
+ ,,,lunch,12:30pm,2pm
4
+ ,,,announcements,2pm,2:15pm
5
+ ,,,end of day,5:30pm,6pm
6
+ ,,,end day,6pm,
7
+ 1,,1+3,yoga,12:15pm,1pm
8
+ 2+3,,2+4,yoga,12:15pm,1pm
9
+ ,,5,check-in groups,9am,9:50am
10
+
11
+ 1,1,1,orientation,all day,
12
+ ,,4,solo day,all day,
13
+ ,,5,group day,all day,
14
+ 1,1,2,feedback and teamwork ee,4:30pm,6pm
15
+ 2,1,3,allyship and inclusion ee,4:30pm,6pm
16
+ 2,2,2,resilience and the inner critic ee,4:30pm,6pm
17
+ 3,2,3,team dynamics ee,3:30pm,4:30pm
18
+ 2,2,3,navigating difficult conversations ee,4:30pm,6pm
19
+ 3,2,4,project pitches,9am,9:20am
20
+ 1,3,1,empathy and authenticity ee, 430pm,6pm
21
+ 1,3,3,p1 assessments,9am,12:45pm
22
+ 2,3,3,p2 assessments,9am,5pm
23
+ 1,3,3,assessment review,9am,5pm
24
+ 1,3,3,assessment results,5pm,6pm
25
+ 3,3,5,p3 graduation!,all day,
26
+ 3,3,5,p3 demo practice,10am,12:30pm
27
+ ,3,5,graduation lunch,12:30pm,2pm
28
+ ,3,5,graduation party,6pm,8pm
@@ -0,0 +1,30 @@
1
+ module Timeable
2
+ private
3
+
4
+ def in_military(time_string)
5
+ return '00:00' unless time_string =~ /\d(:\d{2})?(a|p)m/
6
+
7
+ normalized_time = normalize_time(time_string.dup)
8
+
9
+ meridian = normalized_time.slice!(/(a|p)m/)
10
+ if meridian == 'am' || normalized_time.include?('12:')
11
+ normalized_time.rjust(5, '0')
12
+ else
13
+ add_twelve_hours(normalized_time)
14
+ end
15
+ end
16
+
17
+ def add_twelve_hours(time_string)
18
+ hours, minutes = time_string.split(':')
19
+ new_hours = (hours.to_i + 12).to_s
20
+ "#{new_hours}:#{minutes}"
21
+ end
22
+
23
+ def normalize_time(time_string)
24
+ if time_string.include?(':')
25
+ time_string
26
+ else
27
+ time_string.insert(-3, ':00')
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,3 @@
1
+ module DbcToday
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,63 @@
1
+ require 'colorize'
2
+
3
+ class View
4
+ def show_events(events)
5
+ puts "\n#{header_row}"
6
+
7
+ events.each do |event|
8
+ puts event_row(event)
9
+ end
10
+
11
+ puts
12
+ end
13
+
14
+ private
15
+
16
+ def columns
17
+ {
18
+ phase: 6,
19
+ week: 6,
20
+ day: 6,
21
+ description: 20,
22
+ start_time: 12,
23
+ end_time: 12
24
+ }
25
+ end
26
+
27
+ def cell(value, width)
28
+ string = value
29
+ .to_s
30
+ .tr('_', ' ')
31
+ .ljust(width - 1) + ' '
32
+
33
+ if string.length > width
34
+ string[0..width - 5] + '... '
35
+ else
36
+ string
37
+ end
38
+ end
39
+
40
+ def header_row
41
+ headers =
42
+ columns
43
+ .map { |k, v| cell(k, v) }
44
+
45
+ headers.join.underline
46
+ end
47
+
48
+ def event_row(event)
49
+ cells =
50
+ columns
51
+ .map { |k, v| cell(event.send(k), v) }
52
+
53
+ string = cells.join
54
+
55
+ if event.all_day?
56
+ string.blue
57
+ elsif event.moment?
58
+ string.red
59
+ else
60
+ string
61
+ end
62
+ end
63
+ end
data/lib/dbc_today.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "dbc_today/version"
2
+
3
+ module DbcToday
4
+ # Your code goes here...
5
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dbc_today
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mark Stewart
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-05-26 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.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: colorizer
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 0.0.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 0.0.2
69
+ description: Also serves as a demo for console MVC style
70
+ email:
71
+ - mark.stewart@devbootcamp.com
72
+ executables:
73
+ - dbctoday
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".travis.yml"
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - dbc_today.gemspec
87
+ - exe/dbctoday
88
+ - lib/dbc_today.rb
89
+ - lib/dbc_today/Gemfile
90
+ - lib/dbc_today/controller.rb
91
+ - lib/dbc_today/event.rb
92
+ - lib/dbc_today/schedule.csv
93
+ - lib/dbc_today/timeable.rb
94
+ - lib/dbc_today/version.rb
95
+ - lib/dbc_today/view.rb
96
+ homepage: https://github.com/Devbootcamp/dbc_today
97
+ licenses:
98
+ - MIT
99
+ metadata: {}
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 2.5.1
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: A console app for checking today's schedule at DBC.
120
+ test_files: []