yac 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/lib/yac.rb +19 -12
  2. data/resources/yacrc +3 -0
  3. data/yac.gemspec +1 -1
  4. 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
- File.new(file).each do |x|
87
- format_section(x)
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
- case section
93
- when /^(=+)\s+(.*)/
94
- @level = $1.size
95
- puts "\033[" + CONFIG["level#{@level}"].to_s + "m" + "\s"*2*(@level-1) + $2 +"\033[0m"
96
- when /^(\s*)#/
97
- else
98
- puts section.sub(/^\#/,"#").sub(/^\s*/, "\s" * @level * 2 ).gsub(/@@@(.*)@@@/,"\033[" + CONFIG["empha"].to_s + "m" + '\1' + "\033[0m")
99
- end
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
- ENV['VISUAL'] || ENV['EDITOR'] || "vim"
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}\.ch/
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
@@ -7,6 +7,9 @@ private:
7
7
  # clone-from:
8
8
  # push-to:
9
9
 
10
+ #pdf_command: evince
11
+ #pic_command: evince
12
+ #editor: vim
10
13
 
11
14
  #Set Color
12
15
  #1 - Change text to hicolor (bold) mode
data/yac.gemspec CHANGED
@@ -1,5 +1,5 @@
1
1
  GEM = "yac"
2
- VER = "0.0.4"
2
+ VER = "0.1.0"
3
3
  DATE = %q{2008-10-11}
4
4
  AUTHOR = "Jinzhu Zhang"
5
5
  EMAIL = "wosmvp@gmail.com"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jinzhu Zhang