work_together 0.5.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71b53e8b8573dd1d69a3aaa584a97c01e6d9c66b
4
- data.tar.gz: 0343262c8259704b8c91f17a7a9707fd67a0ccfb
3
+ metadata.gz: a6f2fb796937e7f37d46abee6d075df3d25550d6
4
+ data.tar.gz: a9bede98d7bc13351dc99427d79935b5f30b8ae7
5
5
  SHA512:
6
- metadata.gz: c03983fb0706c03d71f11abf26a98024ea279e08b7f2ea29d24f4ac15412d13c7882d91ce19a80a6d0b6f8597c26e9e6c337b93b8106ff641f389bec9abc2adc
7
- data.tar.gz: f8f3416e7b5e634e3e9a0329f7c5fb75e211db1c9ea2fa63cd718ae1e6b015cafdabd10756bc6bd5456eb4106419b5dca8727d2e71355c00d71a608cbd92c17a
6
+ metadata.gz: 97a17e65266a397f0f303d48f36af43968164d2ba91683ab5d8f648eeb50dc025122ccf752e129b9284fac69522058609456394e81d13602815c6e124363e53b
7
+ data.tar.gz: b398ffa81c018727b8094ba4ee283a07b4d049c27a3f0a75e0a71772e65147ed4b5f3607418af5f4c29516c6ff602e0701a35af600584d9f14d3eb2f451d750b
data/bin/work-together CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
- require 'pry'
2
+
3
3
  require 'csv'
4
4
  require_relative '../lib/work_together.rb'
5
5
 
6
6
  if ARGV.length >= 3
7
- WorkTogether.new(ARGV[2]).generate_togetherness(ARGV)
7
+ WorkTogether::Generator.new(ARGV[2]).generate_togetherness(ARGV)
8
8
  elsif ARGV.include?("--help")
9
- WorkTogether.new.help
9
+ WorkTogether::Generator.new.help
10
10
  else
11
11
  puts "please use work-together --help for a list of options"
12
12
  end
@@ -1,19 +1,9 @@
1
1
  require 'csv'
2
- require_relative './student.rb'
3
2
  class Parser
4
3
 
5
- def self.parse_and_make_students(file)
6
- CSV.parse(file, headers: true).each do |row|
7
- make_student_with_attributes(row.to_h) unless row[0] == "first_name" || row[0].nil?
8
- end
9
- end
10
-
11
- def self.make_student_with_attributes(row)
12
- row.delete_if {|k, v| !Student.instance_methods.include?(k.to_sym)}
13
- Student.new.tap do |student|
14
- row.each do |attribute, value|
15
- student.public_send("#{attribute}=", value)
16
- end
4
+ def self.parse_students(file)
5
+ CSV.parse(file, headers: true).map do |row|
6
+ row
17
7
  end
18
8
  end
19
9
  end
@@ -1,3 +1,3 @@
1
- class WorkTogether
2
- VERSION = "0.5.0"
1
+ module WorkTogether
2
+ VERSION = "0.6.0"
3
3
  end
data/lib/work_together.rb CHANGED
@@ -1,96 +1,131 @@
1
1
  require_relative './work_together/version'
2
- require_relative './work_together/student.rb'
3
2
  require_relative './work_together/parser.rb'
4
3
  require_relative './work_together/table.rb'
5
4
  require_relative './work_together/pair_maker.rb'
6
5
  require_relative './work_together/learn_proxy.rb'
7
- require 'pry'
8
6
  require 'colorize'
9
7
 
10
- class WorkTogether
8
+ module WorkTogether
11
9
 
12
- attr_accessor :batch_id, :client, :pair_maker, :keys, :students
10
+ class Generator
13
11
 
14
- def initialize(batch_id)
15
- @batch_id = batch_id
16
- @pair_maker = PairMaker.new
17
- end
12
+ attr_accessor :batch_id, :client, :pair_maker, :keys
18
13
 
14
+ def initialize(batch_id)
15
+ @batch_id = batch_id
16
+ @pair_maker = PairMaker.new
17
+ end
19
18
 
20
- def generate_togetherness(options, quiet=nil)
21
- make_batch
22
- make_groups(options, quiet=quiet)
23
- end
24
19
 
25
- def make_batch
26
- configure_client
27
- get_and_parse_csv
28
- @students = Student.all
29
- end
20
+ def generate_togetherness(options, quiet=nil)
21
+ make_batch
22
+ make_groups(options, quiet=quiet)
23
+ end
30
24
 
31
- def make_groups(options, quiet)
32
- flag = options[1][2..-1]
33
- if options.include?("pairs")
34
- pair_maker.public_send("make_pairs_#{flag}", self.students)
35
- elsif options.include?("tables")
36
- pair_maker.public_send("make_tables_#{flag}", self.students)
37
- elsif options.include?("--help")
38
- help
39
- else
40
- puts "Please enter a valid command. Type work-together --help for more."
25
+ def make_batch
26
+ configure_client
27
+ student_data = get_and_parse_csv
28
+ Student.generate_from_data(student_data)
29
+ end
30
+
31
+ def make_groups(options, quiet)
32
+ flag = options[1][2..-1]
33
+ if options.include?("pairs")
34
+ pair_maker.public_send("make_pairs_#{flag}", Student.all)
35
+ elsif options.include?("tables")
36
+ pair_maker.public_send("make_tables_#{flag}", Student.all)
37
+ elsif options.include?("--help")
38
+ help
39
+ else
40
+ puts "Please enter a valid command. Type work-together --help for more."
41
+ end
42
+ display_tables if !quiet && Table.all.length > 0
41
43
  end
42
- display_tables if !quiet && Table.all.length > 0
43
- end
44
44
 
45
- private
45
+ private
46
46
 
47
- def display_tables
48
- Table.all.each_with_index do |table, i|
49
- puts "Group #{i + 1}:".colorize(:blue)
50
- table.students.each do |student|
51
- puts student.name.colorize(:light_blue)
47
+ def display_tables
48
+ Table.all.each_with_index do |table, i|
49
+ puts "Group #{i + 1}:".colorize(:blue)
50
+ table.students.each do |student|
51
+ puts student.name.colorize(:light_blue)
52
+ end
53
+ puts "-------------------".colorize(:blue)
52
54
  end
53
- puts "-------------------".colorize(:blue)
54
- end
55
- end
55
+ end
56
+
57
+ def help
58
+ puts "Available commands:"
59
+ puts "work-together pairs --random batch-number generate pairs randomly"
60
+ puts "work-together pairs --progress batch-number generate pairs grouped by similar progress"
61
+ puts "work-together pairs --mindful batch-number generate pairs with one person who is more advanced, one person less advanced"
62
+ puts "work-together tables --random batch-number generate tables randomly"
63
+ puts "work-together tables --progress batch-number generate tables grouped by similar progress"
64
+ puts "work-together tables --mindful batch-number generate tables with some people more advanced, some less"
65
+ end
66
+
67
+ def configure_client
68
+ configure_keys
69
+ credentials = LearnProxy::Credentials.new(self.keys['GITHUB_USERNAME'], self.keys['GITHUB_PASSWORD'])
70
+ @client = LearnProxy::Client.new(credentials)
71
+ end
72
+
73
+ def configure_keys
74
+ @keys = YAML.load_file(File.expand_path(File.dirname(__FILE__)) + '/work_together/client.yml')
75
+ get_and_store_keys unless @keys
76
+ end
77
+
78
+ def get_and_store_keys
79
+ puts "Please enter your github username:"
80
+ username = STDIN.gets.chomp
81
+ puts "Please enter your github password:"
82
+ password = STDIN.gets.chomp
83
+ @keys = {"GITHUB_USERNAME" => username, "GITHUB_PASSWORD" => password}
84
+ File.open(File.expand_path(File.dirname(__FILE__)) + '/work_together/client.yml', 'w') {|f| f.write self.keys.to_yaml }
85
+ end
86
+
87
+ def get_roster
88
+ self.client.csv_for(self.batch_id)
89
+ end
90
+
91
+ def get_and_parse_csv
92
+ roster = get_roster
93
+ Parser.parse_students(roster)
94
+ end
95
+ end
56
96
 
57
- def help
58
- puts "Available commands:"
59
- puts "work-together pairs --random batch-number generate pairs randomly"
60
- puts "work-together pairs --progress batch-number generate pairs grouped by similar progress"
61
- puts "work-together pairs --mindful batch-number generate pairs with one person who is more advanced, one person less advanced"
62
- puts "work-together tables --random batch-number generate tables randomly"
63
- puts "work-together tables --progress batch-number generate tables grouped by similar progress"
64
- puts "work-together tables --mindful batch-number generate tables with some people more advanced, some less"
65
- end
97
+ class Student
98
+ @@all = []
66
99
 
67
- def configure_client
68
- configure_keys
69
- credentials = LearnProxy::Credentials.new(self.keys['GITHUB_USERNAME'], self.keys['GITHUB_PASSWORD'])
70
- @client = LearnProxy::Client.new(credentials)
100
+ attr_accessor :first_name, :last_name, :completion, :github_username, :email, :active_track
101
+
102
+ def initialize
103
+ @@all << self
71
104
  end
72
105
 
73
- def configure_keys
74
- @keys = YAML.load_file(File.expand_path(File.dirname(__FILE__)) + '/work_together/client.yml')
75
- get_and_store_keys unless @keys
106
+ def self.all
107
+ @@all
76
108
  end
77
109
 
78
- def get_and_store_keys
79
- puts "Please enter your github username:"
80
- username = STDIN.gets.chomp
81
- puts "Please enter your github password:"
82
- password = STDIN.gets.chomp
83
- @keys = {"GITHUB_USERNAME" => username, "GITHUB_PASSWORD" => password}
84
- File.open(File.expand_path(File.dirname(__FILE__)) + '/work_together/client.yml', 'w') {|f| f.write self.keys.to_yaml }
110
+ def name
111
+ "#{first_name} #{last_name}"
85
112
  end
86
113
 
87
- def get_roster
88
- self.client.csv_for(self.batch_id)
114
+ def progress
115
+ self.completion
89
116
  end
90
117
 
91
- def get_and_parse_csv
92
- roster = get_roster
93
- Parser.parse_and_make_students(roster)
118
+ def self.generate_from_data(data)
119
+ data.each do |student_hash|
120
+ student_hash.delete_if {|attribute, value| !Student.instance_methods.include?(attribute.to_sym)}
121
+ self.new.tap do |student|
122
+ student_hash.each do |attribute, value|
123
+ student.public_send("#{attribute}=", value)
124
+ end
125
+ end
126
+ end
94
127
  end
128
+
129
+ end
95
130
  end
96
131
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: work_together
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sophie DeBenedetto
@@ -122,7 +122,6 @@ files:
122
122
  - lib/work_together/learn_proxy.rb
123
123
  - lib/work_together/pair_maker.rb
124
124
  - lib/work_together/parser.rb
125
- - lib/work_together/student.rb
126
125
  - lib/work_together/table.rb
127
126
  - lib/work_together/version.rb
128
127
  homepage: https://github.com/SophieDeBenedetto/work-together
@@ -1,23 +0,0 @@
1
- class Student
2
-
3
- @@all = []
4
-
5
- attr_accessor :first_name, :last_name, :completion, :github_username, :email, :active_track
6
-
7
- def initialize
8
- @@all << self
9
- end
10
-
11
- def self.all
12
- @@all
13
- end
14
-
15
- def name
16
- "#{first_name} #{last_name}"
17
- end
18
-
19
- def progress
20
- self.completion
21
- end
22
-
23
- end