dandelion 0.4.0.beta2 → 0.4.0
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/README.md +4 -0
- data/lib/dandelion/command.rb +12 -0
- data/lib/dandelion/deployer.rb +29 -2
- data/lib/dandelion/version.rb +2 -2
- data/spec/dandelion/command_spec.rb +5 -0
- data/spec/dandelion/deployer_spec.rb +22 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f59aa5e5acccd85dd1817152e3ccc785c47eee57
|
4
|
+
data.tar.gz: 9df39ffc76d631968539f2bf32f608ff5df90ac2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be0340dee738190692e082c98a1bd4e95d5d3dfa9d15ad3243af6387c8ff3997d02e2c6f89c07d3d635c2e6d41744e5f400397b368b812e5482783541d0b5d70
|
7
|
+
data.tar.gz: 43c8d4fae12b32497eecf8c89b289be5a9746fab0a297249adc0a1e1d6ba1958b1713df81bbfe7201e198d3f54b93d8aa0da629b4873506d567f7b51f2df9dc6
|
data/README.md
CHANGED
data/lib/dandelion/command.rb
CHANGED
@@ -44,6 +44,18 @@ module Dandelion
|
|
44
44
|
opts.on('--config=[CONFIG]', 'Use the given config file') do |config|
|
45
45
|
options[:config] = config
|
46
46
|
end
|
47
|
+
|
48
|
+
opts.on('--log=[level]', 'Use the given log level (fatal, error, warn, info, debug)') do |level|
|
49
|
+
levels = {
|
50
|
+
fatal: Logger::FATAL,
|
51
|
+
error: Logger::ERROR,
|
52
|
+
warn: Logger::WARN,
|
53
|
+
info: Logger::INFO,
|
54
|
+
debug: Logger::DEBUG
|
55
|
+
}
|
56
|
+
|
57
|
+
Dandelion.logger.level = levels[level.to_sym]
|
58
|
+
end
|
47
59
|
end
|
48
60
|
end
|
49
61
|
end
|
data/lib/dandelion/deployer.rb
CHANGED
@@ -23,13 +23,25 @@ module Dandelion
|
|
23
23
|
local_path, remote_path = path.first
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
if File.directory?(local_path)
|
27
|
+
paths = expand_paths(local_path, remote_path)
|
28
|
+
else
|
29
|
+
paths = [[local_path, remote_path]]
|
30
|
+
end
|
31
|
+
|
32
|
+
paths.each do |local_path, remote_path|
|
33
|
+
deploy_file!(local_path, remote_path)
|
34
|
+
end
|
28
35
|
end
|
29
36
|
end
|
30
37
|
|
31
38
|
private
|
32
39
|
|
40
|
+
def deploy_file!(local_path, remote_path)
|
41
|
+
log.debug("Writing file: #{local_path} -> #{remote_path}")
|
42
|
+
@adapter.write(remote_path, IO.read(local_path))
|
43
|
+
end
|
44
|
+
|
33
45
|
def deploy_change!(change)
|
34
46
|
case change.type
|
35
47
|
when :write
|
@@ -46,6 +58,21 @@ module Dandelion
|
|
46
58
|
excluded.map { |e| path.start_with?(e) }.any?
|
47
59
|
end
|
48
60
|
|
61
|
+
def expand_paths(dir, remote_path)
|
62
|
+
paths = Dir.glob(File.join(dir, '**/*')).map do |path|
|
63
|
+
trimmed = trim_path(dir, path)
|
64
|
+
[path, File.join(remote_path, trimmed)]
|
65
|
+
end
|
66
|
+
|
67
|
+
paths.reject do |local_path, remote_path|
|
68
|
+
File.directory?(local_path)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def trim_path(dir, path)
|
73
|
+
path[dir.length..-1]
|
74
|
+
end
|
75
|
+
|
49
76
|
def log
|
50
77
|
Dandelion.logger
|
51
78
|
end
|
data/lib/dandelion/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Dandelion
|
2
|
-
VERSION = '0.4.0
|
3
|
-
end
|
2
|
+
VERSION = '0.4.0'
|
3
|
+
end
|
@@ -66,5 +66,10 @@ describe Dandelion::Command::Base do
|
|
66
66
|
parser.order!(['--config=foo'])
|
67
67
|
expect(options[:config]).to eq 'foo'
|
68
68
|
end
|
69
|
+
|
70
|
+
it 'parses log level' do
|
71
|
+
parser.order!(['--log=warn'])
|
72
|
+
expect(Dandelion.logger.level).to eq Logger::WARN
|
73
|
+
end
|
69
74
|
end
|
70
75
|
end
|
@@ -35,6 +35,8 @@ describe Dandelion::Deployer do
|
|
35
35
|
before(:each) do
|
36
36
|
IO.stub(:read).with('a.txt').and_return('A')
|
37
37
|
IO.stub(:read).with('b.txt').and_return('B')
|
38
|
+
IO.stub(:read).with('c/a.txt').and_return('cA')
|
39
|
+
IO.stub(:read).with('c/b.txt').and_return('cB')
|
38
40
|
end
|
39
41
|
|
40
42
|
context 'local paths' do
|
@@ -61,5 +63,25 @@ describe Dandelion::Deployer do
|
|
61
63
|
deployer.deploy_files!(files)
|
62
64
|
end
|
63
65
|
end
|
66
|
+
|
67
|
+
context 'directory' do
|
68
|
+
let(:files) {[
|
69
|
+
{ 'c/' => 'C/' }
|
70
|
+
]}
|
71
|
+
|
72
|
+
before(:each) do
|
73
|
+
File.stub(:directory?).with('c/').and_return(true)
|
74
|
+
File.stub(:directory?).with('c/a.txt').and_return(false)
|
75
|
+
File.stub(:directory?).with('c/b.txt').and_return(false)
|
76
|
+
Dir.stub(:glob).with('c/**/*').and_return(['c/a.txt', 'c/b.txt'])
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'performs writes on adapter' do
|
80
|
+
adapter.should_receive(:write).with('C/a.txt', 'cA')
|
81
|
+
adapter.should_receive(:write).with('C/b.txt', 'cB')
|
82
|
+
|
83
|
+
deployer.deploy_files!(files)
|
84
|
+
end
|
85
|
+
end
|
64
86
|
end
|
65
87
|
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.0
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Nelson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rugged
|
@@ -122,9 +122,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
122
122
|
version: '0'
|
123
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
124
|
requirements:
|
125
|
-
- - '
|
125
|
+
- - '>='
|
126
126
|
- !ruby/object:Gem::Version
|
127
|
-
version:
|
127
|
+
version: '0'
|
128
128
|
requirements: []
|
129
129
|
rubyforge_project:
|
130
130
|
rubygems_version: 2.0.14
|