Sha256: ab4b56aae1f84dea2c7dd8790100d79396789944b716e222ba250189cba3702a

Contents?: true

Size: 918 Bytes

Versions: 1

Compression:

Stored size: 918 Bytes

Contents

require "fileutils"

module Shepherd
	class Setup
		def initialize
      puts "[shep] performing a setup:\n\n"
			@schema = <<-EOS
create table if not exists sheeps (
	id integer primary key autoincrement,
	name varchar(128) not null,
	path varchar(256) not null,
	files integer(6) not null,
	lines integer(7) not null,
	chars integer(10) not null,
	bytes integer(10) not null,
	inited_at datetime not null,
  updated_at datetime not null
);
EOS

			crdir "#{Dir.home}/.shepherd"
			crfile "#{Dir.home}/.shepherd/herd.db"
			puts "[shep] setup: making a real database: #{Dir.home}/.shepherd/herd.db"
			Db.new.execute "#{@schema}"
			exit 0
		end
		
		private
			def crdir dir
				puts "[shep] setup: creating dir:  #{dir}"
				::FileUtils.mkdir "#{Dir.home}/.shepherd"
			end
			
			def crfile file
				puts "[shep] setup: creating file: #{file}"
				::FileUtils.touch "#{Dir.home}/.shepherd/herd.db"
			end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shepherd-0.3.0 lib/shepherd/setup.rb