yac 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/yac.rb +6 -8
- data/resources/yacrc +3 -3
- data/yac.gemspec +2 -2
- metadata +2 -2
data/lib/yac.rb
CHANGED
@@ -5,7 +5,7 @@ module Yac
|
|
5
5
|
include Format
|
6
6
|
extend self
|
7
7
|
|
8
|
-
VERSION = '1.4.
|
8
|
+
VERSION = '1.4.1'
|
9
9
|
|
10
10
|
@color = {
|
11
11
|
'head1' => "1;31",
|
@@ -197,15 +197,13 @@ module Yac
|
|
197
197
|
end
|
198
198
|
|
199
199
|
def search_content(args)
|
200
|
-
# find -type f -exec sh -c 'file="{}";type=$(file $file);[[ $type =~ " text" ]] && echo $file' \; => Too slow
|
201
|
-
|
202
200
|
# If use @ as prefix , only search private repository
|
203
201
|
result = args.sub!(/^@/,'') ? [] : %x(
|
204
|
-
find "#{@main_path}" -not -iwholename '*\/.git\/*' |
|
202
|
+
find "#{@main_path}" -not -iwholename '*\/.git\/*' | xargs grep -HniP '#{args}' --binary-files=without-match | sed 's/^/@/g'
|
205
203
|
).to_a
|
206
204
|
|
207
205
|
result.concat %x(
|
208
|
-
find "#{@pri_path}" -not -iwholename '*\/.git\/*' |
|
206
|
+
find "#{@pri_path}" -not -iwholename '*\/.git\/*' | xargs grep -HniP '#{args}' --binary-files=without-match
|
209
207
|
).to_a
|
210
208
|
|
211
209
|
all_result = []
|
@@ -232,7 +230,7 @@ module Yac
|
|
232
230
|
|
233
231
|
def confirm(*msg)
|
234
232
|
colorful("#{msg.to_s}\nAre You Sure (Y/N) (q:quit):","notice",false)
|
235
|
-
return STDIN.gets
|
233
|
+
return (STDIN.gets || exit) =~ /n|q/i ? false : true
|
236
234
|
end
|
237
235
|
|
238
236
|
def choose_one(args)
|
@@ -250,13 +248,13 @@ module Yac
|
|
250
248
|
end
|
251
249
|
|
252
250
|
def trancate_filename(name)
|
253
|
-
name.sub
|
251
|
+
name = name.sub(/\..*$/,'').sub(/^@/,'')
|
254
252
|
content = name.size > 22 ? '..' + name.reverse[0,20].reverse : name
|
255
253
|
end
|
256
254
|
|
257
255
|
def choose_range(size)
|
258
256
|
colorful("Please Input A Valid Number (1..#{size}) (q:quit): ","notice",false)
|
259
|
-
num = STDIN.gets
|
257
|
+
num = STDIN.gets || exit
|
260
258
|
return false if num =~ /q/i
|
261
259
|
choosed_num = num.strip.empty? ? 1 : num.to_i
|
262
260
|
(1..size).member?(choosed_num) ? (return choosed_num) : choose_range(size)
|
data/resources/yacrc
CHANGED
data/yac.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{yac}
|
5
|
-
s.version = "1.4.
|
5
|
+
s.version = "1.4.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Jinzhu Zhang"]
|
9
|
-
s.date = %q{
|
9
|
+
s.date = %q{2009-01-06}
|
10
10
|
s.default_executable = %q{yac}
|
11
11
|
s.description = %q{Yet Another Cheat: sexy command line tool for cheat sheet.}
|
12
12
|
s.email = %q{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: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jinzhu Zhang
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-01-06 00:00:00 +08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|