exercism 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
data/lib/cli.rb CHANGED
@@ -12,6 +12,21 @@ class Exercism
12
12
 
13
13
  map "-v" => "version", "--version" => "version"
14
14
 
15
+ desc "demo", "Fetch first assignment for each language from exercism.io"
16
+ method_option :host, aliases: '-h', default: 'http://exercism.io', desc: 'the url of the exercism application'
17
+ def demo
18
+ require 'exercism'
19
+
20
+ guest = Object.new
21
+ def guest.key
22
+ "demo"
23
+ end
24
+
25
+ exercism = Exercism::Api.new(options[:host], guest, '.')
26
+ assignments = exercism.demo
27
+ report(assignments)
28
+ end
29
+
15
30
  desc "fetch", "Fetch current assignment from exercism.io"
16
31
  method_option :host, aliases: '-h', default: 'http://exercism.io', desc: 'the url of the exercism application'
17
32
  def fetch
@@ -15,19 +15,23 @@ class Exercism
15
15
  end
16
16
  end
17
17
 
18
+ def demo
19
+ get_and_save('assignments/demo')
20
+ end
21
+
18
22
  def fetch
19
- get_and_save('current')
23
+ get_and_save('user/assignments/current')
20
24
  end
21
25
 
22
26
  def peek
23
- get_and_save('next')
27
+ get_and_save('user/assignments/next')
24
28
  end
25
29
 
26
30
  def submit(filename)
27
31
  path = File.join(filename)
28
32
  contents = File.read path
29
33
  response = conn.post do |req|
30
- req.url endpoint
34
+ req.url endpoint('user/assignments')
31
35
  req.headers['Accept'] = 'application/json'
32
36
  req.headers['Content-Type'] = 'application/json'
33
37
  req.body = {code: contents, key: user.key, path: path}.to_json
@@ -50,7 +54,7 @@ class Exercism
50
54
  end
51
55
 
52
56
  def endpoint(action = nil)
53
- "/api/v1/user/assignments/#{action}".chomp('/')
57
+ "/api/v1/#{action}".chomp('/')
54
58
  end
55
59
 
56
60
  def save(body)
@@ -1,3 +1,3 @@
1
1
  class Exercism
2
- VERSION = "0.0.15"
2
+ VERSION = "0.0.16"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exercism
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-22 00:00:00.000000000 Z
12
+ date: 2013-07-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday