jekyll-s3-yearofmoo 0.0.26 → 0.0.27
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/jekyll-s3-yearofmoo/uploader.rb +30 -12
- data/lib/jekyll-s3-yearofmoo/version.rb +1 -1
- metadata +2 -2
@@ -42,14 +42,22 @@ cloudfront_distribution_id: YOUR_CLOUDFRONT_DIST_ID (OPTIONAL)
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
def local_files(
|
45
|
+
def local_files(campaign=nil)
|
46
46
|
dir = @production_directory || SITE_DIR
|
47
47
|
paths = []
|
48
48
|
|
49
|
-
|
50
|
-
if
|
49
|
+
campaign = @config['campaigns'][campaign]
|
50
|
+
if campaign
|
51
|
+
include_files = campaign['include_files']
|
52
|
+
exclude_files = campaign['exclude_files']
|
53
|
+
end
|
54
|
+
|
55
|
+
include_pattern ||= '**/*'
|
56
|
+
exclude_pattern ||= nil
|
57
|
+
|
58
|
+
if include_pattern.is_a?(Array)
|
51
59
|
files = []
|
52
|
-
|
60
|
+
include_pattern.each do |pat|
|
53
61
|
files |= Dir[dir + '/' + pat]
|
54
62
|
end
|
55
63
|
else
|
@@ -63,8 +71,20 @@ cloudfront_distribution_id: YOUR_CLOUDFRONT_DIST_ID (OPTIONAL)
|
|
63
71
|
f.gsub(dir + '/', '')
|
64
72
|
}
|
65
73
|
|
66
|
-
if
|
67
|
-
|
74
|
+
if exclude_pattern
|
75
|
+
exclude_pattern = exclude_pattern.is_a?(Array) ? exclude_pattern : [exclude_pattern]
|
76
|
+
end
|
77
|
+
|
78
|
+
exclude_pattern ||= []
|
79
|
+
|
80
|
+
p = @config['exclude_files']
|
81
|
+
if p
|
82
|
+
p = p.is_a?(Array) ? p : [p]
|
83
|
+
exclude_pattern |= p
|
84
|
+
end
|
85
|
+
|
86
|
+
if exclude_pattern.length > 0
|
87
|
+
patterns = exclude_pattern.map do |p|
|
68
88
|
Regexp.new(p)
|
69
89
|
end
|
70
90
|
files.each do |file|
|
@@ -125,17 +145,15 @@ cloudfront_distribution_id: YOUR_CLOUDFRONT_DIST_ID (OPTIONAL)
|
|
125
145
|
def upload_to_s3!(campaign=nil)
|
126
146
|
|
127
147
|
if campaign
|
128
|
-
raise campaign.to_s+'-'+@config.to_yaml
|
129
148
|
campaign = @config['campaigns'][campaign]
|
130
149
|
end
|
131
150
|
|
132
|
-
remove_files = true
|
133
|
-
pattern = '**/*'
|
134
151
|
if campaign
|
135
|
-
pattern = campaign['files']
|
136
152
|
remove_files = false
|
153
|
+
puts "Deploying *#{campaign}* to #{@s3_bucket}"
|
154
|
+
else
|
155
|
+
puts "Deploying _site/#{pattern} to #{@s3_bucket}"
|
137
156
|
end
|
138
|
-
puts "Deploying _site/#{pattern} to #{@s3_bucket}"
|
139
157
|
|
140
158
|
AWS::S3::Base.establish_connection!(
|
141
159
|
:access_key_id => @s3_id,
|
@@ -152,7 +170,7 @@ cloudfront_distribution_id: YOUR_CLOUDFRONT_DIST_ID (OPTIONAL)
|
|
152
170
|
remote_files = bucket.objects.map { |f| f.key }
|
153
171
|
|
154
172
|
dir = @production_directory || SITE_DIR
|
155
|
-
to_upload = local_files(
|
173
|
+
to_upload = local_files(campaign)
|
156
174
|
to_upload.each do |f|
|
157
175
|
run_with_retry do
|
158
176
|
path = "#{dir}/#{f}"
|