lib/awestruct/config.rb in awestruct-0.5.3 vs lib/awestruct/config.rb in awestruct-0.5.4.beta1
- old
+ new
@@ -1,5 +1,6 @@
+require 'awestruct/cli/options'
module Awestruct
class Config
@@ -16,25 +17,27 @@
attr_accessor :images_dir
attr_accessor :stylesheets_dir
attr_accessor :verbose
+ attr_accessor :options
- def initialize(dir = Dir.pwd)
- @dir = Pathname.new( dir )
- @layouts_dir = Pathname.new( File.join(dir, '_layouts') )
- @config_dir = Pathname.new( File.join(dir, '_config') )
- @input_dir = Pathname.new( File.join(dir, '') )
- @output_dir = Pathname.new( File.join(dir, '_site') )
- @extension_dir = Pathname.new( File.join(dir, '_ext') )
- @skin_dir = Pathname.new( File.join(dir, '_skin') )
- @tmp_dir = Pathname.new( File.join(dir, '_tmp') )
+ def initialize(opts = Awestruct::CLI::Options.new)
+ @dir = Pathname.new( opts.source_dir )
+ @layouts_dir = Pathname.new( File.join(@dir, '_layouts') )
+ @config_dir = Pathname.new( File.join(@dir, '_config') )
+ @input_dir = Pathname.new( File.join(@dir, '') )
+ @output_dir = Pathname.new( opts.output_dir )
+ @extension_dir = Pathname.new( File.join(@dir, '_ext') )
+ @skin_dir = Pathname.new( File.join(@dir, '_skin') )
+ @tmp_dir = Pathname.new( File.join(@dir, '_tmp') )
- @images_dir = Pathname.new( File.join(dir, 'images') )
- @stylesheets_dir = Pathname.new( File.join(dir, 'stylesheets') )
+ @images_dir = Pathname.new( File.join(@dir, 'images') )
+ @stylesheets_dir = Pathname.new( File.join(@dir, 'stylesheets') )
+ @options = opts
# Dir[] doesn't like empty list
- ignore_file = File.join(dir, ".awestruct_ignore")
+ ignore_file = File.join(@dir, ".awestruct_ignore")
if File.exists?(ignore_file)
ignore_stmts = IO.read(ignore_file).each_line.map(&:strip)
end
@ignore = (!ignore_stmts.nil? and ignore_stmts.size > 0) ? Dir[*ignore_stmts] : []