et 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 659755ddf3d5c95f243c0f589a186e7e5182dfcb
4
- data.tar.gz: a0e8250a68aed83fd6ba768afbf318be17c6a8ce
3
+ metadata.gz: b6265a35fbd53ec50dbd1f0c661a3f55863eaeb8
4
+ data.tar.gz: 71a553c9f295034abb2878b146d1c715c87a61d5
5
5
  SHA512:
6
- metadata.gz: 5595fd4b14e94e2f1651f837802f8abaad0114fbb00008909caf93154e87f418ee8ac8a6ca8d61cdd574821bfb56b7ec96861652cba46522041119e82cd420bb
7
- data.tar.gz: 55aa57f61366edb9a281119bea0778e7c36eadcddec5958c081103cc0ffc6b0b4cb48f8b1f02ac361e5058dea98617de1323c1a7790b1738e1ec6a7084ebe51d
6
+ metadata.gz: 2a0dd2902e3c5ef89eadd8e4b07544f32756579e714b0acadf9b34d1b3d60951258ed3ce81a73c85c336119c7721c7f81154cc776a998e74618126f486c600a9
7
+ data.tar.gz: 81cd40a31acbfb853fc8d676bcae5ee8e923d43f79fdb084a89a8e44cc39752f4c70f66a422331b211e272daa6cc8132765b6d6a3ccd47741a6eccc5039d96d8
@@ -1 +1 @@
1
- 2.1.3
1
+ 2.2.0
@@ -1,3 +1,3 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.3
3
+ - 2.2.0
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- et (0.5.1)
4
+ et (0.5.2)
5
5
  gli (= 2.11.0)
6
- rest-client (~> 1.7)
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
- mime-types (2.4.3)
16
- netrc (0.10.2)
15
+ multipart-post (2.0.0)
17
16
  rake (10.3.2)
18
- rest-client (1.7.2)
19
- mime-types (>= 1.16, < 3.0)
20
- netrc (~> 0.7)
21
- rspec (3.1.0)
22
- rspec-core (~> 3.1.0)
23
- rspec-expectations (~> 3.1.0)
24
- rspec-mocks (~> 3.1.0)
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.1.0)
30
- rspec-mocks (3.1.3)
31
- rspec-support (~> 3.1.0)
32
- rspec-support (3.1.2)
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("rest-client", "~> 1.7")
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
@@ -1,3 +1,4 @@
1
+ require "tmpdir"
1
2
  require "et/version"
2
3
  require "et/runner"
3
4
  require "et/api"
@@ -1,4 +1,4 @@
1
- require "rest-client"
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 = RestClient.get(lessons_url)
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 = RestClient.get(lesson_url(slug))
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
- RestClient.post(submission_url(lesson.slug),
47
- { submission: { archive: File.new(submission_file) }},
48
- { "Authorization" => auth_header })
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").to_s
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").to_s
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").to_s
72
+ URI.join(host, "lessons/#{slug}/submissions.json")
63
73
  end
64
74
 
65
75
  def random_filename
@@ -1,3 +1,3 @@
1
1
  module ET
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
@@ -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(RestClient).to receive(:get).
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(RestClient).to receive(:get).
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")
@@ -51,7 +51,7 @@ RSpec.configure do |config|
51
51
  config.include ArchiveHelper
52
52
 
53
53
  config.before :each do
54
- allow(RestClient).to receive(:get)
55
- allow(RestClient).to receive(:post)
54
+ allow(Net::HTTP).to receive(:start)
55
+ allow(Net::HTTP).to receive(:get)
56
56
  end
57
57
  end
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.1
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-01-07 00:00:00.000000000 Z
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: rest-client
56
+ name: multipart-post
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.7'
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: '1.7'
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.2.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.