dandelion 0.4.6 → 0.4.7

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: 2e24ed3bb3d909f2dde31c896dc0a55ba7bea103
4
- data.tar.gz: 40301d574cfbd917d0ccc85da4449ff79f73226e
3
+ metadata.gz: ba3c395e5c9d4ab9b7c3192e69c40a0f95441ef3
4
+ data.tar.gz: 9978670bf800e50566e1298c99ffe051626ad16a
5
5
  SHA512:
6
- metadata.gz: a33bd1ff022f1c5f0c0497d52e04b545db4f38b9f69487bd7ebe6d83753e2f3189b057d1b03a670a9057f5b8d9494c2a3e62b7a84b26a0b0fe7d55980ce3fc04
7
- data.tar.gz: 963b92769bd3ab6c1af4af22662f056776ce801472c9542d726e3e5adb9f3aefecde44700a3744fbc6148c3e517b9c3bf079cc359f03364ffc37c435de2ec2bc
6
+ metadata.gz: 1df3eea14e4b717a71f8db414e69bf52d5fe634282df26ed09c863a62937615b2b9cd5b139be20c8e9455a564ac11da15334d17c849bff9870c43162f41acc2a
7
+ data.tar.gz: 53b054c31c571c285cad178499ef9a20fdb57dbd587146f823e52fdd45a8d65347e103a87793b239c4cc76896898cff15f6205a43957aa8685ca281ecf7b9888
data/README.md CHANGED
@@ -10,7 +10,7 @@ Incremental Git repository deployment.
10
10
  Install
11
11
  -------
12
12
 
13
- Ensure that Ruby >= 1.9 is installed, then run:
13
+ Ensure that Ruby >= 1.9.2 is installed, then run:
14
14
 
15
15
  $ gem install dandelion
16
16
 
@@ -32,7 +32,7 @@ path: path/to/deployment
32
32
  exclude:
33
33
  - .gitignore
34
34
  - dandelion.yml
35
- - folder/
35
+ - dir/
36
36
 
37
37
  additional:
38
38
  - config/auth.yml
@@ -50,6 +50,14 @@ Optional:
50
50
  * `additional` (additional list of files from your working directory that will be deployed)
51
51
  * `revision_file` (remote file in which revision SHA is stored, defaults to .revision)
52
52
 
53
+ The `additional` section can either take a list of local file names or key-value formats if you want to upload something to a specific path:
54
+ ```
55
+ additional:
56
+ - localdir: remotedir
57
+ - file.txt: remotedir/file.txt
58
+ ```
59
+ The `localdir` in this example is relative to the repository root (ignoring `local_path` if you set it).
60
+
53
61
  Each adapter also has additional required and optional configuration parameters (see below).
54
62
 
55
63
  Adapters
@@ -59,13 +67,13 @@ There is support for multiple backend file transfer adapters. The configuration
59
67
  must specify one of these adapters and the set of additional parameters required
60
68
  by the given adapter.
61
69
 
62
- **SFTP**: `adapter: sftp`
70
+ **SFTP**: `adapter: sftp` (honors SSH config files)
63
71
 
64
72
  Required:
65
73
 
66
74
  * `host`
67
75
  * `username`
68
- * `password`
76
+ * `password` (not required if you're using an SSH key)
69
77
 
70
78
  Optional:
71
79
 
@@ -85,6 +93,22 @@ Optional:
85
93
  * `port` (defaults to 21)
86
94
  * `passive` (defaults to false)
87
95
 
96
+ **FTPS**: `adapter: ftps` (ftp over TLS, based on [DoubleBagFTPS](https://github.com/bnix/double-bag-ftps) and Dandelions native FTP adapter)
97
+
98
+ Required: (same as FTP)
99
+
100
+ * `host`
101
+ * `username`
102
+ * `password`
103
+
104
+ Optional: (in addition to options for FTP)
105
+
106
+ * `port`
107
+ * `passive`
108
+ * `auth_tls` (default false)
109
+ * `ftps_implicit` (default false: explicit TLS)
110
+ * `insecure` (default false, true to allow self-signed certificates)
111
+
88
112
  **Amazon S3**: `adapter: s3`
89
113
 
90
114
  Required:
@@ -126,9 +150,12 @@ For a more complete summary of usage options, run:
126
150
  Available commands:
127
151
  deploy
128
152
  status
129
-
153
+
130
154
  Note that when specifying the repository or configuration file, the given paths
131
- are relative to the current working directory (not the repository root). To see
132
- the options for a particular command, run:
155
+ are relative to the current working directory (not the repository root).
156
+
157
+ To see the options for a particular command, run `dandelion <command> -h`:
133
158
 
134
- $ dandelion <command> -h
159
+ $ dandelion deploy -h
160
+ Usage: dandelion deploy [options] [<revision>]
161
+ --dry-run Show what would have been deployed
data/dandelion.gemspec CHANGED
@@ -25,5 +25,5 @@ Gem::Specification.new do |s|
25
25
  ! additional gems need to be installed.
26
26
  MSG
27
27
 
28
- s.add_dependency 'rugged', '~> 0.19.0'
29
- end
28
+ s.add_dependency 'rugged', '~> 0.21.2'
29
+ end
@@ -42,4 +42,5 @@ end
42
42
  require 'dandelion/adapter/noop'
43
43
  require 'dandelion/adapter/ftp'
44
44
  require 'dandelion/adapter/sftp'
45
+ require 'dandelion/adapter/ftps'
45
46
  require 'dandelion/adapter/s3'
@@ -6,7 +6,7 @@ module Dandelion
6
6
  include ::Dandelion::Utils
7
7
 
8
8
  adapter 'ftp'
9
-
9
+
10
10
  def initialize(config)
11
11
  require 'net/ftp'
12
12
 
@@ -19,7 +19,7 @@ module Dandelion
19
19
 
20
20
  def read(file)
21
21
  begin
22
- @ftp.getbinaryfile(file, nil)
22
+ @ftp.getbinaryfile(path(file), nil)
23
23
  rescue Net::FTPPermError => e
24
24
  nil
25
25
  end
@@ -28,34 +28,34 @@ module Dandelion
28
28
  def write(file, data)
29
29
  temp(file, data) do |temp|
30
30
  begin
31
- @ftp.putbinaryfile(temp, file)
31
+ @ftp.putbinaryfile(temp, path(file))
32
32
  rescue Net::FTPPermError => e
33
- mkdir_p(File.dirname(file))
34
- @ftp.putbinaryfile(temp, file)
33
+ raise e unless e.to_s =~ /553/
34
+ mkdir_p(File.dirname(path(file)))
35
+ @ftp.putbinaryfile(temp, path(file))
35
36
  end
36
37
  end
37
38
  end
38
39
 
39
40
  def delete(file)
40
41
  begin
41
- @ftp.delete(file)
42
- cleanup(File.dirname(file))
42
+ @ftp.delete(path(file))
43
+ cleanup(File.dirname(path(file)))
43
44
  rescue Net::FTPPermError => e
44
45
  end
45
46
  end
46
-
47
+
47
48
  def to_s
48
49
  "ftp://#{@config['username']}@#{@config['host']}/#{@config['path']}"
49
50
  end
50
51
 
51
- private
52
+ private
52
53
 
53
54
  def ftp_client
54
55
  ftp = Net::FTP.new
55
56
  ftp.connect(@config['host'], @config['port'])
56
57
  ftp.login(@config['username'], @config['password'])
57
58
  ftp.passive = @config['passive']
58
- ftp.chdir(@config['path']) if @config['path']
59
59
  ftp
60
60
  end
61
61
 
@@ -82,10 +82,18 @@ module Dandelion
82
82
  end
83
83
  end
84
84
  end
85
-
85
+
86
+ def path(file)
87
+ if @config['path'] and !@config['path'].empty?
88
+ File.join(@config['path'], file)
89
+ else
90
+ file
91
+ end
92
+ end
93
+
86
94
  def to_b(value)
87
95
  return [true, 'true', 1, '1', 'T', 't'].include?(value.class == String ? value.downcase : value)
88
96
  end
89
97
  end
90
98
  end
91
- end
99
+ end
@@ -0,0 +1,45 @@
1
+ require 'dandelion/utils'
2
+
3
+ module Dandelion
4
+ module Adapter
5
+ class FTPS < Dandelion::Adapter::FTP
6
+ include ::Dandelion::Utils
7
+
8
+ adapter 'ftps'
9
+ requires_gems 'double-bag-ftps'
10
+
11
+ def initialize(config)
12
+ require 'double_bag_ftps'
13
+
14
+ config[:auth_tls] = to_b(config[:auth_tls])
15
+ config[:ftps_implicit] = to_b(config[:ftps_implicit])
16
+ config[:inscecure] = to_b(config[:insecure])
17
+
18
+ super(config)
19
+ end
20
+
21
+ private
22
+
23
+ def ftp_client
24
+ ftps = DoubleBagFTPS.new(@config['host'], nil, nil, nil, ftps_mode, {})
25
+
26
+ if @config['insecure']
27
+ ftps.ssl_context = DoubleBagFTPS.create_ssl_context(verify_mode: OpenSSL::SSL::VERIFY_NONE)
28
+ end
29
+
30
+ ftps.login(@config['username'], @config['password'], nil, ftps_auth)
31
+ ftps.passive = @config[:passive]
32
+
33
+ ftps
34
+ end
35
+
36
+ def ftps_auth
37
+ @config['auth_tls'] ? 'TLS' : nil
38
+ end
39
+
40
+ def ftps_mode
41
+ @config['ftps_implicit'] ? DoubleBagFTPS::IMPLICIT : DoubleBagFTPS::EXPLICIT
42
+ end
43
+ end
44
+ end
45
+ end
@@ -3,10 +3,10 @@ module Dandelion
3
3
  class S3 < Adapter::Base
4
4
  adapter 's3'
5
5
  requires_gems 'aws-s3'
6
-
6
+
7
7
  def initialize(config)
8
8
  require 'aws/s3'
9
-
9
+
10
10
  @config = config
11
11
  @config.defaults(preserve_permissions: true)
12
12
  end
@@ -21,7 +21,7 @@ module Dandelion
21
21
  connect!
22
22
 
23
23
  key = path(file)
24
-
24
+
25
25
  begin
26
26
  policy = AWS::S3::S3Object.acl(key, bucket_name) if @config[:preserve_permissions]
27
27
  rescue AWS::S3::NoSuchKey
@@ -35,13 +35,13 @@ module Dandelion
35
35
  connect!
36
36
  AWS::S3::S3Object.delete(path(file), bucket_name)
37
37
  end
38
-
38
+
39
39
  def to_s
40
40
  "s3://#{@config[:access_key_id]}@#{bucket_name}/#{@config[:path]}"
41
41
  end
42
42
 
43
- protected
44
-
43
+ protected
44
+
45
45
  def connect!
46
46
  options = {
47
47
  access_key_id: @config[:access_key_id],
@@ -49,14 +49,14 @@ module Dandelion
49
49
  use_ssl: true
50
50
  }
51
51
 
52
- options[:server] = @config[:host] if @config[:host]
52
+ AWS::S3::DEFAULT_HOST.replace(@config[:host]) if @config[:host]
53
53
  AWS::S3::Base.establish_connection!(options) unless AWS::S3::Base.connected?
54
54
  end
55
55
 
56
56
  def bucket_name
57
57
  @config[:bucket_name]
58
58
  end
59
-
59
+
60
60
  def path(file)
61
61
  if @config[:path] and !@config[:path].empty?
62
62
  "#{@config[:path]}/#{file}"
@@ -66,4 +66,4 @@ module Dandelion
66
66
  end
67
67
  end
68
68
  end
69
- end
69
+ end
@@ -8,7 +8,7 @@ module Dandelion
8
8
 
9
9
  adapter 'sftp'
10
10
  requires_gems 'net-sftp'
11
-
11
+
12
12
  def initialize(config)
13
13
  require 'net/sftp'
14
14
 
@@ -54,12 +54,12 @@ module Dandelion
54
54
  raise unless e.code == 2
55
55
  end
56
56
  end
57
-
57
+
58
58
  def to_s
59
59
  "sftp://#{@config['username']}@#{@config['host']}/#{@config['path']}"
60
60
  end
61
61
 
62
- private
62
+ private
63
63
 
64
64
  def sftp_client
65
65
  options = {
@@ -87,7 +87,7 @@ module Dandelion
87
87
  end
88
88
  end
89
89
  end
90
-
90
+
91
91
  def empty?(dir)
92
92
  @sftp.dir.entries(dir).delete_if do |file|
93
93
  file.name == '.' or file.name == '..'
@@ -103,7 +103,7 @@ module Dandelion
103
103
  @sftp.mkdir!(dir)
104
104
  end
105
105
  end
106
-
106
+
107
107
  def path(file)
108
108
  if @config['path'] and !@config['path'].empty?
109
109
  File.join(@config['path'], file)
@@ -113,4 +113,4 @@ module Dandelion
113
113
  end
114
114
  end
115
115
  end
116
- end
116
+ end
@@ -39,7 +39,7 @@ module Dandelion
39
39
 
40
40
  def deploy_file!(local_path, remote_path)
41
41
  log.debug("Writing file: #{local_path} -> #{remote_path}")
42
- @adapter.write(remote_path, IO.read(local_path))
42
+ @adapter.write(remote_path, IO.binread(local_path))
43
43
  end
44
44
 
45
45
  def deploy_change!(change)
@@ -42,7 +42,7 @@ module Dandelion
42
42
  path = object.read_raw.data
43
43
 
44
44
  result = data(path)
45
- result ||= IO.read(path) # external link
45
+ result ||= IO.binread(path) # external link
46
46
  result
47
47
  end
48
48
  end
@@ -1,3 +1,3 @@
1
1
  module Dandelion
2
- VERSION = '0.4.6'
2
+ VERSION = '0.4.7'
3
3
  end
@@ -3,7 +3,7 @@ module Dandelion
3
3
 
4
4
  class Workspace
5
5
  attr_reader :adapter, :config
6
-
6
+
7
7
  def initialize(repo, adapter, config = nil)
8
8
  @repo = repo
9
9
  @adapter = adapter
@@ -60,17 +60,20 @@ module Dandelion
60
60
 
61
61
  def lookup_ref(val)
62
62
  ref = @repo.ref(val)
63
- lookup_sha(ref.target) if ref
63
+ lookup_sha(ref.target.oid) if ref
64
64
  rescue Rugged::ReferenceError
65
65
  nil
66
66
  end
67
67
 
68
68
  def local_sha
69
- @config[:revision] || @repo.head.target
69
+ @config[:revision] || @repo.head.target.oid
70
70
  end
71
71
 
72
72
  def remote_sha
73
- @remote_sha ||= @adapter.read(@config[:revision_file])
73
+ @remote_sha ||= begin
74
+ sha = @adapter.read(@config[:revision_file])
75
+ sha.chomp if sha
76
+ end
74
77
  end
75
78
 
76
79
  def remote_sha=(sha)
@@ -78,4 +81,4 @@ module Dandelion
78
81
  @remote_sha = sha
79
82
  end
80
83
  end
81
- end
84
+ end
@@ -33,10 +33,10 @@ describe Dandelion::Deployer do
33
33
 
34
34
  describe '#deploy_files!' do
35
35
  before(:each) do
36
- IO.stub(:read).with('a.txt').and_return('A')
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')
36
+ IO.stub(:binread).with('a.txt').and_return('A')
37
+ IO.stub(:binread).with('b.txt').and_return('B')
38
+ IO.stub(:binread).with('c/a.txt').and_return('cA')
39
+ IO.stub(:binread).with('c/b.txt').and_return('cB')
40
40
  end
41
41
 
42
42
  context 'local paths' do
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dandelion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
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-05-15 00:00:00.000000000 Z
11
+ date: 2014-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rugged
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.19.0
19
+ version: 0.21.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.19.0
26
+ version: 0.21.2
27
27
  description:
28
28
  email:
29
29
  - scott@scttnlsn.com
@@ -32,9 +32,9 @@ executables:
32
32
  extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
- - .gitignore
36
- - .rspec
37
- - .travis.yml
35
+ - ".gitignore"
36
+ - ".rspec"
37
+ - ".travis.yml"
38
38
  - Gemfile
39
39
  - LICENSE
40
40
  - README.md
@@ -44,6 +44,7 @@ files:
44
44
  - lib/dandelion.rb
45
45
  - lib/dandelion/adapter.rb
46
46
  - lib/dandelion/adapter/ftp.rb
47
+ - lib/dandelion/adapter/ftps.rb
47
48
  - lib/dandelion/adapter/noop.rb
48
49
  - lib/dandelion/adapter/s3.rb
49
50
  - lib/dandelion/adapter/sftp.rb
@@ -151,17 +152,17 @@ require_paths:
151
152
  - lib
152
153
  required_ruby_version: !ruby/object:Gem::Requirement
153
154
  requirements:
154
- - - '>='
155
+ - - ">="
155
156
  - !ruby/object:Gem::Version
156
157
  version: '0'
157
158
  required_rubygems_version: !ruby/object:Gem::Requirement
158
159
  requirements:
159
- - - '>='
160
+ - - ">="
160
161
  - !ruby/object:Gem::Version
161
162
  version: '0'
162
163
  requirements: []
163
164
  rubyforge_project:
164
- rubygems_version: 2.0.14
165
+ rubygems_version: 2.2.2
165
166
  signing_key:
166
167
  specification_version: 4
167
168
  summary: Incremental Git repository deployment