work_together 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 37991469f21918cdbc8d5893b009706744e2f612
4
+ data.tar.gz: a835103329e4d1751b832e3c57b483bd9d60f5a4
5
+ SHA512:
6
+ metadata.gz: ca071d41e94e3fe661b381db7503695b4e236411a6ab26a68fe0cb309ae79f782e56a5fd5914064aaed1681948ae6177ef7931d89be6ac22e0942c2a7bb1d32d
7
+ data.tar.gz: 2ef26c270c8ad6f05980f293875139eeb734e839874a93129c8692a08ec599d68b58f0416c9a22cea4519695b700900a7a71833f3854d693fd90c159ac56653a
@@ -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,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in work_together.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 TODO: Write your name
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,41 @@
1
+ # WorkTogether
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/work_together`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'work_together'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install work_together
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/work_together.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
@@ -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 "work_together"
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,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pry'
3
+ require 'csv'
4
+ require_relative '../lib/work_together.rb'
5
+
6
+ if ARGV.length >= 3
7
+ WorkTogether.new(ARGV[2]).generate_togetherness(ARGV)
8
+ elsif ARGV.include?("--help")
9
+ WorkTogether.new.help
10
+ else
11
+ puts "please use work-together --help for a list of options"
12
+ end
@@ -0,0 +1,56 @@
1
+ require_relative './work_together/version'
2
+ require_relative './work_together/student.rb'
3
+ require_relative './work_together/parser.rb'
4
+ require_relative './work_together/table.rb'
5
+ require_relative './work_together/pair_maker.rb'
6
+
7
+ class WorkTogether
8
+
9
+ attr_accessor :roster, :students, :pair_maker
10
+
11
+ def initialize(path_to_csv=nil)
12
+ @roster = path_to_csv
13
+ @pair_maker = PairMaker.new
14
+ end
15
+
16
+ def generate_togetherness(options)
17
+ make_students
18
+ flag = options[1][2..-1]
19
+ if options.include?("pairs")
20
+ pair_maker.public_send("make_pairs_#{flag}", self.students)
21
+ display_tables
22
+ elsif options.include?("tables")
23
+ pair_maker.public_send("make_tables_#{flag}", self.students)
24
+ display_tables
25
+ elsif options.include?("--help")
26
+ help
27
+ else
28
+ puts "Please enter a valid command. Type work-together --help for more."
29
+ end
30
+ end
31
+
32
+ def display_tables
33
+ Table.all.each_with_index do |table, i|
34
+ puts "Group #{i + 1}:"
35
+ table.students.each do |student|
36
+ puts student.name
37
+ end
38
+ puts "-------------------"
39
+ end
40
+ end
41
+
42
+ def help
43
+ puts "Available commands:"
44
+ puts "work-together pairs --random path/to/csv-roster generate pairs randomly"
45
+ puts "work-together pairs --progress path/to/csv-roster generate pairs grouped by similar progress"
46
+ puts "work-together pairs --mindful path/to/csv-roster generate pairs with one person who is more advanced, one person less advanced"
47
+ puts "work-together tables --random path/to/csv-roster generate tables randomly"
48
+ puts "work-together tables --random path/to/csv-roster generate tables grouped by similar progress"
49
+ puts "work-together tables --random path/to/csv-roster generate tables with some people more advanced, some less"
50
+ end
51
+
52
+ def make_students
53
+ Parser.parse_and_make_students(roster)
54
+ @students = Student.all
55
+ end
56
+ end
@@ -0,0 +1,115 @@
1
+ require_relative "./table.rb"
2
+
3
+ class PairMaker
4
+
5
+ attr_accessor :batches
6
+
7
+ def initialize
8
+ @batches = []
9
+ end
10
+
11
+ def make_pairs_random(students)
12
+ students.shuffle!
13
+ two_from_batch(students)
14
+ make_tables
15
+ end
16
+
17
+ def make_pairs_mindful(students)
18
+ sorted = sort_by_progress(students)
19
+ two_from_batch(sorted)
20
+ two_groups_of_two = []
21
+ self.batches.each_slice(2) {|slice| two_groups_of_two << slice}
22
+ mindful_batch_of_two(two_groups_of_two)
23
+ end
24
+
25
+ def make_pairs_progress(students)
26
+ sorted_students = sort_by_progress(students)
27
+ two_from_batch(sorted_students)
28
+ make_tables
29
+ end
30
+
31
+ def make_tables_progress(students)
32
+ sorted_students = sort_by_progress(students)
33
+ four_from_batch(sorted_students)
34
+ make_tables
35
+ end
36
+
37
+ def make_tables_random(students)
38
+ students.shuffle!
39
+ four_from_batch(students)
40
+ make_tables
41
+ end
42
+
43
+ def make_tables_mindful(students)
44
+ sorted_students = sort_by_progress(students)
45
+ four_from_batch(sorted_students)
46
+ two_groups_of_four = []
47
+ self.batches.each_slice(2) {|slice| two_groups_of_four << slice}
48
+ mindful_batch_of_four(two_groups_of_four)
49
+ end
50
+
51
+ private
52
+
53
+ def randomize_students(students)
54
+ students.collect {|student| student.name}.shuffle!
55
+ end
56
+
57
+ def sort_by_progress(students)
58
+ students.sort_by! do |student|
59
+ student.progress.to_i
60
+ end
61
+ end
62
+
63
+ def four_from_batch(students)
64
+ students.each_slice(4) {|slice| self.batches << slice}
65
+ self.batches
66
+ end
67
+
68
+ def two_from_batch(students)
69
+ students.each_slice(2) {|slice| self.batches << slice}
70
+ self.batches
71
+ end
72
+
73
+ def make_tables
74
+ self.batches.each do |batch|
75
+ Table.new(batch)
76
+ end
77
+ end
78
+
79
+ def mindful_batch_of_four(students)
80
+ students.each do |group|
81
+ first = group[0]
82
+ second = group[1]
83
+ if second
84
+ last_two_first = first.values_at(-1, -2)
85
+ first_two_second = second.values_at(0, 1)
86
+ 2.times do
87
+ first.delete_at(-1)
88
+ second.delete_at(0)
89
+ end
90
+ first = first + first_two_second
91
+ second = second + last_two_first
92
+ Table.new(first)
93
+ Table.new(second)
94
+ else
95
+ Table.new(first)
96
+ end
97
+ end
98
+ end
99
+
100
+ def mindful_batch_of_two(two_groups_of_two)
101
+ two_groups_of_two.each do |group|
102
+ first = group[0]
103
+ second = group[1]
104
+ first_last = first[-1]
105
+ second_first = second[0]
106
+ first.delete_at(-1)
107
+ second.delete_at(0)
108
+ first << second_first
109
+ second << first_last
110
+ Table.new(first)
111
+ Table.new(second)
112
+ end
113
+ end
114
+
115
+ end
@@ -0,0 +1,13 @@
1
+ require 'csv'
2
+ require_relative './student.rb'
3
+
4
+ class Parser
5
+
6
+ def self.parse_and_make_students(file)
7
+ CSV.foreach(file) do |row|
8
+ name = "#{row[0]} #{row[1]}"
9
+ progress = row[5]
10
+ Student.new(name, progress)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ class Student
2
+
3
+ @@all = []
4
+
5
+ attr_accessor :name, :progress
6
+
7
+ def initialize(name, progress)
8
+ @name = name
9
+ @progress = progress
10
+ @@all << self
11
+ end
12
+
13
+ def self.all
14
+ @@all
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ class Table
2
+ @@all = []
3
+
4
+ def initialize(student_array)
5
+ @students = student_array
6
+ @@all << self unless student_array.include?([])
7
+ end
8
+
9
+ def students
10
+ @students
11
+ end
12
+
13
+ def self.all
14
+ @@all
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ class WorkTogether
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'work_together/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "work_together"
8
+ spec.version = WorkTogether::VERSION
9
+ spec.authors = ["Sophie DeBenedetto"]
10
+ spec.email = ["sophie.debenedetto@gmail.com"]
11
+
12
+ spec.summary = %q{Automatically generate pairs and tables for you class from the command line.}
13
+ spec.homepage = "https://github.com/SophieDeBenedetto/work-together"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
17
+ # delete this section to allow pushing this gem 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 public gem pushes."
22
+ end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ # spec.bindir = "exec"
26
+ # spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.executables << 'work-together'
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.10"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec"
33
+ end
34
+
35
+
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: work_together
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sophie DeBenedetto
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-02 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - sophie.debenedetto@gmail.com
58
+ executables:
59
+ - work-together
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".travis.yml"
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/console
71
+ - bin/setup
72
+ - bin/work-together
73
+ - lib/work_together.rb
74
+ - lib/work_together/pair_maker.rb
75
+ - lib/work_together/parser.rb
76
+ - lib/work_together/student.rb
77
+ - lib/work_together/table.rb
78
+ - lib/work_together/version.rb
79
+ - work_together.gemspec
80
+ homepage: https://github.com/SophieDeBenedetto/work-together
81
+ licenses:
82
+ - MIT
83
+ metadata:
84
+ allowed_push_host: https://rubygems.org
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.4.8
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: Automatically generate pairs and tables for you class from the command line.
105
+ test_files: []