work_together 0.3.0 → 0.4.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 +4 -4
- data/lib/work_together.rb +68 -28
- data/lib/work_together/client.yml +0 -0
- data/lib/work_together/learn_proxy.rb +67 -0
- data/lib/work_together/parser.rb +9 -6
- data/lib/work_together/student.rb +11 -4
- data/lib/work_together/version.rb +1 -1
- metadata +60 -12
- data/.gitignore +0 -9
- data/.rspec +0 -2
- data/.travis.yml +0 -4
- data/Gemfile +0 -5
- data/LICENSE.txt +0 -21
- data/README.md +0 -21
- data/Rakefile +0 -6
- data/bin/console +0 -14
- data/bin/setup +0 -7
- data/work_together.gemspec +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1679b25e7d146fbaa554685957d3f12a0674b821
|
4
|
+
data.tar.gz: 01d3619e464df51b5a0c0e2cfb1ce23d0e4ce61a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf8ecb36bf2ea4375ba8ccf1818b0d81f7814bb05aa08b776030b4e923a54beb2165c7b9f385ff9897b40e2919da4451f6bfd00188dfe299dcebc81d20106141
|
7
|
+
data.tar.gz: f28d681035b1ec65e534417c35714d510b0c49c90949f3dc9526bfcae5f2c6dcf17421f9a4eefa79f0bafd304628fae65f9313a476fcd4a8384b4e0681f7e282
|
data/lib/work_together.rb
CHANGED
@@ -3,54 +3,94 @@ require_relative './work_together/student.rb'
|
|
3
3
|
require_relative './work_together/parser.rb'
|
4
4
|
require_relative './work_together/table.rb'
|
5
5
|
require_relative './work_together/pair_maker.rb'
|
6
|
+
require_relative './work_together/learn_proxy.rb'
|
7
|
+
require 'pry'
|
8
|
+
require 'colorize'
|
6
9
|
|
7
10
|
class WorkTogether
|
8
11
|
|
9
|
-
attr_accessor :
|
12
|
+
attr_accessor :batch_id, :client, :pair_maker, :keys, :students
|
10
13
|
|
11
|
-
def initialize(
|
12
|
-
@
|
14
|
+
def initialize(batch_id)
|
15
|
+
@batch_id = batch_id
|
13
16
|
@pair_maker = PairMaker.new
|
14
17
|
end
|
15
18
|
|
16
|
-
|
17
|
-
|
19
|
+
|
20
|
+
def generate_togetherness(options, quiet=nil)
|
21
|
+
make_batch
|
22
|
+
make_groups(options, quiet=quiet)
|
23
|
+
end
|
24
|
+
|
25
|
+
def make_batch
|
26
|
+
configure_client
|
27
|
+
get_and_parse_csv
|
28
|
+
@students = Student.all
|
29
|
+
end
|
30
|
+
|
31
|
+
def make_groups(options, quiet)
|
18
32
|
flag = options[1][2..-1]
|
19
33
|
if options.include?("pairs")
|
20
34
|
pair_maker.public_send("make_pairs_#{flag}", self.students)
|
21
|
-
display_tables
|
22
35
|
elsif options.include?("tables")
|
23
36
|
pair_maker.public_send("make_tables_#{flag}", self.students)
|
24
|
-
display_tables
|
25
37
|
elsif options.include?("--help")
|
26
38
|
help
|
27
39
|
else
|
28
40
|
puts "Please enter a valid command. Type work-together --help for more."
|
29
41
|
end
|
42
|
+
display_tables if !quiet && Table.all.length > 0
|
30
43
|
end
|
31
44
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
puts
|
45
|
+
private
|
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(:green)
|
52
|
+
end
|
53
|
+
puts "-------------------".colorize(:pink)
|
37
54
|
end
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
55
|
+
end
|
41
56
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
51
66
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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_and_make_students(roster)
|
94
|
+
end
|
56
95
|
end
|
96
|
+
|
File without changes
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'mechanize'
|
2
|
+
|
3
|
+
module LearnProxy
|
4
|
+
class Client
|
5
|
+
CSV_URL = -> (batch_id) {"https://learn.co/batches/#{batch_id}/students.csv"}
|
6
|
+
|
7
|
+
def initialize(credentials)
|
8
|
+
@credentials = credentials
|
9
|
+
end
|
10
|
+
|
11
|
+
def csv_for(batch_id)
|
12
|
+
connection.get(CSV_URL[batch_id]).body
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
attr_reader :credentials
|
17
|
+
|
18
|
+
def connection
|
19
|
+
@connection ||= Connection.new(credentials)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Connection
|
24
|
+
extend Forwardable
|
25
|
+
def_delegator :@session, :get
|
26
|
+
|
27
|
+
def initialize(credentials)
|
28
|
+
@credentials = credentials
|
29
|
+
connect!
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
attr_reader :credentials
|
34
|
+
def connect!
|
35
|
+
@session ||= begin
|
36
|
+
Mechanize.new.tap do |client|
|
37
|
+
client.get('https://learn.co/sign_in/github?sign_in=true')
|
38
|
+
form = client.page.form_with!(action: "/session")
|
39
|
+
GithubForm.submit(form, credentials)
|
40
|
+
client.page.link_with!(href: /learn\.co/).click
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
module GithubForm
|
47
|
+
def self.submit(form, credentials)
|
48
|
+
form['login'] = credentials.username
|
49
|
+
form['password'] = credentials.password
|
50
|
+
form.submit
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class Credentials
|
55
|
+
attr_accessor :username, :password
|
56
|
+
def initialize(username, password)
|
57
|
+
@username = username
|
58
|
+
@password = password
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
data/lib/work_together/parser.rb
CHANGED
@@ -3,14 +3,17 @@ require_relative './student.rb'
|
|
3
3
|
class Parser
|
4
4
|
|
5
5
|
def self.parse_and_make_students(file)
|
6
|
-
CSV.
|
7
|
-
|
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
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
def self.
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
17
|
+
end
|
15
18
|
end
|
16
19
|
end
|
@@ -2,15 +2,22 @@ class Student
|
|
2
2
|
|
3
3
|
@@all = []
|
4
4
|
|
5
|
-
attr_accessor :
|
5
|
+
attr_accessor :first_name, :last_name, :completion, :github_username, :email, :active_track
|
6
6
|
|
7
|
-
def initialize
|
8
|
-
@name = name
|
9
|
-
@progress = progress
|
7
|
+
def initialize
|
10
8
|
@@all << self
|
11
9
|
end
|
12
10
|
|
13
11
|
def self.all
|
14
12
|
@@all
|
15
13
|
end
|
14
|
+
|
15
|
+
def name
|
16
|
+
"#{first_name} #{last_name}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def progress
|
20
|
+
self.completion
|
21
|
+
end
|
22
|
+
|
16
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: work_together
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sophie DeBenedetto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,62 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mechanize
|
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: webmock
|
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: vcr
|
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: colorize
|
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'
|
55
111
|
description:
|
56
112
|
email:
|
57
113
|
- sophie.debenedetto@gmail.com
|
@@ -60,23 +116,15 @@ executables:
|
|
60
116
|
extensions: []
|
61
117
|
extra_rdoc_files: []
|
62
118
|
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
119
|
- bin/work-together
|
73
120
|
- lib/work_together.rb
|
121
|
+
- lib/work_together/client.yml
|
122
|
+
- lib/work_together/learn_proxy.rb
|
74
123
|
- lib/work_together/pair_maker.rb
|
75
124
|
- lib/work_together/parser.rb
|
76
125
|
- lib/work_together/student.rb
|
77
126
|
- lib/work_together/table.rb
|
78
127
|
- lib/work_together/version.rb
|
79
|
-
- work_together.gemspec
|
80
128
|
homepage: https://github.com/SophieDeBenedetto/work-together
|
81
129
|
licenses:
|
82
130
|
- MIT
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
@@ -1,21 +0,0 @@
|
|
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.
|
data/README.md
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# WorkTogether
|
2
|
-
|
3
|
-
`gem install work_together`
|
4
|
-
|
5
|
-
`work-together --help`
|
6
|
-
|
7
|
-
`work-together pairs --random /path/to/student/csv`
|
8
|
-
|
9
|
-
`work-together tables --random /path/to/student/csv`
|
10
|
-
|
11
|
-
`work-together pairs --mindful /path/to/student/csv`
|
12
|
-
|
13
|
-
`work-together talbes --mindful /path/to/student/csv`
|
14
|
-
|
15
|
-
`work-together pairs --progress /path/to/student/csv`
|
16
|
-
|
17
|
-
`work-together tables --progress /path/to/student/csv`
|
18
|
-
|
19
|
-
Download student roster csv from batch, progress view in learn.co
|
20
|
-
|
21
|
-
Tests coming soon...
|
data/Rakefile
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
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
|
data/bin/setup
DELETED
data/work_together.gemspec
DELETED
@@ -1,35 +0,0 @@
|
|
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
|
-
|