jekyll-s3 2.4.3 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +27 -1
- data/changelog.md +4 -0
- data/jekyll-s3.gemspec +1 -1
- data/lib/jekyll-s3/uploader.rb +18 -4
- data/spec/lib/uploader_spec.rb +11 -0
- metadata +9 -3
data/README.md
CHANGED
@@ -96,6 +96,15 @@ s3_endpoint: ap-northeast-1
|
|
96
96
|
The valid `s3_endpoint` values consist of the [S3 location constraint
|
97
97
|
values](http://docs.amazonwebservices.com/general/latest/gr/rande.html#s3_region).
|
98
98
|
|
99
|
+
### Ignoring files you want to keep on AWS
|
100
|
+
|
101
|
+
Sometimes there are files or directories you want to keep on S3, but not on
|
102
|
+
your local machine. You may define a regular expression to ignore files like so:
|
103
|
+
|
104
|
+
```yaml
|
105
|
+
ignore_on_server: that_folder_of_stuff_i_dont_keep_locally
|
106
|
+
```
|
107
|
+
|
99
108
|
### Reduced Redundancy
|
100
109
|
|
101
110
|
You can reduce the cost of hosting your blog on S3 by using Reduced Redundancy Storage:
|
@@ -125,16 +134,32 @@ bucket that are not on your local computer.
|
|
125
134
|
Enable the headless mode by adding the `--headless` or `-h` argument after
|
126
135
|
`jekyll-s3`.
|
127
136
|
|
128
|
-
|
137
|
+
### Using `jekyll-s3` as a library
|
129
138
|
|
130
139
|
By nature, `jekyll-s3` is a command-line interface tool. You can, however, use
|
131
140
|
it programmatically by calling the same API as the executable `jekyll-s3` does:
|
132
141
|
|
133
142
|
````ruby
|
143
|
+
require 'jekyll-s3'
|
134
144
|
is_headless = true
|
135
145
|
Jekyll::S3::CLI.new.run('/path/to/your/jekyll-site/_site/', is_headless)
|
136
146
|
````
|
137
147
|
|
148
|
+
You can also use a basic `Hash` instead of a `_jekyll_s3.yml` file:
|
149
|
+
|
150
|
+
```ruby
|
151
|
+
config = {
|
152
|
+
"s3_id" => YOUR_AWS_S3_ACCESS_KEY_ID,
|
153
|
+
"s3_secret" => YOUR_AWS_S3_SECRET_ACCESS_KEY,
|
154
|
+
"s3_bucket" => your.blog.bucket.com
|
155
|
+
}
|
156
|
+
in_headless = true
|
157
|
+
Jekyll::S3::Uploader.run('/path/to/your/jekyll-site/_site/', config, in_headless)
|
158
|
+
```
|
159
|
+
|
160
|
+
The code above will assume that you have the `_jekyll_s3.yml` in the directory
|
161
|
+
`/path/to/your/jekyll-site`.
|
162
|
+
|
138
163
|
## Known issues
|
139
164
|
|
140
165
|
None. Please send a pull request if you spot any.
|
@@ -175,6 +200,7 @@ MIT
|
|
175
200
|
Copyright (c) 2011 VersaPay, Philippe Creux.
|
176
201
|
|
177
202
|
Contributors (in alphabetical order)
|
203
|
+
* Alan deLevie
|
178
204
|
* Cory Kaufman-Schofield
|
179
205
|
* Chris Kelly
|
180
206
|
* Chris Moos
|
data/changelog.md
CHANGED
data/jekyll-s3.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "jekyll-s3"
|
6
|
-
s.version = "2.
|
6
|
+
s.version = "2.5.0"
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["Philippe Creux", "Lauri Lehmijoki"]
|
9
9
|
s.email = ["pcreux@gmail.com", "lauri.lehmijoki@iki.fi"]
|
data/lib/jekyll-s3/uploader.rb
CHANGED
@@ -12,8 +12,10 @@ module Jekyll
|
|
12
12
|
s3, config, site_dir
|
13
13
|
)
|
14
14
|
|
15
|
-
deleted_files_count = remove_superfluous_files(
|
16
|
-
|
15
|
+
deleted_files_count = remove_superfluous_files(s3, { :s3_bucket => config['s3_bucket'],
|
16
|
+
:site_dir => site_dir,
|
17
|
+
:in_headless_mode => in_headless_mode,
|
18
|
+
:ignore_on_server => config["ignore_on_server"] })
|
17
19
|
|
18
20
|
print_done_report config
|
19
21
|
|
@@ -63,10 +65,16 @@ module Jekyll
|
|
63
65
|
end
|
64
66
|
end
|
65
67
|
|
66
|
-
def self.remove_superfluous_files(s3,
|
68
|
+
def self.remove_superfluous_files(s3, options)
|
69
|
+
s3_bucket_name = options.fetch(:s3_bucket)
|
70
|
+
site_dir = options.fetch(:site_dir)
|
71
|
+
in_headless_mode = options.fetch(:in_headless_mode)
|
72
|
+
|
67
73
|
remote_files = s3.buckets[s3_bucket_name].objects.map { |f| f.key }
|
68
74
|
local_files = load_all_local_files(site_dir)
|
69
|
-
files_to_delete = remote_files
|
75
|
+
files_to_delete = build_list_of_files_to_delete(remote_files, local_files, options[:ignore_on_server])
|
76
|
+
|
77
|
+
|
70
78
|
deleted_files_count = 0
|
71
79
|
if in_headless_mode
|
72
80
|
files_to_delete.each { |s3_object_key|
|
@@ -82,6 +90,12 @@ module Jekyll
|
|
82
90
|
deleted_files_count
|
83
91
|
end
|
84
92
|
|
93
|
+
def self.build_list_of_files_to_delete(remote_files, local_files, ignore_on_server = nil)
|
94
|
+
ignore_on_server = Regexp.new(ignore_on_server || "a_string_that_should_never_match_ever")
|
95
|
+
files_to_delete = remote_files - local_files
|
96
|
+
files_to_delete.reject { |file| ignore_on_server.match(file) }
|
97
|
+
end
|
98
|
+
|
85
99
|
def self.delete_s3_object(s3, s3_bucket_name, s3_object_key)
|
86
100
|
Retry.run_with_retry do
|
87
101
|
s3.buckets[s3_bucket_name].objects[s3_object_key].delete
|
data/spec/lib/uploader_spec.rb
CHANGED
@@ -16,4 +16,15 @@ describe Jekyll::S3::Uploader do
|
|
16
16
|
files.should include('.vimrc')
|
17
17
|
end
|
18
18
|
end
|
19
|
+
|
20
|
+
context "#build_list_of_files_to_delete" do
|
21
|
+
it "ignores files which match a regular expression" do
|
22
|
+
files_to_delete = Jekyll::S3::Uploader.build_list_of_files_to_delete(["a", "b", "ignored"], ["a"], "ignored")
|
23
|
+
files_to_delete.should eq ["b"]
|
24
|
+
end
|
25
|
+
it "does not ignore when you don't provide an ignored regex" do
|
26
|
+
files_to_delete = Jekyll::S3::Uploader.build_list_of_files_to_delete(["a", "b", "ignored"], ["a"])
|
27
|
+
files_to_delete.should eq ["b", "ignored"]
|
28
|
+
end
|
29
|
+
end
|
19
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-04-
|
13
|
+
date: 2013-04-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: aws-sdk
|
@@ -331,15 +331,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
331
331
|
- - ! '>='
|
332
332
|
- !ruby/object:Gem::Version
|
333
333
|
version: '0'
|
334
|
+
segments:
|
335
|
+
- 0
|
336
|
+
hash: 392463145716040126
|
334
337
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
335
338
|
none: false
|
336
339
|
requirements:
|
337
340
|
- - ! '>='
|
338
341
|
- !ruby/object:Gem::Version
|
339
342
|
version: '0'
|
343
|
+
segments:
|
344
|
+
- 0
|
345
|
+
hash: 392463145716040126
|
340
346
|
requirements: []
|
341
347
|
rubyforge_project:
|
342
|
-
rubygems_version: 1.8.
|
348
|
+
rubygems_version: 1.8.25
|
343
349
|
signing_key:
|
344
350
|
specification_version: 3
|
345
351
|
summary: Push your Jekyll blog to S3
|