Skip to content
This repository has been archived by the owner on Jan 2, 2018. It is now read-only.

Commit

Permalink
remove unused class definition from generated service template
Browse files Browse the repository at this point in the history
  • Loading branch information
kamui committed Aug 27, 2013
1 parent 1ab17ff commit 5b6e413
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 61 deletions.
59 changes: 59 additions & 0 deletions templates/Thorfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# encoding: utf-8
$:.unshift File.expand_path("../lib", __FILE__)
require 'bundler'
require 'active_support/inflector'

class Default < Thor
include Thor::Actions

desc "service VERB URI FILENAME", "Generate scaffolding for a new service"
def service(verb, route, path)
route = route.gsub(/^\//, "") # strip leading forward slash
path_without_suffix = path.gsub(/\.rb$/, "")
create_file(File.join("api", "#{path_without_suffix}.rb")) do
<<-RUBY.gsub(/^\s{6}/, '')
describe_service "#{route}" do |service|
service.formats :json
service.http_verb :#{verb.downcase}
service.disable_auth # on by default
# INPUT
service.param.string :name, :default => 'World', :doc => "The name of the person to greet."
# OUTPUT
service.response do |response|
response.object do |obj|
obj.string :message, :doc => "The greeting message sent back. Defaults to 'World'."
obj.datetime :at, :doc => "The timestamp of when the message was dispatched."
end
end
# DOCUMENTATION
service.documentation do |doc|
doc.overall "This service provides a simple hello world implementation example."
doc.example "curl -I 'http://localhost:9292/hello_world?name=Matt'"
end
# ACTION/IMPLEMENTATION
service.implementation do
halt 501, "Not Implemented, which is a pity, I'm sure"
end
end
RUBY
end

class_name = path_without_suffix.classify.gsub(/::/, '') # strip modules; just want a unique class name for spec
create_file(File.join("test", "integration", "#{path_without_suffix}_test.rb")) do
<<-RUBY.gsub(/^\s{6}/, '')
require 'test_helpers'
class #{class_name}Spec < MiniTest::Spec
it "performs request" do
TestApi.#{verb} "/#{route}", {}
assert_api_response
end
end
RUBY
end
end
end
61 changes: 0 additions & 61 deletions templates/Thorfile.tt

This file was deleted.

0 comments on commit 5b6e413

Please sign in to comment.