dandelion 0.4.9 → 0.4.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dandelion/changeset.rb +9 -5
- data/lib/dandelion/cli.rb +6 -6
- data/lib/dandelion/version.rb +1 -1
- data/spec/dandelion/changeset_spec.rb +3 -3
- data/spec/dandelion/command/deploy_spec.rb +16 -16
- data/spec/dandelion/command/init_spec.rb +1 -1
- data/spec/dandelion/config_spec.rb +2 -2
- data/spec/dandelion/deployer_spec.rb +20 -20
- data/spec/dandelion/workspace_spec.rb +7 -7
- 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: d80fc2861138ce9058efaf8ab53e71b854314b4b
|
4
|
+
data.tar.gz: a32ec46d1ad6f00daf7f078b3002e4f28513ae46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6282aff815d0c4017adb1c8e17c1b1f292b501e8a333efdff233e353c3725cb2277d9a0b64039e92688b205e9f03e480b943ae1362c92e6750b8c6a3b4b260c7
|
7
|
+
data.tar.gz: a323d6165bfedb74f9f3f46be3decc42df8518b847c2af322bff2ae383fcfc61fea89279dfa3806f1feba41f18ff3fa6463351f54b76e3f9b44d7d0a61b7f5fa
|
data/lib/dandelion/changeset.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Dandelion
|
2
2
|
class Changeset
|
3
3
|
include Enumerable
|
4
|
-
|
4
|
+
|
5
5
|
def initialize(tree, commit, options = {})
|
6
6
|
@tree = tree
|
7
7
|
@commit = commit
|
@@ -33,18 +33,22 @@ module Dandelion
|
|
33
33
|
|
34
34
|
private
|
35
35
|
|
36
|
+
def expand_path(path)
|
37
|
+
File.expand_path(path).to_s
|
38
|
+
end
|
39
|
+
|
36
40
|
def local_path
|
37
|
-
@options[:local_path] || ''
|
41
|
+
expand_path(@options[:local_path] || '')
|
38
42
|
end
|
39
43
|
|
40
44
|
def applicable?(path)
|
41
|
-
path.start_with?(local_path)
|
45
|
+
expand_path(path).start_with?(expand_path(local_path))
|
42
46
|
end
|
43
47
|
|
44
48
|
def transform_path(path)
|
45
|
-
trimmed = path[local_path.length..-1]
|
49
|
+
trimmed = expand_path(path)[expand_path(local_path).length..-1]
|
46
50
|
trimmed = trimmed[1..-1] if trimmed[0] == File::SEPARATOR
|
47
51
|
trimmed
|
48
52
|
end
|
49
53
|
end
|
50
|
-
end
|
54
|
+
end
|
data/lib/dandelion/cli.rb
CHANGED
@@ -46,19 +46,19 @@ module Dandelion
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def execute!
|
49
|
-
parse!(@parser)
|
50
|
-
|
51
49
|
if @args.length == 0
|
52
50
|
@options[:help] = true
|
53
51
|
end
|
52
|
+
|
53
|
+
parse!(@parser)
|
54
54
|
|
55
|
-
if @options[:
|
56
|
-
|
55
|
+
if @options[:version]
|
56
|
+
log.info("Dandelion #{Dandelion::VERSION}")
|
57
57
|
exit
|
58
58
|
end
|
59
59
|
|
60
|
-
if @options[:
|
61
|
-
|
60
|
+
if @options[:help]
|
61
|
+
display_help
|
62
62
|
exit
|
63
63
|
end
|
64
64
|
|
data/lib/dandelion/version.rb
CHANGED
@@ -27,7 +27,7 @@ describe Dandelion::Changeset do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
context 'non-empty local path' do
|
30
|
-
let(:changeset) { test_changeset(local_path: 'baz') }
|
30
|
+
let(:changeset) { test_changeset(local_path: './baz') }
|
31
31
|
|
32
32
|
describe '#enumerable' do
|
33
33
|
let(:changes) { changeset.to_a }
|
@@ -53,7 +53,7 @@ describe Dandelion::Changeset do
|
|
53
53
|
|
54
54
|
context 'empty diff' do
|
55
55
|
let(:changeset) { test_changeset }
|
56
|
-
before(:each) { changeset.
|
56
|
+
before(:each) { allow(changeset).to receive(:diff) { [] } }
|
57
57
|
|
58
58
|
describe '#enumerable' do
|
59
59
|
let(:changes) { changeset.to_a }
|
@@ -70,4 +70,4 @@ describe Dandelion::Changeset do
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
73
|
-
end
|
73
|
+
end
|
@@ -22,7 +22,7 @@ describe Dandelion::Command::Deploy do
|
|
22
22
|
describe '#deployer_adapter' do
|
23
23
|
it 'returns workspace adapter' do
|
24
24
|
adapter = double('adapter')
|
25
|
-
workspace.
|
25
|
+
expect(workspace).to receive(:adapter).and_return(adapter)
|
26
26
|
expect(command.deployer_adapter).to eq adapter
|
27
27
|
end
|
28
28
|
|
@@ -31,18 +31,18 @@ describe Dandelion::Command::Deploy do
|
|
31
31
|
|
32
32
|
it 'uses no-op adapter' do
|
33
33
|
noop = double('no-op adapter')
|
34
|
-
Dandelion::Adapter::NoOpAdapter.
|
34
|
+
expect(Dandelion::Adapter::NoOpAdapter).to receive(:new).with(command.config).and_return(noop)
|
35
35
|
expect(command.deployer_adapter).to eq noop
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
describe '#deployer' do
|
41
|
-
before(:each) { command.
|
41
|
+
before(:each) { allow(command).to receive(:adapter).and_return(double('adapter')) }
|
42
42
|
|
43
43
|
it 'creates deployer for adapter, and config' do
|
44
44
|
deployer = double('deployer')
|
45
|
-
Dandelion::Deployer.
|
45
|
+
expect(Dandelion::Deployer).to receive(:new).with(command.deployer_adapter, command.config).and_return(deployer)
|
46
46
|
expect(command.deployer).to eq deployer
|
47
47
|
end
|
48
48
|
end
|
@@ -63,49 +63,49 @@ describe Dandelion::Command::Deploy do
|
|
63
63
|
let(:changeset) { double('changeset') }
|
64
64
|
|
65
65
|
before(:each) do
|
66
|
-
workspace.
|
67
|
-
command.
|
66
|
+
allow(workspace).to receive(:changeset) { changeset }
|
67
|
+
allow(command).to receive(:deployer) { deployer }
|
68
68
|
end
|
69
69
|
|
70
70
|
context 'empty changeset' do
|
71
|
-
before(:each) { changeset.
|
71
|
+
before(:each) { allow(changeset).to receive(:empty?) { true } }
|
72
72
|
|
73
73
|
it 'does nothing' do
|
74
|
-
deployer.
|
74
|
+
expect(deployer).to_not receive(:deploy!)
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
78
|
context 'non-empty changeset' do
|
79
79
|
before(:each) do
|
80
|
-
deployer.
|
81
|
-
changeset.
|
80
|
+
allow(deployer).to receive(:deploy_changeset!)
|
81
|
+
allow(changeset).to receive(:empty?) { false }
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'deploys changeset' do
|
85
|
-
deployer.
|
85
|
+
expect(deployer).to receive(:deploy_changeset!).with(changeset)
|
86
86
|
command.execute!
|
87
87
|
end
|
88
88
|
|
89
89
|
it 'sets remote revision to local revision' do
|
90
|
-
workspace.
|
90
|
+
expect(workspace).to receive(:remote_commit=).with(workspace.local_commit)
|
91
91
|
command.execute!
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
95
|
context 'non-empty additional files' do
|
96
96
|
before(:each) do
|
97
|
-
changeset.
|
97
|
+
allow(changeset).to receive(:empty?) { true }
|
98
98
|
end
|
99
99
|
|
100
100
|
before(:each) do
|
101
|
-
deployer.
|
101
|
+
allow(deployer).to receive(:deploy_files!)
|
102
102
|
config[:additional] = ['foo']
|
103
103
|
end
|
104
104
|
|
105
105
|
it 'deploys files' do
|
106
|
-
deployer.
|
106
|
+
expect(deployer).to receive(:deploy_files!).with(['foo'])
|
107
107
|
command.execute!
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
111
|
-
end
|
111
|
+
end
|
@@ -11,7 +11,7 @@ describe Dandelion::Command::Init do
|
|
11
11
|
before { command.setup([revision]) }
|
12
12
|
|
13
13
|
it 'sets remote revision to specified revision' do
|
14
|
-
workspace.
|
14
|
+
expect(workspace).to receive(:remote_commit=).with(workspace.lookup(revision))
|
15
15
|
command.execute!
|
16
16
|
end
|
17
17
|
end
|
@@ -10,7 +10,7 @@ describe Dandelion::Config do
|
|
10
10
|
|
11
11
|
before(:each) do
|
12
12
|
ENV['BAZ'] = 'qux'
|
13
|
-
IO.
|
13
|
+
expect(IO).to receive(:read).with('foo').and_return(yaml)
|
14
14
|
end
|
15
15
|
|
16
16
|
let(:config) { Dandelion::Config.new(path: 'foo') }
|
@@ -22,4 +22,4 @@ describe Dandelion::Config do
|
|
22
22
|
it 'parses ERB' do
|
23
23
|
expect(config[:baz]).to eq 'qux'
|
24
24
|
end
|
25
|
-
end
|
25
|
+
end
|
@@ -12,9 +12,9 @@ describe Dandelion::Deployer do
|
|
12
12
|
]}
|
13
13
|
|
14
14
|
it 'perfoms writes and deletions on adapter' do
|
15
|
-
adapter.
|
16
|
-
adapter.
|
17
|
-
adapter.
|
15
|
+
expect(adapter).to receive(:write).with('foo', 'bar')
|
16
|
+
expect(adapter).to receive(:write).with('bar/baz', 'baz')
|
17
|
+
expect(adapter).to receive(:delete).with('qux')
|
18
18
|
|
19
19
|
deployer.deploy_changeset!(changeset)
|
20
20
|
end
|
@@ -23,8 +23,8 @@ describe Dandelion::Deployer do
|
|
23
23
|
let(:deployer) { Dandelion::Deployer.new(adapter, exclude: ['foo']) }
|
24
24
|
|
25
25
|
it 'perfoms writes and deletions on adapter' do
|
26
|
-
adapter.
|
27
|
-
adapter.
|
26
|
+
expect(adapter).to receive(:write).with('bar/baz', 'baz')
|
27
|
+
expect(adapter).to receive(:delete).with('qux')
|
28
28
|
|
29
29
|
deployer.deploy_changeset!(changeset)
|
30
30
|
end
|
@@ -33,18 +33,18 @@ describe Dandelion::Deployer do
|
|
33
33
|
|
34
34
|
describe '#deploy_files!' do
|
35
35
|
before(:each) do
|
36
|
-
IO.
|
37
|
-
IO.
|
38
|
-
IO.
|
39
|
-
IO.
|
36
|
+
allow(IO).to receive(:binread).with('a.txt').and_return('A')
|
37
|
+
allow(IO).to receive(:binread).with('b.txt').and_return('B')
|
38
|
+
allow(IO).to receive(:binread).with('c/a.txt').and_return('cA')
|
39
|
+
allow(IO).to receive(:binread).with('c/b.txt').and_return('cB')
|
40
40
|
end
|
41
41
|
|
42
42
|
context 'local paths' do
|
43
43
|
let(:files) { ['a.txt', 'b.txt'] }
|
44
44
|
|
45
45
|
it 'performs writes on adapter' do
|
46
|
-
adapter.
|
47
|
-
adapter.
|
46
|
+
expect(adapter).to receive(:write).with('a.txt', 'A')
|
47
|
+
expect(adapter).to receive(:write).with('b.txt', 'B')
|
48
48
|
|
49
49
|
deployer.deploy_files!(files)
|
50
50
|
end
|
@@ -57,8 +57,8 @@ describe Dandelion::Deployer do
|
|
57
57
|
]}
|
58
58
|
|
59
59
|
it 'performs writes on adapter' do
|
60
|
-
adapter.
|
61
|
-
adapter.
|
60
|
+
expect(adapter).to receive(:write).with('files/a.txt', 'A')
|
61
|
+
expect(adapter).to receive(:write).with('files/b.txt', 'B')
|
62
62
|
|
63
63
|
deployer.deploy_files!(files)
|
64
64
|
end
|
@@ -70,18 +70,18 @@ describe Dandelion::Deployer do
|
|
70
70
|
]}
|
71
71
|
|
72
72
|
before(:each) do
|
73
|
-
File.
|
74
|
-
File.
|
75
|
-
File.
|
76
|
-
Dir.
|
73
|
+
allow(File).to receive(:directory?).with('c/').and_return(true)
|
74
|
+
allow(File).to receive(:directory?).with('c/a.txt').and_return(false)
|
75
|
+
allow(File).to receive(:directory?).with('c/b.txt').and_return(false)
|
76
|
+
allow(Dir).to receive(:glob).with('c/**/*').and_return(['c/a.txt', 'c/b.txt'])
|
77
77
|
end
|
78
78
|
|
79
79
|
it 'performs writes on adapter' do
|
80
|
-
adapter.
|
81
|
-
adapter.
|
80
|
+
expect(adapter).to receive(:write).with('C/a.txt', 'cA')
|
81
|
+
expect(adapter).to receive(:write).with('C/b.txt', 'cB')
|
82
82
|
|
83
83
|
deployer.deploy_files!(files)
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
87
|
-
end
|
87
|
+
end
|
@@ -55,7 +55,7 @@ describe Dandelion::Workspace do
|
|
55
55
|
|
56
56
|
describe '#remote_commit' do
|
57
57
|
before(:each) do
|
58
|
-
adapter.
|
58
|
+
allow(adapter).to receive(:read).with('.revision').and_return(initial_revision)
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'returns commit for revision read from adapter' do
|
@@ -65,7 +65,7 @@ describe Dandelion::Workspace do
|
|
65
65
|
|
66
66
|
describe '#remote_commit=' do
|
67
67
|
it 'writes commit revision to adapter' do
|
68
|
-
adapter.
|
68
|
+
allow(adapter).to receive(:write).with('.revision', head_revision)
|
69
69
|
workspace.remote_commit = workspace.local_commit
|
70
70
|
end
|
71
71
|
end
|
@@ -73,7 +73,7 @@ describe Dandelion::Workspace do
|
|
73
73
|
describe '#tree' do
|
74
74
|
it 'returns tree for repo and local commit' do
|
75
75
|
tree = double()
|
76
|
-
Dandelion::Tree.
|
76
|
+
expect(Dandelion::Tree).to receive(:new).with(test_repo, workspace.local_commit).and_return(tree)
|
77
77
|
expect(workspace.tree).to eq tree
|
78
78
|
end
|
79
79
|
end
|
@@ -84,12 +84,12 @@ describe Dandelion::Workspace do
|
|
84
84
|
tree = double('tree')
|
85
85
|
remote_commit = double('remote_commit')
|
86
86
|
|
87
|
-
workspace.
|
88
|
-
workspace.
|
87
|
+
allow(workspace).to receive(:tree).and_return(tree)
|
88
|
+
allow(workspace).to receive(:remote_commit).and_return(remote_commit)
|
89
89
|
|
90
|
-
Dandelion::Changeset.
|
90
|
+
allow(Dandelion::Changeset).to receive(:new).with(tree, remote_commit, workspace.config).and_return(changeset)
|
91
91
|
|
92
92
|
expect(workspace.changeset).to eq changeset
|
93
93
|
end
|
94
94
|
end
|
95
|
-
end
|
95
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dandelion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Nelson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rugged
|