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
f3813529
Commit
f3813529
authored
Mar 22, 2011
by
John E. Vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
link work. unproductive
parent
e7f7ef43
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
5 deletions
+52
-5
noah.rb
lib/noah.rb
+6
-0
base_agent.rb
lib/noah/agents/base_agent.rb
+0
-1
models.rb
lib/noah/models.rb
+32
-1
link.rb
lib/noah/models/link.rb
+13
-3
tags.rb
lib/noah/models/tags.rb
+1
-0
No files found.
lib/noah.rb
View file @
f3813529
module
Noah
PROTECTED_PATHS
=
%w[applications configurations hosts services watches ark noah]
PATH_MAPPING
=
{
"Noah::Application"
=>
"//noah/application"
,
"Noah::Service"
=>
"//noah/service"
,
"Noah::Configuration"
=>
"//noah/configuration"
,
"Noah::Host"
=>
"//noah/host"
,
"Noah::Tag"
=>
"//noah/tag"
,
"Noah::Ephemeral"
=>
"//noah/ephemeral"
}
end
begin
require
'yajl'
...
...
lib/noah/agents/base_agent.rb
View file @
f3813529
require
'logger'
require
'logger'
module
Noah::Agents
module
Base
...
...
lib/noah/models.rb
View file @
f3813529
...
...
@@ -2,6 +2,7 @@ require 'ohm'
require
'ohm/contrib'
module
Noah
class
Model
<
Ohm
::
Model
def
self
.
inherited
(
model
)
model
.
send
:include
,
Ohm
::
Timestamping
...
...
@@ -24,6 +25,10 @@ module Noah
module
ModelClassMethods
def
self
.
included
(
base
)
Noah
::
RegisteredModels
.
register_model
(
base
)
end
def
is_new?
self
.
created_at
==
self
.
updated_at
end
...
...
@@ -32,6 +37,19 @@ module Noah
tags
.
to_s
.
split
(
/\s*,\s*/
).
uniq
end
def
link!
(
path
)
base_pattern
=
"
#{
self
.
patternize_me
}
"
path
.
nil?
?
(
raise
ArgumentError
,
"Must provide a path"
)
:
p
=
path
begin
l
=
Link
.
new
:path
=>
p
,
:source
=>
base_pattern
l
.
valid?
?
l
.
save
:
(
raise
"
#{
l
.
errors
}
"
)
l
.
name
rescue
Exception
=>
e
e
.
message
end
end
def
watch!
(
opts
=
{
:endpoint
=>
nil
,
:pattern
=>
nil
})
base_pattern
=
"
#{
self
.
patternize_me
}
"
opts
[
:endpoint
].
nil?
?
(
raise
ArgumentError
,
"Need an endpoint"
)
:
endpoint
=
opts
[
:endpoint
]
...
...
@@ -45,7 +63,7 @@ module Noah
e
.
message
end
end
protected
def
patternize_me
name
.
match
(
/^\//
)
?
n
=
name
.
gsub
(
/^\//
,
''
)
:
n
=
name
...
...
@@ -94,7 +112,20 @@ module Noah
end
end
class
RegisteredModels
@@models
=
[]
def
self
.
register_model
(
model
)
@@models
<<
model
end
def
self
.
models
@@models
end
end
end
require
File
.
join
(
File
.
dirname
(
__FILE__
),
'models'
,
'tags'
)
require
File
.
join
(
File
.
dirname
(
__FILE__
),
'models'
,
'hosts'
)
require
File
.
join
(
File
.
dirname
(
__FILE__
),
'models'
,
'services'
)
...
...
lib/noah/models/link.rb
View file @
f3813529
module
Noah
class
Link
<
Model
attribute
:path
attribute
:
nodes
attribute
:
source
index
:path
index
:source
def
validate
super
assert_present
:path
assert_present
:source
assert_unique
[
:path
,
:source
]
end
# Nothing to see yet.
# This will be for creating "overlays" or "link" relationships
# between arbitrary objects or modeling your data the way you want.
...
...
@@ -33,5 +39,9 @@ module Noah
#
# Almost a "choose your own model" thing.
def
name
@name
=
path
end
end
end
lib/noah/models/tags.rb
View file @
f3813529
...
...
@@ -10,4 +10,5 @@ module Noah
super
(
encode
(
id
))
||
create
(
:id
=>
encode
(
id
))
end
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