lib/jruby_art/creators/creator.rb in jruby_art-0.4.2 vs lib/jruby_art/creators/creator.rb in jruby_art-0.5.0
- old
+ new
@@ -45,10 +45,34 @@
# smooth # here
end
end
CODE
+EMACS_BASIC = <<-CODE
+require 'jruby_art'
+require 'jruby_art/app'
+
+Processing::App::SKETCH_PATH = __FILE__
+
+class %s < Processing::App
+ def setup
+ sketch_title '%s'
+ end
+
+ def draw
+
+ end
+
+ def settings
+ size %s, %s
+ # smooth # here
+ end
+end
+
+%s.new unless defined? $app
+CODE
+
CLASS_MODE = <<-CODE
class %s < Processing::App
def setup
sketch_title '%s'
end
@@ -62,10 +86,34 @@
# smooth # here
end
end
CODE
+EMACS_MODE = <<-CODE
+require 'jruby_art'
+require 'jruby_art/app'
+
+Processing::App::SKETCH_PATH = __FILE__
+
+class %s < Processing::App
+ def setup
+ sketch_title '%s'
+ end
+
+ def draw
+
+ end
+
+ def settings
+ size %s, %s, %s
+ # smooth # here
+ end
+end
+
+%s.new unless defined? $app
+CODE
+
INNER = <<-CODE
class %s
include Processing::Proxy
end
@@ -163,9 +211,34 @@
writer = SketchWriter.new(main_file)
@title = StringExtra.new(main_file).titleize
@width, @height = args[0], args[1]
@mode = args[2].upcase unless args[2].nil?
template = @mode.nil? ? class_template : class_template_mode
+ writer.save(template)
+ end
+ end
+
+ # This class creates class wrapped sketches, with an optional render mode
+ class EmacsSketch < Creator
+ def emacs_template
+ format(EMACS_BASIC, @name, @title, @width, @height, @name)
+ end
+
+ def emacs_template_mode
+ format(EMACS_MODE, @name, @title, @width, @height, @mode, @name)
+ end
+ # Create a class wrapped sketch, given a path.
+ def create!(path, args)
+ return usage if /\?/ =~ path || /--help/ =~ path
+ main_file = File.basename(path, '.rb') # allow uneeded extension input
+ # Check to make sure that the main file doesn't exist already
+ already_exist(path)
+ @name = CamelString.new(main_file).camelize
+ writer = SketchWriter.new(main_file)
+ @title = StringExtra.new(main_file).titleize
+ @width, @height = args[0], args[1]
+ @mode = args[2].upcase unless args[2].nil?
+ template = @mode.nil? ? emacs_template : emacs_template_mode
writer.save(template)
end
end
# This class creates a pseudo 'java inner class' of the sketch