capistrano-cloudflare 0.0.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +3 -2
- data/README.md +2 -0
- data/capistrano-cloudflare.gemspec +1 -1
- data/lib/capistrano/cloudflare.rb +2 -24
- data/lib/capistrano/cloudflare/version.rb +1 -1
- data/lib/capistrano/tasks/cloudflare.rake +16 -0
- data/spec/capistrano/cloudflare_spec.rb +14 -22
- metadata +25 -38
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bc115805b03ba0ec658a5dba1e009287728b84eb
|
4
|
+
data.tar.gz: b7bc367c5d490b49129b93a96dda44ec89a1f61e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6001115c10aa2659be81d970e4bfaae30dde7a83851d63d2646bf4867c9dd642e9f900c0a53f14cadc27e450b23dd1e8eb202150d1d5fe527c057fa6108fa7ba
|
7
|
+
data.tar.gz: 7faf63fac70b2d7fd49c728e5b030d899342f24e57c83bdb4a5863772baf27b9aa6c4c9294f1bee22ba66e286ca6ec8642d5ce515e3e7437598f79562d5c5020
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
[CloudFlare](http://www.cloudflare.com/) is a service that protects and speeds up websites. Capistrano Cloudflare provides [Capistrano](https://github.com/capistrano/capistrano/wiki/Documentation-v2.x) tasks to update your CloudFlare settings.
|
4
4
|
|
5
|
+
Capistrano CloudFlare Version 1.0 and above supports the new Capistrano v3 API. For compatbility with Capistrano v2, please use version `0.0.2`.
|
6
|
+
|
5
7
|
Currently only cache purging is supported.
|
6
8
|
|
7
9
|
## Installation
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = Capistrano::CloudFlare::VERSION
|
17
17
|
|
18
|
-
gem.add_dependency 'capistrano', '>=
|
18
|
+
gem.add_dependency 'capistrano', '>= 3.0'
|
19
19
|
gem.add_dependency 'json'
|
20
20
|
|
21
21
|
gem.add_development_dependency 'rake'
|
@@ -2,6 +2,7 @@ require 'capistrano'
|
|
2
2
|
require 'capistrano/cloudflare/version'
|
3
3
|
require 'json'
|
4
4
|
require 'net/http'
|
5
|
+
require 'rake'
|
5
6
|
|
6
7
|
module Capistrano
|
7
8
|
module CloudFlare
|
@@ -20,30 +21,7 @@ module Capistrano
|
|
20
21
|
})
|
21
22
|
response = JSON.parse(http.request(request).body)
|
22
23
|
end
|
23
|
-
|
24
|
-
def self.load_into(configuration)
|
25
|
-
configuration.set :capistrano_cloudflare, self
|
26
|
-
configuration.load do
|
27
|
-
namespace :cloudflare do
|
28
|
-
namespace :cache do
|
29
|
-
desc "Purge the CloudFlare cache"
|
30
|
-
task :purge do
|
31
|
-
raise unless fetch(:cloudflare_options).respond_to?(:[])
|
32
|
-
response = capistrano_cloudflare.send_request(cloudflare_options)
|
33
|
-
if response['result'] == 'success'
|
34
|
-
logger.info("Purged CloudFlare cache for #{cloudflare_options[:domain]}")
|
35
|
-
else
|
36
|
-
logger.info("CloudFlare cache purge failed. Reason: #{response['msg'] || 'unknown.'}")
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|
44
24
|
end
|
45
25
|
end
|
46
26
|
|
47
|
-
|
48
|
-
Capistrano::CloudFlare.load_into(Capistrano::Configuration.instance)
|
49
|
-
end
|
27
|
+
load File.expand_path('../tasks/cloudflare.rake', __FILE__)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
namespace :cloudflare do
|
2
|
+
namespace :cache do
|
3
|
+
desc "Purge the CloudFlare cache"
|
4
|
+
task :purge do
|
5
|
+
on roles(:all) do
|
6
|
+
raise 'Missing CloudFlare configuration.' unless fetch(:cloudflare_options).respond_to?(:[])
|
7
|
+
response = Capistrano::CloudFlare.send_request(fetch(:cloudflare_options))
|
8
|
+
if response['result'] == 'success'
|
9
|
+
info "Purged CloudFlare cache for #{fetch(:cloudflare_options)[:domain]}"
|
10
|
+
else
|
11
|
+
error "CloudFlare cache purge failed. Reason: #{response['msg'] || 'unknown.'}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,30 +1,22 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Capistrano::CloudFlare do
|
4
|
-
|
5
|
-
@configuration = Capistrano::Configuration.new
|
6
|
-
Capistrano::CloudFlare.load_into(@configuration)
|
7
|
-
@options = { :domain => 'example.com',
|
8
|
-
:email => 'me@example.com',
|
9
|
-
:api_key => 'F' }
|
10
|
-
stub_request(:post, 'https://www.cloudflare.com/api_json.html').to_return(
|
11
|
-
:status => 200, :body => '{}'
|
12
|
-
)
|
4
|
+
it { should be_a Module }
|
13
5
|
|
14
|
-
|
15
|
-
|
16
|
-
|
6
|
+
describe '.send_request' do
|
7
|
+
it 'should POST to the cloudflare API and return the response body as a hash' do
|
8
|
+
options = {
|
9
|
+
domain: 'example.com',
|
10
|
+
email: 'me@example.com',
|
11
|
+
api_key: 'F'
|
12
|
+
}
|
17
13
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
@configuration.set(:cloudflare_options, @options)
|
23
|
-
expect { @configuration.find_and_execute_task('cloudflare:cache:purge') }.to_not raise_error
|
24
|
-
end
|
14
|
+
body = { 'result' => 'success' }
|
15
|
+
stub_request(:post, 'https://www.cloudflare.com/api_json.html').to_return(
|
16
|
+
:status => 200, :body => body.to_json
|
17
|
+
)
|
25
18
|
|
26
|
-
|
27
|
-
|
28
|
-
described_class.send_request(@options).should be_a_kind_of(Hash)
|
19
|
+
Capistrano::CloudFlare.send_request(options).should eq(body)
|
20
|
+
end
|
29
21
|
end
|
30
22
|
end
|
metadata
CHANGED
@@ -1,110 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-cloudflare
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Nathan L Smith
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-02-27 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: capistrano
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
19
|
+
version: '3.0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
26
|
+
version: '3.0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: json
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rake
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rspec
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - ">="
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - ">="
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: capistrano-spec
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - ">="
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - ">="
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: webmock
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - ">="
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - ">="
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
description: Capistrano extensions for CloudFlare
|
@@ -114,9 +101,9 @@ executables: []
|
|
114
101
|
extensions: []
|
115
102
|
extra_rdoc_files: []
|
116
103
|
files:
|
117
|
-
- .gitignore
|
118
|
-
- .rspec
|
119
|
-
- .travis.yml
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- ".travis.yml"
|
120
107
|
- Gemfile
|
121
108
|
- Guardfile
|
122
109
|
- LICENSE
|
@@ -125,31 +112,31 @@ files:
|
|
125
112
|
- capistrano-cloudflare.gemspec
|
126
113
|
- lib/capistrano/cloudflare.rb
|
127
114
|
- lib/capistrano/cloudflare/version.rb
|
115
|
+
- lib/capistrano/tasks/cloudflare.rake
|
128
116
|
- spec/capistrano/cloudflare_spec.rb
|
129
117
|
- spec/spec_helper.rb
|
130
118
|
homepage: https://github.com/cramerdev/capistrano-cloudflare
|
131
119
|
licenses: []
|
120
|
+
metadata: {}
|
132
121
|
post_install_message:
|
133
122
|
rdoc_options: []
|
134
123
|
require_paths:
|
135
124
|
- lib
|
136
125
|
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
126
|
requirements:
|
139
|
-
- -
|
127
|
+
- - ">="
|
140
128
|
- !ruby/object:Gem::Version
|
141
129
|
version: '0'
|
142
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
-
none: false
|
144
131
|
requirements:
|
145
|
-
- -
|
132
|
+
- - ">="
|
146
133
|
- !ruby/object:Gem::Version
|
147
134
|
version: '0'
|
148
135
|
requirements: []
|
149
136
|
rubyforge_project:
|
150
|
-
rubygems_version:
|
137
|
+
rubygems_version: 2.2.0
|
151
138
|
signing_key:
|
152
|
-
specification_version:
|
139
|
+
specification_version: 4
|
153
140
|
summary: Lets you make CloudFlare API calls when deploying with Capistrano.
|
154
141
|
test_files:
|
155
142
|
- spec/capistrano/cloudflare_spec.rb
|