dropbox-deployment 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/dropbox-deployment +6 -0
- data/lib/dropbox-deployment.rb +58 -51
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e41aedfe5255834c8b8b15780e29f99017d66525
|
4
|
+
data.tar.gz: 724af439d693400a57f5b820d50ab0e8f86ebd61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a14ff7c7fe07a62f98b72a531116513d7bee5a68a8961c0f32cdecaed4078bc9f31dea5dab3d7e9e4e9ac06dbd1612b228133ff38822fe4b7c56807c71d070a3
|
7
|
+
data.tar.gz: ca82e697e8632ddc817505d692535deb2a4991004bf3ce053cd74be3039c27ffd874d81de580e42ab44955b7881755bb28900b7ecfdbe2f23cbd2cc4c15cc0ca
|
data/lib/dropbox-deployment.rb
CHANGED
@@ -1,65 +1,72 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
1
|
require 'dropbox_api'
|
3
2
|
require 'yaml'
|
4
3
|
require 'logger'
|
5
4
|
require 'find'
|
6
5
|
|
7
|
-
|
8
|
-
|
6
|
+
module DropboxDeployment
|
7
|
+
class Deployer
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
content = IO.read(file)
|
13
|
-
dropboxClient.upload dropboxPath + "/" + fileName, content
|
14
|
-
end
|
9
|
+
logger = Logger.new(STDOUT)
|
10
|
+
logger.level = Logger::WARN
|
15
11
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
if !File.directory?(file)
|
21
|
-
uploadFile(dropboxClient, file, dropboxPath)
|
12
|
+
def uploadFile(dropboxClient, file, dropboxPath)
|
13
|
+
fileName = File.basename(file)
|
14
|
+
content = IO.read(file)
|
15
|
+
dropboxClient.upload dropboxPath + "/" + fileName, content
|
22
16
|
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
# Validation
|
26
|
-
config = YAML.load_file("upload-to-dropbox.yml")
|
27
|
-
testing = false
|
28
|
-
if !config["deploy"]
|
29
|
-
puts "\nError in config file! Build file must contain a `deploy` object.\n\n"
|
30
|
-
exit(1)
|
31
|
-
end
|
32
|
-
artifactPath = config["deploy"]["artifacts_path"]
|
33
|
-
dropboxPath = config["deploy"]["dropbox_path"]
|
34
17
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
18
|
+
def uploadDirectory(dropboxClient, directoryPath, dropboxPath)
|
19
|
+
Find.find(directoryPath) do |file|
|
20
|
+
# TODO need to have the path of the parent as part of the dropbox path
|
21
|
+
# so that we keep the hierarchy we want
|
22
|
+
if !File.directory?(file)
|
23
|
+
uploadFile(dropboxClient, file, dropboxPath)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
41
27
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
28
|
+
def deploy()
|
29
|
+
# Validation
|
30
|
+
config = YAML.load_file("upload-to-dropbox.yml")
|
31
|
+
testing = false
|
32
|
+
if !config["deploy"]
|
33
|
+
puts "\nError in config file! Build file must contain a `deploy` object.\n\n"
|
34
|
+
exit(1)
|
35
|
+
end
|
36
|
+
artifactPath = config["deploy"]["artifacts_path"]
|
37
|
+
dropboxPath = config["deploy"]["dropbox_path"]
|
46
38
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
39
|
+
# Just for testing, load the local oauth token from the file
|
40
|
+
if File.file?("testconfig")
|
41
|
+
oauth = IO.read "testconfig"
|
42
|
+
ENV["DROPBOX_OAUTH_BEARER"] = oauth
|
43
|
+
testing = true
|
44
|
+
end
|
45
|
+
|
46
|
+
if ENV["DROPBOX_OAUTH_BEARER"].nil?
|
47
|
+
puts "\nYou must have an environment variable of `DROPBOX_OAUTH_BEARER` in order to deploy to Dropbox\n\n"
|
48
|
+
exit(1)
|
49
|
+
end
|
51
50
|
|
52
|
-
|
51
|
+
if config["deploy"]["debug"]
|
52
|
+
logger.level = Logger::DEBUG
|
53
|
+
logger.debug("We are in debug mode")
|
54
|
+
end
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
logger.debug("
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
56
|
+
dropboxClient = DropboxApi::Client.new
|
57
|
+
|
58
|
+
# Upload all files
|
59
|
+
logger.debug("Artifact Path: " + artifactPath)
|
60
|
+
logger.debug("Dropbox Path: " + dropboxPath)
|
61
|
+
isDirectory = File.directory?(artifactPath)
|
62
|
+
logger.debug("Is directory: " + "#{isDirectory}")
|
63
|
+
if isDirectory
|
64
|
+
uploadDirectory(dropboxClient, artifactPath, dropboxPath)
|
65
|
+
else
|
66
|
+
artifactFile = File.open(artifactPath)
|
67
|
+
uploadFile(dropboxClient, artifactFile, dropboxPath)
|
68
|
+
end
|
69
|
+
logger.debug("Uploading complete")
|
70
|
+
end
|
71
|
+
end
|
64
72
|
end
|
65
|
-
logger.debug("Uploading complete")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dropbox-deployment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Carlson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dropbox_api
|
@@ -27,10 +27,12 @@ dependencies:
|
|
27
27
|
description:
|
28
28
|
email:
|
29
29
|
- jawnnypoo@gmail.com
|
30
|
-
executables:
|
30
|
+
executables:
|
31
|
+
- dropbox-deployment
|
31
32
|
extensions: []
|
32
33
|
extra_rdoc_files: []
|
33
34
|
files:
|
35
|
+
- bin/dropbox-deployment
|
34
36
|
- lib/dropbox-deployment.rb
|
35
37
|
homepage: https://github.com/Jawnnypoo/dropbox-deployment
|
36
38
|
licenses:
|