exercism 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/cli.rb +6 -2
- data/lib/exercism.rb +0 -8
- data/lib/exercism/api.rb +13 -6
- data/lib/exercism/version.rb +1 -1
- data/test/exercism/api_test.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NGM5OTNiOGM4OGEyOGUxMTRmYzhlODRkYjcxOWQ3YWM3M2U2YmFmMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
N2RhYzc3MzE2MTg1YjJlM2NlYzY3NzJkYTE1Y2E4Y2JkMDY3NTBjMQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NmVjZTBjZjBlYjVhZGQ3ZTE4YjE1OGQwZDdkZTg4Y2E1MzkwMDE1Zjk0ZGQw
|
10
|
+
MWJjOTM0MDIzNWNiNzgzYTJkOWQzZmZkMDViODBkNmJiYjkwN2IxOGFiOTZk
|
11
|
+
ZDc0MWIxMTE0Yjk1MDc3ZWNhZjg2NThmMjRmYzk3NGI1MDEyNjM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDI2NWVjMGI1NjE2MGYxNjU5MTM5NDAzMjNmNjIyOGI5YTdmZTQ1Y2JhMzk2
|
14
|
+
YjEyMGJkNzAwNGVkYTcxZDkwMTE1MGJmNzAyMjRlNGEwZDkxZWY0MmNjZmQ0
|
15
|
+
MDAzN2NiMTk3MDYwZTc3ZDZmMDc5ZTc5MWRiMjk2OGU5YjVhYzI=
|
data/lib/cli.rb
CHANGED
@@ -4,10 +4,12 @@ class Exercism
|
|
4
4
|
class CLI < Thor
|
5
5
|
|
6
6
|
desc "fetch", "Fetch current assignment from exercism.io"
|
7
|
+
method_option :host, aliases: '-h', default: 'http://exercism.io', desc: 'the url of the exercism application'
|
7
8
|
def fetch
|
8
9
|
require 'exercism'
|
9
10
|
|
10
|
-
|
11
|
+
api = Exercism::Api.new(options[:host], Exercism.user, Exercism.project_dir)
|
12
|
+
assignments = api.fetch
|
11
13
|
if assignments.empty?
|
12
14
|
puts "No assignments fetched."
|
13
15
|
else
|
@@ -18,10 +20,12 @@ class Exercism
|
|
18
20
|
end
|
19
21
|
|
20
22
|
desc "submit FILE", "Submit code to exercism.io on your current assignment"
|
23
|
+
method_option :host, aliases: '-h', default: 'http://exercism.io', desc: 'the url of the exercism application'
|
21
24
|
def submit(file)
|
22
25
|
require 'exercism'
|
23
26
|
|
24
|
-
|
27
|
+
path = File.join(FileUtils.pwd, file)
|
28
|
+
Exercism::Api.new(options[:host], Exercism.user).submit(file)
|
25
29
|
end
|
26
30
|
|
27
31
|
desc "login", "Save exercism.io api credentials"
|
data/lib/exercism.rb
CHANGED
data/lib/exercism/api.rb
CHANGED
@@ -1,22 +1,29 @@
|
|
1
1
|
class Exercism
|
2
2
|
class Api
|
3
|
-
|
4
|
-
|
3
|
+
|
4
|
+
attr_reader :url, :user, :project_dir
|
5
|
+
def initialize(url, user, project_dir = nil)
|
6
|
+
@url = url
|
7
|
+
@user = user
|
8
|
+
@project_dir = project_dir
|
9
|
+
end
|
10
|
+
|
11
|
+
def conn
|
12
|
+
conn = Faraday.new(:url => url) do |c|
|
5
13
|
c.use Faraday::Adapter::NetHttp
|
6
14
|
end
|
7
15
|
end
|
8
16
|
|
9
|
-
def
|
17
|
+
def fetch
|
10
18
|
response = conn.get do |req|
|
11
19
|
req.url '/api/v1/user/assignments/current'
|
12
20
|
req.headers['User-Agent'] = "exercism-CLI v#{Exercism::VERSION}"
|
13
21
|
req.params['key'] = user.key
|
14
22
|
end
|
15
|
-
Assignment.save(JSON.parse(response.body),
|
23
|
+
Assignment.save(JSON.parse(response.body), project_dir)
|
16
24
|
end
|
17
25
|
|
18
|
-
def
|
19
|
-
user = options[:for]
|
26
|
+
def submit(filename)
|
20
27
|
path = File.join(filename)
|
21
28
|
contents = File.read path
|
22
29
|
response = conn.post do |req|
|
data/lib/exercism/version.rb
CHANGED
data/test/exercism/api_test.rb
CHANGED
@@ -36,7 +36,7 @@ class ApiTest < MiniTest::Unit::TestCase
|
|
36
36
|
|
37
37
|
Exercism.stub(:home, home) do
|
38
38
|
VCR.use_cassette('alice-gets-bob') do
|
39
|
-
Exercism::Api.
|
39
|
+
Exercism::Api.new('http://localhost:4567', Exercism.user, project_dir).fetch
|
40
40
|
|
41
41
|
Approvals.verify(File.read(readme_path), name: 'alice_gets_bob_readme')
|
42
42
|
Approvals.verify(File.read(tests_path), name: 'alice_gets_bob_tests')
|
@@ -54,7 +54,7 @@ class ApiTest < MiniTest::Unit::TestCase
|
|
54
54
|
|
55
55
|
Exercism.stub(:home, home) do
|
56
56
|
VCR.use_cassette('alice-submits-bob') do
|
57
|
-
response = Exercism::Api.
|
57
|
+
response = Exercism::Api.new('http://localhost:4567', Exercism.user).submit(submission)
|
58
58
|
assert_equal 201, response.status
|
59
59
|
end
|
60
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exercism
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katrina Owen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|