ipecache 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ipecache (0.0.1)
4
+ ipecache (0.0.3)
5
5
  app_conf (>= 0.4.0)
6
6
  choice (>= 0.1.6)
7
7
  faraday_middleware (>= 0.9.0)
@@ -25,7 +25,7 @@ GEM
25
25
  httpi (2.0.2)
26
26
  rack
27
27
  multipart-post (1.2.0)
28
- nokogiri (1.5.6)
28
+ nokogiri (1.5.9)
29
29
  nori (2.0.4)
30
30
  rack (1.4.1)
31
31
  savon (2.1.0)
data/bin/ipecache CHANGED
@@ -40,6 +40,12 @@ Choice.options do
40
40
  long '--cdn-only'
41
41
  desc 'Only purge from CDNs'
42
42
  end
43
+
44
+ option :log_file, :required => false do
45
+ short '-l'
46
+ long '--log-file'
47
+ desc 'Log errors to specified file in addition to stdout'
48
+ end
43
49
  end
44
50
 
45
51
  if Choice.choices[:status]
@@ -66,6 +72,10 @@ else
66
72
  Choice.help
67
73
  end
68
74
 
75
+ if Choice.choices[:log_file]
76
+ @log_file = Choice.choices[:log_file]
77
+ end
78
+
69
79
  if !Choice.choices[:cdnonly]
70
80
  puts ""
71
81
  puts "Running plugins registered for Proxy Purge..."
data/ipecache.gemspec CHANGED
@@ -2,7 +2,7 @@ $:.push File.expand_path('../lib', __FILE__)
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'ipecache'
5
- gem.version = '0.0.1'
5
+ gem.version = '0.0.3'
6
6
  gem.authors = ["Jon Cowie"]
7
7
  gem.email = 'jonlives@gmail.com'
8
8
  gem.homepage = 'https://github.com/jonlives/ipecache'
@@ -53,7 +53,7 @@ module Ipecache
53
53
  </soap:Envelope>")
54
54
  response_hash = response.to_hash
55
55
  if response_hash[:purge_request_response][:return][:result_msg] != "Success."
56
- plugin_puts "An Error occured: #{response_hash[:purge_request_response][:return][:result_msg]}"
56
+ plugin_puts_error(url,"An Error occured: #{response_hash[:purge_request_response][:return][:result_msg]}")
57
57
  exit 1
58
58
  else
59
59
  plugin_puts "Purge successful!"
@@ -50,7 +50,7 @@ module Ipecache
50
50
  elsif result.include?("404")
51
51
  plugin_puts "--Purge from #{ats} not needed, asset not found"
52
52
  else
53
- plugin_puts "--Purge from #{ats} failed"
53
+ plugin_puts_error(url,"--Purge from #{ats} failed")
54
54
  end
55
55
 
56
56
  end
@@ -46,8 +46,8 @@ module Ipecache
46
46
  response = connection.put("/v2/mcc/customers/#{account_id}/edge/purge",{ :MediaPath => url, :MediaType => 8})
47
47
 
48
48
  if response.status != 200
49
- plugin_puts "Response Code: #{response.status}"
50
- plugin_puts response.body
49
+ plugin_puts_error(url,"Response Code: #{response.status}")
50
+ plugin_puts_error(url,response.body)
51
51
  exit 1
52
52
  else
53
53
  plugin_puts "Purge successful!"
@@ -41,8 +41,8 @@ module Ipecache
41
41
  response = http.request(request)
42
42
 
43
43
  if response.code.to_i != 200
44
- plugin_puts "Response Code: #{response.code}"
45
- plugin_puts response.body
44
+ plugin_puts_error(url,"Response Code: #{response.code}")
45
+ plugin_puts_error(url,response.body)
46
46
  exit 1
47
47
  else
48
48
  plugin_puts "Purge successful!"
@@ -39,6 +39,10 @@ module Ipecache
39
39
  @options[:urls]
40
40
  end
41
41
 
42
+ def log_file
43
+ @options[:log_file]
44
+ end
45
+
42
46
  def name
43
47
  self.class.to_s
44
48
  end
@@ -47,6 +51,13 @@ module Ipecache
47
51
  puts "#{name}: #{message}"
48
52
  end
49
53
 
54
+ def plugin_puts_error(url,message)
55
+ if log_file
56
+ File.open(log_file, 'a') { |file| file.write("#{Time.now.getutc} #{url} #{name}: #{message}\n") }
57
+ end
58
+ puts "#{name}: #{message}"
59
+ end
60
+
50
61
  private
51
62
  def config
52
63
  @options[:config].plugins.send(self.class.name.to_sym) unless @options[:config].nil? || @options[:config].plugins.nil?
@@ -24,10 +24,12 @@ module Ipecache
24
24
 
25
25
  def run_plugins(hook)
26
26
  urls = @urls
27
+ log_file = @log_file
27
28
  Ipecache::Plugins.run(
28
29
  :config => ipecache_config,
29
30
  :hook => hook.to_sym,
30
- :urls => urls
31
+ :urls => urls,
32
+ :log_file => log_file
31
33
  )
32
34
  end
33
35
 
data/plugins/ATSChef.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ATSChef
2
2
  ========
3
- Queries chef for nodes in the specified role and purges the URL list from each server
3
+ Queries chef for nodes in the specified role and purges the URL list from each Apache Traffic Server
4
4
 
5
5
  Gem Requirements
6
6
  ----------------
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ipecache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-20 00:00:00.000000000 Z
12
+ date: 2013-09-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: app_conf