dropbox-deployment 0.0.4 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 73b2fe55c7ac8b63490b72f9edad059392cce68d
4
- data.tar.gz: 2c7c5fcc20519dceab71e883e5e23dd7864e87c4
3
+ metadata.gz: 5fa6f4afecf0d6b17a9b7084128a8683609ae98d
4
+ data.tar.gz: 0b0396ae2791268c3cd3f5c58546e52df9080250
5
5
  SHA512:
6
- metadata.gz: 2747aaa4bd06a05afd1562dd3cfabfdf6e434766e6aa3594ba87903515bdb8f29d87d58f5643b19c92bc3c665727544b8d660d133d87e0e8922001fa3fdbabd8
7
- data.tar.gz: 0df1c98307f984e82a4966250bfa1db7ae389a6dd6d5e6ee95107b80c1577c0578d78536eee56e3d550cb59fc6fe5e3d00c88f740c3a2824ba71d6ac7484c0fe
6
+ metadata.gz: 9ced33980d89c1f6c3a05cfcc6032abe9663d569ddc1572f5ae7c2173b98632d26107f613b64f36c35bce30844797e244576147b02366412ca3aa5d922d608e6
7
+ data.tar.gz: 8f9a34afb6cf620c9662c0105e25a1a22a8ee14b4a4f9567afed5cac3d7758ede8c02e4e21f9517204541d2c6c960e42f9e64c2b97a527d8c7aff8227e8147e9
@@ -1,6 +1,6 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'dropbox-deployment'
4
-
5
- deployer = DropboxDeployment::Deployer.new
6
- deployer.deploy
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'dropbox-deployment'
4
+
5
+ deployer = DropboxDeployment::Deployer.new
6
+ deployer.deploy
@@ -1,73 +1,82 @@
1
- require 'dropbox_api'
2
- require 'yaml'
3
- require 'logger'
4
- require 'find'
5
- require 'dotenv'
6
- Dotenv.load
7
-
8
- module DropboxDeployment
9
- class Deployer
10
-
11
- def initialize
12
- @@logger = Logger.new(STDOUT)
13
- @@logger.level = Logger::WARN
14
- end
15
-
16
- def uploadFile(dropboxClient, file, dropboxPath)
17
- fileName = File.basename(file)
18
- content = IO.read(file)
19
- dropboxClient.upload dropboxPath + "/" + fileName, content, :mode => :overwrite
20
- end
21
-
22
- def uploadDirectory(dropboxClient, directoryPath, dropboxPath)
23
- Find.find(directoryPath) do |file|
24
- # TODO need to have the path of the parent as part of the dropbox path
25
- # so that we keep the hierarchy we want
26
- if !File.directory?(file)
27
- uploadFile(dropboxClient, file, dropboxPath)
28
- end
29
- end
30
- end
31
-
32
- def deploy()
33
- # Validation
34
- if !File.file?("dropbox-deployment.yml")
35
- puts "\nNo config file found. You need a file called `dropbox-deployment.yml` with the configuration. See the README for details\n\n"
36
- exit(1)
37
- end
38
- config = YAML.load_file("dropbox-deployment.yml")
39
- testing = false
40
- if !config.has_key?("deploy")
41
- puts "\nError in config file! Build file must contain a `deploy` object.\n\n"
42
- exit(1)
43
- end
44
- artifactPath = config["deploy"]["artifacts_path"]
45
- dropboxPath = config["deploy"]["dropbox_path"]
46
-
47
- if ENV["DROPBOX_OAUTH_BEARER"].nil?
48
- puts "\nYou must have an environment variable of `DROPBOX_OAUTH_BEARER` in order to deploy to Dropbox\n\n"
49
- exit(1)
50
- end
51
-
52
- if config["deploy"]["debug"]
53
- @@logger.level = Logger::DEBUG
54
- @@logger.debug("We are in debug mode")
55
- end
56
-
57
- dropboxClient = DropboxApi::Client.new
58
-
59
- # Upload all files
60
- @@logger.debug("Artifact Path: " + artifactPath)
61
- @@logger.debug("Dropbox Path: " + dropboxPath)
62
- isDirectory = File.directory?(artifactPath)
63
- @@logger.debug("Is directory: " + "#{isDirectory}")
64
- if isDirectory
65
- uploadDirectory(dropboxClient, artifactPath, dropboxPath)
66
- else
67
- artifactFile = File.open(artifactPath)
68
- uploadFile(dropboxClient, artifactFile, dropboxPath)
69
- end
70
- @@logger.debug("Uploading complete")
71
- end
72
- end
73
- end
1
+ require 'dropbox_api'
2
+ require 'yaml'
3
+ require 'logger'
4
+ require 'find'
5
+ require 'dotenv'
6
+ require 'pathname'
7
+ Dotenv.load
8
+
9
+ module DropboxDeployment
10
+ class Deployer
11
+
12
+ def initialize
13
+ @@logger = Logger.new(STDOUT)
14
+ @@logger.level = Logger::WARN
15
+ end
16
+
17
+ def uploadFile(dropboxClient, file, dropboxPath)
18
+ fileName = File.basename(file)
19
+ content = IO.read(file)
20
+ @@logger.debug("Uploading " + fileName + " to " + dropboxPath + "/" + fileName)
21
+ dropboxClient.upload dropboxPath + "/" + fileName, content, :mode => :overwrite
22
+ end
23
+
24
+ def uploadDirectory(dropboxClient, directoryPath, dropboxPath)
25
+ Find.find(directoryPath) do |file|
26
+
27
+ if !File.directory?(file)
28
+ currentFileDir = File.dirname(file)
29
+ if currentFileDir == directoryPath
30
+ modifedPath = dropboxPath
31
+ else
32
+ # adjust for if we are a subdirectory within the desired saved build folder
33
+ modifedPath = dropboxPath + "/" + Pathname.new(currentFileDir).relative_path_from(Pathname.new(directoryPath)).to_s
34
+ end
35
+
36
+ uploadFile(dropboxClient, file, modifedPath)
37
+ end
38
+ end
39
+ end
40
+
41
+ def deploy()
42
+ # Validation
43
+ if !File.file?("dropbox-deployment.yml")
44
+ puts "\nNo config file found. You need a file called `dropbox-deployment.yml` with the configuration. See the README for details\n\n"
45
+ exit(1)
46
+ end
47
+ config = YAML.load_file("dropbox-deployment.yml")
48
+ testing = false
49
+ if !config.has_key?("deploy")
50
+ puts "\nError in config file! Build file must contain a `deploy` object.\n\n"
51
+ exit(1)
52
+ end
53
+ artifactPath = config["deploy"]["artifacts_path"]
54
+ dropboxPath = config["deploy"]["dropbox_path"]
55
+
56
+ if ENV["DROPBOX_OAUTH_BEARER"].nil?
57
+ puts "\nYou must have an environment variable of `DROPBOX_OAUTH_BEARER` in order to deploy to Dropbox\n\n"
58
+ exit(1)
59
+ end
60
+
61
+ if config["deploy"]["debug"]
62
+ @@logger.level = Logger::DEBUG
63
+ @@logger.debug("We are in debug mode")
64
+ end
65
+
66
+ dropboxClient = DropboxApi::Client.new
67
+
68
+ # Upload all files
69
+ @@logger.debug("Artifact Path: " + artifactPath)
70
+ @@logger.debug("Dropbox Path: " + dropboxPath)
71
+ isDirectory = File.directory?(artifactPath)
72
+ @@logger.debug("Is directory: " + "#{isDirectory}")
73
+ if isDirectory
74
+ uploadDirectory(dropboxClient, artifactPath, dropboxPath)
75
+ else
76
+ artifactFile = File.open(artifactPath)
77
+ uploadFile(dropboxClient, artifactFile, dropboxPath)
78
+ end
79
+ @@logger.debug("Uploading complete")
80
+ end
81
+ end
82
+ end
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
4
+ version: 1.0.0
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-04-21 00:00:00.000000000 Z
11
+ date: 2017-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dropbox_api
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  version: '0'
76
76
  requirements: []
77
77
  rubyforge_project:
78
- rubygems_version: 2.6.8
78
+ rubygems_version: 2.6.11
79
79
  signing_key:
80
80
  specification_version: 4
81
81
  summary: Deploy your CI artifacts to Dropbox