Class: CukeParser::ParseEngine::ParserUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/parse_engine/parser_utils.rb

Instance Method Summary collapse

Instance Method Details

#dir_purge(dir_path, build_stamp) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/parse_engine/parser_utils.rb', line 22

def dir_purge(dir_path, build_stamp)
	#get rid of directories we already have data for
	drop_num = 2
	if Dir.exists?(dir_path)
		dir = Dir.entries(dir_path)
		if build_stamp != "empty"
			dir.each do |build_folder|
				if build_folder <= build_stamp
					drop_num = dir.index(build_folder) + 1
				end
			end
		end
		dir = dir.drop(drop_num)
		return dir
	else
		#not a valid directory (does not exist must let App know so User can be notified)
		return false
	end
end

#format_time(time) ⇒ Object



69
70
71
# File 'lib/parse_engine/parser_utils.rb', line 69

def format_time(time)
	Time.at(time / 1000000000.00).gmtime.strftime('%R:%S:%L')
end

#intializeObject



5
6
7
# File 'lib/parse_engine/parser_utils.rb', line 5

def intialize
	#nothing yet
end

#parse_time(datetime) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/parse_engine/parser_utils.rb', line 9

def parse_time(datetime)
	timestamp = Hash['date', datetime[0], 'time', datetime[1], 'runstamp', 0]
	dt = []
	timestamp['date'].split("-").each do |d|
		dt.push(d.to_i)
	end
	timestamp['time'].split("-").each do |t|
		dt.push(t.to_i)
	end
	timestamp['runstamp'] = Time.new(dt[0],dt[1],dt[2],dt[3],dt[4],dt[5])
	return timestamp
end

#pretty(build, file) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/parse_engine/parser_utils.rb', line 42

def pretty(build,file)
	#build is always first line, no indentation needed to make it "pretty"
	file.puts build.to_csv
	build.features.each do |feature|
		file.puts feature.to_csv_pretty
		feature.scenarios.each do |scenario|
			file.puts scenario.to_csv_pretty
			scenario.steps.each do |step|
				file.puts step.to_csv_pretty
			end
		end
	end
end

#ugly(build, file) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/parse_engine/parser_utils.rb', line 56

def ugly(build,file)
	file.puts build.to_csv
	build.features.each do |feature|
		file.puts feature.to_csv
		feature.scenarios.each do |scenario|
			file.puts scenario.to_csv
			scenario.steps.each do |step|
				file.puts step.to_csv
			end
		end
	end
end