candle 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. data/LICENSE.txt +20 -0
  2. data/README.md +4 -0
  3. data/VERSION +1 -0
  4. data/bin/candle +21 -0
  5. data/lib/candle.rb +68 -0
  6. data/lib/candle/command.rb +27 -0
  7. data/lib/candle/generators/actions.rb +183 -0
  8. data/lib/candle/generators/blank.rb +127 -0
  9. data/lib/candle/generators/cli.rb +55 -0
  10. data/lib/candle/generators/help.rb +47 -0
  11. data/lib/candle/generators/jam.rb +80 -0
  12. data/lib/candle/generators/lua/scripts/AppDelegate.lua +36 -0
  13. data/lib/candle/generators/lua/scripts/tests/init.lua +6 -0
  14. data/lib/candle/generators/lua/scripts/tests/someTest.lua +12 -0
  15. data/lib/candle/generators/lua/wax/ProtocolLoader.h +12 -0
  16. data/lib/candle/generators/lua/wax/bin/hammer +157 -0
  17. data/lib/candle/generators/lua/wax/bin/update-xibs +131 -0
  18. data/lib/candle/generators/lua/wax/bin/waxsim +0 -0
  19. data/lib/candle/generators/lua/wax/lib/build-scripts/compile-stdlib.sh +14 -0
  20. data/lib/candle/generators/lua/wax/lib/build-scripts/copy-scripts.sh +58 -0
  21. data/lib/candle/generators/lua/wax/lib/build-scripts/luac.lua +80 -0
  22. data/lib/candle/generators/lua/wax/lib/extensions/CGAffine/wax_CGTransform.h +12 -0
  23. data/lib/candle/generators/lua/wax/lib/extensions/CGAffine/wax_CGTransform.m +85 -0
  24. data/lib/candle/generators/lua/wax/lib/extensions/CGContext/wax_CGContext.h +12 -0
  25. data/lib/candle/generators/lua/wax/lib/extensions/CGContext/wax_CGContext.m +251 -0
  26. data/lib/candle/generators/lua/wax/lib/extensions/HTTP/wax_http.h +14 -0
  27. data/lib/candle/generators/lua/wax/lib/extensions/HTTP/wax_http.m +240 -0
  28. data/lib/candle/generators/lua/wax/lib/extensions/HTTP/wax_http_connection.h +54 -0
  29. data/lib/candle/generators/lua/wax/lib/extensions/HTTP/wax_http_connection.m +304 -0
  30. data/lib/candle/generators/lua/wax/lib/extensions/filesystem/wax_filesystem.h +9 -0
  31. data/lib/candle/generators/lua/wax/lib/extensions/filesystem/wax_filesystem.m +273 -0
  32. data/lib/candle/generators/lua/wax/lib/extensions/json/Rakefile +10 -0
  33. data/lib/candle/generators/lua/wax/lib/extensions/json/wax_json.c +304 -0
  34. data/lib/candle/generators/lua/wax/lib/extensions/json/wax_json.h +11 -0
  35. data/lib/candle/generators/lua/wax/lib/extensions/json/yajl-1.0.9.tar.gz +0 -0
  36. data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/api/yajl_common.h +85 -0
  37. data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/api/yajl_gen.h +159 -0
  38. data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/api/yajl_parse.h +193 -0
  39. data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl.c +159 -0
  40. data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_alloc.c +65 -0
  41. data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_alloc.h +50 -0
  42. data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_buf.c +119 -0
  43. data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_buf.h +73 -0
  44. data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_bytestack.h +85 -0
  45. data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_common.h +85 -0
  46. data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_encode.c +188 -0
  47. data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_encode.h +50 -0
  48. data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_gen.c +322 -0
  49. data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_gen.h +159 -0
  50. data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_lex.c +737 -0
  51. data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_lex.h +133 -0
  52. data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_parse.h +193 -0
  53. data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_parser.c +448 -0
  54. data/lib/candle/generators/lua/wax/lib/extensions/json/yajl/yajl_parser.h +82 -0
  55. data/lib/candle/generators/lua/wax/lib/lua/lapi.c +1087 -0
  56. data/lib/candle/generators/lua/wax/lib/lua/lapi.h +16 -0
  57. data/lib/candle/generators/lua/wax/lib/lua/lauxlib.c +652 -0
  58. data/lib/candle/generators/lua/wax/lib/lua/lauxlib.h +174 -0
  59. data/lib/candle/generators/lua/wax/lib/lua/lbaselib.c +653 -0
  60. data/lib/candle/generators/lua/wax/lib/lua/lcode.c +839 -0
  61. data/lib/candle/generators/lua/wax/lib/lua/lcode.h +76 -0
  62. data/lib/candle/generators/lua/wax/lib/lua/ldblib.c +397 -0
  63. data/lib/candle/generators/lua/wax/lib/lua/ldebug.c +638 -0
  64. data/lib/candle/generators/lua/wax/lib/lua/ldebug.h +33 -0
  65. data/lib/candle/generators/lua/wax/lib/lua/ldo.c +518 -0
  66. data/lib/candle/generators/lua/wax/lib/lua/ldo.h +57 -0
  67. data/lib/candle/generators/lua/wax/lib/lua/ldump.c +164 -0
  68. data/lib/candle/generators/lua/wax/lib/lua/lfunc.c +174 -0
  69. data/lib/candle/generators/lua/wax/lib/lua/lfunc.h +34 -0
  70. data/lib/candle/generators/lua/wax/lib/lua/lgc.c +711 -0
  71. data/lib/candle/generators/lua/wax/lib/lua/lgc.h +110 -0
  72. data/lib/candle/generators/lua/wax/lib/lua/linit.c +38 -0
  73. data/lib/candle/generators/lua/wax/lib/lua/liolib.c +553 -0
  74. data/lib/candle/generators/lua/wax/lib/lua/llex.c +461 -0
  75. data/lib/candle/generators/lua/wax/lib/lua/llex.h +81 -0
  76. data/lib/candle/generators/lua/wax/lib/lua/llimits.h +128 -0
  77. data/lib/candle/generators/lua/wax/lib/lua/lmathlib.c +263 -0
  78. data/lib/candle/generators/lua/wax/lib/lua/lmem.c +86 -0
  79. data/lib/candle/generators/lua/wax/lib/lua/lmem.h +49 -0
  80. data/lib/candle/generators/lua/wax/lib/lua/loadlib.c +666 -0
  81. data/lib/candle/generators/lua/wax/lib/lua/lobject.c +214 -0
  82. data/lib/candle/generators/lua/wax/lib/lua/lobject.h +381 -0
  83. data/lib/candle/generators/lua/wax/lib/lua/lopcodes.c +102 -0
  84. data/lib/candle/generators/lua/wax/lib/lua/lopcodes.h +268 -0
  85. data/lib/candle/generators/lua/wax/lib/lua/loslib.c +243 -0
  86. data/lib/candle/generators/lua/wax/lib/lua/lparser.c +1339 -0
  87. data/lib/candle/generators/lua/wax/lib/lua/lparser.h +82 -0
  88. data/lib/candle/generators/lua/wax/lib/lua/lstate.c +214 -0
  89. data/lib/candle/generators/lua/wax/lib/lua/lstate.h +169 -0
  90. data/lib/candle/generators/lua/wax/lib/lua/lstring.c +111 -0
  91. data/lib/candle/generators/lua/wax/lib/lua/lstring.h +31 -0
  92. data/lib/candle/generators/lua/wax/lib/lua/lstrlib.c +869 -0
  93. data/lib/candle/generators/lua/wax/lib/lua/ltable.c +588 -0
  94. data/lib/candle/generators/lua/wax/lib/lua/ltable.h +40 -0
  95. data/lib/candle/generators/lua/wax/lib/lua/ltablib.c +287 -0
  96. data/lib/candle/generators/lua/wax/lib/lua/ltm.c +75 -0
  97. data/lib/candle/generators/lua/wax/lib/lua/ltm.h +54 -0
  98. data/lib/candle/generators/lua/wax/lib/lua/lua.h +388 -0
  99. data/lib/candle/generators/lua/wax/lib/lua/luaconf.h +753 -0
  100. data/lib/candle/generators/lua/wax/lib/lua/lualib.h +53 -0
  101. data/lib/candle/generators/lua/wax/lib/lua/lundump.c +227 -0
  102. data/lib/candle/generators/lua/wax/lib/lua/lundump.h +36 -0
  103. data/lib/candle/generators/lua/wax/lib/lua/lvm.c +763 -0
  104. data/lib/candle/generators/lua/wax/lib/lua/lvm.h +36 -0
  105. data/lib/candle/generators/lua/wax/lib/lua/lzio.c +82 -0
  106. data/lib/candle/generators/lua/wax/lib/lua/lzio.h +67 -0
  107. data/lib/candle/generators/lua/wax/lib/lua/print.c +227 -0
  108. data/lib/candle/generators/lua/wax/lib/project.rake +159 -0
  109. data/lib/candle/generators/lua/wax/lib/stdlib/enums.lua +396 -0
  110. data/lib/candle/generators/lua/wax/lib/stdlib/ext/http.lua +43 -0
  111. data/lib/candle/generators/lua/wax/lib/stdlib/ext/init.lua +4 -0
  112. data/lib/candle/generators/lua/wax/lib/stdlib/ext/number.lua +21 -0
  113. data/lib/candle/generators/lua/wax/lib/stdlib/ext/string.lua +97 -0
  114. data/lib/candle/generators/lua/wax/lib/stdlib/ext/table.lua +165 -0
  115. data/lib/candle/generators/lua/wax/lib/stdlib/helpers/WaxServer.lua +49 -0
  116. data/lib/candle/generators/lua/wax/lib/stdlib/helpers/autoload.lua +10 -0
  117. data/lib/candle/generators/lua/wax/lib/stdlib/helpers/base64.lua +64 -0
  118. data/lib/candle/generators/lua/wax/lib/stdlib/helpers/bit.lua +274 -0
  119. data/lib/candle/generators/lua/wax/lib/stdlib/helpers/cache.lua +73 -0
  120. data/lib/candle/generators/lua/wax/lib/stdlib/helpers/callback.lua +22 -0
  121. data/lib/candle/generators/lua/wax/lib/stdlib/helpers/frame.lua +76 -0
  122. data/lib/candle/generators/lua/wax/lib/stdlib/helpers/init.lua +78 -0
  123. data/lib/candle/generators/lua/wax/lib/stdlib/helpers/pickView.lua +54 -0
  124. data/lib/candle/generators/lua/wax/lib/stdlib/helpers/time.lua +102 -0
  125. data/lib/candle/generators/lua/wax/lib/stdlib/init.lua +18 -0
  126. data/lib/candle/generators/lua/wax/lib/stdlib/luaspec/init.lua +2 -0
  127. data/lib/candle/generators/lua/wax/lib/stdlib/luaspec/luamock.lua +84 -0
  128. data/lib/candle/generators/lua/wax/lib/stdlib/luaspec/luaspec.lua +377 -0
  129. data/lib/candle/generators/lua/wax/lib/stdlib/repl.lua +9 -0
  130. data/lib/candle/generators/lua/wax/lib/stdlib/structs.lua +11 -0
  131. data/lib/candle/generators/lua/wax/lib/stdlib/waxClass.lua +42 -0
  132. data/lib/candle/generators/lua/wax/lib/wax.h +16 -0
  133. data/lib/candle/generators/lua/wax/lib/wax.m +260 -0
  134. data/lib/candle/generators/lua/wax/lib/wax_class.h +18 -0
  135. data/lib/candle/generators/lua/wax/lib/wax_class.m +190 -0
  136. data/lib/candle/generators/lua/wax/lib/wax_gc.h +20 -0
  137. data/lib/candle/generators/lua/wax/lib/wax_gc.m +56 -0
  138. data/lib/candle/generators/lua/wax/lib/wax_helpers.h +102 -0
  139. data/lib/candle/generators/lua/wax/lib/wax_helpers.m +870 -0
  140. data/lib/candle/generators/lua/wax/lib/wax_instance.h +34 -0
  141. data/lib/candle/generators/lua/wax/lib/wax_instance.m +810 -0
  142. data/lib/candle/generators/lua/wax/lib/wax_server.h +47 -0
  143. data/lib/candle/generators/lua/wax/lib/wax_server.m +252 -0
  144. data/lib/candle/generators/lua/wax/lib/wax_stdlib.h +3 -0
  145. data/lib/candle/generators/lua/wax/lib/wax_struct.h +26 -0
  146. data/lib/candle/generators/lua/wax/lib/wax_struct.m +335 -0
  147. data/lib/candle/generators/templates/blank/WaxApplication.xcodeproj/project.pbxproj +836 -0
  148. data/lib/candle/generators/templates/blank/WaxApplication.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  149. data/lib/candle/generators/templates/blank/WaxApplication.xcodeproj/project.xcworkspace/xcuserdata/eiffel.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  150. data/lib/candle/generators/templates/blank/WaxApplication.xcodeproj/xcuserdata/eiffel.xcuserdatad/xcschemes/WaxApplication.xcscheme +86 -0
  151. data/lib/candle/generators/templates/blank/WaxApplication.xcodeproj/xcuserdata/eiffel.xcuserdatad/xcschemes/xcschememanagement.plist +22 -0
  152. data/lib/candle/generators/templates/blank/WaxApplication/Default-568h@2x.png +0 -0
  153. data/lib/candle/generators/templates/blank/WaxApplication/Default.png +0 -0
  154. data/lib/candle/generators/templates/blank/WaxApplication/Default@2x.png +0 -0
  155. data/lib/candle/generators/templates/blank/WaxApplication/ProtocolLoader.h +12 -0
  156. data/lib/candle/generators/templates/blank/WaxApplication/WaxApplication-Info.plist.tt +38 -0
  157. data/lib/candle/generators/templates/blank/WaxApplication/WaxApplication-Prefix.pch.tt +14 -0
  158. data/lib/candle/generators/templates/blank/WaxApplication/en.lproj/InfoPlist.strings +2 -0
  159. data/lib/candle/generators/templates/blank/WaxApplication/main.m.tt +20 -0
  160. data/lib/candle/tasks.rb +22 -0
  161. data/lib/candle/utility.rb +30 -0
  162. data/lib/candle/version.rb +9 -0
  163. data/lib/candle/view.rb +48 -0
  164. metadata +582 -0
@@ -0,0 +1,55 @@
1
+ require 'rubygems'
2
+ require 'thor/group'
3
+ require 'cli-colorize'
4
+ require 'hirb'
5
+
6
+ module Candle
7
+ module Generators
8
+ ##
9
+ # This class bootstrap +config/boot+ and perform +Candle::Generators.load_components!+ for handle
10
+ # 3rd party generators
11
+ #
12
+ class Cli < Thor::Group
13
+ include CLIColorize
14
+
15
+ CLIColorize.default_color = :red
16
+
17
+ RENDER_OPTIONS = { :fields => [:category,:command,:description] }
18
+ # Include related modules
19
+ include Thor::Actions
20
+ desc "Candle Version:\t#{Candle::Version::STRING}"
21
+ class_option :help, :desc => "Help screen", :aliases => '-h', :type => :string
22
+
23
+ # We need to TRY to load boot because some of our app dependencies maybe have
24
+ # custom generators, so is necessary know who are.
25
+ def load_boot
26
+ begin
27
+ ENV['BUNDLE_GEMFILE'] = File.join(options[:root], "Gemfile") if options[:root]
28
+ rescue Exception => e
29
+ puts "=> Problem loading #{boot}"
30
+ puts ["=> #{e.message}", *e.backtrace].join("\n ")
31
+ end
32
+ end
33
+
34
+ def setup
35
+ Candle::Generators.load_components!
36
+
37
+ generator_kind = ARGV.delete_at(0).to_s.downcase.to_sym if ARGV[0].present?
38
+ generator_class = Candle::Generators.mappings[generator_kind]
39
+ if generator_class
40
+ args = ARGV.empty? && generator_class.require_arguments? ? ["-h"] : ARGV
41
+ generator_class.start(args)
42
+ else
43
+ puts colorize( "Candle Version: #{Candle::Version::STRING}", { :foreground => :red, :background => :white, :config => :underline } )
44
+ puts
45
+ puts "Candle is a rubygem for wax iOS framework which writes iOS application in lua, it contains xcode 4 template generators."
46
+ puts
47
+ puts colorize("For more information")
48
+ puts
49
+ puts "puer help"
50
+ puts
51
+ end
52
+ end
53
+ end # Cli
54
+ end # Generators
55
+ end # Candle
@@ -0,0 +1,47 @@
1
+ require 'rubygems'
2
+ require 'cli-colorize'
3
+ require 'thor/group'
4
+ require 'hirb'
5
+
6
+ require File.dirname(__FILE__) + '/jam'
7
+
8
+ module Candle
9
+ module Generators
10
+ class Help < Jam
11
+ include CLIColorize
12
+
13
+ CLIColorize.default_color = :red
14
+ RENDER_OPTIONS = { :fields => [:category,:command,:description] }
15
+
16
+ # Add this generator to our candle
17
+ Candle::Generators.add_generator(:help, self)
18
+
19
+ # Define the source root
20
+ def self.source_root; File.expand_path(File.dirname(__FILE__)); end
21
+ def self.banner; "candle help"; end
22
+
23
+ # Include related modules
24
+ include Thor::Actions
25
+ include Candle::Generators::Actions
26
+
27
+ desc "Description:\n\n\tcandle help screen"
28
+ argument :name, :default => ""
29
+
30
+ def create_help
31
+ @developer = "eiffel"
32
+ @created_on = Date.today.to_s
33
+ puts colorize( "Candle Version: #{Candle::Version::STRING}", { :foreground => :red, :background => :white, :config => :underline } )
34
+ puts
35
+ puts "Candle is a wax iOS code generators tool."
36
+ puts
37
+ puts colorize("Generator Options")
38
+ opt = [{ :category => "generators", :command => "candle blank todo", :description => "generate a wax blank iOS project"}
39
+ ]
40
+ View.render(opt, RENDER_OPTIONS)
41
+ puts
42
+ end
43
+
44
+ end # Search
45
+ end # Generators
46
+ end # Candle
47
+
@@ -0,0 +1,80 @@
1
+ require 'thor'
2
+ require 'hirb'
3
+ require 'thor/group'
4
+ require 'thor/actions'
5
+ require 'active_support/core_ext/string'
6
+ require 'active_support/inflector'
7
+ require 'date'
8
+ require File.dirname(__FILE__) + '/actions'
9
+ require File.dirname(__FILE__) + '/../view'
10
+
11
+ module Candle
12
+ module Generators
13
+ class Jam < Thor::Group
14
+
15
+ def self.init_generator
16
+ # Define the source template root
17
+ def self.source_root; File.expand_path(File.dirname(__FILE__)); end
18
+ def self.banner; "candle #{self.to_s.downcase.intern} [name]"; end
19
+
20
+ # Include related modules
21
+ include Thor::Actions
22
+ include Candle::Generators::Actions
23
+ end
24
+
25
+ def self.parseTemplate(data)
26
+ eval(data)
27
+ end
28
+
29
+ desc "Description:\n\n\tthis should not be used, only acts as Parent Class"
30
+
31
+ argument :name, :desc => "The name of your #{self.to_s.downcase.intern}"
32
+
33
+ class_option :root, :desc => "The root destination", :aliases => '-r', :default => ".", :type => :string
34
+ class_option :destroy, :aliases => '-d', :default => false, :type => :boolean
35
+
36
+ def in_app_root?
37
+ # File.exist?('Classes')
38
+ Dir.glob("*.xcodeproj").count >= 1
39
+ end
40
+
41
+ def create_jam
42
+ valid_constant?(options["#{self.to_s.downcase.intern}"] || name)
43
+ @jam_name = (options["#{self.to_s.downcase.intern}"] || name).gsub(/\W/, "_").downcase
44
+ @developer = "#{`whoami`.strip}"
45
+ @created_on = Date.today.to_s
46
+ self.destination_root = options[:root]
47
+ project = options["#{self.to_s.downcase.intern}"]
48
+ self.behavior = :revoke if options[:destroy]
49
+
50
+ #empty_directory "#{@jam_name}"
51
+
52
+ # View.render(options)
53
+ # say (<<-TEXT).gsub(/ {10}/,'')
54
+ #
55
+ # =================================================================
56
+ # Your #{@jam_name} has been generated.
57
+ # =================================================================
58
+ #
59
+ # TEXT
60
+ end
61
+
62
+ class << self
63
+ # The methods below define the JAM DSL.
64
+ attr_reader :stable, :unstable
65
+
66
+ def self.attr_rw(*attrs)
67
+ attrs.each do |attr|
68
+ class_eval %Q{
69
+ def #{attr}(val=nil)
70
+ val.nil? ? @#{attr} : @#{attr} = val
71
+ end
72
+ }
73
+ end
74
+ end
75
+ attr_rw :version, :homepage, :author, :email, :data
76
+ end
77
+
78
+ end # Jam
79
+ end # Generators
80
+ end # Candle
@@ -0,0 +1,36 @@
1
+ waxClass{"AppDelegate", protocols = {"UIApplicationDelegate"}}
2
+
3
+ -- Well done! You are almost ready to run a lua app on your iPhone!
4
+ --
5
+ -- Just run the app (⌘↵) in the simulator or on a device!
6
+ -- You will see a dull, bland "hello world" app (it is your job to spice it up.)
7
+ --
8
+ -- If your prefer using TextMate to edit the Lua code just type
9
+ -- 'rake tm' from the command line to setup a wax TextMate project.
10
+ --
11
+ -- What's next?
12
+ -- 1. Check out some of the example apps to learn how to do
13
+ -- more complicated apps.
14
+ -- 2. Then you start writing your app!
15
+ -- 3. Let us know if you need any help at http://groups.google.com/group/iphonewax
16
+
17
+ function applicationDidFinishLaunching(self, application)
18
+ local frame = UIScreen:mainScreen():bounds()
19
+ self.window = UIWindow:initWithFrame(frame)
20
+ self.window:setBackgroundColor(UIColor:colorWithRed_green_blue_alpha(0.196, 0.725, 0.702, 1))
21
+
22
+ local label = UILabel:initWithFrame(CGRect(0, 100, 320, 40))
23
+ label:setFont(UIFont:boldSystemFontOfSize(30))
24
+ label:setColor(UIColor:whiteColor())
25
+ label:setBackgroundColor(UIColor:colorWithRed_green_blue_alpha(0.173, 0.651, 0.627, 1))
26
+ label:setText("Hello Lua!")
27
+ label:setTextAlignment(UITextAlignmentCenter)
28
+ self.window:addSubview(label)
29
+
30
+ self.window:makeKeyAndVisible()
31
+
32
+ puts("")
33
+ puts("-------------------------------------------------")
34
+ puts("- You can print stuff to the console like this! -")
35
+ puts("-------------------------------------------------")
36
+ end
@@ -0,0 +1,6 @@
1
+ require "wax.luaspec"
2
+
3
+ require "tests.someTest"
4
+
5
+ print("\nResults\n-------")
6
+ spec:report()
@@ -0,0 +1,12 @@
1
+ describe["Some Test"] = function()
2
+ it["can test!"] = function()
3
+ expect(1).should_be(1)
4
+ expect(1).should_not_be(2)
5
+ expect("hi mystery person123").should_match("person%d+")
6
+ expect(string.match).should_exist()
7
+ expect(string.crazy).should_not_exist()
8
+
9
+ local func = function() empty.nothing() end
10
+ expect(func).should_error()
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ // Many protocols will work from wax out of the box. But some need to be preloaded.
2
+ // If the protocol you are using isn't found, just add the protocol to this object
3
+ //
4
+ // This seems to be a bug, or there is a runtime method I'm unaware of
5
+
6
+ #import <UIKit/UIKit.h>
7
+
8
+ @interface ProtocolLoader : NSObject <UIApplicationDelegate, UIWebViewDelegate, UIActionSheetDelegate, UIAlertViewDelegate, UISearchBarDelegate, UITextViewDelegate, UITabBarControllerDelegate, UISearchDisplayDelegate> {}
9
+ @end
10
+
11
+ @implementation ProtocolLoader
12
+ @end
@@ -0,0 +1,157 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # ---------------------
4
+ # Builds xcode projects
5
+ # ---------------------
6
+
7
+ require 'optparse'
8
+ require 'ostruct'
9
+ require 'fileutils'
10
+ require 'open3'
11
+ require 'stringio'
12
+
13
+ $stdout.sync = true
14
+
15
+ class Hammer
16
+ @args = {"-configuration" => "Debug"}
17
+ @settings = {}
18
+
19
+ @should_run_headless = false
20
+ @should_run = false
21
+ @verbose = false
22
+ @device = "iphone"
23
+
24
+ def self.setup
25
+ opts = OptionParser.new do |opts|
26
+ opts.banner = "Description: Builds an iPhone app and optionaly will run it in the simulator"
27
+ opts.banner = "Usage: hammer [options]"
28
+ opts.on("-h", "--help", "Help stuff") do
29
+ puts opts
30
+ exit
31
+ end
32
+
33
+ opts.on("-c", "--configuration ARG", "Debug? Release?") do |v|
34
+ @args["-configuration"] = v
35
+ end
36
+
37
+ opts.on("-o", "--outputname ARG", "Name of the executable") do |v|
38
+ v.gsub!(/\.app$/, "") # .app is automatically added by xcode
39
+ @settings["CONFIGURATION_BUILD_DIR"]= "."
40
+ @settings["PRODUCT_NAME"] = v
41
+ end
42
+
43
+ opts.on("-h", "--headless", "Just runs the app from the command line, no simulator") do
44
+ @should_run_headless = true
45
+ end
46
+
47
+ opts.on("-r", "--run", "Run the app in the simulator") do
48
+ @should_run = true
49
+
50
+ end
51
+
52
+ opts.on("-d", "--device ARG", "Choose what device to run on (iphone/ipad)") do |v|
53
+ @device = v
54
+ end
55
+
56
+ opts.on("-s", "--sdk ARG", "Choose he SDK. Use --showsdks to see options.") do |v|
57
+ v = "iphonesimulator#{v}" if v =~ /^[\d\.]+/ # if only the version is given... assume user wants a simulator build
58
+ @args["-sdk"] = v
59
+ end
60
+
61
+ opts.on("-v", "--verbose", "blah blah blah.") do |v|
62
+ @verbose = v
63
+ end
64
+
65
+ opts.on("--showsdks", "Lists available SDKS.") do
66
+ output = `xcodebuild -showsdks`
67
+ sdks = output.scan(/-sdk (.*?$)/m)
68
+ puts "Availible sdks:"
69
+ sdks.each {|sdk| puts " #{sdk}"}
70
+
71
+ exit
72
+ end
73
+ end.parse!
74
+
75
+ # if no sdk given, default to the most recent simulator build
76
+ if !@args["-sdk"]
77
+ output = `xcodebuild -showsdks`
78
+ sdks = output.scan(/-sdk (.*?$)/m).map {|a| a.join}
79
+
80
+ if @device !~ /pad/i # remove sdk version 3.2, it is ipad only
81
+ sdks.reject! {|a| a =~ /3.2$/}
82
+ end
83
+
84
+ @args["-sdk"] = sdks.find_all {|sdk| sdk =~ /iphonesimulator/}.sort.last
85
+ end
86
+ end
87
+
88
+ def self.build # Build the app
89
+ extra_args = ARGV
90
+
91
+ extra_args += ["build"] if extra_args.empty?
92
+ arg_string = @args.collect {|k, v| v ? "#{k} #{v}" : k}.join(" ")
93
+ setting_string = @settings.collect {|k, v| v ? "#{k}=#{v}" : k}.join(" ")
94
+ cmd = "xcodebuild #{arg_string} #{setting_string} #{extra_args.join(' ')}"
95
+ puts cmd if @verbose
96
+
97
+ output = `#{cmd}`
98
+ successful = ($? == 0)
99
+
100
+ if @verbose or not successful
101
+ puts output
102
+ if not successful
103
+ puts("** BUILD FAILED **")
104
+ exit 1
105
+ end
106
+ end
107
+
108
+ # Take on the builds ENV
109
+ output.scan(/^\s*(\w+)=(.*?)$/).each {|k,v| ENV[k] = v}
110
+
111
+ return output
112
+ end
113
+
114
+ def self.headless
115
+ return if not @should_run_headless
116
+ if ENV["PLATFORM_NAME"] !~ /simulator/
117
+ puts "Can only be run on the simulator not #{ENV["PLATFORM_NAME"]}"
118
+ exit 1
119
+ end
120
+
121
+ `/usr/bin/killall "iPhone Simulator" 2> /dev/null` #make sure the simulator is killed
122
+
123
+ # See http://developer.apple.com/technotes/tn2004/tn2124.html for an explanation of these environment variables.
124
+ ENV["DYLD_ROOT_PATH"] = ENV["SDKROOT"]
125
+ ENV["DYLD_FRAMEWORK_PATH"] = ENV["CONFIGURATION_BUILD_DIR"]
126
+ ENV["IPHONE_SIMULATOR_ROOT"] = ENV["SDKROOT"]
127
+ ENV["CFFIXED_USER_HOME"] = ENV["TEMP_FILES_DIR"] + "/iPhone Simulator User Dir"
128
+
129
+ FileUtils.rm_rf(ENV["CFFIXED_USER_HOME"]) if File.exists?(ENV["CFFIXED_USER_HOME"])
130
+ FileUtils.mkdir_p(ENV["CFFIXED_USER_HOME"] + "/Documents")
131
+
132
+ system("#{self.app_path}/#{ENV['EXECUTABLE_NAME']} -RegisterForSystemEvents")
133
+
134
+ exit 0
135
+ end
136
+
137
+ def self.run
138
+ return if not @should_run
139
+ `/usr/bin/killall "iPhone Simulator" 2> /dev/null` #make sure the simulator is killed
140
+ sdk_version = @args["-sdk"][/([\d\.]+)/, 1]
141
+ cmd = "wax/bin/waxsim -d #{@device} -s #{sdk_version} #{self.app_path} #{File.expand_path('.')}"
142
+ puts cmd
143
+ system cmd
144
+ end
145
+
146
+ def self.app_path
147
+ return "#{ENV['TARGET_BUILD_DIR']}/#{ENV['EXECUTABLE_FOLDER_PATH']}"
148
+ end
149
+ end
150
+
151
+ Hammer.setup
152
+
153
+ Hammer.build
154
+
155
+ Hammer.headless
156
+
157
+ Hammer.run
@@ -0,0 +1,131 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'xml'
5
+ require 'erb'
6
+
7
+ PROJECT_DIR = Dir.pwd
8
+ XML.indent_tree_output = true
9
+ XML.default_tree_indent_string = "\t"
10
+
11
+ class LuaClass
12
+ attr :class_name
13
+ attr :superclass_name
14
+ attr :outlets
15
+ attr :actions
16
+
17
+ def self.all
18
+ lua_files = Dir["#{PROJECT_DIR}/**/*.lua"]
19
+ lua_files.map {|f| parse(open(f).read)}.compact
20
+ end
21
+
22
+ def self.parse(string)
23
+ if string =~ /waxClass[{(\s]+(.*?)[})\s]+$/
24
+ arguments = $1.split(/\s*,\s*/).map {|a| a.sub(/^['"]([^'"]+).*/, "\\1")}
25
+
26
+ class_name = arguments[0]
27
+ superclass_name = arguments[1]
28
+ superclass_name = nil if arguments[1] and arguments[1] =~ /=/ # Don't want no protocols!
29
+
30
+ return new(class_name, superclass_name, string)
31
+ end
32
+
33
+ return nil
34
+ end
35
+
36
+ def initialize(class_name, superclass_name, contents)
37
+ @class_name = class_name
38
+ @superclass_name = superclass_name
39
+ @outlets = contents.scan(/IBOutlet\s+[\s"'(]+([^"']+)[\s)"']/).map {|o| o[0]}
40
+ @actions = contents.scan(/function\s+(\w+).*?--\s*IBA/i).map {|o| o[0]}
41
+ end
42
+
43
+ def to_xml
44
+ @@template ||= DATA.read
45
+
46
+ xml = ERB.new(@@template, 0, "-").result(binding)
47
+ doc = XML::Parser.string(xml, :encoding => XML::Encoding::UTF_8, :options => XML::Parser::Options::NOBLANKS).parse
48
+ doc.root
49
+ end
50
+ end
51
+
52
+ # A bunch of helper methods
53
+ def xib_files
54
+ xibs = Dir["#{PROJECT_DIR}/**/*.xib"]
55
+ xibs.reject! {|f| f =~ /^#{Regexp.escape PROJECT_DIR}\/wax/} # Don't include any of the xibs in the wax folder
56
+
57
+ xibs
58
+ end
59
+
60
+ classes_as_xml = LuaClass.all.map {|o| o.to_xml}
61
+
62
+ for xib_file in xib_files
63
+ puts(xib_file)
64
+ doc = XML::Document.file(xib_file, :encoding => XML::Encoding::UTF_8, :options => XML::Parser::Options::NOBLANKS)
65
+ ib_classes = doc.find("//object[@key='IBDocument.Classes']").first
66
+
67
+ doc.find("//object[@key='referencedPartialClassDescriptions']").each {|e| e.remove!}
68
+ class_descriptions = XML::Node.new("object")
69
+ class_descriptions["class"] = "NSMutableArray"
70
+ class_descriptions["key"] = "referencedPartialClassDescriptions"
71
+
72
+ encoding_node = XML::Node.new("bool")
73
+ encoding_node['key'] = "EncodedWithXMLCoder"
74
+ encoding_node.content = "YES"
75
+ class_descriptions << encoding_node
76
+
77
+ ib_classes << class_descriptions
78
+
79
+ class_descriptions.find("object[@class='IBPartialClassDescription']").each {|e| e.remove!}
80
+ classes_as_xml.each {|e| class_descriptions << e.copy(true)}
81
+ doc.save(xib_file)
82
+ end
83
+
84
+
85
+ __END__
86
+ <object class="IBPartialClassDescription">
87
+ <string key="className"><%= @class_name %></string>
88
+ <string key="superclassName"><%= @superclass_name or "NSObject" %></string>
89
+
90
+ <%- if @outlets.any? -%>
91
+ <object class="NSMutableDictionary" key="outlets">
92
+ <bool key="EncodedWithXMLCoder">YES</bool>
93
+ <object class="NSArray" key="dict.sortedKeys">
94
+ <bool key="EncodedWithXMLCoder">YES</bool>
95
+ <%- for outlet in @outlets -%>
96
+ <string><%= outlet %></string>
97
+ <%- end -%>
98
+ </object>
99
+ <object class="NSMutableArray" key="dict.values">
100
+ <bool key="EncodedWithXMLCoder">YES</bool>
101
+ <%- for outlet in @outlets -%>
102
+ <string>id</string>
103
+ <%- end -%>
104
+ </object>
105
+ </object>
106
+ <%- end -%>
107
+
108
+ <%- if @actions.any? -%>
109
+ <object class="NSMutableDictionary" key="actions">
110
+ <bool key="EncodedWithXMLCoder">YES</bool>
111
+ <object class="NSArray" key="dict.sortedKeys">
112
+ <bool key="EncodedWithXMLCoder">YES</bool>
113
+ <%- for action in @actions -%>
114
+ <string><%= action %>:</string>
115
+ <%- end -%>
116
+ </object>
117
+ <object class="NSMutableArray" key="dict.values">
118
+ <bool key="EncodedWithXMLCoder">YES</bool>
119
+ <%- for action in actions -%>
120
+ <string>id</string>
121
+ <%- end -%>
122
+ </object>
123
+ </object>
124
+ <%- end -%>
125
+
126
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
127
+ <string key="majorKey">IBUserSource</string>
128
+ <string key="minorKey"/>
129
+ </object>
130
+ </object>
131
+