middleman-s3_sync 3.0.14 → 3.0.15

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.
@@ -0,0 +1,3 @@
1
+ ---
2
+ aws_access_key_id: <AWS Access Key>
3
+ aws_secret_access_key: <AWS Secret Access Key>
data/README.md CHANGED
@@ -67,6 +67,37 @@ activate :s3_sync do |s3_sync|
67
67
  end
68
68
  ```
69
69
 
70
+ ### Providing AWS Credentials
71
+
72
+ There are a few ways to provide the AWS credentials for s3_sync:
73
+
74
+ #### Through ```config.rb```
75
+
76
+ You can set the aws_access_key_id and aws_secret_access_key in the block
77
+ that is passed to the activate method.
78
+
79
+ #### Through ```.s3_sync``` File
80
+
81
+ You can create a ```.s3_sync``` at the root of your middleman project.
82
+ The credentials are passed in the YAML format. The keys match the
83
+ options keys.
84
+
85
+ The .s3_sync file takes precedence to the configuration passed in the
86
+ activate method.
87
+
88
+ A sample ```.s3_sync``` file is included at the root of this repo.
89
+
90
+ #### Through Environment
91
+
92
+ You can also pass the credentials through environment variables. They
93
+ map to the following values:
94
+
95
+ | aws_access_key_id | ```ENV['AWS_ACCESS_KEY_ID``` |
96
+ | aws_secret_access_key | ```ENV['AWS_SECRET_ACCESS_KEY']``` |
97
+
98
+ The environment is used when the credentials are not set in the activate
99
+ method or passed through the ```.s3_sync``` configuration file.
100
+
70
101
  ## Push All Content to S3
71
102
 
72
103
  There are situations where you might need to push the files to S3. In
@@ -34,6 +34,15 @@ module Middleman
34
34
  shared_inst.s3_sync_options.bucket = options[:bucket] if options[:bucket]
35
35
  shared_inst.s3_sync_options.verbose = options[:verbose] if options[:verbose]
36
36
 
37
+ config_file = File.join(shared_inst.root_path, ".s3_sync")
38
+
39
+ if File.exist?(config_file)
40
+ config = YAML::load( File.open( config_file ) )
41
+
42
+ shared_inst.s3_sync_options.aws_secret_access_key = config["aws_secret_access_key"] if config["aws_secret_access_key"]
43
+ shared_inst.s3_sync_options.aws_access_key_id = config["aws_access_key_id"] if config["aws_access_key_id"]
44
+ end
45
+
37
46
  ::Middleman::S3Sync.sync
38
47
  end
39
48
  end
@@ -76,7 +76,7 @@ module Middleman
76
76
  end
77
77
 
78
78
  def remote_paths
79
- @remote_paths ||= bucket.files.map{ |f| f.key }.reject { |p| p =~ %r{/$} }
79
+ @remote_paths ||= bucket.files.map{ |f| f.key }
80
80
  end
81
81
 
82
82
  def create_resources
@@ -92,7 +92,12 @@ module Middleman
92
92
  end
93
93
 
94
94
  def ignore!
95
- say_status "Ignoring".yellow + " #{path} #{ redirect? ? "(redirect)".white : "" }"
95
+ reason = if redirect?
96
+ :redirect
97
+ elsif directory?
98
+ :directory
99
+ end
100
+ say_status "Ignoring".yellow + " #{path} #{ reason ? "(#{reason})".white : "" }"
96
101
  end
97
102
 
98
103
  def to_delete?
@@ -120,7 +125,9 @@ module Middleman
120
125
  end
121
126
 
122
127
  def status
123
- @status ||= if local? && remote?
128
+ @status ||= if directory?
129
+ :ignored
130
+ elsif local? && remote?
124
131
  if content_md5 != remote_md5
125
132
  :updated
126
133
  else
@@ -147,6 +154,10 @@ module Middleman
147
154
  s3_resource.metadata.has_key? 'x-amz-website-redirect-location'
148
155
  end
149
156
 
157
+ def directory?
158
+ File.directory?(local_path)
159
+ end
160
+
150
161
  def relative_path
151
162
  @relative_path ||= local_path.gsub(/#{build_dir}/, '')
152
163
  end
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module S3Sync
3
- VERSION = "3.0.14"
3
+ VERSION = "3.0.15"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-s3_sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.14
4
+ version: 3.0.15
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-08-13 00:00:00.000000000 Z
13
+ date: 2013-08-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: middleman-core
@@ -229,6 +229,7 @@ extra_rdoc_files: []
229
229
  files:
230
230
  - .gitignore
231
231
  - .rspec
232
+ - .s3_sync.sample
232
233
  - .travis.yml
233
234
  - Changelog.md
234
235
  - Gemfile
@@ -262,7 +263,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
262
263
  version: '0'
263
264
  segments:
264
265
  - 0
265
- hash: -2891873384991304950
266
+ hash: -3960336143999785597
266
267
  required_rubygems_version: !ruby/object:Gem::Requirement
267
268
  none: false
268
269
  requirements:
@@ -271,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
271
272
  version: '0'
272
273
  segments:
273
274
  - 0
274
- hash: -2891873384991304950
275
+ hash: -3960336143999785597
275
276
  requirements: []
276
277
  rubyforge_project:
277
278
  rubygems_version: 1.8.23