middleman-s3_sync 3.0.4 → 3.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,9 +15,10 @@ module Middleman
15
15
  class << self
16
16
  def sync
17
17
  puts "Gathering local files."
18
- local_files = (Dir[options.public_path + "/**/*"] + Dir[options.public_path + "/**/.*"])
18
+
19
+ local_files = (Dir[options.build_dir + "/**/*"] + Dir[options.build_dir + "/**/.*"])
19
20
  .reject { |f| File.directory?(f) }
20
- .map { |f| f.gsub(/^build\//, '') }
21
+ .map { |f| f.gsub(/^#{options.build_dir}\//, '') }
21
22
  puts "Gathering remote files."
22
23
  remote_files = bucket.files.map { |f| f.key }
23
24
 
@@ -35,7 +36,7 @@ module Middleman
35
36
  files_to_reject = []
36
37
  Parallel.each(files_to_evaluate, :in_threads => 4) do |f|
37
38
  print '.'
38
- local_mtime = File.mtime("build/#{f}")
39
+ local_mtime = File.mtime("#{options.build_dir}/#{f}")
39
40
  remote_mtime = s3_files.get(f).last_modified
40
41
  files_to_reject << f if remote_mtime >= local_mtime
41
42
  end
@@ -47,7 +48,7 @@ module Middleman
47
48
  puts "\n\nDetermine which remaining files are actually different than their S3 counterpart."
48
49
  Parallel.each(files_to_evaluate, :in_threads => 4) do |f|
49
50
  print '.'
50
- local_md5 = Digest::MD5.hexdigest(File.read("build/#{f}"))
51
+ local_md5 = Digest::MD5.hexdigest(File.read("#{options.build_dir}/#{f}"))
51
52
  remote_md5 = s3_files.get(f).etag
52
53
  files_to_push << f if local_md5 != remote_md5
53
54
  end
@@ -59,14 +60,14 @@ module Middleman
59
60
  if remote_files.include?(f)
60
61
  puts "Updating #{f}"
61
62
  file = s3_files.get(f)
62
- file.body = File.open("build/#{f}")
63
+ file.body = File.open("#{options.build_dir}/#{f}")
63
64
  file.public = true
64
65
  file.save
65
66
  else
66
67
  puts "Creating #{f}"
67
68
  file = bucket.files.create({
68
69
  :key => f,
69
- :body => File.open("build/#{f}"),
70
+ :body => File.open("#{options.build_dir}/#{f}"),
70
71
  :public => true,
71
72
  :acl => 'public-read'
72
73
  })
@@ -4,7 +4,6 @@ module Middleman
4
4
  module S3Sync
5
5
  class Options < Struct.new(
6
6
  :prefix,
7
- :public_path,
8
7
  :bucket,
9
8
  :region,
10
9
  :aws_access_key_id,
@@ -12,6 +11,7 @@ module Middleman
12
11
  :after_build,
13
12
  :delete,
14
13
  :existing_remote_file,
14
+ :build_dir
15
15
  )
16
16
  end
17
17
 
@@ -28,11 +28,12 @@ module Middleman
28
28
 
29
29
  app.send :include, Helpers
30
30
 
31
- options.public_path ||= "build"
32
31
  app.after_configuration do |config|
33
- after_build do |builder|
34
- ::Middleman::S3Sync.sync if options.after_build
35
- end
32
+ options.build_dir = build_dir
33
+ end
34
+
35
+ app.after_build do |builder|
36
+ ::Middleman::S3Sync.sync if options.after_build
36
37
  end
37
38
  end
38
39
 
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module S3Sync
3
- VERSION = "3.0.4"
3
+ VERSION = "3.0.6"
4
4
  end
5
5
  end
@@ -20,4 +20,6 @@ Gem::Specification.new do |gem|
20
20
  gem.add_runtime_dependency 'middleman-core', '>= 3.0.0'
21
21
  gem.add_runtime_dependency 'fog'
22
22
  gem.add_runtime_dependency 'parallel'
23
+
24
+ gem.add_development_dependency 'rake'
23
25
  end
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: middleman-s3_sync
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 3.0.4
5
+ version: 3.0.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Frederic Jean
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-11 00:00:00.000000000 Z
12
+ date: 2013-02-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  type: :runtime
@@ -59,6 +59,22 @@ dependencies:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ type: :development
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ name: rake
71
+ prerelease: false
72
+ requirement: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
62
78
  description: Only syncs files that have been updated to S3.
63
79
  email:
64
80
  - fred@fredjean.net
@@ -90,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
106
  - !ruby/object:Gem::Version
91
107
  segments:
92
108
  - 0
93
- hash: 3029396681136123709
109
+ hash: 4207882760766588596
94
110
  version: '0'
95
111
  required_rubygems_version: !ruby/object:Gem::Requirement
96
112
  none: false
@@ -99,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
115
  - !ruby/object:Gem::Version
100
116
  segments:
101
117
  - 0
102
- hash: 3029396681136123709
118
+ hash: 4207882760766588596
103
119
  version: '0'
104
120
  requirements: []
105
121
  rubyforge_project: