jekyll-s3-yearofmoo 0.0.20 → 0.0.21

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.
@@ -42,11 +42,12 @@ cloudfront_distribution_id: YOUR_CLOUDFRONT_DIST_ID (OPTIONAL)
42
42
  end
43
43
  end
44
44
 
45
- def local_files
45
+ def local_files(pattern=nil)
46
46
  dir = @production_directory || SITE_DIR
47
47
  paths = []
48
48
 
49
- files = Dir[dir + '/**/*']
49
+ pattern ||= '**/*'
50
+ files = Dir[dir + '/' + pattern]
50
51
  files = files.delete_if { |f|
51
52
  File.directory?(f)
52
53
  }.map { |f|
@@ -112,8 +113,19 @@ cloudfront_distribution_id: YOUR_CLOUDFRONT_DIST_ID (OPTIONAL)
112
113
 
113
114
 
114
115
  # Please spec me!
115
- def upload_to_s3!
116
- puts "Deploying _site/* to #{@s3_bucket}"
116
+ def upload_to_s3!(campaign=nil)
117
+
118
+ if campaign
119
+ campaign = @config['campaigns'][campaign]
120
+ end
121
+
122
+ remove_files = true
123
+ pattern = '**/*'
124
+ if campaign
125
+ pattern = campaign['files']
126
+ remove_files = false
127
+ end
128
+ puts "Deploying _site/#{pattern} to #{@s3_bucket}"
117
129
 
118
130
  AWS::S3::Base.establish_connection!(
119
131
  :access_key_id => @s3_id,
@@ -130,7 +142,7 @@ cloudfront_distribution_id: YOUR_CLOUDFRONT_DIST_ID (OPTIONAL)
130
142
  remote_files = bucket.objects.map { |f| f.key }
131
143
 
132
144
  dir = @production_directory || SITE_DIR
133
- to_upload = local_files
145
+ to_upload = local_files(pattern)
134
146
  to_upload.each do |f|
135
147
  run_with_retry do
136
148
  path = "#{dir}/#{f}"
@@ -143,34 +155,41 @@ cloudfront_distribution_id: YOUR_CLOUDFRONT_DIST_ID (OPTIONAL)
143
155
  end
144
156
  end
145
157
 
146
- to_delete = remote_files - local_files
147
-
148
- delete_all = false
149
- keep_all = false
150
- to_delete.each do |f|
151
- delete = false
152
- keep = false
153
- until delete || delete_all || keep || keep_all
154
- puts "#{f} is on S3 but not in your _site directory anymore. Do you want to [d]elete, [D]elete all, [k]eep, [K]eep all?"
155
- case STDIN.gets.chomp
156
- when 'd' then delete = true
157
- when 'D' then delete_all = true
158
- when 'k' then keep = true
159
- when 'K' then keep_all = true
158
+ if remove_files
159
+ to_delete = remote_files - local_files
160
+
161
+ delete_all = false
162
+ keep_all = false
163
+ to_delete.each do |f|
164
+ delete = false
165
+ keep = false
166
+ until delete || delete_all || keep || keep_all
167
+ puts "#{f} is on S3 but not in your _site directory anymore. Do you want to [d]elete, [D]elete all, [k]eep, [K]eep all?"
168
+ case STDIN.gets.chomp
169
+ when 'd' then delete = true
170
+ when 'D' then delete_all = true
171
+ when 'k' then keep = true
172
+ when 'K' then keep_all = true
173
+ end
160
174
  end
161
- end
162
- if (delete_all || delete) && !(keep_all || keep)
163
- run_with_retry do
164
- if AWS::S3::S3Object.delete(f, @s3_bucket)
165
- puts("Delete #{f}: Success!")
166
- else
167
- puts("Delete #{f}: FAILURE!")
175
+ if (delete_all || delete) && !(keep_all || keep)
176
+ run_with_retry do
177
+ if AWS::S3::S3Object.delete(f, @s3_bucket)
178
+ puts("Delete #{f}: Success!")
179
+ else
180
+ puts("Delete #{f}: FAILURE!")
181
+ end
168
182
  end
169
183
  end
170
184
  end
171
185
  end
172
186
 
173
- puts "Done! Go visit: http://#{@s3_bucket}.s3.amazonaws.com/index.html"
187
+ domain = 'http://#{@s3_bucket}.s3.amazonaws.com/index.html'
188
+ if @config['www']
189
+ domain = @config['www']
190
+ end
191
+ puts "Done! Go visit: #{domain}"
192
+
174
193
  true
175
194
  end
176
195
 
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module S3
3
- VERSION = "0.0.20"
3
+ VERSION = "0.0.21"
4
4
  end
5
5
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 20
9
- version: 0.0.20
8
+ - 21
9
+ version: 0.0.21
10
10
  platform: ruby
11
11
  authors:
12
12
  - Philippe Creux
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-08-28 00:00:00 -04:00
17
+ date: 2012-09-26 00:00:00 -04:00
18
18
  default_executable: jekyll-s3-yearofmoo
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency