yac 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/CHANGELOG +3 -0
  2. data/lib/git.rb +2 -2
  3. data/lib/yac.rb +38 -24
  4. data/yac.gemspec +2 -2
  5. metadata +2 -2
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ === 1.4.2 / 2009-2-1
2
+ * Ruby 1.9 compatible
3
+
1
4
  === 1.4.0 / 2008-12-28
2
5
 
3
6
  * highlight commands,e.g: $ ls
data/lib/git.rb CHANGED
@@ -34,8 +34,8 @@ class Git
34
34
  self.commit("#{cleanup_name(file)} Removed")
35
35
  end
36
36
 
37
- def commit(msg,*args)
38
- system("git commit #{args.to_s} -m '#{msg}' >/dev/null")
37
+ def commit(msg,args='')
38
+ system("git commit #{args} -m '#{msg}' >/dev/null")
39
39
  end
40
40
 
41
41
  def cleanup_name(f)
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.1'
8
+ VERSION = '1.4.2'
9
9
 
10
10
  @color = {
11
11
  'head1' => "1;31",
@@ -34,22 +34,22 @@ module Yac
34
34
  @pri_path = File.join(CONFIG["root"],"/private/")
35
35
 
36
36
  def new(args)
37
- (help && exit) if args.empty?
38
- operate,target = args.first,args[1,args.size].join(' ')
37
+ operate, target = args.shift.to_s , args.join(' ').to_s
38
+
39
39
  case operate
40
40
  when "-i" then init
41
- when "-S" then search(target)
42
- when "-u" then update(target)
43
- when "-p" then push(target)
44
- when "-l" then log(target)
45
- when "-a" then add(target)
46
- when "-e" then edit(target)
41
+ when "-S" then search target
42
+ when "-u" then update target
43
+ when "-p" then push target
44
+ when "-l" then log target
45
+ when "-a" then add target
46
+ when "-e" then edit target
47
+ when "-s" then shell target
48
+ when "-r" then rm target
49
+ when "-m" then mv args
47
50
  when /^(help|-h|yac|--help)$/ then help
48
- when "-s" then shell(target)
49
- when "-r" then rm(target)
50
- when "-m" then mv(args[1,args.size])
51
51
  when "-v" then colorful("Yac Version: #{Yac::VERSION}",'notice')
52
- else show(operate + ' ' + target)
52
+ else show operate + ' ' + target
53
53
  end
54
54
  end
55
55
 
@@ -99,7 +99,22 @@ module Yac
99
99
  end
100
100
 
101
101
  def help
102
- handle_file(File.dirname(__FILE__)+"/../README.rdoc")
102
+ puts <<-DOC.gsub(/^(\s*)/,'').gsub(/^\|(\s*)/,'\1')
103
+ Usage:
104
+ | yac -i <keyword> init
105
+ | yac -S <keyword> search
106
+ | yac -u <keyword> update
107
+ | yac -p <keyword> push
108
+ | yac -l <keyword> log
109
+ | yac -a <keyword> add
110
+ | yac -e <keyword> edit
111
+ | yac -s <keyword> shell
112
+ | yac -r <keyword> delete<rm>
113
+ | yac -m <keyword> rename<mv>
114
+ | yac -h Show this help
115
+ | yac -v Show Version
116
+ | yac <keyword> Show
117
+ DOC
103
118
  end
104
119
 
105
120
  def shell(args)
@@ -127,15 +142,14 @@ module Yac
127
142
  end
128
143
 
129
144
  protected
130
- def add_file(args,*suffix)
131
- suffix = suffix ? suffix.to_s : ''
132
- if args.include?('/') && args =~ /(@?)(?:(.*)\/)(.+)/ #choose directory
145
+ def add_file(args,suffix='')
146
+ if args.include?('/') && args =~ /(@?)(?:(.*)\/)(.+)/ #choose directory
133
147
  prefix,path_name,file_name = $1,$2,$3
134
- path = prefix.empty? ? @pri_path : @main_path #choose git path
148
+ path = prefix.empty? ? @pri_path : @main_path #choose git path
135
149
  # Use 'l/e' to choose 'linux/gentoo'
136
150
  all_path = %x{
137
151
  find -L #{path} -type d -iwholename '#{path}*#{path_name.gsub(/\//,'*/*')}*' -not -iwholename '*\/.git\/*' | sed 's/^.*\\/\\(private\\|main\\)\\//#{prefix}/'
138
- }.to_a.map(&:strip).concat([prefix+path_name]).uniq
152
+ }.split("\n").map(&:strip).concat([prefix+path_name]).uniq
139
153
 
140
154
  colorful("Which directory do you want to use:","notice")
141
155
  choosed_path = choose_one(all_path)
@@ -184,7 +198,7 @@ module Yac
184
198
  path.each do |x|
185
199
  result.concat( %x{
186
200
  find -L "#{x}" -type f -iwholename '#{x}*#{args.gsub(/\//,'*/*').sub(/^@/,'').strip}*' -not -iwholename '*\/.git\/*'| sed 's/^.*\\/\\(private\\|main\\)\\//#{x=~/main/ ? '@':'' }/'
187
- }.to_a )
201
+ }.split("\n") )
188
202
  end
189
203
 
190
204
  if result.empty?
@@ -200,11 +214,11 @@ module Yac
200
214
  # If use @ as prefix , only search private repository
201
215
  result = args.sub!(/^@/,'') ? [] : %x(
202
216
  find "#{@main_path}" -not -iwholename '*\/.git\/*' | xargs grep -HniP '#{args}' --binary-files=without-match | sed 's/^/@/g'
203
- ).to_a
217
+ ).split("\n")
204
218
 
205
219
  result.concat %x(
206
220
  find "#{@pri_path}" -not -iwholename '*\/.git\/*' | xargs grep -HniP '#{args}' --binary-files=without-match
207
- ).to_a
221
+ ).split("\n")
208
222
 
209
223
  all_result = []
210
224
  result.each do |x|
@@ -228,8 +242,8 @@ module Yac
228
242
  return filename.strip
229
243
  end
230
244
 
231
- def confirm(*msg)
232
- colorful("#{msg.to_s}\nAre You Sure (Y/N) (q:quit):","notice",false)
245
+ def confirm(msg='')
246
+ colorful("#{msg}\nAre You Sure (Y/N) (q:quit):","notice",false)
233
247
  return (STDIN.gets || exit) =~ /n|q/i ? false : true
234
248
  end
235
249
 
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{yac}
5
- s.version = "1.4.1"
5
+ s.version = "1.4.2"
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{2009-01-06}
9
+ s.date = %q{2009-02-02}
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.1
4
+ version: 1.4.2
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: 2009-01-06 00:00:00 +08:00
12
+ date: 2009-02-02 00:00:00 +08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15