public
Description: Code as Art, Art as Code. Processing and Ruby are meant for each other.
Homepage: http://github.com/jashkenas/ruby-processing/wikis
Clone URL: git://github.com/jashkenas/ruby-processing.git
Ha ha\! Application exporting for the Mac\!
jashkenas (author)
Fri Apr 18 15:54:48 -0700 2008
commit  7daef75d11faa543bfb82f1028ad8ba1284c8dce
tree    698beaa728984a90b21283dda62fe38f9f5951b8
parent  d8ad434a85bfae52eee0c7d31050b372c0ebefbf
...
31
32
33
34
35
 
36
...
31
32
33
 
34
35
36
0
@@ -31,4 +31,4 @@ class FullScreen < Processing::App
0
   end
0
 end
0
 
0
-FullScreen.new(:full_screen => true)
0
\ No newline at end of file
0
+FullScreen.new(:full_screen => true, :title => "Full Screen")
0
\ No newline at end of file
...
34
35
36
 
37
38
39
...
34
35
36
37
38
39
40
0
@@ -34,6 +34,7 @@ module Processing
0
       # Copy over all the required files
0
       necessary_files = [@main_file_path, "ruby-processing.rb", "core.jar"]
0
       necessary_files << "data" if File.exists?("data")
0
+ necessary_files += Dir.glob("script/base_files/{*,**}") # Base files
0
       necessary_files += Dir.glob("script/applet_files/{*,**}") # Exporter files
0
       necessary_files += Dir.glob("library/{#{libs_to_load.join(",")}}") if libs_to_load.length > 0
0
       cp_r(necessary_files, applet_dir)
...
10
11
12
13
 
14
15
16
...
32
33
34
35
 
 
36
37
38
 
39
40
41
42
 
 
43
44
45
46
47
 
 
 
 
 
 
 
 
 
 
 
 
48
49
50
...
10
11
12
 
13
14
15
16
...
32
33
34
 
35
36
37
38
 
39
40
41
42
43
44
45
46
47
 
 
 
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
0
@@ -10,7 +10,7 @@ module Processing
0
     def export!
0
 
0
       # Check to make sure that the main file exists
0
- @main_file_path, main_file = *get_main_file()
0
+ @main_file_path, @main_file = *get_main_file()
0
       unless PLATFORM.match(/darwin/)
0
         puts <<-ERROR
0
           
0
@@ -32,19 +32,31 @@ module Processing
0
       end
0
       
0
       # Extract all the cool details.
0
- source_code, class_name, title, width, height, description, libs_to_load = *extract_information()
0
+ source_code, @class_name, title, width, height, description, libs_to_load = *extract_information()
0
+ @title = title ? title[1] : "Ruby-Processing Sketch"
0
       
0
       # Make the appropriate directory
0
- app_dir = "applications/#{File.basename(main_file, ".rb")}.app"
0
+ app_dir = "applications/#{@title}.app"
0
       remove_entry_secure app_dir if File.exists?(app_dir)
0
       mkdir_p app_dir
0
       
0
       # Copy over all the required files
0
+ prefix = "Contents/Resources/Java"
0
+ cp_r(Dir.glob("script/application_files/{*,**}"), app_dir)
0
       necessary_files = [@main_file_path, "ruby-processing.rb", "core.jar"]
0
       necessary_files << "data" if File.exists?("data")
0
- necessary_files += Dir.glob("script/application_files/{*,**}") # Exporter files
0
- necessary_files += Dir.glob("library/{#{libs_to_load.join(",")}}") if libs_to_load.length > 0
0
- cp_r(necessary_files, app_dir)
0
+ necessary_files += Dir.glob("script/base_files/{*,**}") # Base files
0
+ cp_r(necessary_files, File.join(app_dir, prefix))
0
+ library_files = Dir.glob("library/{#{libs_to_load.join(",")}}") if libs_to_load.length > 0
0
+ cp_r(library_files, File.join(app_dir, prefix, "library")) if library_files
0
+
0
+ # Figure out the substitutions.
0
+ file_list = Dir.glob(app_dir + "{/**/*.{rb,jar},/data/*.*}").map {|f| f.sub(app_dir + "/", "")}
0
+ @class_path = file_list.map {|f| "$JAVAROOT/" + f.sub(prefix+"/", "") }.join(":")
0
+
0
+ # Do it.
0
+ render_erb_in_path_with_binding(app_dir, binding)
0
+ rm Dir.glob(app_dir + "/**/*.{class,java}")
0
       
0
     end
0
   end
...
1
2
3
 
 
4
5
6
...
21
22
23
24
 
25
26
27
28
29
30
 
 
 
 
 
31
32
33
34
35
36
37
38
39
40
41
...
1
 
 
2
3
4
5
6
...
21
22
23
 
24
25
26
27
28
29
 
30
31
32
33
34
35
36
37
 
38
 
39
 
40
41
42
0
@@ -1,6 +1,6 @@
0
 <?xml version="1.0" encoding="UTF-8"?>
0
-<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
0
-<plist version="0.9">
0
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
0
+<plist version="1.0">
0
 <dict>
0
   <key>CFBundleName</key>
0
   <string><%= @title %></string>
0
@@ -21,21 +21,22 @@
0
   <key>CFBundleIconFile</key>
0
   <string>sketch.icns</string>
0
   <key>CFBundleIdentifier</key>
0
- <string>org.ruby-processing.<%= @short_title %></string>
0
+ <string>org.ruby-processing.<%= @class_name %></string>
0
   <key>Java</key>
0
   <dict>
0
     <key>VMOptions</key>
0
     <string>-Xms128M -Xmx256M</string>
0
     <key>MainClass</key>
0
- <string><%= @main_class %></string>
0
+ <string>RubyLauncher</string>
0
+ <key>WorkingDirectory</key>
0
+ <string>$JAVAROOT</string>
0
+ <key>Arguments</key>
0
+ <string><%= @main_file %></string>
0
     <key>JVMVersion</key>
0
     <string>1.3+</string>
0
     <key>ClassPath</key>
0
- <!--<string>$JAVAROOT/binary_ring.jar:$JAVAROOT/core.jar</string>-->
0
     <string><%= @class_path %></string>
0
-
0
     <key>Properties</key>
0
- <!-- http://developer.apple.com/releasenotes/Java/java141/system_properties/chapter_4_section_1.html#//apple_ref/doc/uid/TP30000285 -->
0
     <dict>
0
       <key>apple.laf.useScreenMenuBar</key>
0
       <string>true</string>
...
36
37
38
 
 
 
 
 
 
 
 
 
39
40
41
...
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
0
@@ -36,6 +36,15 @@ module Processing
0
       return [source_code, class_name, title, width, height, description, libs_to_load]
0
     end
0
     
0
+ def render_erb_in_path_with_binding(path, some_binding)
0
+ erbs = Dir.glob(path + "/**/*.erb")
0
+ erbs.each do |erb|
0
+ rendered = ERB.new(File.new(erb).read, nil, "<>", "rendered").result(some_binding)
0
+ File.open(erb.sub(".erb", ""), "w") {|f| f.print rendered }
0
+ rm erb
0
+ end
0
+ end
0
+
0
     # Ripped from activesupport
0
     def titleize(word)
0
       humanize(underscore(word)).gsub(/\b([a-z])/) { $1.capitalize }

Comments

    No one has commented yet.