class Object

Public Instance Methods

get_pairs() click to toggle source
# File lib/templatit/xml_update.rb, line 18
def get_pairs()
  puts Pathname.new(__FILE__).realpath
  all_in_one_config_file = File.join(File.dirname(__FILE__), "android.xml")
  xmlfile = File.new(all_in_one_config_file)
  xmldoc = Document.new(xmlfile)  
  pairs = {}
  xmldoc.elements.each('/resources/build/string') do |e|
    #pairs.store(e.attributes['name'],e.text)
    k=e.attributes['name']
    v=e.text
    pairs.store(k,v)
    end
    # pairs.each do |key,value|
    #   puts key
    #   puts value
    # end
pairs
end
get_tags(directory) click to toggle source
# File lib/templatit/xml_update.rb, line 10
def get_tags(directory)
puts Pathname.new(__FILE__).realpath
all_in_one_config_file = File.join(File.dirname(__FILE__), "android.xml")
  @doc = Nokogiri::XML(File.open(all_in_one_config_file))
  @doc.xpath("//"+directory+"//string")
#this return nodes
end
get_template(directory) click to toggle source
# File lib/templatit/xml_update.rb, line 37
def get_template(directory)
  case directory
  when 'config'
  %{


    <resources>
    <% for @result_node in @pairs %>
    <%= @result_node  %><% end %>
    <string name="client_server_grant_type">password</string>
    
    <string name="client_show_sliding">true</string>
    <string name="client_show_handle">true</string>
    <string name="client_show_ext_network">true</string>
    <string name="client_show_contact_ocu">true</string>
    <string name="client_show_contact_company">true</string>
    <string name="client_show_mail">false</string>
    <string name="client_show_scan">true</string>
    <!-- control encrypt the cell phone number -->
    <!-- 
    <string name="client_encrypt_cellphone">3,7</string>
     -->
    <string name="client_conf_sdcard_root">/minxing_ylx</string>
    <string name="client_conf_query_robot_url">http://183.6.158.5:8197/empvoice/machine/mob/query.do?mxLayout=0</string>
    <string name="client_conf_consultant_url">http://183.6.158.5:8197/empvoice/expert/mob/info.do?mxLayout=0</string>
    <string name="client_conf_share_knowledge_url">http://183.6.158.5:8197/empvoice/knowledge/mob/edit.do?mxLayout=0</string>
    <string name="client_app_center_force_refresh">true</string> 
    <string name="client_water_mark_enable">true</string>
    </resources>

    }
  when 'strings'
      %{<resources>
        <% for @result_node in @pairs %>
        <%= @result_node  %><% end %>
    </resources>
    }
  when 'build'
      %{<% @pairs.each do |key,value| %><%= key %>:<%= value%>
<% end %>}
  end
end