Skip to content

Instantly share code, notes, and snippets.

@chorn
Created June 6, 2012 18:12
Show Gist options
  • Select an option

  • Save chorn/2883685 to your computer and use it in GitHub Desktop.

Select an option

Save chorn/2883685 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require "rubygems"
require "json"
require "sinatra"
require "./lib/nameable"
get '/*/*.*' do |raw_name, function, type|
begin
name = Nameable::Latin.new.parse(raw_name)
rescue Nameable::Latin::InvalidNameError => e
""
end
if type.to_sym == :json
content_type 'application/json'
name.to_hash.to_json
else
content_type 'text/plain'
name.send("to_#{function}") if function =~ /^(fullname|nameable|firstname|lastname|middlename)$/
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment