jekyll-publish 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll-publish.rb +35 -22
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84853e6b379d82877ad54d958105da9e51fe30e2
|
4
|
+
data.tar.gz: 17f167187eaa0764977eae1ed239beeb2c4e5ea9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fd3fd2d8e152783f7f70fe10bf57548fe62f401a132b76b2baa29575dd763b26865638b1d9a9fb674f1b4db964eb18d59f7f3bf51a00c48e544a18ad12078b1
|
7
|
+
data.tar.gz: 6bb23720960f1b4432f290bd599de4498e68ae444ab48809f076d38dfff2fbcf4b9c309d46cc14e724b960e740cb84eb4756897f147dd3e18c6b3bb91beaf889
|
data/lib/jekyll-publish.rb
CHANGED
@@ -1,36 +1,49 @@
|
|
1
1
|
require 'aws-sdk'
|
2
2
|
class Publish < Jekyll::Command
|
3
3
|
class << self
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
return Jekyll.configuration({})['aws_region']
|
4
|
+
def get_aws_region()
|
5
|
+
if @config['aws_region'].to_s != ''
|
6
|
+
region = @config['aws_region']
|
7
|
+
Jekyll.logger.info "AWS Region:", region
|
8
|
+
return region
|
10
9
|
else
|
11
10
|
raise "No region defined - use -r AWS_REGION or set aws_region: AWS_REGION in _config.yml"
|
12
11
|
end
|
13
12
|
end
|
14
13
|
|
15
|
-
def
|
16
|
-
if
|
17
|
-
bucket_name =
|
18
|
-
|
19
|
-
|
14
|
+
def get_bucket_name()
|
15
|
+
if @config['bucket_name'].to_s != ''
|
16
|
+
bucket_name = @config['bucket_name']
|
17
|
+
Jekyll.logger.info "AWS Bucket Name:", bucket_name
|
18
|
+
return bucket_name
|
20
19
|
else
|
21
20
|
raise "No bucket_name defined - use -b BUCKET_NAME or set bucket_name: BUCKET_NAME in _config.yml"
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
25
|
-
def
|
24
|
+
def get_files()
|
26
25
|
Dir.chdir("./_site")
|
26
|
+
if @config['include_file_extensions'].to_s != ''
|
27
|
+
extensions = "html,css,js,xml,#{@config['include_file_extensions']}"
|
28
|
+
else
|
29
|
+
extensions = "html,css,js,xml"
|
30
|
+
end
|
31
|
+
Jekyll.logger.info "File Extensions:", extensions
|
32
|
+
file_regex = "./**/*.{#{extensions}}"
|
33
|
+
return Dir[file_regex]
|
34
|
+
end
|
35
|
+
|
36
|
+
def upload_to_s3(region, bucket_name, files)
|
27
37
|
s3 = Aws::S3::Resource.new(region: region)
|
28
|
-
|
38
|
+
Jekyll.logger.info "Uploading:"
|
39
|
+
files.each do |file|
|
29
40
|
key = file[2..-1]
|
30
|
-
puts "Uploading -> #{key}"
|
31
41
|
obj = s3.bucket(bucket_name).object(key)
|
32
42
|
obj.upload_file(File.absolute_path(file))
|
43
|
+
Jekyll.logger.info "", key
|
33
44
|
end
|
45
|
+
Jekyll.logger.info "Done!"
|
46
|
+
Jekyll.logger.info "Published to:", s3.bucket(bucket_name).url
|
34
47
|
end
|
35
48
|
|
36
49
|
def init_with_program(prog)
|
@@ -38,16 +51,16 @@ class Publish < Jekyll::Command
|
|
38
51
|
c.syntax "publish [options]"
|
39
52
|
c.description 'Publish Jekyll site to AWS S3.'
|
40
53
|
|
41
|
-
c.option '
|
42
|
-
c.option 'bucket_name', '-b BUCKET_NAME', '
|
54
|
+
c.option 'aws_region', '-r AWS_REGION', 'Region with the S3 Bucket.'
|
55
|
+
c.option 'bucket_name', '-b BUCKET_NAME', 'Name of the S3 Bucket'
|
56
|
+
c.option 'include_file_extensions', '-e FILE_EXTENSION', 'Additionally uploads files with specified extension'
|
43
57
|
|
44
58
|
c.action do |args, options|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
upload_to_s3 region, bucket_name
|
50
|
-
puts "Done!"
|
59
|
+
@config = configuration_from_options options
|
60
|
+
region = get_aws_region
|
61
|
+
bucket_name = get_bucket_name
|
62
|
+
files = get_files
|
63
|
+
upload_to_s3 region, bucket_name, files
|
51
64
|
end
|
52
65
|
end
|
53
66
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-publish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Rankine
|
@@ -31,7 +31,7 @@ extensions: []
|
|
31
31
|
extra_rdoc_files: []
|
32
32
|
files:
|
33
33
|
- lib/jekyll-publish.rb
|
34
|
-
homepage:
|
34
|
+
homepage: https://github.com/theseanything/jekyll-publish
|
35
35
|
licenses:
|
36
36
|
- MIT
|
37
37
|
metadata: {}
|