yac 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/yac.rb +19 -12
- data/resources/yacrc +3 -0
- data/yac.gemspec +1 -1
- metadata +1 -1
data/lib/yac.rb
CHANGED
@@ -83,20 +83,27 @@ module Yac
|
|
83
83
|
protected
|
84
84
|
def format_file(file)
|
85
85
|
@level = 0
|
86
|
-
|
87
|
-
|
86
|
+
case `file #{file}`
|
87
|
+
when / PDF /
|
88
|
+
system("#{CONFIG["pdf_command"]||'evince'} #{file}")
|
89
|
+
when / image /
|
90
|
+
system("#{CONFIG["pic_command"]||'eog'} #{file}")
|
91
|
+
else
|
92
|
+
File.new(file).each do |x|
|
93
|
+
format_section(x)
|
94
|
+
end
|
88
95
|
end
|
89
96
|
end
|
90
97
|
|
91
98
|
def format_section(section)
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
99
|
+
case section
|
100
|
+
when /^(=+)\s+(.*)/
|
101
|
+
@level = $1.size
|
102
|
+
puts "\033[" + CONFIG["level#{@level}"].to_s + "m" + "\s"*2*(@level-1) + $2 +"\033[0m"
|
103
|
+
when /^(\s*)#/
|
104
|
+
else
|
105
|
+
puts section.sub(/^\#/,"#").sub(/^\s*/, "\s" * @level * 2 ).gsub(/@@@(.*)@@@/,"\033[" + CONFIG["empha"].to_s + "m" + '\1' + "\033[0m")
|
106
|
+
end
|
100
107
|
end
|
101
108
|
|
102
109
|
def full_path(args)
|
@@ -128,7 +135,7 @@ module Yac
|
|
128
135
|
end
|
129
136
|
|
130
137
|
def editor
|
131
|
-
|
138
|
+
CONFIG["editor"] || ENV['EDITOR'] || "vim"
|
132
139
|
end
|
133
140
|
|
134
141
|
def show_single(args)
|
@@ -138,7 +145,7 @@ module Yac
|
|
138
145
|
format_file(result.first)
|
139
146
|
else
|
140
147
|
result.map do |x|
|
141
|
-
if x =~ /\/#{args}
|
148
|
+
if x =~ /\/#{args}\.\w+/
|
142
149
|
puts "\n\033[#{CONFIG["filename"]}m#{x}\033[0m\n"
|
143
150
|
format_file(x)
|
144
151
|
end
|
data/resources/yacrc
CHANGED
data/yac.gemspec
CHANGED