lib/buildmaster/site.rb in BuildMaster-0.6.0 vs lib/buildmaster/site.rb in BuildMaster-0.7.0
- old
+ new
@@ -2,10 +2,11 @@
require 'fileutils'
require 'redcloth'
require 'source_file_handler'
require 'file_processor'
+require 'site_spec'
module BuildMaster
#todo match only beginning of the file
TEXTILE_REGX = /---(-)*\n(.*)\n(-)*---/
@@ -13,55 +14,10 @@
def << message
puts "IGNORED: #{message}"
end
end
- class SiteSpec
- def self.get_instance
- self.new()
- end
-
- attr_accessor :output_dir, :content_dir, :template, :template_file
-
- def validate_inputs
- validate_dir(@content_dir, :content_dir)
- end
-
- def load_template
- if (@template)
- return XTemplate.new(@template)
- else
- return XTemplate.new(File.open(@template_file))
- end
- end
-
- private
- def validate_dir(directory, symbol)
- if not directory
- raise "Directory for #{symbol.id2name} not specified"
- end
- if not File.exists? directory
- raise "Directory for #{symbol.id2name} -- <#{directory}#> does not exist"
- end
- if not File.directory? directory
- raise "<#{directory}> should be a directory for #{symbol.id2name}"
- end
- end
-
- def validate_file(file, symbol)
- if not file
- raise "File for #{symbol.id2name} not specified"
- end
- if (not File.exists? file)
- raise "File for #{symbol.id2name} -- <#{file}> does not exist"
- end
- if not File.file? file
- raise "#<{file} should be a file for #{symbol.id2name}"
- end
- end
- end
-
class Site
def initialize(spec)
@spec = spec
@spec.validate_inputs
@template = @spec.load_template
@@ -71,10 +27,10 @@
def execute(arguments)
action = 'build'
if arguments.size > 0
action = arguments[0]
end
- method(action).call
+ send action
end
def build
@count = 0
build_directory(@spec.output_dir, @spec.content_dir, @template)