about summary refs log tree commit diff stats
path: root/data/types.rb
blob: 6efc189ce0ca86e6aab656e2792c90b3a272c333 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
## This file specifies WHAT program is run,
## depending on the file.
##
## as soon as a "use.myprogram" is reached,
## this programm will be used an the function
## is finished.

class Directory::Entry
	def get_handler
		## directories or sockets don't have any handler
		use.no_handler if dir? or socket?


		## first look at the basename
		case @basename
		when 'Makefile'
			use.make

		when /^[Rr]akefile(.rb)?$/
			use.rake
		end

		## then at the extension
		case @ext
		when 'svg'
			use.firefox
		when 'm4v'
			use.mplayer
		end

		## then look at the mime-type
		case @mimetype
		when /^video/
			use.mplayer "d"

		when /^audio/
			use.mplayer

		when "application/pdf"
			use.evince

		when /^image/
			use.feh

		when /^(text|application)\/x-(#{INTR})$/
			use.interpreted_language

		when 'text/x-java'
			use.javac

		when 'application/java-vm'
			use.java

		when 'text/html', 'application/x-shockwave-flash'
			use.firefox
		end


		## then at the extension again
		case @ext
		when 'swc', 'smc'
			use.zsnes

		when 'rar', 'zip', 'tar', 'gz', '7z', 'jar', 'bz', 'bz2'
			use.aunpack
		end


		## is it executable?
		use.vi_or_run if executable?

		## if there is nothing found, use a default application,
		## for example a text- or hex-editor.
		use.vi
	end

	## interpreted languages
	INTR = %w[haskell perl python ruby sh].join('|')
end