lib/xmvc/generators/base.rb in xmvc-0.1.0 vs lib/xmvc/generators/base.rb in xmvc-0.1.1
- old
+ new
@@ -7,31 +7,33 @@
TEMPLATE_PATH = "#{File.dirname(__FILE__)}/templates"
def initialize *args
@gsubs ||= {}
- @gsubs['namespace'] = Xmvc.environment['namespace']
+ @gsubs['namespace'] = "development" #Xmvc.environment['namespace']
end
protected
def ensure_directories_present! *args
args.each do |a|
- Dir.mkdir(a) unless File.exists?(a)
+ path = public_path(a)
+ Dir.mkdir(path) unless File.exists?(path)
end
end
def ensure_no_overwrite! *args
args.each do |a|
- if File.exists?(a) && !ARGV.include?("--force")
+ path = public_path(a)
+ if File.exists?(path) && !ARGV.include?("--force")
raise Xmvc::FileExists.new("File already exists: #{a}")
end
end
end
def template(template_filename, destination_filename)
#write the file
- File.open(destination_filename, 'w') {|f| f.puts(render_template(template_filename))}
+ File.open(public_path(destination_filename), 'w') {|f| f.puts(render_template(template_filename))}
Xmvc.ui.confirm(" Created #{destination_filename}")
end
def render_template(template_filename, gsubs = @gsubs)
@@ -49,17 +51,24 @@
def include_script html_filename, script_filename, dom_id
end
private
-
+
+ def public_path(f)
+ File.join("public", f)
+ end
+
##
# write a newly generated controller, model or view to environment.json
# Unfortunately, we cannot JSON.parse the entire config/environment.json, since it contains comments
# and such. Have to RegExp, pick-out the requested key, and JSON.parse the returned chunk.
# Is this Regexp satisfactory?? Could probably be made better.
#
def to_environment(key, item)
+ Xmvc.ui.warn('Generator::Base#to_environment disabled')
+ return
+
re = Regexp.new("\"#{key}\"\s*\:\s*(\\[.*?\\](?!\}))", Regexp::MULTILINE)
content = File.read('config/environment.json')
m = content.match(re)
if m
begin
\ No newline at end of file