noah 0.2 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/bin/noah-watcher.rb CHANGED
@@ -14,7 +14,8 @@ begin
14
14
  require 'noah'
15
15
  require 'noah/agent'
16
16
  require 'json'
17
- rescue LoadError
17
+ rescue LoadError => e
18
+ puts e.message
18
19
  puts HELP
19
20
  exit
20
21
  end
data/config.ru CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rubygems'
2
2
  require File.join('.', 'lib','noah')
3
3
  ## Uncomment the following to hardcode a redis url
4
- ENV['REDIS_URL'] = "redis://localhost:6379/1"
4
+ ENV['REDIS_URL'] = "redis://localhost:6379/0"
5
5
  noah = Noah::App.new
6
6
  run noah
data/lib/noah/agent.rb CHANGED
@@ -9,9 +9,6 @@ module Noah
9
9
  class Agent
10
10
  include EM::Deferrable
11
11
 
12
- Noah::Agents::HttpAgent.register
13
- Noah::Agents::DummyAgent.register
14
-
15
12
  @@watchers = Noah::Watcher.watch_list
16
13
  @@agents = Noah::Watchers.agents
17
14
 
@@ -0,0 +1,17 @@
1
+ require 'logger'
2
+ require 'logger'
3
+
4
+ module Noah::Agents
5
+ module Base
6
+ class << self
7
+ include EM::Deferrable
8
+
9
+ PREFIX = "base"
10
+ NAME = "base-agent"
11
+ end
12
+
13
+ def self.included(base)
14
+ Noah::Watchers.register_agent(base)
15
+ end
16
+ end
17
+ end
@@ -1,14 +1,12 @@
1
+ require File.join(File.dirname(__FILE__), 'base_agent')
2
+
1
3
  module Noah::Agents
2
4
  class DummyAgent
3
- include EM::Deferrable
5
+ include Noah::Agents::Base
4
6
 
5
7
  PREFIX = "dummy"
6
8
  NAME = "dummy"
7
9
 
8
- def self.register
9
- Noah::Watchers.register_agent(self)
10
- end
11
-
12
10
  def self.notify(event, message, watch_list)
13
11
  logger = LOGGER
14
12
  logger.info("#{NAME}: Worker initiated")
@@ -1,16 +1,12 @@
1
- require 'logger'
1
+ require File.join(File.dirname(__FILE__), 'base_agent')
2
2
 
3
3
  module Noah::Agents
4
4
  class HttpAgent
5
- include EM::Deferrable
5
+ include Noah::Agents::Base
6
6
 
7
7
  PREFIX = "http"
8
8
  NAME = "http"
9
9
 
10
- def self.register
11
- Noah::Watchers.register_agent(self)
12
- end
13
-
14
10
  def self.notify(event, message, watch_list)
15
11
  logger = LOGGER
16
12
  logger.info("#{NAME}: Worker initiated")
@@ -28,8 +24,8 @@ module Noah::Agents
28
24
  http.errback {
29
25
  logger.error("#{NAME}: Something went wrong with #{ep}")
30
26
  }
31
- iter.next
32
27
  end
28
+ iter.next
33
29
  end
34
30
  end
35
31
 
data/lib/noah/models.rb CHANGED
@@ -42,7 +42,8 @@ module Noah
42
42
 
43
43
  protected
44
44
  def patternize_me
45
- "//noah/#{self.class_to_lower}/#{name}"
45
+ name.match(/^\//) ? n = name.gsub(/^\//, '') : n = name
46
+ "//noah/#{self.class_to_lower}/#{n}"
46
47
  end
47
48
 
48
49
  def stash_name
data/lib/noah/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Noah
2
- VERSION = "0.2"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: noah
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: "0.2"
5
+ version: 0.2.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - John E. Vincent
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-15 00:00:00 -04:00
13
+ date: 2011-03-16 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -264,6 +264,7 @@ files:
264
264
  - examples/websocket.rb
265
265
  - lib/noah.rb
266
266
  - lib/noah/agent.rb
267
+ - lib/noah/agents/base_agent.rb
267
268
  - lib/noah/agents/dummy_agent.rb
268
269
  - lib/noah/agents/http_agent.rb
269
270
  - lib/noah/app.rb
@@ -332,7 +333,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
332
333
  requirements: []
333
334
 
334
335
  rubyforge_project: noah
335
- rubygems_version: 1.5.2
336
+ rubygems_version: 1.6.2
336
337
  signing_key:
337
338
  specification_version: 3
338
339
  summary: Application registry based on Apache Zookeeper