exercism 0.0.19 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  .approvals
19
+ tags
data/README.md CHANGED
@@ -29,6 +29,8 @@ This submits `example.rb` on your current assignment.
29
29
 
30
30
  Reveals stack traces on errors.
31
31
 
32
+ By default, Exercism will create a config file in the base of your home directory, i.e. `~/.exercism`. This file can be moved to `~/.config/exercism` if desired.
33
+
32
34
  ## Contributing
33
35
 
34
36
  1. Fork it
data/lib/cli.rb CHANGED
@@ -77,26 +77,7 @@ class Exercism
77
77
  def login
78
78
  require 'exercism'
79
79
 
80
- username = ask("Your GitHub username:")
81
- key = ask("Your exercism.io API key:")
82
- default_dir = FileUtils.pwd
83
- say "What is your exercism exercises project path?"
84
- say "Press Enter to select the default (#{default_dir}):\n"
85
- dir = ask ">"
86
- if dir.empty?
87
- dir = default_dir
88
- end
89
- project_dir = File.expand_path(dir)
90
-
91
- say "Where do you want your configuration stored? (type a number)"
92
- say "1. #{File.join(Exercism.home, '.exercism')}"
93
- say "2. #{File.join(Exercism.home, '.config', 'exercism')}"
94
-
95
- if ask(">").to_i == 2
96
- Exercism.login username, key, project_dir, File.join(Exercism.home, '.config')
97
- else
98
- Exercism.login username, key, project_dir, Exercism.home
99
- end
80
+ Exercism.login username, key, project_dir
100
81
 
101
82
  say("Your credentials have been written to #{Exercism.config.file}")
102
83
  end
@@ -119,6 +100,22 @@ class Exercism
119
100
 
120
101
  private
121
102
 
103
+ def username
104
+ ask("Your GitHub username:")
105
+ end
106
+
107
+ def key
108
+ ask("Your exercism.io API key:")
109
+ end
110
+
111
+ def project_dir
112
+ default_dir = FileUtils.pwd
113
+ say "What is your exercism exercises project path?"
114
+ say "Press Enter to select the default (#{default_dir}):\n"
115
+ dir = ask ">", :default => default_dir
116
+ File.expand_path(dir)
117
+ end
118
+
122
119
  def api(host = options[:host])
123
120
  Exercism::Api.new(host, Exercism.user, Exercism.project_dir)
124
121
  end
@@ -25,13 +25,13 @@ class Exercism
25
25
  @home ||= Env.home
26
26
  end
27
27
 
28
- def self.login(github_username, key, dir, config_path)
28
+ def self.login(github_username, key, dir)
29
29
  data = {
30
30
  'github_username' => github_username,
31
31
  'key' => key,
32
32
  'project_dir' => dir
33
33
  }
34
- Config.write(config_path, data)
34
+ Config.write home, data
35
35
  end
36
36
 
37
37
  def self.user
@@ -56,7 +56,7 @@ class Exercism
56
56
  def endpoint(action = nil)
57
57
  "/api/v1/#{action}".chomp('/')
58
58
  end
59
-
59
+
60
60
  def save(body)
61
61
  Assignment.save(JSON.parse(body), project_dir)
62
62
  end
@@ -7,9 +7,7 @@ class Exercism
7
7
 
8
8
  def self.read(path)
9
9
  config = new(path)
10
- return config if config.exists?
11
-
12
- new(alternate_path) unless config.exists?
10
+ config.exists? ? config : new(alternate_path)
13
11
  end
14
12
 
15
13
  def self.write(path, data)
@@ -1,3 +1,3 @@
1
1
  class Exercism
2
- VERSION = "0.0.19"
2
+ VERSION = "0.0.20"
3
3
  end
@@ -21,7 +21,7 @@ class ExercismTest < Minitest::Test
21
21
  home = './test/fixtures'
22
22
  Exercism.stub(:home, home) do
23
23
  key = '97e9975'
24
- Exercism.login('bob', key, '/tmp', home)
24
+ Exercism.login('bob', key, '/tmp')
25
25
  user = Exercism.user
26
26
  assert_equal 'bob', user.github_username
27
27
  assert_equal key, user.key
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.19
4
+ version: 0.0.20
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-28 00:00:00.000000000 Z
12
+ date: 2013-07-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json