s3deploy 0.0.3 → 0.0.4

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.
data/README.md CHANGED
@@ -44,9 +44,7 @@ If you want to test-drive your configuration you can simulate a deploy
44
44
  $ s3deploy simulate
45
45
 
46
46
  ## Whats in the pipe-line
47
- 1. Setting caching-headers by regex
48
- 2. Skipping files by regex
49
- 3. Putting it on github for others to contribute
47
+ 1. Putting it on github for others to contribute
50
48
 
51
49
  ## Contributing
52
50
  (you cant do this riktigt now, but it will be on the githubz soon)
data/lib/.s3deploy.yml CHANGED
@@ -12,6 +12,10 @@ aws_bucket: # the bucket you want to deploy to *required*
12
12
  # sa-east-1 South America (Sao Paulo)
13
13
  #path: # the relative path to the files you want to deploy, leave it blank for current directory.
14
14
  #remote_path: # the path within the bucket to where you want to deploy, leave it blank for bucket root.
15
+ #cache_regex: ^(images|javascripts|stylesheets)\/.+\.(png|jpg|js|css)(\.gz)?$
16
+ # Adds headers for browser cache for files matching regex.
17
+ #skip_regex: \.DS_Store$
18
+ # Skips files that match this regex.
15
19
  extras:
16
20
  #- delete_old_files # deletes files that were in the bucket but not in the latest deploy
17
21
  #- replace_with_gzip # replaces files with gz versions if they exist
@@ -1,3 +1,3 @@
1
1
  class S3deploy
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/s3deploy.rb CHANGED
@@ -37,9 +37,14 @@ class S3deploy
37
37
  path = File.expand_path(@options["path"])
38
38
  raise "#{@options["path"]} is not a path." unless File.directory? path
39
39
 
40
- puts "Deploying to #{@options["aws_bucket"]}"
40
+ puts simulate ? "Deploying to #{@options["aws_bucket"]}" : "Simulating deployment to #{@options["aws_bucket"]}"
41
41
 
42
42
  files = all_files(path).map { |f| f.gsub(/^#{path}\//, "")}
43
+
44
+ if @options["skip_regex"]
45
+ files.delete_if { |f| f =~ Regexp.new(@options["skip_regex"]) }
46
+ end
47
+
43
48
  skip_files = []
44
49
  active_files = []
45
50
  files.each do |file|
@@ -97,6 +102,11 @@ class S3deploy
97
102
 
98
103
  def upload_file(local, remote, simulate, options = {})
99
104
  options[:access] = :public_read
105
+
106
+ if @options["cache_regex"] && remote =~ Regexp.new(@options["cache_regex"])
107
+ options[:"Cache-Control"] = "public, max-age=31557600"
108
+ end
109
+
100
110
  options[:"Content-Encoding"] = "gzip" if local =~ /.+.gz$/
101
111
  AWS::S3::S3Object.store(remote, open(local), @options["aws_bucket"], options) unless simulate
102
112
  puts "Uploaded\t#{remote}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-22 00:00:00.000000000 Z
12
+ date: 2012-08-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-s3