jekyll-to-s3 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/jekyll-to-s3.rb +79 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bd20728ed1b1dc3573f5c9d004485ff74f6a4dcc
|
4
|
+
data.tar.gz: 2ff12332d354b2908809167c3b92eef79d04e43d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c960e31bfd789cb47c545719f94d75919ab948480e2de4adfaf0474a5f4d55b6186f5b0caf4650b75af2b19819cd09f01b899eb375a8a8142f5b0942d1e5547d
|
7
|
+
data.tar.gz: cf01110fb1d3d47640714bfc64a90e36616cb1efc03925f7912a704e22d26355677f9a7a5566c384f945badb40a823470fdbd53d679ffc46205399f2e6ac890f
|
data/lib/jekyll-to-s3.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
module Jekyll::ToS3
|
2
|
+
|
3
|
+
class Deploy
|
4
|
+
|
5
|
+
EXTENSIONS = {
|
6
|
+
'.css' => 'text/css',
|
7
|
+
'.gif' => 'image/gif',
|
8
|
+
'.html' => 'text/html',
|
9
|
+
'.ico' => 'image/x-icon',
|
10
|
+
'.jpg' => 'image/jpeg',
|
11
|
+
'.js' => 'application/javascript',
|
12
|
+
'.pdf' => 'application/pdf',
|
13
|
+
'.png' => 'image/png',
|
14
|
+
'.ttf' => 'application/x-font-ttf',
|
15
|
+
'.woff' => 'application/font-woff',
|
16
|
+
'.xml' => 'application/atom+xml',
|
17
|
+
}
|
18
|
+
|
19
|
+
def initialize(region:, access_key_id:, secret_access_key:, bucket:)
|
20
|
+
credentials = Aws::Credentials.new(
|
21
|
+
access_key_id,
|
22
|
+
secret_access_key
|
23
|
+
)
|
24
|
+
|
25
|
+
Aws.config.update(
|
26
|
+
region: region,
|
27
|
+
credentials: credentials
|
28
|
+
)
|
29
|
+
|
30
|
+
@bucket = Aws::S3::Resource.new.bucket(bucket)
|
31
|
+
@root_path = "_site"
|
32
|
+
end
|
33
|
+
|
34
|
+
attr_reader :bucket, :root_path
|
35
|
+
|
36
|
+
def deploy
|
37
|
+
upload_directory(root_path)
|
38
|
+
cleanup_bucket
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def upload_directory(path)
|
44
|
+
Dir["#{path}/*"].each do |file|
|
45
|
+
if File.directory?(file)
|
46
|
+
upload_directory(file)
|
47
|
+
elsif EXTENSIONS.keys.include?(File.extname(file).downcase)
|
48
|
+
key = file.split("#{root_path}/").last
|
49
|
+
puts "Uploading #{key}"
|
50
|
+
upload_file(Pathname.new(file), key)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def upload_file(path, key)
|
56
|
+
object = bucket.object(key)
|
57
|
+
|
58
|
+
File.open(path, 'rb') do |file|
|
59
|
+
object.put(
|
60
|
+
body: file,
|
61
|
+
acl: 'public-read',
|
62
|
+
content_type: EXTENSIONS[File.extname(path)]
|
63
|
+
)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def cleanup_bucket
|
68
|
+
bucket.objects.each do |object|
|
69
|
+
unless File.exists?("#{root_path}/#{object.key}")
|
70
|
+
puts "Removing #{object.key}"
|
71
|
+
|
72
|
+
object.delete
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-to-s3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aurélien Malisart
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-02-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
- jekyll-to-s3@aurels.be
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/jekyll-to-s3.rb
|
21
|
+
homepage: https://github.com/aurels/jekyll-to-s3
|
22
|
+
licenses:
|
23
|
+
- MIT
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.5.2.3
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Deploys a Jekyll build to S3.
|
45
|
+
test_files: []
|