githug 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7d79d4ffee6020278723a688b4a55dc3dfba4ac
4
- data.tar.gz: ee2e0f4be70b93e83e5f77d8160960e27ec36c6d
3
+ metadata.gz: 9ef20410caf64b37405990b315bcb0a6c0534d77
4
+ data.tar.gz: da283777c0e13586c8ba42ac8c93461ec4274bbc
5
5
  SHA512:
6
- metadata.gz: ab986424a092306825c2c11962ee68b643c5bc3384e3571839e220a354df25112c4f22bf8665c7b6ad8cb029e5b66d0aba3390f96156b487b6801fe75ea1d552
7
- data.tar.gz: b44c21dec92e90bbb5241778b9455cad34ffa4894ab846fe3c0ecc4325c19c43329f13b4498b05f499f152385a1ee0b90f71843c9632b38f6d8877503a3d1dd8
6
+ metadata.gz: 9b32b0a9ddf2f78aeaa865b6f26b01a25e926476dc965b770f39d80ac5bf75cf740fbb4e700ca2dbcaa3c883df8a6a4740ccae7f0a0e63f4dd34eeede7217f96
7
+ data.tar.gz: 06ee6264ed7517a8d14de09acd95ab31b4b418d712f9eb7c1b258d70a6ce4e77855df6ce3be055f266392553313623c478a57cf42e7b7ebf23fb4e5189a3a541
@@ -1,6 +1,6 @@
1
1
  difficulty 2
2
2
 
3
- description "This projects has a remote repository. Identify it."
3
+ description "This project has a remote repository. Identify it."
4
4
 
5
5
  setup do
6
6
  repo.init
@@ -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 Level.load(path) if Level.list.include?(path)
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)
@@ -100,7 +100,7 @@ module Githug
100
100
  end
101
101
 
102
102
  def test
103
- @solution.call
103
+ _solution
104
104
  end
105
105
 
106
106
  def show_hint
@@ -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
- settings[:level] = next_level
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
@@ -1,3 +1,3 @@
1
1
  module Githug
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -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")
@@ -100,7 +100,7 @@ end
100
100
 
101
101
  describe "test" do
102
102
  it "should call solve" do
103
- @level.instance_variable_get("@solution").should_receive(:call)
103
+ @level.should_receive(:_solution)
104
104
  @level.test
105
105
  end
106
106
  end
@@ -31,35 +31,53 @@ describe Githug::Profile do
31
31
  profile.save
32
32
  end
33
33
 
34
- describe "level_bump" do
34
+ describe "level methods" do
35
+
36
+ let(:profile) { Githug::Profile.load }
37
+
35
38
  before(:each) do
36
- @profile = Githug::Profile.load
39
+ profile.stub(:save)
37
40
  @levels = Githug::Level::LEVELS
38
41
  Githug::Level::LEVELS = ["init", "add", "rm", "rm_cached", "diff"]
39
- @profile.level = "init"
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
- it "should bump the level" do
48
- @profile.level_bump.should eql("add")
49
- end
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
- it "should reset the current_attempts" do
52
- @profile.current_attempts = 1
53
- @profile.level_bump
54
- @profile.current_attempts.should eql(0)
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
- it "should set the level to the first incomplete level" do
58
- @profile.settings.stub(:[]).with(:level).and_return("rm_cached")
59
- @profile.settings.stub(:[]).with(:completed_levels).and_return(["init", "add"])
60
- @profile.level_bump.should eql("rm")
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.0
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-12 00:00:00.000000000 Z
11
+ date: 2013-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec