Sha256: 92e293fdc64e16c598a9e6876ba2402d0db02df51aedc3394a27611cb148977d

Contents?: true

Size: 1.31 KB

Versions: 7

Compression:

Stored size: 1.31 KB

Contents

module Shaddox
	class ShadowScript
		attr_reader :script
		def initialize(config, task_key, opts = {})
			# Initialize properties
			@installer = opts[:installer]
			@config = config
			@cast_tasks = []

			# Generate script
			params = "{}"
			params = "{:installer => :#{@installer}}" if @installer
			@script = %Q{
require 'shaddox'
Shaddox::Shadow.new(#{params}) do
	## begin generated shadow ##
			}
			add_repos
			cast(task_key)
			@script += %Q{
	## end generated shadow ##
end
			}
		end

		## cast
		# Retrieves a task from the @config and ensures all of its dependencies
		# have been added to the script before adding itself. Tasks are only cast
		# once to elimate redundency.
		def cast(task_key)
			task = @config.tasks[task_key]
			if !task
				raise "The task :#{task_key} could not be found. Please check your Doxfile and try again."
			end
			task.deps.each do |dep_key|
				cast(dep_key) if !@cast_tasks.include? dep_key
			end
			@script += %Q{
	## #{task_key} ##
	#{task.to_source}
			}
			@cast_tasks.push(task_key)
		end

		## add_repos
		# Retrieves all repos from the @config and ensures their data is copied
		# to the script for use by tasks.
		def add_repos
			@script += %Q(
	@repos = {)
			@config.repos.each do |key, repo|
				@script += ":#{key} => #{repo.to_source}"
			end
			@script += %Q(})
		end
	end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
shaddox-0.0.9 lib/shaddox/shadow_script.rb
shaddox-0.0.8 lib/shaddox/shadow_script.rb
shaddox-0.0.7 lib/shaddox/shadow_script.rb
shaddox-0.0.6 lib/shaddox/shadow_script.rb
shaddox-0.0.5 lib/shaddox/shadow_script.rb
shaddox-0.0.4 lib/shaddox/shadow_script.rb
shaddox-0.0.3 lib/shaddox/shadow_script.rb