middleman-cloudfront 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +4 -0
- data/README.md +5 -2
- data/lib/middleman-cloudfront/commands.rb +8 -3
- data/lib/middleman-cloudfront/extension.rb +2 -1
- data/lib/middleman-cloudfront/pkg-info.rb +1 -1
- data/middleman-cloudfront.gemspec +7 -6
- metadata +18 -1
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
-
# Middleman CloudFront
|
1
|
+
# Middleman CloudFront [![Build Status](https://travis-ci.org/andrusha/middleman-cloudfront.png)](https://travis-ci.org/andrusha/middleman-cloudfront) [![Dependency Status](https://gemnasium.com/andrusha/middleman-cloudfront.png)](https://gemnasium.com/andrusha/middleman-cloudfront) [![Code Climate](https://codeclimate.com/github/andrusha/middleman-cloudfront.png)](https://codeclimate.com/github/andrusha/middleman-cloudfront)
|
2
2
|
A deploying tool for middleman which allows you to interact with Amazon CloudFront.
|
3
3
|
Some of its features are:
|
4
4
|
|
5
5
|
* CloudFront cache invalidation;
|
6
6
|
* Ability to call it from command line and after middleman build;
|
7
|
+
* Ability to filter files which are going to be invalidated by regex;
|
7
8
|
|
8
9
|
# Usage
|
10
|
+
andrusha/middleman-cloudfront
|
9
11
|
|
10
12
|
## Installation
|
11
13
|
Add this to `Gemfile`:
|
@@ -26,7 +28,8 @@ activate :cloudfront do |cf|
|
|
26
28
|
cf.access_key_id = 'I'
|
27
29
|
cf.secret_access_key = 'love'
|
28
30
|
cf.distribution_id = 'cats'
|
29
|
-
# cf.
|
31
|
+
# cf.filter = /\.html$/i # default is /.*/
|
32
|
+
# cf.after_build = false # default is false
|
30
33
|
end
|
31
34
|
```
|
32
35
|
|
@@ -28,7 +28,7 @@ module Middleman
|
|
28
28
|
distribution = cdn.distributions.get options.distribution_id
|
29
29
|
|
30
30
|
# CloudFront limits amount of files which can be invalidated by one request
|
31
|
-
list_files.each_slice(1000) do |slice|
|
31
|
+
list_files(options.filter).each_slice(1000) do |slice|
|
32
32
|
puts "Please wait while Cloudfront is reloading #{slice.length} paths, it might take up to 10 minutes"
|
33
33
|
invalidation = distribution.invalidations.create :paths => slice
|
34
34
|
invalidation.wait_for { ready? }
|
@@ -48,17 +48,22 @@ module Middleman
|
|
48
48
|
cf.access_key_id = 'I'
|
49
49
|
cf.secret_access_key = 'love'
|
50
50
|
cf.distribution_id = 'cats'
|
51
|
+
cf.filter = /\.html/i # default /.*/
|
51
52
|
cf.after_build = true # default is false
|
52
53
|
end
|
53
54
|
EOF
|
54
55
|
end
|
55
56
|
|
56
|
-
def list_files
|
57
|
+
def list_files(filter)
|
57
58
|
Dir.chdir('build/') do
|
58
59
|
files = Dir.glob('**/*', File::FNM_DOTMATCH).reject { |f| File.directory? f }
|
59
60
|
# if :directory_indexes is active, we must invalidate both files and dirs
|
60
61
|
files += files.map{|f| f.gsub(/\/index\.html$/, '/') }
|
61
|
-
files.uniq
|
62
|
+
files.uniq!
|
63
|
+
.map! { |f| f.start_with?('/') ? f : "/#{f}" }
|
64
|
+
.reject! { |f| not filter =~ f }
|
65
|
+
|
66
|
+
files
|
62
67
|
end
|
63
68
|
end
|
64
69
|
|
@@ -2,7 +2,7 @@ require 'middleman-core'
|
|
2
2
|
|
3
3
|
module Middleman
|
4
4
|
module CloudFront
|
5
|
-
class Options < Struct.new(:access_key_id, :secret_access_key, :distribution_id, :after_build); end
|
5
|
+
class Options < Struct.new(:access_key_id, :secret_access_key, :distribution_id, :filter, :after_build); end
|
6
6
|
|
7
7
|
class << self
|
8
8
|
def options
|
@@ -14,6 +14,7 @@ module Middleman
|
|
14
14
|
yield options if block_given?
|
15
15
|
|
16
16
|
options.after_build ||= false
|
17
|
+
options.filter ||= /.*/
|
17
18
|
|
18
19
|
app.after_build do
|
19
20
|
::Middleman::Cli::CloudFront.new.invalidate if options.after_build
|
@@ -18,11 +18,12 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.test_files = `git ls-files -z -- {fixtures,features}/*`.split("\0")
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
s.add_dependency
|
22
|
-
s.add_dependency
|
21
|
+
s.add_dependency "middleman-core", ["~> 3.0.0"]
|
22
|
+
s.add_dependency "fog", ["~> 1.9.0"]
|
23
23
|
|
24
|
-
s.add_development_dependency
|
25
|
-
s.add_development_dependency
|
26
|
-
s.add_development_dependency
|
27
|
-
s.add_development_dependency
|
24
|
+
s.add_development_dependency "rake"
|
25
|
+
s.add_development_dependency "cucumber"
|
26
|
+
s.add_development_dependency "aruba"
|
27
|
+
s.add_development_dependency "fivemat"
|
28
|
+
s.add_development_dependency "simplecov"
|
28
29
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-cloudfront
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: 1.9.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
46
62
|
- !ruby/object:Gem::Dependency
|
47
63
|
name: cucumber
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,6 +132,7 @@ extensions: []
|
|
116
132
|
extra_rdoc_files: []
|
117
133
|
files:
|
118
134
|
- .gitignore
|
135
|
+
- .travis.yml
|
119
136
|
- Gemfile
|
120
137
|
- LICENSE
|
121
138
|
- README.md
|