webs 0.1.17 → 0.1.18

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
3
3
  require 'rake'
4
4
  require 'echoe'
5
5
 
6
- Echoe.new('webs', '0.1.17') do |p|
6
+ Echoe.new('webs', '0.1.18') do |p|
7
7
  p.description = "Reusable webs stuff."
8
8
  p.url = "https://colczak@github.com/websdev/websgem.git"
9
9
  p.author = "Chuck Olczak"
@@ -12,16 +12,13 @@ class Webs::AliveController < ActionController::Base
12
12
  # Only force down if calling from localhost
13
13
  render( :text=>'OK' ) and return unless Webs.cache
14
14
 
15
- this_host = Socket.gethostname
16
- key = "alive_#{this_host}"
17
-
18
- server_down = Webs.cache.read(key)
15
+ server_down = fetch_server_down
19
16
  if request.local?
20
17
  if ['1', '-1'].include?( params['forceDown'] )
21
18
  server_down = '1'
22
- Webs.cache.write(key, server_down)
19
+ set_server_down( server_down )
23
20
  elsif params['forceDown'] == '0'
24
- Webs.cache.delete(key)
21
+ Webs.cache.delete(cache_key)
25
22
  server_down = nil
26
23
  end
27
24
  end
@@ -32,4 +29,26 @@ class Webs::AliveController < ActionController::Base
32
29
  render :text=>'OK'
33
30
  end
34
31
  end
32
+
33
+ private
34
+ def cache_key
35
+ this_host = Socket.gethostname
36
+ "alive_#{this_host}"
37
+ end
38
+
39
+ def fetch_server_down
40
+ if Webs.cache.respond_to?( 'read' )
41
+ Webs.cache.read( cache_key )
42
+ else
43
+ Webs.cache[ cache_key ]
44
+ end
45
+ end
46
+
47
+ def set_server_down server_down
48
+ if Webs.cache.respond_to?( 'write' )
49
+ Webs.cache.write(cache_key, server_down)
50
+ else
51
+ Webs.cache[ cache_key ] = server_down
52
+ end
53
+ end
35
54
  end
data/lib/webs.rb CHANGED
@@ -7,7 +7,7 @@ require dir + 'helper/params'
7
7
  require dir + 'helper/tags'
8
8
 
9
9
  module Webs
10
- VERSION = '0.1.17'.freeze
10
+ VERSION = '0.1.18'.freeze
11
11
 
12
12
  # def self.load_constants
13
13
  # s = File.read("#{Pathname(__FILE__).dirname.expand_path}/config/webs_constants.yml")
data/webs.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{webs}
5
- s.version = "0.1.17"
5
+ s.version = "0.1.18"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Chuck Olczak"]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 17
9
- version: 0.1.17
8
+ - 18
9
+ version: 0.1.18
10
10
  platform: ruby
11
11
  authors:
12
12
  - Chuck Olczak