middleman-cloudfront 0.0.7 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4ceeae12fb6b9a58a9af56cb8ad6c8c0a01064ba
4
- data.tar.gz: 4eccab87e01e2070bf51054b2a59e34f07ac0799
3
+ metadata.gz: 86426bb088d94149e2d8a94a151a9cdebfe56124
4
+ data.tar.gz: 661a5dababcb3690b5af7b910a241428f3784a9b
5
5
  SHA512:
6
- metadata.gz: ecaaf4fc80e0d53f7987b75ea905333f7a6b2ea0284f7e15e190851153feb11816e5cec552c16ba67d520f4cb613c6c3cd1ddc6ac78b5f35ba219b2ac1956048
7
- data.tar.gz: 939a74033b608adf00b574f7dca2715044d4f140801a195c745be13af4bb17c16193f1c175ece3b6adc2576df5e637c6e4a40e82f9f0f452af4b90846bb7e1d0
6
+ metadata.gz: 4f75b4a87b8c0d7545d2d88500bc58df6c986a5614ba8fc1488c0f4b51d54468156da7fa4fcee2a7bbf79eee78255627afc5077dc33e5a6bb63b73deee739561
7
+ data.tar.gz: 70b64829e5a60b459ad7e77d4802591d7a4a42456946798165e27ae91ea7a406c2a7b4df30b10c96e1ba87892a5e427ae228b1b204d7a27c7b100daef50962e2
@@ -19,7 +19,30 @@ module Middleman
19
19
  end
20
20
 
21
21
  desc "cloudfront:invalidate", "A way to deal with your ClodFront distributions"
22
- def invalidate
22
+ def invalidate(options = nil)
23
+ if options.nil?
24
+ app_instance = ::Middleman::Application.server.inst
25
+ unless app_instance.respond_to?(:cloudfront_options)
26
+ raise Error, <<-TEXT
27
+ ERROR: You need to activate the cloudfront extension in config.rb.
28
+
29
+ The example configuration is:
30
+ activate :cloudfront do |cf|
31
+ cf.access_key_id = 'I'
32
+ cf.secret_access_key = 'love'
33
+ cf.distribution_id = 'cats'
34
+ cf.filter = /\.html/i # default /.*/
35
+ cf.after_build = true # default is false
36
+ end
37
+ TEXT
38
+ end
39
+ options = app_instance.cloudfront_options
40
+ end
41
+ options.filter ||= /.*/
42
+ [:access_key_id, :secret_access_key, :distribution_id, :filter].each do |key|
43
+ raise StandardError, "Configuration key #{key} is missing." if options.public_send(key).nil?
44
+ end
45
+
23
46
  puts "## Invalidating files on CloudFront"
24
47
  cdn = Fog::CDN.new({
25
48
  :provider => 'AWS',
@@ -53,23 +76,6 @@ module Middleman
53
76
 
54
77
  protected
55
78
 
56
- def options
57
- ::Middleman::Application.server.inst.cloudfront_options
58
- rescue
59
- raise Error, <<-TEXT
60
- ERROR: You need to activate the cloudfront extension in config.rb.
61
-
62
- The example configuration is:
63
- activate :cloudfront do |cf|
64
- cf.access_key_id = 'I'
65
- cf.secret_access_key = 'love'
66
- cf.distribution_id = 'cats'
67
- cf.filter = /\.html/i # default /.*/
68
- cf.after_build = true # default is false
69
- end
70
- TEXT
71
- end
72
-
73
79
  def list_files(filter)
74
80
  Dir.chdir('build/') do
75
81
  Dir.glob('**/*', File::FNM_DOTMATCH).tap do |files|
@@ -10,17 +10,13 @@ module Middleman
10
10
  end
11
11
 
12
12
  def registered(app, options_hash = {}, &block)
13
- options = Options.new options_hash
14
- yield options if block_given?
15
-
16
- options.after_build ||= false
17
- options.filter ||= /.*/
13
+ @@cloudfront_options = Options.new(options_hash)
14
+ yield @@cloudfront_options if block_given?
18
15
 
19
16
  app.after_build do
20
- ::Middleman::Cli::CloudFront.new.invalidate if options.after_build
17
+ ::Middleman::Cli::CloudFront.new.invalidate(@@cloudfront_options) if @@cloudfront_options.after_build
21
18
  end
22
19
 
23
- @@cloudfront_options = options
24
20
  app.send :include, Helpers
25
21
  end
26
22
  alias :included :registered
@@ -1,6 +1,6 @@
1
1
  module Middleman
2
2
  module CloudFront
3
3
  PACKAGE = 'middleman-cloudfront'
4
- VERSION = '0.0.7'
4
+ VERSION = '0.0.9'
5
5
  end
6
6
  end
@@ -18,13 +18,19 @@ 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 "middleman-core", ["~> 3.0"]
22
- s.add_dependency "fog", ["~> 1.9"]
21
+ s.add_dependency 'fog', '~> 1.9'
23
22
 
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"
29
- s.add_development_dependency 'guard-rspec', '~> 3.0.3'
23
+ s.add_development_dependency 'cucumber', '~> 1.3'
24
+ s.add_development_dependency 'aruba', '~> 0.5'
25
+ s.add_development_dependency 'fivemat', '~> 1.3'
26
+ s.add_development_dependency 'simplecov', '~> 0.8'
27
+ s.add_development_dependency 'rake', '>= 0.9.0'
28
+ s.add_development_dependency 'rspec', '~> 3.0'
29
+
30
+ if RUBY_VERSION <= '1.9.2'
31
+ s.add_dependency 'middleman-core', '~> 3.0', '<= 3.2.0'
32
+ s.add_development_dependency 'activesupport', '< 4.0.0'
33
+ else
34
+ s.add_dependency 'middleman-core', '~> 3.0'
35
+ end
30
36
  end
@@ -3,18 +3,16 @@ require 'spec_helper'
3
3
  require 'fog/aws/models/cdn/distributions'
4
4
 
5
5
  describe Middleman::Cli::CloudFront do
6
- let(:cloudfront) do
7
- described_class.new.tap do |cloudfront|
8
- cloudfront.stub(:options).and_return Middleman::CloudFront::Options.new(
9
- 'access_key_id_123',
10
- 'secret_access_key_123',
11
- 'distribution_id_123',
12
- 'filter_123',
13
- 'after_build_123'
14
- );
15
- end
6
+ let(:cloudfront) { described_class.new }
7
+ let(:options) do
8
+ Middleman::CloudFront::Options.new(
9
+ 'access_key_id_123',
10
+ 'secret_access_key_123',
11
+ 'distribution_id_123',
12
+ 'filter_123',
13
+ 'after_build_123'
14
+ )
16
15
  end
17
-
18
16
  let(:distribution) { double('distribution', invalidations: double('invalidations')) }
19
17
 
20
18
  describe '#invalidate' do
@@ -28,7 +26,7 @@ describe Middleman::Cli::CloudFront do
28
26
  it 'gets the correct distribution' do
29
27
  cloudfront.stub(:list_files).and_return []
30
28
  expect_any_instance_of(Fog::CDN::AWS::Distributions).to receive(:get).with('distribution_id_123')
31
- cloudfront.invalidate
29
+ cloudfront.invalidate(options)
32
30
  end
33
31
 
34
32
  context 'when the amount of files to invalidate is under the limit' do
@@ -38,7 +36,7 @@ describe Middleman::Cli::CloudFront do
38
36
  end
39
37
  cloudfront.stub(:list_files).and_return files
40
38
  expect(distribution.invalidations).to receive(:create).once.with(paths: files)
41
- cloudfront.invalidate
39
+ cloudfront.invalidate(options)
42
40
  end
43
41
  end
44
42
 
@@ -51,7 +49,7 @@ describe Middleman::Cli::CloudFront do
51
49
  expect(distribution.invalidations).to receive(:create).once.with(paths: files[0, Middleman::Cli::CloudFront::INVALIDATION_LIMIT])
52
50
  expect(distribution.invalidations).to receive(:create).once.with(paths: files[Middleman::Cli::CloudFront::INVALIDATION_LIMIT, Middleman::Cli::CloudFront::INVALIDATION_LIMIT])
53
51
  expect(distribution.invalidations).to receive(:create).once.with(paths: files[Middleman::Cli::CloudFront::INVALIDATION_LIMIT * 2, Middleman::Cli::CloudFront::INVALIDATION_LIMIT])
54
- cloudfront.invalidate
52
+ cloudfront.invalidate(options)
55
53
  end
56
54
  end
57
55
  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.7
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Korzhuev
@@ -9,120 +9,120 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-28 00:00:00.000000000 Z
12
+ date: 2014-06-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: middleman-core
15
+ name: fog
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - ~>
19
19
  - !ruby/object:Gem::Version
20
- version: '3.0'
20
+ version: '1.9'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ~>
26
26
  - !ruby/object:Gem::Version
27
- version: '3.0'
27
+ version: '1.9'
28
28
  - !ruby/object:Gem::Dependency
29
- name: fog
29
+ name: cucumber
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - ~>
33
33
  - !ruby/object:Gem::Version
34
- version: '1.9'
35
- type: :runtime
34
+ version: '1.3'
35
+ type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - ~>
40
40
  - !ruby/object:Gem::Version
41
- version: '1.9'
41
+ version: '1.3'
42
42
  - !ruby/object:Gem::Dependency
43
- name: rake
43
+ name: aruba
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - '>='
46
+ - - ~>
47
47
  - !ruby/object:Gem::Version
48
- version: '0'
48
+ version: '0.5'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - '>='
53
+ - - ~>
54
54
  - !ruby/object:Gem::Version
55
- version: '0'
55
+ version: '0.5'
56
56
  - !ruby/object:Gem::Dependency
57
- name: cucumber
57
+ name: fivemat
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - '>='
60
+ - - ~>
61
61
  - !ruby/object:Gem::Version
62
- version: '0'
62
+ version: '1.3'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - '>='
67
+ - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: '0'
69
+ version: '1.3'
70
70
  - !ruby/object:Gem::Dependency
71
- name: aruba
71
+ name: simplecov
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - '>='
74
+ - - ~>
75
75
  - !ruby/object:Gem::Version
76
- version: '0'
76
+ version: '0.8'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - '>='
81
+ - - ~>
82
82
  - !ruby/object:Gem::Version
83
- version: '0'
83
+ version: '0.8'
84
84
  - !ruby/object:Gem::Dependency
85
- name: fivemat
85
+ name: rake
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - '>='
89
89
  - !ruby/object:Gem::Version
90
- version: '0'
90
+ version: 0.9.0
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - '>='
96
96
  - !ruby/object:Gem::Version
97
- version: '0'
97
+ version: 0.9.0
98
98
  - !ruby/object:Gem::Dependency
99
- name: simplecov
99
+ name: rspec
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - '>='
102
+ - - ~>
103
103
  - !ruby/object:Gem::Version
104
- version: '0'
104
+ version: '3.0'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - '>='
109
+ - - ~>
110
110
  - !ruby/object:Gem::Version
111
- version: '0'
111
+ version: '3.0'
112
112
  - !ruby/object:Gem::Dependency
113
- name: guard-rspec
113
+ name: middleman-core
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
116
  - - ~>
117
117
  - !ruby/object:Gem::Version
118
- version: 3.0.3
119
- type: :development
118
+ version: '3.0'
119
+ type: :runtime
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - ~>
124
124
  - !ruby/object:Gem::Version
125
- version: 3.0.3
125
+ version: '3.0'
126
126
  description: Adds ability to invalidate a specific set of files in your CloudFront
127
127
  cache
128
128
  email:
@@ -166,9 +166,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  version: '0'
167
167
  requirements: []
168
168
  rubyforge_project: middleman-cloudfront
169
- rubygems_version: 2.0.14
169
+ rubygems_version: 2.2.2
170
170
  signing_key:
171
171
  specification_version: 4
172
172
  summary: Invalidate CloudFront cache after deployment to S3
173
173
  test_files:
174
174
  - features/support/env.rb
175
+ has_rdoc: