Sha256: d586740ef06c501425f6ad4382474347f2e7b9ff400f4e831bea2964054a723e

Contents?: true

Size: 997 Bytes

Versions: 1

Compression:

Stored size: 997 Bytes

Contents

class Kit

	def initialize path

		load path + "config.rb"

		load 'kit/db_sqlite3.rb' if DB_BACKEND == :sqlite3

		load path + NAME + ".rb"

		@@kit_path = path
		@@db = Backend.new DB_CONFIG
		@@info = INFO
		@@actions = ACTIONS
	end

	def add_bit info
		Bit.new info
	end

	def add_task action, options
		fail NoAction unless @@actions.include? action
		@@db.insert_action action, options
	end

	def run_tasks

		collect_tasks_by_bit.each do |bit, tasks|
			s = Bit.new bit

			actions = tasks.group_by { |t| t[:action] } . keys

			actions.each do |a|
				load @@kit_path + "/#{a}/#{s.project_name}.rb"
				s.extend Actions
			end

			tasks.each do |t|
				s.add_task t
			end

			s.run_all

		end
	end

	private
	def collect_tasks_by_bit

		tasks = []
		@@actions.each_key do |action|
			tasks.push @@db.select_all_actions_by_status action, @@actions[action], :pending
		end
		tasks.flatten!

		tasks.group_by { |t| t[:bit] }
	end

	class NoAction < StandardError
	end

end

require 'kit/bit'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kit-0.0.3 lib/kit.rb