exercism 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +1 -0
- data/README.md +4 -14
- data/Rakefile +8 -0
- data/bin/exercism +4 -1
- data/exercism.gemspec +5 -1
- data/lib/cli.rb +48 -0
- data/lib/exercism.rb +38 -3
- data/lib/exercism/api.rb +34 -0
- data/lib/exercism/assignment.rb +46 -0
- data/lib/exercism/config.rb +55 -0
- data/lib/exercism/user.rb +1 -0
- data/lib/exercism/version.rb +2 -2
- data/test/exercism/api_test.rb +62 -0
- data/test/exercism/assignment_test.rb +51 -0
- data/test/exercism/config_test.rb +38 -0
- data/test/exercism_test.rb +39 -0
- data/test/fixtures/approvals/alice_gets_bob_readme.approved.txt +25 -0
- data/test/fixtures/approvals/alice_gets_bob_tests.approved.txt +46 -0
- data/test/fixtures/home/.exercism +3 -0
- data/test/fixtures/vcr_cassettes/alice-gets-bob.yml +63 -0
- data/test/fixtures/vcr_cassettes/alice-submits-bob.yml +41 -0
- data/test/test_helper.rb +9 -0
- metadata +86 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmUyM2MyMTFkZDNiMTQwNzUxZmUzOGQwZjZiMGFlNWI5OTUxNThlOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NWNkN2NjMWVmYjUwYWMyNzVmNjFjYmQ1Yjk1NzVhYTcyMGZkZTMyOA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OWVjYjAxZWM5NzNmNmZlYTQ4YmZiNzA4NTM4N2U1OGY1YTAwNzUyZDI1Y2I0
|
10
|
+
YjRjMDg3ODU1Y2U4MTMwNmM2NTI1YmEwYjcxZTcxNTE0ZjQ0YzM3NTJlZWQ0
|
11
|
+
YjNmMjg1ZmNlY2I1NDBjMzczNDkwZDFiMDVkNGJkYmFiNmYyYjQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Y2RmYjQyYWE1ZWU1NzM4Mzc5MWQwYmZkODJkY2YzMjM4NmY5NzYzNGQzMWZj
|
14
|
+
Y2VkNWJhNzhlYjY2MzdiMDQzNTAzMDE2ZGYyOWQzNzU5ZWI1Nzc4MmYxOTRl
|
15
|
+
M2ViYjYwMWM4ZTc4NjdiYWJhNjdiZTEzZTliY2RiNjJjNDA4NWI=
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,24 +1,14 @@
|
|
1
1
|
# Exercism
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'exercism'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
3
|
+
Client gem for the warmup-exercise app exercism.io.
|
16
4
|
|
17
5
|
$ gem install exercism
|
18
6
|
|
19
7
|
## Usage
|
20
8
|
|
21
|
-
|
9
|
+
$ exercism login YOUR_GITHUB_USERNAME -s YOUR_EXERCISM_SECRET
|
10
|
+
$ exercism fetch
|
11
|
+
$ exercism submit -f example.rb
|
22
12
|
|
23
13
|
## Contributing
|
24
14
|
|
data/Rakefile
CHANGED
data/bin/exercism
CHANGED
data/exercism.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Katrina Owen"]
|
10
10
|
spec.email = ["katrina.owen@gmail.com"]
|
11
11
|
spec.description = %q{Client gem for the exercism.io app}
|
12
|
-
spec.summary = %q{
|
12
|
+
spec.summary = %q{This gem provides a command line client to allow users of the exercism.io application to easily fetch and submit assignments.}
|
13
13
|
spec.homepage = ""
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -18,6 +18,10 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_dependency "faraday"
|
22
|
+
spec.add_dependency "thor"
|
21
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
24
|
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "vcr", '~> 2.4'
|
26
|
+
spec.add_development_dependency "fakeweb"
|
23
27
|
end
|
data/lib/cli.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
class Exercism
|
4
|
+
class CLI < Thor
|
5
|
+
|
6
|
+
desc "fetch", "Fetch current assignment from exercism.io"
|
7
|
+
def fetch
|
8
|
+
require 'exercism'
|
9
|
+
|
10
|
+
Exercism::Api.fetch_for(Exercism.user)
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "submit FILE", "Submit code to exercism.io on your current assignment"
|
14
|
+
def submit(file)
|
15
|
+
require 'exercism'
|
16
|
+
|
17
|
+
Exercism::Api.submit(file, {for: Exercism.user})
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "login", "Save exercism.io api credentials"
|
21
|
+
def login
|
22
|
+
require 'exercism'
|
23
|
+
|
24
|
+
username = ask("Your GitHub username:")
|
25
|
+
key = ask("Your exercism.io API key:")
|
26
|
+
Exercism.login(username, key)
|
27
|
+
|
28
|
+
say("Your credentials have been written to #{Exercism.config.file}")
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "logout", "Clear exercism.io api credentials"
|
32
|
+
def logout
|
33
|
+
require 'exercism'
|
34
|
+
|
35
|
+
Exercism.config.delete
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "whoami", "Get the github username that you are logged in as"
|
39
|
+
def whoami
|
40
|
+
require 'exercism'
|
41
|
+
|
42
|
+
puts Exercism.user.github_username
|
43
|
+
rescue Errno::ENOENT
|
44
|
+
puts "You are not logged in."
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
data/lib/exercism.rb
CHANGED
@@ -1,5 +1,40 @@
|
|
1
|
-
require
|
1
|
+
require 'etc'
|
2
|
+
require 'json'
|
3
|
+
require 'yaml'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'faraday'
|
6
|
+
require 'exercism/version'
|
7
|
+
require 'exercism/config'
|
8
|
+
require 'exercism/user'
|
9
|
+
require 'exercism/assignment'
|
10
|
+
require 'exercism/api'
|
11
|
+
|
12
|
+
class Exercism
|
13
|
+
|
14
|
+
def self.url
|
15
|
+
if ENV['EXERCISM_ENV'] == 'test'
|
16
|
+
'http://localhost:4567'
|
17
|
+
else
|
18
|
+
'http://exercism.herokuapp.com'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.home
|
23
|
+
Dir.home(Etc.getlogin)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.login(github_username, key)
|
27
|
+
data = {'github_username' => github_username, 'key' => key}
|
28
|
+
Config.write(home, data)
|
29
|
+
User.new(github_username, key)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.config
|
33
|
+
@config ||= Config.read(home)
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.user
|
37
|
+
User.new(config.github_username, config.key)
|
38
|
+
end
|
2
39
|
|
3
|
-
module Exercism
|
4
|
-
# Your code goes here...
|
5
40
|
end
|
data/lib/exercism/api.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
class Exercism
|
2
|
+
class Api
|
3
|
+
def self.conn
|
4
|
+
conn = Faraday.new(:url => Exercism.url) do |c|
|
5
|
+
c.use Faraday::Adapter::NetHttp
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.fetch_for(user)
|
10
|
+
response = conn.get do |req|
|
11
|
+
req.url '/api/v1/user/assignments/current'
|
12
|
+
req.headers['User-Agent'] = "exercism-CLI v#{Exercism::VERSION}"
|
13
|
+
req.params['key'] = user.key
|
14
|
+
end
|
15
|
+
assignment = Assignment.new(JSON.parse(response.body))
|
16
|
+
assignment.save
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.submit(filename, options)
|
20
|
+
user = options[:for]
|
21
|
+
path = File.join(FileUtils.pwd, filename)
|
22
|
+
contents = File.read path
|
23
|
+
response = conn.post do |req|
|
24
|
+
req.url '/api/v1/user/assignments'
|
25
|
+
req.headers['Accept'] = 'application/json'
|
26
|
+
req.headers['Content-Type'] = 'application/json'
|
27
|
+
req.headers['User-Agent'] = "exercism-CLI v#{Exercism::VERSION}"
|
28
|
+
req.body = {code: contents, key: user.key, path: path}.to_json
|
29
|
+
end
|
30
|
+
response
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class Exercism
|
2
|
+
class Assignment
|
3
|
+
|
4
|
+
attr_reader :track, :slug, :readme, :testfile, :tests
|
5
|
+
|
6
|
+
def initialize(attributes)
|
7
|
+
@track = attributes['track']
|
8
|
+
@slug = attributes['slug']
|
9
|
+
@readme = attributes['readme']
|
10
|
+
@testfile = attributes['testfile']
|
11
|
+
@tests = attributes['tests']
|
12
|
+
end
|
13
|
+
|
14
|
+
def save
|
15
|
+
FileUtils.mkdir_p assignment_dir
|
16
|
+
File.open readme_path, 'w' do |f|
|
17
|
+
f.write readme
|
18
|
+
end
|
19
|
+
File.write tests_path, tests
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def readme_path
|
25
|
+
File.join(assignment_dir, 'README.md')
|
26
|
+
end
|
27
|
+
|
28
|
+
def tests_path
|
29
|
+
File.join(assignment_dir, testfile)
|
30
|
+
end
|
31
|
+
|
32
|
+
def assignment_dir
|
33
|
+
File.join(project_dir, track, slug)
|
34
|
+
end
|
35
|
+
|
36
|
+
def project_dir
|
37
|
+
dir = FileUtils.pwd
|
38
|
+
if File.basename(dir) == track
|
39
|
+
dir.gsub(/#{track}\z/, '')
|
40
|
+
else
|
41
|
+
dir
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
@@ -0,0 +1,55 @@
|
|
1
|
+
class Exercism
|
2
|
+
class Config
|
3
|
+
|
4
|
+
def self.read(path)
|
5
|
+
new(path)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.write(path, data)
|
9
|
+
config = new(path)
|
10
|
+
config.github_username = data['github_username']
|
11
|
+
config.key = data['key']
|
12
|
+
config.save
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :file
|
16
|
+
attr_writer :github_username, :key
|
17
|
+
|
18
|
+
def initialize(path)
|
19
|
+
@file = File.join(path, '.exercism')
|
20
|
+
end
|
21
|
+
|
22
|
+
def github_username
|
23
|
+
@github_username ||= from_yaml['github_username']
|
24
|
+
end
|
25
|
+
|
26
|
+
def key
|
27
|
+
@key ||= from_yaml['key']
|
28
|
+
end
|
29
|
+
|
30
|
+
def save
|
31
|
+
File.open file, 'w' do |f|
|
32
|
+
data = {'github_username' => github_username, 'key' => key}
|
33
|
+
f.write data.to_yaml
|
34
|
+
end
|
35
|
+
self
|
36
|
+
end
|
37
|
+
|
38
|
+
def delete
|
39
|
+
FileUtils.rm(file) if File.exists?(file)
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def from_yaml
|
45
|
+
unless @data
|
46
|
+
@data = YAML.load(File.read(file))
|
47
|
+
unless @data
|
48
|
+
raise StandardError.new "Cannot read #{file}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
@data
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
User = Struct.new(:github_username, :key)
|
data/lib/exercism/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = "0.0.
|
1
|
+
class Exercism
|
2
|
+
VERSION = "0.0.2"
|
3
3
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require './test/test_helper'
|
2
|
+
|
3
|
+
require 'vcr'
|
4
|
+
|
5
|
+
test_dir = File.join(FileUtils.pwd, 'test/fixtures')
|
6
|
+
|
7
|
+
VCR.configure do |c|
|
8
|
+
c.cassette_library_dir = File.join(test_dir, 'vcr_cassettes')
|
9
|
+
c.hook_into :fakeweb
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'approvals'
|
13
|
+
Approvals.configure do |c|
|
14
|
+
c.approvals_path = File.join(test_dir, 'approvals') + '/'
|
15
|
+
end
|
16
|
+
|
17
|
+
class ApiTest < MiniTest::Unit::TestCase
|
18
|
+
|
19
|
+
def setup
|
20
|
+
@project_dir = FileUtils.pwd
|
21
|
+
end
|
22
|
+
|
23
|
+
def teardown
|
24
|
+
FileUtils.cd @project_dir
|
25
|
+
FileUtils.rm_rf File.join(@project_dir, 'test/fixtures/home/ruby')
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_fetch_assignment_from_api
|
29
|
+
home = File.join(@project_dir, 'test/fixtures/home')
|
30
|
+
readme_path = File.join(home, 'ruby/bob/README.md')
|
31
|
+
tests_path = File.join(home, 'ruby/bob/test.rb')
|
32
|
+
|
33
|
+
Exercism.stub(:home, home) do
|
34
|
+
FileUtils.cd home
|
35
|
+
VCR.use_cassette('alice-gets-bob') do
|
36
|
+
Exercism::Api.fetch_for(Exercism.user)
|
37
|
+
|
38
|
+
Approvals.verify(File.read(readme_path), name: 'alice_gets_bob_readme')
|
39
|
+
Approvals.verify(File.read(tests_path), name: 'alice_gets_bob_tests')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_send_assignment_to_api
|
45
|
+
home = File.join(@project_dir, 'test/fixtures/home')
|
46
|
+
assignment_path = File.join(home, 'ruby/bob')
|
47
|
+
FileUtils.mkdir_p(assignment_path)
|
48
|
+
submission = File.join(assignment_path, 'bob.rb')
|
49
|
+
File.open(submission, 'w') do |f|
|
50
|
+
f.write "puts 'hello world'"
|
51
|
+
end
|
52
|
+
|
53
|
+
Exercism.stub(:home, home) do
|
54
|
+
FileUtils.cd assignment_path
|
55
|
+
VCR.use_cassette('alice-submits-bob') do
|
56
|
+
response = Exercism::Api.submit('bob.rb', {for: Exercism.user})
|
57
|
+
assert_equal 201, response.status
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require './test/test_helper'
|
2
|
+
|
3
|
+
class AssignmentTest < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@project_dir = FileUtils.pwd
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
FileUtils.cd @project_dir
|
11
|
+
FileUtils.rm_rf File.join(@project_dir, 'test/fixtures/ruby')
|
12
|
+
end
|
13
|
+
|
14
|
+
def readme_path
|
15
|
+
File.join(@project_dir, 'test/fixtures/ruby/queens/README.md')
|
16
|
+
end
|
17
|
+
|
18
|
+
def tests_path
|
19
|
+
File.join(@project_dir, 'test/fixtures/ruby/queens/test.rb')
|
20
|
+
end
|
21
|
+
|
22
|
+
def assignment_data
|
23
|
+
{
|
24
|
+
'track' => 'ruby',
|
25
|
+
'slug' => 'queens',
|
26
|
+
'readme' => 'Do it',
|
27
|
+
'testfile' => 'test.rb',
|
28
|
+
'tests' => 'assert true'
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_write_assignment_from_project_directory
|
33
|
+
FileUtils.cd 'test/fixtures'
|
34
|
+
assignment = Exercism::Assignment.new(assignment_data)
|
35
|
+
assignment.save
|
36
|
+
|
37
|
+
assert_equal "Do it", File.read(readme_path)
|
38
|
+
assert_equal "assert true", File.read(tests_path)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_write_assignment_from_language_directory
|
42
|
+
FileUtils.mkdir File.join(@project_dir, 'test/fixtures/ruby')
|
43
|
+
FileUtils.cd 'test/fixtures/ruby'
|
44
|
+
assignment = Exercism::Assignment.new(assignment_data)
|
45
|
+
assignment.save
|
46
|
+
|
47
|
+
assert_equal "Do it", File.read(readme_path)
|
48
|
+
assert_equal "assert true", File.read(tests_path)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require './test/test_helper'
|
2
|
+
|
3
|
+
class ConfigTest < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
def teardown
|
6
|
+
if File.exists?('./test/fixtures/.exercism')
|
7
|
+
FileUtils.rm('./test/fixtures/.exercism')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_read_config_file
|
12
|
+
path = './test/fixtures/home'
|
13
|
+
key = '634abfb095ed621e1c793c9875fcd9fda455ea90'
|
14
|
+
config = Exercism::Config.read(path)
|
15
|
+
assert_equal 'alice', config.github_username
|
16
|
+
assert_equal key, config.key
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_write_config_file
|
20
|
+
path = './test/fixtures'
|
21
|
+
key = '7a7096c'
|
22
|
+
data = {'github_username' => 'bob', 'key' => key}
|
23
|
+
config = Exercism::Config.write(path, data)
|
24
|
+
assert_equal 'bob', config.github_username
|
25
|
+
assert_equal key, config.key
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_delete_config_file
|
29
|
+
path = './test/fixtures'
|
30
|
+
key = '7a7096c'
|
31
|
+
data = {'github_username' => 'bob', 'key' => key}
|
32
|
+
config = Exercism::Config.write(path, data)
|
33
|
+
filename = config.file
|
34
|
+
config.delete
|
35
|
+
assert !File.exists?(filename)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require './test/test_helper'
|
2
|
+
|
3
|
+
class ExercismTest < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
def teardown
|
6
|
+
if File.exists?('./test/fixtures/.exercism')
|
7
|
+
FileUtils.rm('./test/fixtures/.exercism')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_logged_in_user
|
12
|
+
Exercism.stub(:home, './test/fixtures/home') do
|
13
|
+
user = Exercism.user
|
14
|
+
key = '634abfb095ed621e1c793c9875fcd9fda455ea90'
|
15
|
+
assert_equal 'alice', user.github_username
|
16
|
+
assert_equal key, user.key
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_login_gives_you_a_user
|
21
|
+
Exercism.stub(:home, './test/fixtures') do
|
22
|
+
key = '97e9975'
|
23
|
+
user = Exercism.login('bob', key)
|
24
|
+
assert_equal 'bob', user.github_username
|
25
|
+
assert_equal key, user.key
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_login_writes_the_config_file
|
30
|
+
Exercism.stub(:home, './test/fixtures') do
|
31
|
+
key = '97e9975'
|
32
|
+
Exercism.login('bob', key)
|
33
|
+
user = Exercism.user
|
34
|
+
assert_equal 'bob', user.github_username
|
35
|
+
assert_equal key, user.key
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Bob
|
2
|
+
|
3
|
+
Bob is a lackadaisical teenager. In conversation, his responses are very limited.
|
4
|
+
|
5
|
+
Bob answers 'Sure.' if you ask him a question.
|
6
|
+
|
7
|
+
He answers 'Whatever.' if you tell him something.
|
8
|
+
|
9
|
+
He answers 'Woah, chill out!' if you yell at him (ALL CAPS).
|
10
|
+
|
11
|
+
He says 'Fine. Be that way!' if you address him without actually saying anything.
|
12
|
+
|
13
|
+
Bob, Inspired by the 90s, is bringing back "l33t sP34k", and he'll teach you how to do it. Start any sentence with "Bro, ", and he'll translate the rest of it into l33t sP34k for you.
|
14
|
+
|
15
|
+
## Hints
|
16
|
+
|
17
|
+
`gets`, _get string_ is the opposite of `puts` _put string_.
|
18
|
+
|
19
|
+
Notice that when you type "Something" and then hit enter, you get the string
|
20
|
+
`"Something\n"`
|
21
|
+
|
22
|
+
|
23
|
+
## Source
|
24
|
+
|
25
|
+
Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial. [view source](http://pine.fm/LearnToProgram/?Chapter=06)
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'minitest/pride'
|
3
|
+
require_relative 'bob'
|
4
|
+
|
5
|
+
class BobTest < MiniTest::Unit::TestCase
|
6
|
+
attr_reader :bob
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@bob = Bob.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_stating_something
|
13
|
+
assert_equal 'Whatever.', bob.hey('Tom-ay-to, tom-aaaah-to.')
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_shouting
|
17
|
+
skip
|
18
|
+
assert_equal 'Woah, chill out!', bob.hey('WATCH OUT!')
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_asking_a_question
|
22
|
+
skip
|
23
|
+
assert_equal 'Sure.', bob.hey('Does this cryogenic chamber make me look fat?')
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_talking_forcefully
|
27
|
+
skip
|
28
|
+
assert_equal 'Whatever.', bob.hey("Let's go make out behind the gym!")
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_shouting_numbers
|
32
|
+
skip
|
33
|
+
assert_equal 'Woah, chill out!', bob.hey('1, 2, 3 GO!')
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_shouting_with_special_characters
|
37
|
+
skip
|
38
|
+
assert_equal 'Woah, chill out!', bob.hey('ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!')
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_silence
|
42
|
+
skip
|
43
|
+
assert_equal 'Fine, be that way.', bob.hey('')
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://localhost:4567/api/v1/user/assignments/current?key=634abfb095ed621e1c793c9875fcd9fda455ea90
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
user-agent:
|
11
|
+
- exercism-CLI v0.0.1.pre-alpha
|
12
|
+
accept-encoding:
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
+
accept:
|
15
|
+
- ! '*/*'
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
content-type:
|
22
|
+
- text/html;charset=utf-8
|
23
|
+
x-xss-protection:
|
24
|
+
- 1; mode=block
|
25
|
+
x-content-type-options:
|
26
|
+
- nosniff
|
27
|
+
x-frame-options:
|
28
|
+
- SAMEORIGIN
|
29
|
+
set-cookie:
|
30
|
+
- rack.session=BAh7B0kiD3Nlc3Npb25faWQGOgZFRiJFYzk0MGNlOTJmYzJhNWIyOWU4YmUw%0AZmYxZTVmY2IxMTA2ZDcwNTk3OTRkZjFhZTEzOWJiZWRjMzdlMWE5ODNjMEki%0ADXRyYWNraW5nBjsARnsISSIUSFRUUF9VU0VSX0FHRU5UBjsARiItMGJiOWI4%0AY2FjOWEzZmQxMWMyNDVlZWE3YmIwNzk4NTZlZDY2NDc4MkkiGUhUVFBfQUND%0ARVBUX0VOQ09ESU5HBjsARiItZGRkMDk4OTE3NGYxOWE1YjE4NzkxMjEzY2M0%0AMGM1YTYwOWQyNTQ2Y0kiGUhUVFBfQUNDRVBUX0xBTkdVQUdFBjsARiItZGEz%0AOWEzZWU1ZTZiNGIwZDMyNTViZmVmOTU2MDE4OTBhZmQ4MDcwOQ%3D%3D%0A--2dec80587d5e97276c5cc9656485b9801d551970;
|
31
|
+
path=/; HttpOnly
|
32
|
+
connection:
|
33
|
+
- close
|
34
|
+
content-length:
|
35
|
+
- '1961'
|
36
|
+
body:
|
37
|
+
encoding: US-ASCII
|
38
|
+
string: ! '{"track":"ruby","slug":"bob","readme":"# Bob\n\nBob is a lackadaisical
|
39
|
+
teenager. In conversation, his responses are very limited.\n\nBob answers
|
40
|
+
''Sure.'' if you ask him a question.\n\nHe answers ''Whatever.'' if you tell
|
41
|
+
him something.\n\nHe answers ''Woah, chill out!'' if you yell at him (ALL
|
42
|
+
CAPS).\n\nHe says ''Fine. Be that way!'' if you address him without actually
|
43
|
+
saying anything.\n\nBob, Inspired by the 90s, is bringing back \"l33t sP34k\",
|
44
|
+
and he''ll teach you how to do it. Start any sentence with \"Bro, \", and
|
45
|
+
he''ll translate the rest of it into l33t sP34k for you.\n\n## Hints\n\n`gets`,
|
46
|
+
_get string_ is the opposite of `puts` _put string_.\n\nNotice that when you
|
47
|
+
type \"Something\" and then hit enter, you get the string\n`\"Something\\n\"`\n\n\n##
|
48
|
+
Source\n\nInspired by the ''Deaf Grandma'' exercise in Chris Pine''s Learn
|
49
|
+
to Program tutorial. [view source](http://pine.fm/LearnToProgram/?Chapter=06)\n","testfile":"test.rb","tests":"require
|
50
|
+
''minitest/autorun''\nrequire ''minitest/pride''\nrequire_relative ''bob''\n\nclass
|
51
|
+
BobTest < MiniTest::Unit::TestCase\n attr_reader :bob\n\n def setup\n @bob
|
52
|
+
= Bob.new\n end\n\n def test_stating_something\n assert_equal ''Whatever.'',
|
53
|
+
bob.hey(''Tom-ay-to, tom-aaaah-to.'')\n end\n\n def test_shouting\n skip\n assert_equal
|
54
|
+
''Woah, chill out!'', bob.hey(''WATCH OUT!'')\n end\n\n def test_asking_a_question\n skip\n assert_equal
|
55
|
+
''Sure.'', bob.hey(''Does this cryogenic chamber make me look fat?'')\n end\n\n def
|
56
|
+
test_talking_forcefully\n skip\n assert_equal ''Whatever.'', bob.hey(\"Let''s
|
57
|
+
go make out behind the gym!\")\n end\n\n def test_shouting_numbers\n skip\n assert_equal
|
58
|
+
''Woah, chill out!'', bob.hey(''1, 2, 3 GO!'')\n end\n\n def test_shouting_with_special_characters\n skip\n assert_equal
|
59
|
+
''Woah, chill out!'', bob.hey(''ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!'')\n end\n\n def
|
60
|
+
test_silence\n skip\n assert_equal ''Fine, be that way.'', bob.hey('''')\n end\n\nend\n"}'
|
61
|
+
http_version: '1.1'
|
62
|
+
recorded_at: Sun, 02 Jun 2013 15:46:06 GMT
|
63
|
+
recorded_with: VCR 2.5.0
|
@@ -0,0 +1,41 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://localhost:4567/api/v1/user/assignments
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ! '{"code":"puts ''hello world''","key":"634abfb095ed621e1c793c9875fcd9fda455ea90","path":"/Users/kytrinyx/code/exercism/test/fixtures/home/ruby/bob/bob.rb"}'
|
9
|
+
headers:
|
10
|
+
user-agent:
|
11
|
+
- exercism-CLI v0.0.1
|
12
|
+
accept:
|
13
|
+
- application/json
|
14
|
+
content-type:
|
15
|
+
- application/json
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 201
|
19
|
+
message: Created
|
20
|
+
headers:
|
21
|
+
content-type:
|
22
|
+
- text/html;charset=utf-8
|
23
|
+
x-xss-protection:
|
24
|
+
- 1; mode=block
|
25
|
+
x-content-type-options:
|
26
|
+
- nosniff
|
27
|
+
x-frame-options:
|
28
|
+
- SAMEORIGIN
|
29
|
+
set-cookie:
|
30
|
+
- rack.session=BAh7CEkiD3Nlc3Npb25faWQGOgZFRiJFNWY4MWJlYmZkMjY0NzE5MDVmMDli%0AZDM0NzJmOTZhN2VmODgxM2JmMzY2NmY5NGJhZGZmNjEwMDQxZWI1YmJhM0ki%0ACWNzcmYGOwBGIkU4Y2M5MTRmMTIzOWUyMjA5NTZkM2ExZjhlYzFkM2ExN2U5%0ANTJjMDdmY2ZmY2Y4NTY3NGY0M2FhM2ZjMDFlNDhkSSINdHJhY2tpbmcGOwBG%0AewhJIhRIVFRQX1VTRVJfQUdFTlQGOwBGIi1hY2NhNzllM2E2MjE0MzY1NzUz%0AYmUyZGJlMTkyM2EyYmUyNjFjM2M1SSIZSFRUUF9BQ0NFUFRfRU5DT0RJTkcG%0AOwBGIi1kYTM5YTNlZTVlNmI0YjBkMzI1NWJmZWY5NTYwMTg5MGFmZDgwNzA5%0ASSIZSFRUUF9BQ0NFUFRfTEFOR1VBR0UGOwBGIi1kYTM5YTNlZTVlNmI0YjBk%0AMzI1NWJmZWY5NTYwMTg5MGFmZDgwNzA5%0A--0153d74f359b84b80ec7a049b9b11fff39c0abf0;
|
31
|
+
path=/; HttpOnly
|
32
|
+
connection:
|
33
|
+
- close
|
34
|
+
content-length:
|
35
|
+
- '28'
|
36
|
+
body:
|
37
|
+
encoding: US-ASCII
|
38
|
+
string: Saved submission on ruby/bob
|
39
|
+
http_version: '1.1'
|
40
|
+
recorded_at: Sun, 02 Jun 2013 16:47:15 GMT
|
41
|
+
recorded_with: VCR 2.5.0
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
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.2
|
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-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: bundler
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +66,34 @@ dependencies:
|
|
38
66
|
- - ! '>='
|
39
67
|
- !ruby/object:Gem::Version
|
40
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: vcr
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.4'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.4'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: fakeweb
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
41
97
|
description: Client gem for the exercism.io app
|
42
98
|
email:
|
43
99
|
- katrina.owen@gmail.com
|
@@ -53,8 +109,23 @@ files:
|
|
53
109
|
- Rakefile
|
54
110
|
- bin/exercism
|
55
111
|
- exercism.gemspec
|
112
|
+
- lib/cli.rb
|
56
113
|
- lib/exercism.rb
|
114
|
+
- lib/exercism/api.rb
|
115
|
+
- lib/exercism/assignment.rb
|
116
|
+
- lib/exercism/config.rb
|
117
|
+
- lib/exercism/user.rb
|
57
118
|
- lib/exercism/version.rb
|
119
|
+
- test/exercism/api_test.rb
|
120
|
+
- test/exercism/assignment_test.rb
|
121
|
+
- test/exercism/config_test.rb
|
122
|
+
- test/exercism_test.rb
|
123
|
+
- test/fixtures/approvals/alice_gets_bob_readme.approved.txt
|
124
|
+
- test/fixtures/approvals/alice_gets_bob_tests.approved.txt
|
125
|
+
- test/fixtures/home/.exercism
|
126
|
+
- test/fixtures/vcr_cassettes/alice-gets-bob.yml
|
127
|
+
- test/fixtures/vcr_cassettes/alice-submits-bob.yml
|
128
|
+
- test/test_helper.rb
|
58
129
|
homepage: ''
|
59
130
|
licenses:
|
60
131
|
- MIT
|
@@ -78,6 +149,17 @@ rubyforge_project:
|
|
78
149
|
rubygems_version: 2.0.3
|
79
150
|
signing_key:
|
80
151
|
specification_version: 4
|
81
|
-
summary:
|
82
|
-
|
152
|
+
summary: This gem provides a command line client to allow users of the exercism.io
|
153
|
+
application to easily fetch and submit assignments.
|
154
|
+
test_files:
|
155
|
+
- test/exercism/api_test.rb
|
156
|
+
- test/exercism/assignment_test.rb
|
157
|
+
- test/exercism/config_test.rb
|
158
|
+
- test/exercism_test.rb
|
159
|
+
- test/fixtures/approvals/alice_gets_bob_readme.approved.txt
|
160
|
+
- test/fixtures/approvals/alice_gets_bob_tests.approved.txt
|
161
|
+
- test/fixtures/home/.exercism
|
162
|
+
- test/fixtures/vcr_cassettes/alice-gets-bob.yml
|
163
|
+
- test/fixtures/vcr_cassettes/alice-submits-bob.yml
|
164
|
+
- test/test_helper.rb
|
83
165
|
has_rdoc:
|