Merge pull request #42 from CartoDB/interface-generator-improvements
Interface generator improvements
This commit is contained in:
commit
2fc0521e36
@ -1,5 +1,5 @@
|
|||||||
CREATE OR REPLACE FUNCTION <%= GEOCODER_CLIENT_SCHEMA %>._<%= name %> (user_id name, tx_id bigint, <%= params_with_type %>)
|
CREATE OR REPLACE FUNCTION <%= GEOCODER_CLIENT_SCHEMA %>._<%= name %> (user_id name, tx_id bigint, <%= params_with_type %>)
|
||||||
RETURNS Geometry AS $$
|
RETURNS <%= return_type %> AS $$
|
||||||
CONNECT <%= GEOCODER_CLIENT_SCHEMA %>._server_conn_str();
|
CONNECT <%= GEOCODER_CLIENT_SCHEMA %>._server_conn_str();
|
||||||
SELECT cdb_geocoder_server.<%= name %> (user_id, tx_id, <%= params %>);
|
SELECT cdb_geocoder_server.<%= name %> (user_id, tx_id, <%= params %>);
|
||||||
$$ LANGUAGE plproxy;
|
$$ LANGUAGE plproxy;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
# A script to automatically generate SQL files from an interface definition.
|
# A script to automatically generate SQL files from an interface definition.
|
||||||
# To be called like this: sql-template-renderer interface.csv templates/sql-template.erb
|
# To be called like this: sql-template-renderer interface.yaml sql-template.erb
|
||||||
|
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'erb'
|
require 'erb'
|
||||||
@ -11,7 +11,7 @@ class SqlTemplateRenderer
|
|||||||
GEOCODER_CLIENT_SCHEMA = 'cdb_geocoder_client'
|
GEOCODER_CLIENT_SCHEMA = 'cdb_geocoder_client'
|
||||||
|
|
||||||
def initialize(template_file, function_signature)
|
def initialize(template_file, function_signature)
|
||||||
@f = function_signature
|
@function_signature = function_signature
|
||||||
@template = File.read(template_file)
|
@template = File.read(template_file)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -20,19 +20,19 @@ class SqlTemplateRenderer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def name
|
def name
|
||||||
@f['name']
|
@function_signature['name']
|
||||||
end
|
end
|
||||||
|
|
||||||
def return_type
|
def return_type
|
||||||
@f['return_type']
|
@function_signature['return_type']
|
||||||
end
|
end
|
||||||
|
|
||||||
def params
|
def params
|
||||||
@f['params'].map { |p| p['name'] }.join(', ')
|
@function_signature['params'].map { |p| p['name'] }.join(', ')
|
||||||
end
|
end
|
||||||
|
|
||||||
def params_with_type
|
def params_with_type
|
||||||
@f['params'].map { |p| "#{p['name']} #{p['type']}"}.join(', ')
|
@function_signature['params'].map { |p| "#{p['name']} #{p['type']}"}.join(', ')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user