lib/sitefuel/SiteFuelRuntime.rb in sitefuel-0.1.0a vs lib/sitefuel/SiteFuelRuntime.rb in sitefuel-0.1.0b
- old
+ new
@@ -14,10 +14,11 @@
module SiteFuel
require 'optparse'
require 'term/ansicolor'
+ require 'fileutils'
include Term::ANSIColor
require 'sitefuel/SiteFuelLogger'
@@ -32,11 +33,11 @@
require 'sitefuel/external/SVN'
require 'sitefuel/external/GIT'
# version of SiteFuel
- VERSION = [0, 1, '0a'].freeze
+ VERSION = [0, 1, '0b'].freeze
# a human readable version
VERSION_TEXT = VERSION.join('.').freeze
@@ -245,10 +246,12 @@
end
# pulls files out of a given repository or file system
def pull
+ section_divider 'Pulling'
+
if @scm_system == nil
@scm_system = classify_repository_system!(@deploy_from)
info "Using #{@scm_system} version control to access #{@deploy_from}"
end
@@ -277,10 +280,26 @@
rescue External::ProgramExitedWithFailure => exception
fatal "Couldn't pull files from SCM:\n#{exception}"
end
+
+ # given a file name will remove the staging directory from it and give
+ # just the base name for the resource
+ def get_base_resource_name(filename)
+ filename.gsub(Regexp.new('^'+Regexp.escape(@staging_directory)), '')
+ end
+
+
+ # given a source file name will remove the staging directory and give the
+ # fully qualified fully qualified name to which this resource is being
+ # deployed
+ def get_full_deployed_name(filename)
+ File.join(@deploy_to, get_base_resource_name(filename))
+ end
+
+
# implements the stage command. Staging, by itself, will give statistics on
# the deployment; how many bytes were saved by minification; etc.
#
# However, #stage when part of #deploy will go and create the requisite files
# in a temporary directory
@@ -302,11 +321,12 @@
files.each do |filename|
processor = choose_processor!(filename)
if processor == nil
@resource_processors[filename] = nil
else
- @resource_processors[filename] = processor.process_file(filename)
+ resource_name = get_base_resource_name(filename)
+ @resource_processors[filename] = processor.process_file(filename, :resource_name => resource_name)
end
processor = @resource_processors[filename]
if processor == nil
if only_list_recognized_files == false
@@ -402,10 +422,15 @@
# write out content
@resource_processors.each_key do |filename|
results = @resource_processors[filename]
if results == nil
putc '.'
+
+ # copy the file over
+ file_destination = get_full_deployed_name(filename)
+ info("Copying #{filename} to #{file_destination}")
+ FileUtils.copy(filename, file_destination)
else
putc results.processor_symbol
results.save(file_tree)
end
STDOUT.flush
@@ -416,11 +441,11 @@
end
def finish
puts ''
puts ''
- section_divider('Finishing')
+ section_divider('Finished')
end
# gives an array listing of all files on a given path
#
@@ -461,6 +486,6 @@
end
# load the various processors
SiteFuelRuntime.load_processors
-end
\ No newline at end of file
+end