jekyll-deploy-spaces 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +109 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/jekyll-deploy-spaces.gemspec +27 -0
- data/lib/jekyll/commands/deploy.rb +70 -0
- data/lib/jekyll/deploy/spaces.rb +12 -0
- data/lib/jekyll/deploy/spaces/config.rb +17 -0
- data/lib/jekyll/deploy/spaces/syncer.rb +122 -0
- data/lib/jekyll/deploy/spaces/version.rb +7 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9ec73497e133f568ffd8c47f4a3cca2b323b516ffeccf426aff1603cb5f664cd
|
4
|
+
data.tar.gz: '0320509def37d1477e4e573ef3be7e1dfe396046cd8cb10b92f59aa58dbb210e'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7d5aa2fe0c081d9eb38fae177e42302e79a454354b9dbb86b6fa847933c9c2ae4967ff7d6777bc04f42f7717457a2b82b576300f21ce3a29ee78370c4ce6468a
|
7
|
+
data.tar.gz: 663c76968c6da91d9820748d1b99c9f7516577d37cba426cfb9939a82a34b478d3db049565905314a09466cfa542400404c6ab9bba7469aacc76060168dcadf6
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.0
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at nan@notanumber.io. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jekyll-deploy-spaces (0.1.0)
|
5
|
+
aws-sdk-s3 (~> 1.23.1)
|
6
|
+
jekyll (~> 3.8.4)
|
7
|
+
mimemagic (~> 0.3.2)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.5.2)
|
13
|
+
public_suffix (>= 2.0.2, < 4.0)
|
14
|
+
aws-eventstream (1.0.1)
|
15
|
+
aws-partitions (1.107.0)
|
16
|
+
aws-sdk-core (3.36.0)
|
17
|
+
aws-eventstream (~> 1.0)
|
18
|
+
aws-partitions (~> 1.0)
|
19
|
+
aws-sigv4 (~> 1.0)
|
20
|
+
jmespath (~> 1.0)
|
21
|
+
aws-sdk-kms (1.11.0)
|
22
|
+
aws-sdk-core (~> 3, >= 3.26.0)
|
23
|
+
aws-sigv4 (~> 1.0)
|
24
|
+
aws-sdk-s3 (1.23.1)
|
25
|
+
aws-sdk-core (~> 3, >= 3.26.0)
|
26
|
+
aws-sdk-kms (~> 1)
|
27
|
+
aws-sigv4 (~> 1.0)
|
28
|
+
aws-sigv4 (1.0.3)
|
29
|
+
colorator (1.1.0)
|
30
|
+
concurrent-ruby (1.0.5)
|
31
|
+
diff-lcs (1.3)
|
32
|
+
em-websocket (0.5.1)
|
33
|
+
eventmachine (>= 0.12.9)
|
34
|
+
http_parser.rb (~> 0.6.0)
|
35
|
+
eventmachine (1.2.7)
|
36
|
+
ffi (1.9.25)
|
37
|
+
forwardable-extended (2.6.0)
|
38
|
+
http_parser.rb (0.6.0)
|
39
|
+
i18n (0.9.5)
|
40
|
+
concurrent-ruby (~> 1.0)
|
41
|
+
jekyll (3.8.4)
|
42
|
+
addressable (~> 2.4)
|
43
|
+
colorator (~> 1.0)
|
44
|
+
em-websocket (~> 0.5)
|
45
|
+
i18n (~> 0.7)
|
46
|
+
jekyll-sass-converter (~> 1.0)
|
47
|
+
jekyll-watch (~> 2.0)
|
48
|
+
kramdown (~> 1.14)
|
49
|
+
liquid (~> 4.0)
|
50
|
+
mercenary (~> 0.3.3)
|
51
|
+
pathutil (~> 0.9)
|
52
|
+
rouge (>= 1.7, < 4)
|
53
|
+
safe_yaml (~> 1.0)
|
54
|
+
jekyll-sass-converter (1.5.2)
|
55
|
+
sass (~> 3.4)
|
56
|
+
jekyll-watch (2.1.2)
|
57
|
+
listen (~> 3.0)
|
58
|
+
jmespath (1.4.0)
|
59
|
+
kramdown (1.17.0)
|
60
|
+
liquid (4.0.1)
|
61
|
+
listen (3.1.5)
|
62
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
63
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
64
|
+
ruby_dep (~> 1.2)
|
65
|
+
mercenary (0.3.6)
|
66
|
+
mimemagic (0.3.2)
|
67
|
+
pathutil (0.16.2)
|
68
|
+
forwardable-extended (~> 2.6)
|
69
|
+
public_suffix (3.0.3)
|
70
|
+
rake (12.3.1)
|
71
|
+
rb-fsevent (0.10.3)
|
72
|
+
rb-inotify (0.9.10)
|
73
|
+
ffi (>= 0.5.0, < 2)
|
74
|
+
rouge (3.3.0)
|
75
|
+
rspec (3.8.0)
|
76
|
+
rspec-core (~> 3.8.0)
|
77
|
+
rspec-expectations (~> 3.8.0)
|
78
|
+
rspec-mocks (~> 3.8.0)
|
79
|
+
rspec-core (3.8.0)
|
80
|
+
rspec-support (~> 3.8.0)
|
81
|
+
rspec-expectations (3.8.2)
|
82
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
83
|
+
rspec-support (~> 3.8.0)
|
84
|
+
rspec-mocks (3.8.0)
|
85
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
86
|
+
rspec-support (~> 3.8.0)
|
87
|
+
rspec-support (3.8.0)
|
88
|
+
ruby_dep (1.5.0)
|
89
|
+
safe_yaml (1.0.4)
|
90
|
+
sass (3.6.0)
|
91
|
+
sass-listen (~> 4.0.0)
|
92
|
+
sass-listen (4.0.0)
|
93
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
94
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
95
|
+
|
96
|
+
PLATFORMS
|
97
|
+
ruby
|
98
|
+
|
99
|
+
DEPENDENCIES
|
100
|
+
bundler (~> 1.17)
|
101
|
+
jekyll-deploy-spaces!
|
102
|
+
rake (~> 12.0)
|
103
|
+
rspec (~> 3.8)
|
104
|
+
|
105
|
+
RUBY VERSION
|
106
|
+
ruby 2.5.1p57
|
107
|
+
|
108
|
+
BUNDLED WITH
|
109
|
+
1.17.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Nan Zhong
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Jekyll::Deploy::Spaces
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/jekyll/deploy/spaces`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'jekyll-deploy-spaces'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install jekyll-deploy-spaces
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/jekyll-deploy-spaces. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the Jekyll::Deploy::Spaces project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/jekyll-deploy-spaces/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "jekyll/deploy/spaces"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative 'lib/jekyll/deploy/spaces'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'jekyll-deploy-spaces'
|
5
|
+
spec.version = Jekyll::Deploy::Spaces::VERSION
|
6
|
+
spec.authors = ['Nan Zhong']
|
7
|
+
spec.email = ['nan@notanumber.io']
|
8
|
+
|
9
|
+
spec.summary = %q{Deploy a jekyll static site to DigitalOcean Spaces.}
|
10
|
+
spec.homepage = 'https://github.com/nanzhong/jekyll-deploy-spaces'
|
11
|
+
spec.license = 'MIT'
|
12
|
+
|
13
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
14
|
+
f.match(%r{^(test|spec|features)}i)
|
15
|
+
end
|
16
|
+
spec.bindir = 'exe'
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_dependency 'jekyll', '~> 3.8.4'
|
21
|
+
spec.add_dependency 'aws-sdk-s3', '~> 1.23.1'
|
22
|
+
spec.add_dependency 'mimemagic', '~> 0.3.2'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.17'
|
25
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.8'
|
27
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'jekyll'
|
3
|
+
|
4
|
+
module Jekyll
|
5
|
+
module Commands
|
6
|
+
class Deploy < Command
|
7
|
+
class << self
|
8
|
+
def init_with_program(prog)
|
9
|
+
prog.command(:deploy) do |c|
|
10
|
+
c.syntax 'build [options] TARGET'
|
11
|
+
c.description 'Deploy to DigitalOcean Spaces'
|
12
|
+
|
13
|
+
c.option 'deploy_config', '--deploy_config', 'Deploy configuration file'
|
14
|
+
c.option 'destination', '-d', '--destination DESTINATION', 'The directory where the site is built'
|
15
|
+
c.option 'quiet', '-q', '--quiet', 'Silence output.'
|
16
|
+
c.option 'verbose', '-V', '--verbose', 'Print verbose output.'
|
17
|
+
|
18
|
+
c.action do |args, options|
|
19
|
+
self.apply_default_options(options)
|
20
|
+
self.process(args, options)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def apply_default_options(options)
|
26
|
+
options['deploy_config'] ||= '.deploy.yml'
|
27
|
+
end
|
28
|
+
|
29
|
+
def process(args, options)
|
30
|
+
raise 'Must specify the TARGET to deploy to!' if args.length < 1
|
31
|
+
deploy_target = args.first
|
32
|
+
|
33
|
+
config = configuration_from_options(options)
|
34
|
+
|
35
|
+
Jekyll.logger.debug 'Parsing deploy config...'
|
36
|
+
deploy_config = "#{config['source']}/#{options['deploy_config']}"
|
37
|
+
raise "Could not read deploy config, #{deploy_config} does not exist!" unless File.exists?(deploy_config)
|
38
|
+
deploy_config = YAML.load_file(deploy_config)
|
39
|
+
raise "#{deploy_target} is not configured for deployment" if deploy_config[deploy_target].nil?
|
40
|
+
deploy_config = deploy_config[deploy_target]
|
41
|
+
|
42
|
+
spaces_config = Jekyll::Deploy::Spaces::Config.new(
|
43
|
+
space: deploy_config['space'],
|
44
|
+
key: deploy_config['key'],
|
45
|
+
secret: deploy_config['secret'],
|
46
|
+
endpoint: deploy_config['endpoint'],
|
47
|
+
region: deploy_config['region']
|
48
|
+
)
|
49
|
+
|
50
|
+
syncer = Jekyll::Deploy::Spaces::Syncer.new(config['destination'], spaces_config)
|
51
|
+
|
52
|
+
Jekyll.logger.info "Starting deploy to #{deploy_target}..."
|
53
|
+
|
54
|
+
syncer.sync do |action|
|
55
|
+
case action[:action]
|
56
|
+
when :unchanged
|
57
|
+
Jekyll.logger.info "[SAME] #{action[:file]}: skipped"
|
58
|
+
when :upload
|
59
|
+
Jekyll.logger.info "[NEW] #{action[:file]}: uploaded"
|
60
|
+
when :delete
|
61
|
+
Jekyll.logger.info "[GONE] #{action[:file]}: deleted"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
Jekyll.logger.info "Finished deploy to #{deploy_target}!"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module Deploy
|
3
|
+
module Spaces
|
4
|
+
class Config
|
5
|
+
attr_reader :space, :key, :secret, :endpoint, :region
|
6
|
+
|
7
|
+
def initialize(space:, key:, secret:, endpoint: 'https://nyc3.digitaloceanspaces.com', region: 'nyc3')
|
8
|
+
@space = space
|
9
|
+
@key = key
|
10
|
+
@secret = secret
|
11
|
+
@endpoint = endpoint
|
12
|
+
@region = region
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'find'
|
2
|
+
require 'thread'
|
3
|
+
require 'aws-sdk-s3'
|
4
|
+
require 'mimemagic'
|
5
|
+
|
6
|
+
module Jekyll
|
7
|
+
module Deploy
|
8
|
+
module Spaces
|
9
|
+
UnreadableFileError = Class.new(RuntimeError)
|
10
|
+
|
11
|
+
class Syncer
|
12
|
+
def initialize(local_path, spaces_config)
|
13
|
+
@local_path = local_path
|
14
|
+
@remote_space = spaces_config.space
|
15
|
+
@client = Aws::S3::Client.new(
|
16
|
+
region: spaces_config.region,
|
17
|
+
endpoint: spaces_config.endpoint,
|
18
|
+
credentials: Aws::Credentials.new(spaces_config.key, spaces_config.secret)
|
19
|
+
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def sync(num_threads: 5)
|
24
|
+
local_files = find_local_files
|
25
|
+
remote_files = find_remote_files
|
26
|
+
|
27
|
+
actions = Queue.new
|
28
|
+
|
29
|
+
local_files.each do |local_file, local_data|
|
30
|
+
remote_data = remote_files[local_file]
|
31
|
+
|
32
|
+
actions << if remote_data.nil? ||
|
33
|
+
!remote_data[:mtime].eql?(local_data[:mtime]) ||
|
34
|
+
remote_data[:size] != local_data[:size]
|
35
|
+
{ file: local_file, action: :upload }
|
36
|
+
else
|
37
|
+
{ file: local_file, action: :unchanged }
|
38
|
+
end
|
39
|
+
|
40
|
+
remote_files.delete(local_file)
|
41
|
+
end
|
42
|
+
|
43
|
+
remote_files.each do |remote_file, _|
|
44
|
+
actions << { file: remote_file, action: :delete }
|
45
|
+
end
|
46
|
+
|
47
|
+
threads = []
|
48
|
+
mutex = Mutex.new
|
49
|
+
num_threads.times do
|
50
|
+
threads << Thread.new do
|
51
|
+
until actions.empty?
|
52
|
+
action = actions.pop
|
53
|
+
|
54
|
+
case action[:action]
|
55
|
+
when :upload
|
56
|
+
local_file_path = "#{@local_path}/#{action[:file]}"
|
57
|
+
@client.put_object(
|
58
|
+
acl: 'public-read',
|
59
|
+
body: File.open(local_file_path),
|
60
|
+
bucket: @remote_space,
|
61
|
+
key: action[:file],
|
62
|
+
content_type: MimeMagic.by_path(local_file_path).type
|
63
|
+
)
|
64
|
+
mtime = @client.get_object(
|
65
|
+
bucket: @remote_space,
|
66
|
+
key: action[:file]
|
67
|
+
).last_modified.utc
|
68
|
+
FileUtils.touch "#{@local_path}/#{action[:file]}", mtime: mtime
|
69
|
+
when :delete
|
70
|
+
@client.delete_object(
|
71
|
+
bucket: @remote_space,
|
72
|
+
key: action[:file]
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
mutex.synchronize do
|
77
|
+
yield action
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
threads.each { |t| t.join }
|
83
|
+
end
|
84
|
+
|
85
|
+
def find_local_files
|
86
|
+
local_files = {}
|
87
|
+
|
88
|
+
Find.find(@local_path).each do |path|
|
89
|
+
st = File.stat path
|
90
|
+
raise UnreadableFileError.new(path) unless st.readable?
|
91
|
+
|
92
|
+
next unless st.file?
|
93
|
+
|
94
|
+
file = path.gsub(/^#{@local_path}\/?/, '').squeeze('/')
|
95
|
+
|
96
|
+
local_files[file] = {
|
97
|
+
size: st.size,
|
98
|
+
mtime: st.mtime.utc
|
99
|
+
}
|
100
|
+
end
|
101
|
+
|
102
|
+
local_files
|
103
|
+
end
|
104
|
+
|
105
|
+
def find_remote_files
|
106
|
+
remote_files = {}
|
107
|
+
|
108
|
+
@client.list_objects(bucket: @remote_space).each do |resp|
|
109
|
+
resp.contents.each do |file|
|
110
|
+
remote_files[file.key] = {
|
111
|
+
size: file.size,
|
112
|
+
mtime: file.last_modified.utc
|
113
|
+
}
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
remote_files
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-deploy-spaces
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nan Zhong
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-11-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.8.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.8.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: aws-sdk-s3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.23.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.23.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mimemagic
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.3.2
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.3.2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.17'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.17'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '12.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '12.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.8'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.8'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- nan@notanumber.io
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- ".ruby-version"
|
107
|
+
- ".travis.yml"
|
108
|
+
- CODE_OF_CONDUCT.md
|
109
|
+
- Gemfile
|
110
|
+
- Gemfile.lock
|
111
|
+
- LICENSE.txt
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- bin/console
|
115
|
+
- bin/setup
|
116
|
+
- jekyll-deploy-spaces.gemspec
|
117
|
+
- lib/jekyll/commands/deploy.rb
|
118
|
+
- lib/jekyll/deploy/spaces.rb
|
119
|
+
- lib/jekyll/deploy/spaces/config.rb
|
120
|
+
- lib/jekyll/deploy/spaces/syncer.rb
|
121
|
+
- lib/jekyll/deploy/spaces/version.rb
|
122
|
+
homepage: https://github.com/nanzhong/jekyll-deploy-spaces
|
123
|
+
licenses:
|
124
|
+
- MIT
|
125
|
+
metadata: {}
|
126
|
+
post_install_message:
|
127
|
+
rdoc_options: []
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
requirements: []
|
141
|
+
rubyforge_project:
|
142
|
+
rubygems_version: 2.7.6
|
143
|
+
signing_key:
|
144
|
+
specification_version: 4
|
145
|
+
summary: Deploy a jekyll static site to DigitalOcean Spaces.
|
146
|
+
test_files: []
|