Sha256: d59c2d7f436b6bff8b6a86f09de58b6a310007989712f27f5bed18513e259b62

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'yaml'

class Kit

	def initialize path

		config = YAML.load File.read path + "config.yml"

		load 'kit/db_sqlite3.rb' if config[:db_backend] == :sqlite3

		load path + config[:name] + ".rb"

		@@kit_path = path
		@@db = Backend.new config[:db_config]
		@@info = config[:info]
		@@actions = config[: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.4 lib/kit.rb