Sha256: 2f6e30560217aefe6921af34e58064e3428d5d00e5cf4c175bb3cb5ccb409944

Contents?: true

Size: 959 Bytes

Versions: 5

Compression:

Stored size: 959 Bytes

Contents

puts __FILE__ if defined?(DEBUG)

class History
	attr_accessor :dev

	def initialize dev=nil
		@dev=dev
		@dev=Dev.new if @dev.nil?
	end
	
	# .0. for 0 exit codes
	# .X. for non 0 exit codes
	# project name is contained in directory name
	def get_commands pattern
		commands=Array.new
		Dir.chdir(@dev.log_dir) do
			Dir.glob("*#{pattern.gsub('/','-')}*.*").each{|logfile|
				commands << Command.new(JSON.parse(IO.read(logfile)))
			}
		end
		commands
	end

	def add_command command
		code="0"
		code="X" if command[:exit_code] !=0
		directory=command[:directory].gsub(@dev.root_dir,'').gsub('/','-')
		name="#{command[:input]}.#{code}.#{directory}.json"
		filename="#{@dev.log_dir}/#{name}"
		puts "add command #{filename}" if @dev.debug?
		File.open(filename,'w'){|f|f.write(command.to_json)}
	end

	def get_wrk_command project_fullname
		commands=get_commands("#{project_fullname}".gsub('/','-'))
		return commands[0] if commands.length > 0
		nil
	end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dev-2.1.75 lib/base/history.rb
dev-2.1.74 lib/base/history.rb
dev-2.1.73 lib/base/history.rb
dev-2.1.72 lib/base/history.rb
dev-2.1.71 lib/base/history.rb