githug 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/levels/remote.rb +1 -1
- data/lib/githug/cli.rb +7 -1
- data/lib/githug/level.rb +1 -1
- data/lib/githug/profile.rb +14 -8
- data/lib/githug/version.rb +1 -1
- data/spec/githug/cli_spec.rb +3 -0
- data/spec/githug/level_spec.rb +1 -1
- data/spec/githug/profile_spec.rb +34 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ef20410caf64b37405990b315bcb0a6c0534d77
|
4
|
+
data.tar.gz: da283777c0e13586c8ba42ac8c93461ec4274bbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b32b0a9ddf2f78aeaa865b6f26b01a25e926476dc965b770f39d80ac5bf75cf740fbb4e700ca2dbcaa3c883df8a6a4740ccae7f0a0e63f4dd34eeede7217f96
|
7
|
+
data.tar.gz: 06ee6264ed7517a8d14de09acd95ab31b4b418d712f9eb7c1b258d70a6ce4e77855df6ce3be055f266392553313623c478a57cf42e7b7ebf23fb4e5189a3a541
|
data/levels/remote.rb
CHANGED
data/lib/githug/cli.rb
CHANGED
@@ -61,10 +61,16 @@ module Githug
|
|
61
61
|
|
62
62
|
def load_level(path = nil)
|
63
63
|
return load_level_from_profile unless path
|
64
|
-
return
|
64
|
+
return load_level_from_name(path) if Level.list.include?(path)
|
65
65
|
Level.load_from_file(path)
|
66
66
|
end
|
67
67
|
|
68
|
+
def load_level_from_name(name)
|
69
|
+
profile = Profile.load
|
70
|
+
profile.set_level(name)
|
71
|
+
Level.load(name)
|
72
|
+
end
|
73
|
+
|
68
74
|
def load_level_from_profile
|
69
75
|
profile = Profile.load
|
70
76
|
Level.load(profile.level)
|
data/lib/githug/level.rb
CHANGED
data/lib/githug/profile.rb
CHANGED
@@ -41,25 +41,31 @@ module Githug
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
def set_level(name)
|
45
|
+
settings[:level] = name
|
46
|
+
reset!
|
47
|
+
save
|
48
|
+
end
|
49
|
+
|
44
50
|
def level_bump
|
45
51
|
levels = Level::LEVELS
|
46
52
|
level_no = levels.index(settings[:level])
|
47
53
|
|
48
54
|
settings[:completed_levels] << level
|
49
|
-
|
50
55
|
settings[:current_levels] = levels
|
51
|
-
|
52
|
-
settings[:current_attempts] = 0
|
53
|
-
|
54
|
-
settings[:current_hint_index] = 0
|
55
|
-
|
56
56
|
next_level = (levels - settings[:completed_levels]).first || levels.last
|
57
57
|
|
58
|
-
|
59
|
-
save
|
58
|
+
set_level(next_level)
|
60
59
|
next_level
|
61
60
|
end
|
62
61
|
|
62
|
+
private
|
63
|
+
|
64
|
+
def reset!
|
65
|
+
settings[:current_attempts] = 0
|
66
|
+
settings[:current_hint_index] = 0
|
67
|
+
end
|
68
|
+
|
63
69
|
|
64
70
|
end
|
65
71
|
end
|
data/lib/githug/version.rb
CHANGED
data/spec/githug/cli_spec.rb
CHANGED
@@ -88,6 +88,9 @@ describe Githug::CLI do
|
|
88
88
|
it "should reset the level with a level name" do
|
89
89
|
@level.should_receive(:setup_level)
|
90
90
|
@level.should_receive(:full_description)
|
91
|
+
profile = mock
|
92
|
+
Githug::Profile.stub(:load).and_return(profile)
|
93
|
+
profile.should_receive(:set_level).with("add")
|
91
94
|
Githug::Level.should_receive(:load).with("add").and_return(@level)
|
92
95
|
Githug::UI.should_receive(:word_box).with("Githug")
|
93
96
|
Githug::UI.should_receive(:puts).with("resetting level")
|
data/spec/githug/level_spec.rb
CHANGED
data/spec/githug/profile_spec.rb
CHANGED
@@ -31,35 +31,53 @@ describe Githug::Profile do
|
|
31
31
|
profile.save
|
32
32
|
end
|
33
33
|
|
34
|
-
describe "
|
34
|
+
describe "level methods" do
|
35
|
+
|
36
|
+
let(:profile) { Githug::Profile.load }
|
37
|
+
|
35
38
|
before(:each) do
|
36
|
-
|
39
|
+
profile.stub(:save)
|
37
40
|
@levels = Githug::Level::LEVELS
|
38
41
|
Githug::Level::LEVELS = ["init", "add", "rm", "rm_cached", "diff"]
|
39
|
-
|
40
|
-
@profile.should_receive(:save)
|
42
|
+
profile.level = "init"
|
41
43
|
end
|
42
44
|
|
43
45
|
after(:each) do
|
44
46
|
Githug::Level::LEVELS = @levels
|
45
47
|
end
|
46
48
|
|
47
|
-
|
48
|
-
|
49
|
-
|
49
|
+
describe "level_bump" do
|
50
|
+
|
51
|
+
|
52
|
+
it "should bump the level" do
|
53
|
+
profile.should_receive(:set_level).with("add")
|
54
|
+
profile.level_bump
|
55
|
+
end
|
50
56
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
57
|
+
it "should reset the current_attempts" do
|
58
|
+
profile.current_attempts = 1
|
59
|
+
profile.level_bump
|
60
|
+
profile.current_attempts.should eql(0)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should set the level to the first incomplete level" do
|
64
|
+
profile.settings.stub(:[]).with(:level).and_return("rm_cached")
|
65
|
+
profile.settings.stub(:[]).with(:completed_levels).and_return(["init", "add"])
|
66
|
+
profile.level_bump.should eql("rm")
|
67
|
+
end
|
55
68
|
end
|
56
69
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
70
|
+
describe "set_level" do
|
71
|
+
|
72
|
+
it "should set the level" do
|
73
|
+
profile.should_receive(:save)
|
74
|
+
profile.should_receive(:reset!)
|
75
|
+
profile.set_level("rm")
|
76
|
+
profile.settings[:level].should eql("rm")
|
77
|
+
end
|
78
|
+
|
61
79
|
end
|
62
|
-
end
|
63
80
|
|
81
|
+
end
|
64
82
|
|
65
83
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: githug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gary Rennie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|