exercism 0.0.20 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
data/lib/exercism/api.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'faraday/adapter/net_http'
2
+
1
3
  class Exercism
2
4
  class Api
3
5
 
@@ -1,3 +1,5 @@
1
+ require 'yaml/store'
2
+
1
3
  class Exercism
2
4
  class Config
3
5
 
@@ -40,15 +42,7 @@ class Exercism
40
42
  def save
41
43
  FileUtils.mkdir_p(project_dir)
42
44
  FileUtils.mkdir_p(path)
43
-
44
- File.open file, 'w' do |f|
45
- data = {
46
- 'github_username' => github_username,
47
- 'key' => key,
48
- 'project_dir' => project_dir
49
- }
50
- f.write data.to_yaml
51
- end
45
+ save_to_file
52
46
  self
53
47
  end
54
48
 
@@ -66,6 +60,24 @@ class Exercism
66
60
 
67
61
  private
68
62
 
63
+ def save_to_file
64
+ data = {
65
+ 'github_username' => github_username,
66
+ 'key' => key,
67
+ 'project_dir' => project_dir
68
+ }
69
+
70
+ store.transaction do
71
+ data.each_pair do |k,v|
72
+ store[k] = v
73
+ end
74
+ end
75
+ end
76
+
77
+ def store
78
+ @store ||= YAML::Store.new(file)
79
+ end
80
+
69
81
  def filename
70
82
  default? ? ".exercism" : "exercism"
71
83
  end
@@ -75,12 +87,10 @@ class Exercism
75
87
  end
76
88
 
77
89
  def from_yaml
78
- unless @data
79
- @data = YAML.load(File.read(file))
80
- unless @data
81
- raise StandardError.new "Cannot read #{file}"
82
- end
83
- end
90
+ @data ||= store.load(File.read(file))
91
+ unless @data
92
+ raise StandardError.new "Cannot read #{file}"
93
+ end
84
94
  @data
85
95
  end
86
96
 
data/lib/exercism/env.rb CHANGED
@@ -3,7 +3,7 @@ class Exercism
3
3
  def self.home
4
4
  if windows_nt?
5
5
  ENV["HOMEDRIVE"] + ENV["HOMEPATH"]
6
- elsif ruby18?
6
+ elsif ruby18? || ruby191?
7
7
  File.expand_path('~')
8
8
  else
9
9
  Dir.home(Etc.getlogin)
@@ -17,5 +17,9 @@ class Exercism
17
17
  def self.ruby18?
18
18
  RUBY_VERSION == '1.8.7'
19
19
  end
20
+
21
+ def self.ruby191?
22
+ RUBY_VERSION == '1.9.1'
23
+ end
20
24
  end
21
25
  end
@@ -1,3 +1,3 @@
1
1
  class Exercism
2
- VERSION = "0.0.20"
2
+ VERSION = "0.0.21"
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.20
4
+ version: 0.0.21
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-30 00:00:00.000000000 Z
12
+ date: 2013-08-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json