Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'rexml/document'
include REXML
doc = Document.new( File.new('ex-query-hibernate.xml') )
root = doc.root
root.each_element('//query') { |query|
name = query.elements['name'].text #vem um SEARCH_CLIENT
arr_temp = name.split('_').each { |n|
n.capitalize!
}
spring_id_class = arr_temp.join('') + 'Query' # SearchClientQuery
arr_temp[0].downcase!
spring_id_bean = arr_temp.join('') + 'Query' # searchClientQuery
template_spring_bean = <<-EOF
<property name="#{spring_id_bean}">
<ref bean="#{spring_id_bean}"/>
</property>
<bean id="#{spring_id_bean}"
class="org.example.db.queries.#{spring_id_class}">
<constructor-arg>
<ref bean="#{spring_id_bean}SQL" />
</constructor-arg>
</bean>
EOF
puts template_spring_bean
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment