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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ef874c2394fd9704241353d1357ee07937e61af
4
- data.tar.gz: 491e92a1f8d099131b9b2e697b9714678c5587ba
3
+ metadata.gz: e41aedfe5255834c8b8b15780e29f99017d66525
4
+ data.tar.gz: 724af439d693400a57f5b820d50ab0e8f86ebd61
5
5
  SHA512:
6
- metadata.gz: 478bc08b00a7fab82fa3b4459e9adbd1fd5023f92a80d1254c3876f373c3b9f1643a1c5476c12dc26b72844ae1091e3262441e735ccdc25a7fd0e63222bce4a6
7
- data.tar.gz: 928b667885284cddd132e0ae42d4b97f40f5677d1a7e85d0f2a9dd14cf75b31241dab7a58b4a54f8a83eeebbb3ecdf3d68ebcc727e3e11e0f3a20a99d96c5f3c
6
+ metadata.gz: a14ff7c7fe07a62f98b72a531116513d7bee5a68a8961c0f32cdecaed4078bc9f31dea5dab3d7e9e4e9ac06dbd1612b228133ff38822fe4b7c56807c71d070a3
7
+ data.tar.gz: ca82e697e8632ddc817505d692535deb2a4991004bf3ce053cd74be3039c27ffd874d81de580e42ab44955b7881755bb28900b7ecfdbe2f23cbd2cc4c15cc0ca
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'dropbox-deployment'
4
+
5
+ deployer = DropboxDeployment::Deployer.new
6
+ deployer.deploy
@@ -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
- logger = Logger.new(STDOUT)
8
- logger.level = Logger::WARN
6
+ module DropboxDeployment
7
+ class Deployer
9
8
 
10
- def uploadFile(dropboxClient, file, dropboxPath)
11
- fileName = File.basename(file)
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 uploadDirectory(dropboxClient, directoryPath, dropboxPath)
17
- Find.find(directoryPath) do |file|
18
- # TODO need to have the path of the parent as part of the dropbox path
19
- # so that we keep the hierarchy we want
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
- # Just for testing, load the local oauth token from the file
36
- if File.file?("testconfig")
37
- oauth = IO.read "testconfig"
38
- ENV["DROPBOX_OAUTH_BEARER"] = oauth
39
- testing = true
40
- end
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
- if ENV["DROPBOX_OAUTH_BEARER"].nil?
43
- puts "\nYou must have an environment variable of `DROPBOX_OAUTH_BEARER` in order to deploy to Dropbox\n\n"
44
- exit(1)
45
- end
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
- if config["deploy"]["debug"]
48
- logger.level = Logger::DEBUG
49
- logger.debug("We are in debug mode")
50
- end
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
- dropboxClient = DropboxApi::Client.new
51
+ if config["deploy"]["debug"]
52
+ logger.level = Logger::DEBUG
53
+ logger.debug("We are in debug mode")
54
+ end
53
55
 
54
- # Upload all files
55
- logger.debug("Artifact Path: " + artifactPath)
56
- logger.debug("Dropbox Path: " + dropboxPath)
57
- isDirectory = File.directory?(artifactPath)
58
- logger.debug("Is directory: " + "#{isDirectory}")
59
- if isDirectory
60
- uploadDirectory(dropboxClient, artifactPath, dropboxPath)
61
- else
62
- artifactFile = File.open(artifactPath)
63
- uploadFile(dropboxClient, artifactFile, dropboxPath)
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.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-19 00:00:00.000000000 Z
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: