Top Level Namespace
Defined Under Namespace
Modules: Methods, Puer
Classes: ClassInfo, Converter, MultiConverter, NodeInfo, Session, String
Constant Summary
collapse
- TEMPLATE =
"require File.dirname(__FILE__) + '/jam'\n\nmodule Puer\n module Generators\n class Template < Jam\n\n # Add this generator to our puer\n Puer::Generators.add_generator(:template, self)\n\n # Define the source template root\n def self.source_root; File.expand_path(File.dirname(__FILE__)); end\n def self.banner; \"puer template [name]\"; end\n\n # Include related modules\n include Thor::Actions\n include Puer::Generators::Actions \n\n desc \"Description:\\\\n\\\\n\\\\tpuer will generates an new PureMvc Model for iphone\"\n\n argument :name, :desc => \"The name of your puremvc model\"\n\n class_option :root, :desc => \"The root destination\", :aliases => '-r', :default => \".\", :type => :string\n class_option :destroy, :aliases => '-d', :default => false, :type => :boolean\n\n def in_app_root?\n Dir.glob(\"tiapp.xml\").count >= 1\n end \n\n def create_app\n valid_constant?(options[:template] || name)\n @project_name = (options[:app] || name).gsub(/\\W/, \"_\").downcase\n @class_name = (options[:app] || name).gsub(/\\W/, \"_\").capitalize\n @developer = \"\#{`whoami`.strip}\"\n @created_on = Date.today.to_s\n self.destination_root = options[:root]\n \n eval(File.read(__FILE__) =~ /^__END__\\n/ && $' || '')\n\nsay (<<-TEXT).gsub(/ {10}/,'')\n\n=================================================================\nYour template has been generated.\n=================================================================\n\nTEXT \n end\n\n end # Template\n end # Generators\nend # Puer\n\n__END__\n# put your template command here\n\n"
Instance Method Summary
collapse
Instance Method Details
#creation_call(name, class_name, info) ⇒ Object
17
18
19
20
|
# File 'lib/puer/xibtoti.rb', line 17
def creation_call(name, class_name, info)
"var #{name} = #{class_name}({\n" +
info.keys.sort.map {|key| "\t#{key}:#{inline_js_for(info[key])}"}.join(",\n") + "\n});"
end
|
#inline_js_for(data) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/puer/xibtoti.rb', line 4
def inline_js_for(data)
case data
when Hash
'{' + data.map {|k,v| "#{k}:#{inline_js_for(v)}"}.join(',') + '}'
when String
"'#{data}'"
else
data.to_s
end
end
|
31
32
33
|
# File 'lib/puer/xibtoti.rb', line 31
def text
""
end
|
#js_for(nodes) ⇒ Object
27
28
29
|
# File 'lib/puer/xibtoti.rb', line 27
def js_for(nodes)
nodes.map {|node| js_sections_for(node)}.flatten.join("\n\n")
end
|
#js_sections_for(node) ⇒ Object
22
23
24
25
|
# File 'lib/puer/xibtoti.rb', line 22
def js_sections_for(node)
[creation_call(node.name, node.node_class.creation_call, node.properties)] +
node.subviews.map {|child| [js_sections_for(child), "#{node.name}.add(#{child.name});"]}.flatten
end
|