kurki 0.2.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -4
- data/bin/kurki +77 -0
- data/kurki.gemspec +3 -0
- data/lib/kurki/version.rb +1 -1
- data/lib/kurki.rb +1 -1
- data/spec/kurki_spec.rb +1 -1
- metadata +33 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db479d77a3a2d711264f9aefa65446bdd4ad9136
|
4
|
+
data.tar.gz: a04e7310befd0e261520818a21633d9187a766d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bc5a08affcd5280aa4b22ed5d5cd54b3ac27f345ba947d46a8026c826cd2732ad2188204b10cc8221a1dbf301f14ad2205bbce5047c74fd9ebc8f876fe03b8d
|
7
|
+
data.tar.gz: 7fd2b404a68472d513c4b7f6603e1302dbecd18e55aa1e7f3c95191803cb27946a638a013bc3506d1dd68a3635cbc67c9ff372aad73c3b6ae74bcc04e54532c9
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Kurki [![Build Status](https://travis-ci.org/Coolnesss/kurki.svg?branch=master)](https://travis-ci.org/Coolnesss/kurki) [![Code Climate](https://codeclimate.com/github/Coolnesss/kurki/badges/gpa.svg)](https://codeclimate.com/github/Coolnesss/kurki) [![Test Coverage](https://codeclimate.com/github/Coolnesss/kurki/badges/coverage.svg)](https://codeclimate.com/github/Coolnesss/kurki/coverage)
|
1
|
+
# Kurki [![Build Status](https://travis-ci.org/Coolnesss/kurki.svg?branch=master)](https://travis-ci.org/Coolnesss/kurki) [![Code Climate](https://codeclimate.com/github/Coolnesss/kurki/badges/gpa.svg)](https://codeclimate.com/github/Coolnesss/kurki) [![Test Coverage](https://codeclimate.com/github/Coolnesss/kurki/badges/coverage.svg)](https://codeclimate.com/github/Coolnesss/kurki/coverage) [![Gem Version](https://badge.fury.io/rb/kurki.svg)](https://badge.fury.io/rb/kurki)
|
2
2
|
|
3
3
|
Helsinki University Kurki system API Rubygem.
|
4
4
|
|
@@ -13,7 +13,7 @@ And POST requests to:
|
|
13
13
|
* Add students to a course
|
14
14
|
* Add grades to students of a course
|
15
15
|
|
16
|
-
Requires API token set in environment variable named KURKI_TOKEN
|
16
|
+
Requires API token set in environment variable named KURKI_TOKEN and the API URL set in KURKI_URL.
|
17
17
|
|
18
18
|
## Installation
|
19
19
|
|
@@ -33,7 +33,15 @@ Or install it yourself as:
|
|
33
33
|
|
34
34
|
## Usage
|
35
35
|
|
36
|
-
###
|
36
|
+
### Command Line
|
37
|
+
|
38
|
+
```bash
|
39
|
+
$ kurki help
|
40
|
+
```
|
41
|
+
|
42
|
+
### Ruby methods
|
43
|
+
|
44
|
+
#### GET methods
|
37
45
|
|
38
46
|
```ruby
|
39
47
|
irb(main):002:0> Kurki.url = "http://localhost:1234"
|
@@ -57,7 +65,7 @@ irb(main):004:0> Kurki.get_students("581259.2012.K.K.1")
|
|
57
65
|
=> [{"arvosana"=>"3", "etunimi"=>"LASSE", "sukunimi"=>"TOIVONEN", "id"=>"012345678"}, {"arvosana"=>"5", "etunimi"=>"TERO V E", "sukunimi"=>"SANKARI", "id"=>"012435443"}]
|
58
66
|
```
|
59
67
|
|
60
|
-
|
68
|
+
#### POST methods
|
61
69
|
|
62
70
|
```ruby
|
63
71
|
irb(main):008:0> Kurki.set_students("58131.2010.K.K.1", ["012345678"])
|
data/bin/kurki
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'kurki'
|
4
|
+
require 'gli'
|
5
|
+
require 'awesome_print'
|
6
|
+
|
7
|
+
include GLI::App
|
8
|
+
|
9
|
+
def print(stuff)
|
10
|
+
ap stuff, index: false
|
11
|
+
end
|
12
|
+
program_desc 'Helsinki University department of computer science Kurki command line client'
|
13
|
+
|
14
|
+
#flag [:t,:tasklist], :default_value => File.join(ENV['HOME'],'.todolist')
|
15
|
+
|
16
|
+
pre do |global_options,command,options,args|
|
17
|
+
raise "KURKI_URL or KURKI_TOKEN not set! Set them in environment variables." unless ENV["KURKI_TOKEN"] and ENV["KURKI_URL"]
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'List available courses'
|
22
|
+
long_desc 'Lists all courses that are available for grading and manipulation on this account'
|
23
|
+
|
24
|
+
command :courses do |c|
|
25
|
+
c.action do
|
26
|
+
print Kurki.get_courses
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'List students of course'
|
31
|
+
long_desc 'Lists all students on a single course along with their grades. A valid course ID is required.'
|
32
|
+
|
33
|
+
command :students do |c|
|
34
|
+
c.arg 'courseID'
|
35
|
+
c.action do |global_options,options,args|
|
36
|
+
help_now!('Course ID is required') if args.empty?
|
37
|
+
print Kurki.get_students(args.first)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
desc 'Display information of a course'
|
42
|
+
long_desc 'Displays course information such as its ID and start and end dates. A valid course ID is required.'
|
43
|
+
|
44
|
+
command :course do |c|
|
45
|
+
c.arg 'courseID'
|
46
|
+
c.action do |global_options,options,args|
|
47
|
+
help_now!('Course ID is required') if args.empty?
|
48
|
+
print Kurki.get_course(args.first)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
desc 'Set various course information, such as grades'
|
54
|
+
|
55
|
+
command :set do |c|
|
56
|
+
c.desc 'Set grades for a course from a .csv file'
|
57
|
+
c.long_desc 'Use a .csv file to set grades for a course. The file should have two columns with headers, ' \
|
58
|
+
'the first one including the student IDs and the second the actual grades. You can specify the delimiter as the last parameter. '
|
59
|
+
|
60
|
+
c.arg 'courseID'
|
61
|
+
c.arg 'path'
|
62
|
+
c.arg 'delimiter', :optional
|
63
|
+
|
64
|
+
c.command :grades do |grades|
|
65
|
+
grades.action do |global_options, options, args|
|
66
|
+
help_now!('Course ID and path are required.') if args.size < 2
|
67
|
+
if (args.size == 3)
|
68
|
+
print Kurki.set_grades_from_csv args.first, args[1], args[2]
|
69
|
+
else
|
70
|
+
print Kurki.set_grades_from_csv args.first, args[1]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
exit run(ARGV)
|
data/kurki.gemspec
CHANGED
@@ -25,6 +25,9 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency "codeclimate-test-reporter"
|
26
26
|
spec.add_development_dependency "simplecov"
|
27
27
|
|
28
|
+
spec.add_runtime_dependency "gli"
|
28
29
|
spec.add_runtime_dependency 'rest-client'
|
30
|
+
spec.add_runtime_dependency 'awesome_print'
|
31
|
+
|
29
32
|
|
30
33
|
end
|
data/lib/kurki/version.rb
CHANGED
data/lib/kurki.rb
CHANGED
@@ -34,7 +34,7 @@ module Kurki
|
|
34
34
|
end
|
35
35
|
|
36
36
|
# .csv in two columns, with one header row
|
37
|
-
def self.
|
37
|
+
def self.set_grades_from_csv(course_id, file_path, delimiter=",")
|
38
38
|
grades = {}
|
39
39
|
read_csv(file_path, delimiter).each do |result|
|
40
40
|
grades[result[0]] = result[1]
|
data/spec/kurki_spec.rb
CHANGED
@@ -97,7 +97,7 @@ describe Kurki do
|
|
97
97
|
end
|
98
98
|
|
99
99
|
it "can POST grades from a CSV file" do
|
100
|
-
ans = Kurki.
|
100
|
+
ans = Kurki.set_grades_from_csv("581259.2012.K.K.1", "spec/fixtures/grades.csv")
|
101
101
|
expect(ans).to eq(
|
102
102
|
JSON.parse("{\"success\":[{\"id\":\"123123123\",\"arvosana\":\"3\"},
|
103
103
|
{\"id\":\"014475359\",\"arvosana\":\"5\"},
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kurki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chang Rajani
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-11-
|
12
|
+
date: 2016-11-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -95,6 +95,20 @@ dependencies:
|
|
95
95
|
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: gli
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :runtime
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
98
112
|
- !ruby/object:Gem::Dependency
|
99
113
|
name: rest-client
|
100
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,10 +123,25 @@ dependencies:
|
|
109
123
|
- - ">="
|
110
124
|
- !ruby/object:Gem::Version
|
111
125
|
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: awesome_print
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
type: :runtime
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
112
140
|
description: Support for students and teachers
|
113
141
|
email:
|
114
142
|
- chra@cs.helsinki.fi
|
115
|
-
executables:
|
143
|
+
executables:
|
144
|
+
- kurki
|
116
145
|
extensions: []
|
117
146
|
extra_rdoc_files: []
|
118
147
|
files:
|
@@ -123,6 +152,7 @@ files:
|
|
123
152
|
- LICENSE.txt
|
124
153
|
- README.md
|
125
154
|
- Rakefile
|
155
|
+
- bin/kurki
|
126
156
|
- kurki.gemspec
|
127
157
|
- lib/kurki.rb
|
128
158
|
- lib/kurki/version.rb
|