diff --git a/Rakefile b/Rakefile new file mode 100644 index 00000000..35aa0bff --- /dev/null +++ b/Rakefile @@ -0,0 +1,8 @@ + +$:.push "lib" +require "gemsmith.rb" + + +site :odin_lab do + +end \ No newline at end of file diff --git a/lib/gemsmith.rb b/lib/gemsmith.rb new file mode 100644 index 00000000..16d11e54 --- /dev/null +++ b/lib/gemsmith.rb @@ -0,0 +1,46 @@ + +$gemsmith = { + active: nil, + stages: [], +} + +def load_site(in_path, out_path) + Dir["#{in_path}/*"].map do |f| + out_f = "#{out_path}/#{File.basename f}" + if File.symlink? f then + $stderr.puts "Warning: Skipping symlink #{f}" + nil + elsif File.directory? f then + [File.basename(f), [:directory, load_site(f, out_f)]] + else + [File.basename(f), [:file, { + created: File.birthtime(f), + modified: File.mtime(f), + source_path: f, + dependencies: f, + out_path: out_f, + stages: [ proc { File.open(f) {|io| io.readlines} } ] + }]] + end + end +end + + +def site(site_name, params = {}) + + in_path = params.fetch(:src, "src") + out_path = params.fetch(:out, "build/#{site_name}") + + $gemsmith[:active] = { + in_path: in_path, + out_path: out_path, + files: load_site(in_path) + } + + directory $gemsmith[:active][:in_path] + directory $gemsmith[:active][:out_path] + + yield + + $gemsmith[:active] = nil +end \ No newline at end of file