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
f11cdec6
Commit
f11cdec6
authored
Apr 12, 2011
by
John E. Vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
customizing hash for configurations
parent
7a10fa79
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
29 deletions
+22
-29
application_routes.rb
lib/noah/application_routes.rb
+6
-12
configuration_routes.rb
lib/noah/configuration_routes.rb
+3
-7
applications.rb
lib/noah/models/applications.rb
+1
-1
configurations.rb
lib/noah/models/configurations.rb
+4
-1
configuration_spec.rb
spec/configuration_spec.rb
+3
-2
noahapp_application_spec.rb
spec/noahapp_application_spec.rb
+5
-6
No files found.
lib/noah/application_routes.rb
View file @
f11cdec6
...
...
@@ -12,11 +12,8 @@ class Noah::App
get
'/applications/:appname/?'
do
|
appname
|
app
=
Noah
::
Application
.
find
(
:name
=>
appname
).
first
if
app
.
nil?
halt
404
else
app
.
to_json
end
(
halt
404
)
if
app
.
nil?
app
.
to_json
end
put
'/applications/:appname/tag'
do
|
appname
|
...
...
@@ -63,13 +60,10 @@ class Noah::App
delete
'/applications/:appname/?'
do
|
appname
|
app
=
Noah
::
Application
.
find
(
:name
=>
appname
).
first
if
app
.
nil?
halt
404
else
app
.
delete
r
=
{
"result"
=>
"success"
,
"action"
=>
"delete"
,
"id"
=>
"
#{
app
.
id
}
"
,
"name"
=>
"
#{
appname
}
"
}
r
.
to_json
end
(
halt
404
)
if
app
.
nil?
app
.
delete
r
=
{
"result"
=>
"success"
,
"action"
=>
"delete"
,
"id"
=>
"
#{
app
.
id
}
"
,
"name"
=>
"
#{
appname
}
"
}
r
.
to_json
end
get
'/applications/?'
do
...
...
lib/noah/configuration_routes.rb
View file @
f11cdec6
...
...
@@ -29,13 +29,9 @@ class Noah::App
end
get
'/configurations/?'
do
configs
=
[]
Noah
::
Configuration
.
all
.
sort
.
each
{
|
c
|
configs
<<
c
.
to_hash
}
if
configs
.
empty?
halt
404
else
configs
.
to_json
end
configs
=
Noah
::
Configurations
.
all
.
to_hash
(
halt
404
)
if
configs
.
size
==
0
configs
.
to_json
end
put
'/configurations/:configname/link'
do
|
configname
|
...
...
lib/noah/models/applications.rb
View file @
f11cdec6
...
...
@@ -19,7 +19,7 @@ module Noah
configurations
.
sort
.
each
do
|
cfg
|
cfg_hash
[
"
#{
cfg
.
name
}
"
]
=
{
:format
=>
cfg
.
to_hash
[
:format
],
:body
=>
cfg
.
to_hash
[
:body
]}
end
super
.
merge
(
:name
=>
name
,
:created_at
=>
created_at
,
:updated_at
=>
updated_at
,
:configurations
=>
cfg_hash
)
{
name
=>
{
:id
=>
id
,
:created_at
=>
created_at
,
:updated_at
=>
updated_at
,
:configurations
=>
cfg_hash
}}
end
class
<<
self
...
...
lib/noah/models/configurations.rb
View file @
f11cdec6
...
...
@@ -41,7 +41,10 @@ module Noah
class
Configurations
def
self
.
all
(
options
=
{})
options
.
empty?
?
Configuration
.
all
.
sort
:
Configuration
.
find
(
options
).
sort
config_hash
=
Hash
.
new
options
.
empty?
?
configs
=
Configuration
.
all
.
sort
:
configs
=
Configuration
.
find
(
options
).
sort
configs
.
each
{
|
x
|
config_hash
[
"
#{
x
.
name
}
"
]
=
x
.
to_hash
.
reject
{
|
k
,
v
|
k
==
:name
}
}
config_hash
end
end
end
spec/configuration_spec.rb
View file @
f11cdec6
...
...
@@ -50,9 +50,10 @@ describe "Using the Configuration Model", :reset_redis => true do
a
=
Noah
::
Configuration
.
find_or_create
(
@appconf_string
)
b
=
Noah
::
Configuration
.
find_or_create
(
@appconf_json
)
c
=
Noah
::
Configurations
.
all
c
.
class
.
to_s
.
should
==
'Hash'
c
.
size
.
should
==
2
c
.
member?
(
a
).
should
==
true
c
.
member?
(
b
).
should
==
true
c
.
has_key?
(
a
.
name
).
should
==
true
c
.
has_key?
(
b
.
name
).
should
==
true
end
end
...
...
spec/noahapp_application_spec.rb
View file @
f11cdec6
...
...
@@ -20,12 +20,11 @@ describe "Using the Application API", :reset_redis => false do
get
'/applications/rspec_sample_app'
last_response
.
should
be_ok
response
=
last_response
.
should
return_json
response
[
"name"
].
should
==
@a
.
name
response
[
"id"
].
should
==
@a
.
id
.
to_s
response
[
"name"
].
should
==
@a
.
name
response
.
has_key?
(
"configurations"
).
should
==
true
c
=
response
[
"configurations"
]
response
.
has_key?
(
@a
.
name
).
should
==
true
response
[
@a
.
name
].
class
.
to_s
.
should
==
'Hash'
response
[
@a
.
name
][
"id"
].
should
==
@a
.
id
.
to_s
response
[
@a
.
name
].
has_key?
(
"configurations"
).
should
==
true
c
=
response
[
@a
.
name
][
"configurations"
]
c
.
has_key?
(
@c
.
name
).
should
==
true
c
[
"
#{
@c
.
name
}
"
][
"format"
].
should
==
"
#{
@c
.
format
}
"
c
[
"
#{
@c
.
name
}
"
][
"body"
].
should
==
"
#{
@c
.
body
}
"
...
...
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