Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
Noah
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Noah
Commits
e5af7b2d
Commit
e5af7b2d
authored
Feb 26, 2011
by
John E. Vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ephemeral node support - backend api
parent
4375abb6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
4 deletions
+39
-4
custom-watcher.rb
examples/custom-watcher.rb
+1
-1
models.rb
lib/noah/models.rb
+3
-3
ephemerals.rb
lib/noah/models/ephemerals.rb
+3
-0
ephemeral_spec.rb
spec/ephemeral_spec.rb
+32
-0
No files found.
examples/custom-watcher.rb
View file @
e5af7b2d
...
...
@@ -4,7 +4,7 @@ require File.join(File.dirname(__FILE__), '..','lib','noah','watcher')
class
StdoutWatcher
<
Noah
::
Watcher
redis_host
"redis://127.0.0.1:6379/0"
pattern
"
noah.configuration.redis_server.update
"
pattern
"
//noah/configuration/redis_server.*
"
destination
Proc
.
new
{
|
x
|
puts
x
}
run!
end
lib/noah/models.rb
View file @
e5af7b2d
...
...
@@ -10,7 +10,7 @@ module Noah
model
.
send
:include
,
Ohm
::
ExtraValidations
model
.
after
:save
,
:notify_via_redis_save
model
.
after
:create
,
:notify_via_redis_create
#
model.after :create, :notify_via_redis_create
model
.
after
:update
,
:notify_via_redis_update
model
.
before
:delete
,
:stash_name
model
.
after
:delete
,
:notify_via_redis_delete
...
...
@@ -44,7 +44,7 @@ module Noah
protected
def
patternize_me
"
noah.
#{
self
.
class_to_lower
}
.
#{
name
}
"
"
//noah/
#{
self
.
class_to_lower
}
/
#{
name
.
gsub
(
/^\//
,
''
)
}
"
end
def
stash_name
@deleted_name
=
self
.
name
...
...
@@ -69,7 +69,7 @@ module Noah
#pub_category = "#{db}:noah.#{self.class.to_s}[#{name}].#{meth}"
pub_category
=
"
#{
self
.
patternize_me
}
.
#{
meth
}
"
Ohm
.
redis
.
publish
(
pub_category
,
self
.
to_hash
.
merge
({
"action"
=>
meth
,
"pubcategory"
=>
pub_category
}).
to_json
)
# self.method_defined? "#{meth}_hook".to_sym
self
.
send
(
"
#{
meth
}
_hook"
.
to_sym
)
unless
self
.
protected_methods
.
member?
(
"
#{
meth
}
_hook"
.
to_sym
)
==
false
end
end
end
...
...
lib/noah/models/ephemerals.rb
View file @
e5af7b2d
...
...
@@ -17,6 +17,9 @@ module Noah
@name
=
path
end
protected
def
save_hook
end
end
end
spec/ephemeral_spec.rb
0 → 100644
View file @
e5af7b2d
require
File
.
expand_path
(
File
.
dirname
(
__FILE__
)
+
'/spec_helper'
)
describe
"Using the Ephemeral Model"
,
:reset_redis
=>
true
do
before
(
:all
)
do
@edata
=
{
:path
=>
"//noah/foo/bar/baz"
,
:data
=>
"some_value"
}
@emissing_path
=
@edata
.
reject
{
|
x
|
x
==
:path
}
@emissing_data
=
@edata
.
reject
{
|
x
|
x
==
:data
}
@good_ephemeral
=
Noah
::
Ephemeral
.
new
(
@edata
)
@missing_path
=
Noah
::
Ephemeral
.
new
(
@emissing_path
)
@missing_data
=
Noah
::
Ephemeral
.
new
(
@emissing_data
)
end
before
(
:each
)
do
Ohm
.
redis
.
flushdb
end
after
(
:each
)
do
Ohm
.
redis
.
flushdb
end
describe
"should"
do
it
"create a new Noah::Ephemeral"
do
@good_ephemeral
.
valid?
.
should
==
true
@good_ephemeral
.
save
b
=
Noah
::
Ephemeral
.
find
(
:path
=>
@edata
[
:path
]).
first
b
.
should
==
@good_ephemeral
end
it
"create a new Noah::Ephemeral with missing data"
it
"update an existing Noah::Ephemeral"
it
"delete an existing Noah::Ephemeral"
end
describe
"should not"
do
it
"create a new Noah::Ephemeral with missing path"
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment