et 0.5.1 → 0.5.2
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/.ruby-version +1 -1
- data/.travis.yml +1 -1
- data/Gemfile.lock +15 -18
- data/README.md +27 -0
- data/et.gemspec +1 -1
- data/lib/et.rb +1 -0
- data/lib/et/api.rb +19 -9
- data/lib/et/version.rb +1 -1
- data/spec/lib/api_spec.rb +4 -4
- data/spec/spec_helper.rb +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6265a35fbd53ec50dbd1f0c661a3f55863eaeb8
|
4
|
+
data.tar.gz: 71a553c9f295034abb2878b146d1c715c87a61d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a0dd2902e3c5ef89eadd8e4b07544f32756579e714b0acadf9b34d1b3d60951258ed3ce81a73c85c336119c7721c7f81154cc776a998e74618126f486c600a9
|
7
|
+
data.tar.gz: 81cd40a31acbfb853fc8d676bcae5ee8e923d43f79fdb084a89a8e44cc39752f4c70f66a422331b211e272daa6cc8132765b6d6a3ccd47741a6eccc5039d96d8
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.0
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
et (0.5.
|
4
|
+
et (0.5.2)
|
5
5
|
gli (= 2.11.0)
|
6
|
-
|
6
|
+
multipart-post (~> 2.0)
|
7
7
|
rspec (~> 3.0)
|
8
8
|
rspec-mocks (~> 3.0)
|
9
9
|
|
@@ -12,24 +12,21 @@ GEM
|
|
12
12
|
specs:
|
13
13
|
diff-lcs (1.2.5)
|
14
14
|
gli (2.11.0)
|
15
|
-
|
16
|
-
netrc (0.10.2)
|
15
|
+
multipart-post (2.0.0)
|
17
16
|
rake (10.3.2)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
rspec-
|
24
|
-
|
25
|
-
rspec-core (3.1.7)
|
26
|
-
rspec-support (~> 3.1.0)
|
27
|
-
rspec-expectations (3.1.2)
|
17
|
+
rspec (3.2.0)
|
18
|
+
rspec-core (~> 3.2.0)
|
19
|
+
rspec-expectations (~> 3.2.0)
|
20
|
+
rspec-mocks (~> 3.2.0)
|
21
|
+
rspec-core (3.2.0)
|
22
|
+
rspec-support (~> 3.2.0)
|
23
|
+
rspec-expectations (3.2.0)
|
28
24
|
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
-
rspec-support (~> 3.
|
30
|
-
rspec-mocks (3.
|
31
|
-
|
32
|
-
|
25
|
+
rspec-support (~> 3.2.0)
|
26
|
+
rspec-mocks (3.2.0)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.2.0)
|
29
|
+
rspec-support (3.2.1)
|
33
30
|
|
34
31
|
PLATFORMS
|
35
32
|
ruby
|
data/README.md
CHANGED
@@ -1,3 +1,30 @@
|
|
1
1
|
# ET
|
2
2
|
|
3
3
|
A command-line utility for downloading and submitting code challenges.
|
4
|
+
|
5
|
+
When running locally, use the following command to avoid using the installed gem version:
|
6
|
+
|
7
|
+
```no-highlight
|
8
|
+
$ bundle exec bin/et help
|
9
|
+
|
10
|
+
NAME
|
11
|
+
et -
|
12
|
+
|
13
|
+
SYNOPSIS
|
14
|
+
et [global options] command [command options] [arguments...]
|
15
|
+
|
16
|
+
VERSION
|
17
|
+
0.5.1
|
18
|
+
|
19
|
+
GLOBAL OPTIONS
|
20
|
+
--help - Show this message
|
21
|
+
--version - Display the program version
|
22
|
+
|
23
|
+
COMMANDS
|
24
|
+
get - Download lesson to your working area.
|
25
|
+
help - Shows a list of commands or help for one command
|
26
|
+
init - Initialize current directory as a work area.
|
27
|
+
list - List available lessons.
|
28
|
+
submit - Submit the lesson in this directory.
|
29
|
+
test - Run an exercise test suite.
|
30
|
+
```
|
data/et.gemspec
CHANGED
@@ -22,6 +22,6 @@ DESC
|
|
22
22
|
s.add_development_dependency("rake", "~> 10")
|
23
23
|
s.add_runtime_dependency("rspec", "~> 3.0")
|
24
24
|
s.add_runtime_dependency("rspec-mocks", "~> 3.0")
|
25
|
-
s.add_runtime_dependency("
|
25
|
+
s.add_runtime_dependency("multipart-post", "~> 2.0")
|
26
26
|
s.add_runtime_dependency("gli", "2.11.0")
|
27
27
|
end
|
data/lib/et.rb
CHANGED
data/lib/et/api.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require "
|
1
|
+
require "net/http/post/multipart"
|
2
2
|
require "securerandom"
|
3
3
|
require "base64"
|
4
4
|
require "json"
|
@@ -14,12 +14,12 @@ module ET
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def list_lessons
|
17
|
-
response =
|
17
|
+
response = Net::HTTP.get(lessons_url)
|
18
18
|
JSON.parse(response, symbolize_names: true)[:lessons]
|
19
19
|
end
|
20
20
|
|
21
21
|
def get_lesson(slug)
|
22
|
-
response =
|
22
|
+
response = Net::HTTP.get(lesson_url(slug))
|
23
23
|
body = JSON.parse(response, symbolize_names: true)
|
24
24
|
body[:lesson]
|
25
25
|
end
|
@@ -43,23 +43,33 @@ module ET
|
|
43
43
|
|
44
44
|
def submit_lesson(lesson)
|
45
45
|
submission_file = lesson.archive!
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
url = submission_url(lesson.slug)
|
47
|
+
|
48
|
+
File.open(submission_file) do |f|
|
49
|
+
request = Net::HTTP::Post::Multipart.new(url.path,
|
50
|
+
"submission[archive]" => UploadIO.new(f, "application/x-tar", "archive.tar.gz"))
|
51
|
+
request["Authorization"] = auth_header
|
52
|
+
|
53
|
+
Net::HTTP.start(url.host, url.port,
|
54
|
+
use_ssl: url.scheme == "https") do |http|
|
55
|
+
|
56
|
+
http.request(request)
|
57
|
+
end
|
58
|
+
end
|
49
59
|
end
|
50
60
|
|
51
61
|
private
|
52
62
|
|
53
63
|
def lesson_url(slug)
|
54
|
-
URI.join(host, "lessons/#{slug}.json")
|
64
|
+
URI.join(host, "lessons/#{slug}.json")
|
55
65
|
end
|
56
66
|
|
57
67
|
def lessons_url
|
58
|
-
URI.join(host, "lessons.json?submittable=1")
|
68
|
+
URI.join(host, "lessons.json?submittable=1")
|
59
69
|
end
|
60
70
|
|
61
71
|
def submission_url(slug)
|
62
|
-
URI.join(host, "lessons/#{slug}/submissions.json")
|
72
|
+
URI.join(host, "lessons/#{slug}/submissions.json")
|
63
73
|
end
|
64
74
|
|
65
75
|
def random_filename
|
data/lib/et/version.rb
CHANGED
data/spec/lib/api_spec.rb
CHANGED
@@ -7,8 +7,8 @@ describe ET::API do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it "queries for a list of lessons" do
|
10
|
-
expect(
|
11
|
-
with("http://localhost:3000/lessons.json?submittable=1").
|
10
|
+
expect(Net::HTTP).to receive(:get).
|
11
|
+
with(URI("http://localhost:3000/lessons.json?submittable=1")).
|
12
12
|
and_return(lessons_response)
|
13
13
|
|
14
14
|
results = api.list_lessons
|
@@ -24,8 +24,8 @@ describe ET::API do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it "queries for a single lesson" do
|
27
|
-
expect(
|
28
|
-
with("http://localhost:3000/lessons/rock-paper-scissors.json").
|
27
|
+
expect(Net::HTTP).to receive(:get).
|
28
|
+
with(URI("http://localhost:3000/lessons/rock-paper-scissors.json")).
|
29
29
|
and_return(lesson_response)
|
30
30
|
|
31
31
|
result = api.get_lesson("rock-paper-scissors")
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: et
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Sheehan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -53,19 +53,19 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: multipart-post
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '2.0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '2.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: gli
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
154
|
version: '0'
|
155
155
|
requirements: []
|
156
156
|
rubyforge_project:
|
157
|
-
rubygems_version: 2.
|
157
|
+
rubygems_version: 2.4.5
|
158
158
|
signing_key:
|
159
159
|
specification_version: 4
|
160
160
|
summary: Command-line interface for the event horizon.
|