yac 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/yac.rb +23 -13
  2. data/yac.gemspec +1 -1
  3. metadata +1 -1
data/lib/yac.rb CHANGED
@@ -25,6 +25,7 @@ module Yac
25
25
  when "search" then search(args[1,args.size])
26
26
  when "update" then update(args[1,args.size])
27
27
  when "push" then push(args[1,args.size])
28
+ when "log" then log(args[1,args.size])
28
29
  when "add" then add(args[1,args.size])
29
30
  when "edit" then edit(args[1,args.size])
30
31
  when /^(help|-h|yac|--help)$/ then help
@@ -66,27 +67,34 @@ module Yac
66
67
  end
67
68
 
68
69
  def update(args)
69
- case args.to_s
70
- when /main/ then result = `cd "#{@main_path}" && git pull ` #NOTE There is an bug in the git.gem,Then I will write a new git library use shell command
71
- when /all/ then result = `cd "#{@pri_path}" && git pull && cd "#{@main_path}" && git pull `
72
- else result = `cd "#{@pri_path}" && git pull`
73
- end
74
- colorful(result,"notice")
70
+ git_command(args,'pull')
75
71
  rescue
76
72
  colorful("ERROR: can not update the repository,\n\n#{$!}","warn")
77
73
  end
78
74
 
79
75
  def push(args)
80
- case args.to_s
81
- when /main/ then result=@main_git.push
82
- when /all/ then result=@pri_git.push && result << @main_git.push
83
- else result = @pri_git.push
84
- end
85
- colorful(result,"notice")
76
+ git_command(args,'push')
86
77
  rescue
87
78
  colorful("Usage:\nyac push ( main | all )\n\nTry `yac -h` for more help\n\n#{$1}","warn")
88
79
  end
89
80
 
81
+ def log(args)
82
+ git_command(args,'log --color --date-order --reverse')
83
+ end
84
+
85
+ def git_command(env,command)
86
+ case env.to_s
87
+ when /main/ then git_path = [@main_path]
88
+ when /all/ then git_path = [@main_path,@pri_path]
89
+ else git_path = [@pri_path]
90
+ end
91
+
92
+ git_path.each do |x|
93
+ colorful(x,'filename')
94
+ colorful( `cd #{x} && git #{command}` ,"notice")
95
+ end
96
+ end
97
+
90
98
  def edit(args)
91
99
  args.each {|x| edit_single(x)}
92
100
  end
@@ -117,7 +125,9 @@ module Yac
117
125
  def rename(args)
118
126
  (colorful("Usage:\nyac mv [orign_name] [new_name]\n\nTry `yac -h` for more help","warn");exit) unless args.size == 2
119
127
  file = search_name(args[0],"Rename")
120
- new_name = add_file(args[1].sub(/^(@)?/,file =~ /^#{@main_path}/ ? "@":""),file.sub(/.*(\..*)/,'\1'))
128
+ #You can use $ yac mv linux.ch linux/ to rename linux.ch to linux/linux.ch
129
+ new_filename = args[1].sub(/\/$/,file.sub(/.*\/(.*)(\..*)/,'/\1')).sub(/^(@)?/,file =~ /^#{@main_path}/ ? "@":"")
130
+ new_name = add_file(new_filename ,file.sub(/.*(\..*)/,'\1'))
121
131
  if confirm("You Are Renaming #{file} To #{new_name}")
122
132
  prepare_dir(new_name)
123
133
  `mv "#{file}" "#{new_name}"`
@@ -1,5 +1,5 @@
1
1
  GEM = "yac"
2
- VER = "1.0.1"
2
+ VER = "1.0.2"
3
3
  DATE = %q{2008-10-28}
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: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jinzhu Zhang