Permalink
Browse files

[apied] consolidate path parsing

  • Loading branch information...
1 parent 35a5b41 commit a1cbe4c79c1070d1fdb993af0d01ce7622371d97 @geemus committed Aug 31, 2012
Showing with 17 additions and 21 deletions.
  1. +10 −14 apied/endpoint.rb
  2. +7 −7 apied/output/apps.rb
View
@@ -33,7 +33,7 @@ def self.#{method}(path = nil, &block)
data << {
:accepts => {},
:method => :#{method},
- :path => path,
+ :path => '/' << [name.downcase, path].compact.join,
:requires => {}
}
if block_given?
@@ -104,20 +104,16 @@ def self.to_client
client << " :body => options,"
end
client << " :method => :#{datum[:method]},"
- path = if datum[:path].nil?
- "/#{endpoint}"
- else
- path = []
- "#{endpoint}#{datum[:path]}".split('/').each do |segment|
- if segment[0..1] =~ /^:/
- path << ('#{' << segment[1..-1] << '}')
- else
- path << segment
- end
+ path = []
+ datum[:path].split('/').each do |segment|
+ if segment[0..1] =~ /^:/
+ path << ('#{' << segment[1..-1] << '}')
+ else
+ path << segment
end
- path.join('/')
end
- client << " :path => \"#{path}\""
+ path = path.join('/')
+ client << " :path => \"#{path}\""
client << " )"
client << " end\n"
end
@@ -140,7 +136,7 @@ def self.to_md
docs = ["# #{name}"]
data.each do |datum|
- path = ['/', name.downcase, datum[:path]].compact.join
+ path = datum[:path]
docs << "## #{datum[:method].upcase} #{path}\n"
View
@@ -5,16 +5,16 @@ class Client
def delete_apps(app)
connection.request(
:method => :delete,
- :path => "apps/#{app}"
+ :path => "/apps/#{app}"
)
end
# Public: Get a listing of your apps.
#
- def get_apps
+ def get_apps()
connection.request(
:method => :get,
- :path => "/apps"
+ :path => "/apps"
)
end
@@ -23,7 +23,7 @@ def get_apps
def get_apps(app)
connection.request(
:method => :get,
- :path => "apps/#{app}"
+ :path => "/apps/#{app}"
)
end
@@ -33,11 +33,11 @@ def get_apps(app)
# :name - identifier for app (default: randomly generated name).
# :stack - technology stack to run app on (default: cedar).
#
- def post_apps(options = {})
+ def post_apps(, options = {})
connection.request(
:body => options,
:method => :post,
- :path => "/apps"
+ :path => "/apps"
)
end
@@ -46,7 +46,7 @@ def post_apps(options = {})
def put_apps(app)
connection.request(
:method => :put,
- :path => "apps/#{app}"
+ :path => "/apps/#{app}"
)
end

0 comments on commit a1cbe4c

Please sign in to comment.