jekyll-publish 0.0.1 → 0.0.3

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jekyll-publish.rb +38 -11
  3. metadata +16 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c43d3a18af50c6f1ce1c9dc705bb9b51d729b002
4
- data.tar.gz: d5261c563aa3883f6887755a4783a78b66040b17
3
+ metadata.gz: d11770d3fd4c0dabbcca06a46302f7ef49ff588c
4
+ data.tar.gz: ec2c57be1228f1276fd8b1d6c29985447ea51956
5
5
  SHA512:
6
- metadata.gz: 86e8271e783d9134e83b7e3a9d285d1c61e36a25038479f844f81de5f9ff6b3e3ca1910f30df5ff3bcc1e5b117526e853f44abb6103f602c7b5574f12605b9ed
7
- data.tar.gz: b1da91572fc5d46a097a4bb92dd395d0b20108d62e1282730513444d4668c80bc0b6f75000a5eb65211f8ecf9651bc595d35c0b02d0d431adbe4103cd40658fd
6
+ metadata.gz: deec7400657525fb43aada741874120fa5a45b30404602b1771a1bff7c8a5a1edcf83cabf1597896041df3c45b02de9bd329b890c96320800c7d58062ed173dd
7
+ data.tar.gz: ffed4d4b4c1c835a6f1f30220c2a6a62066dea8f0ed2f487f9d569caf2f697b443117630df5131d2e7456944db36db92ead6cb66d32dcbfcea13e1e6a9bc597a
@@ -1,6 +1,38 @@
1
1
  require 'aws-sdk'
2
2
  class Publish < Jekyll::Command
3
3
  class << self
4
+
5
+ def set_aws_region(options)
6
+ if options['region'].to_s != ''
7
+ return options['region']
8
+ elsif Jekyll.configuration({})['aws_region'].to_s != ''
9
+ return Jekyll.configuration({})['aws_region']
10
+ else
11
+ raise "No region defined - use -r AWS_REGION or set aws_region: AWS_REGION in _config.yml"
12
+ end
13
+ end
14
+
15
+ def set_bucket_name(options)
16
+ if options['bucket_name'].to_s != ''
17
+ bucket_name = options['bucket_name']
18
+ elsif Jekyll.configuration({})['bucket_name'].to_s != ''
19
+ bucket_name = Jekyll.configuration({})['bucket_name']
20
+ else
21
+ raise "No bucket_name defined - use -b BUCKET_NAME or set bucket_name: BUCKET_NAME in _config.yml"
22
+ end
23
+ end
24
+
25
+ def upload_to_s3(region, bucket_name)
26
+ Dir.chdir("./_site")
27
+ s3 = Aws::S3::Resource.new(region: region)
28
+ Dir['./**/*.{html,css,js,xml}'].each do |file|
29
+ key = file[2..-1]
30
+ puts "Uploading -> #{key}"
31
+ obj = s3.bucket(bucket_name).object(key)
32
+ obj.upload_file(File.absolute_path(file))
33
+ end
34
+ end
35
+
4
36
  def init_with_program(prog)
5
37
  prog.command(:publish) do |c|
6
38
  c.syntax "publish [options]"
@@ -10,17 +42,12 @@ class Publish < Jekyll::Command
10
42
  c.option 'bucket_name', '-b BUCKET_NAME', 'Region with the S3 Bucket.'
11
43
 
12
44
  c.action do |args, options|
13
- puts "hello"
14
- Dir.chdir("./_site")
15
- puts Dir.pwd
16
- #Jekyll::Site.new_site_at(options['dest'])
17
- s3 = Aws::S3::Resource.new(region: options['region'])
18
- Dir['./**/*.(?:html|css|js|xml)'].each do |file|
19
- key = file[2..-1]
20
- puts key
21
- obj = s3.bucket(options['bucket_name']).object(key)
22
- obj.upload_file(File.absolute_path(file))
23
- end
45
+ region = set_aws_region options
46
+ bucket_name = set_bucket_name options
47
+ puts "AWS Region: #{region}"
48
+ puts "AWS Bucket Name: #{bucket_name}"
49
+ upload_to_s3 region, bucket_name
50
+ puts "Done!"
24
51
  end
25
52
  end
26
53
  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.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Rankine
@@ -9,7 +9,21 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2016-03-29 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aws-sdk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.0
13
27
  description: Allows you to easily publish your static website to S3
14
28
  email: srdeveloper@icloud.com
15
29
  executables: []