rubolite 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rubolite/client.rb +11 -2
- data/lib/rubolite/version.rb +1 -1
- data/spec/lib/rubolite/client_spec.rb +27 -1
- metadata +2 -2
data/lib/rubolite/client.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
module Rubolite
|
2
2
|
class Client
|
3
|
+
extend Forwardable
|
4
|
+
|
3
5
|
attr_reader :admin, :ssh_keys
|
4
6
|
|
7
|
+
def_delegators :@admin, :git
|
8
|
+
|
5
9
|
def initialize(admin)
|
6
10
|
@admin = admin
|
7
11
|
@ssh_keys = {}
|
@@ -40,8 +44,9 @@ module Rubolite
|
|
40
44
|
end
|
41
45
|
|
42
46
|
def commit!
|
43
|
-
|
44
|
-
admin.git.
|
47
|
+
return unless commitable?
|
48
|
+
admin.git.add(".")
|
49
|
+
admin.git.commit "Modified configuration by rubolite"
|
45
50
|
end
|
46
51
|
|
47
52
|
def push!
|
@@ -61,5 +66,9 @@ module Rubolite
|
|
61
66
|
@groups = nil
|
62
67
|
@ssh_keys = {}
|
63
68
|
end
|
69
|
+
|
70
|
+
def commitable?
|
71
|
+
admin.git.status.changed.size > 0
|
72
|
+
end
|
64
73
|
end
|
65
74
|
end
|
data/lib/rubolite/version.rb
CHANGED
@@ -39,6 +39,10 @@ describe Rubolite::Client do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
context "saving" do
|
42
|
+
let(:git) { stub status: status, add: nil }
|
43
|
+
let(:status) { stub changed: changed }
|
44
|
+
let(:changed) { Hash.new }
|
45
|
+
|
42
46
|
it "saves changes" do
|
43
47
|
admin.writer.should_receive(:write!)
|
44
48
|
subject.save!
|
@@ -55,7 +59,14 @@ describe Rubolite::Client do
|
|
55
59
|
end
|
56
60
|
|
57
61
|
it "commits the changes to the repo" do
|
58
|
-
admin.git.should_receive(:
|
62
|
+
admin.git.should_receive(:commit)
|
63
|
+
subject.commit!
|
64
|
+
end
|
65
|
+
|
66
|
+
it "commits only if things have changed" do
|
67
|
+
subject.admin.stub(git: git)
|
68
|
+
|
69
|
+
admin.git.should_not_receive(:commit_all)
|
59
70
|
subject.commit!
|
60
71
|
end
|
61
72
|
|
@@ -108,4 +119,19 @@ describe Rubolite::Client do
|
|
108
119
|
expect(subject.ssh_keys.object_id).not_to eq(ssh_keys)
|
109
120
|
end
|
110
121
|
end
|
122
|
+
|
123
|
+
context "status reporting" do
|
124
|
+
let(:git) { stub status: status }
|
125
|
+
let(:status) { stub changed: changed }
|
126
|
+
let(:changed) { Hash.new }
|
127
|
+
|
128
|
+
before(:each) do
|
129
|
+
subject.admin.stub(git: git)
|
130
|
+
end
|
131
|
+
|
132
|
+
it "reports that it is commitable" do
|
133
|
+
changed.should_receive(:size).and_return(1)
|
134
|
+
expect(subject).to be_commitable
|
135
|
+
end
|
136
|
+
end
|
111
137
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubolite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
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: 2012-11-
|
12
|
+
date: 2012-11-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|