yac 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.cn +1 -1
- data/README.rdoc +1 -1
- data/lib/yac.rb +25 -23
- data/yac.gemspec +3 -2
- metadata +2 -2
data/README.cn
CHANGED
data/README.rdoc
CHANGED
data/lib/yac.rb
CHANGED
@@ -8,8 +8,7 @@ module Yac
|
|
8
8
|
CONFIG = YAML.load_file(File.join(ENV['HOME'],".yacrc"))
|
9
9
|
CONFIG["root"] ||= File.join(ENV['HOME'],".yac")
|
10
10
|
|
11
|
-
@main_path = File.join(CONFIG["root"],"/main/")
|
12
|
-
@pri_path = File.join(CONFIG["root"],"/private/")
|
11
|
+
@main_path, @pri_path = File.join(CONFIG["root"],"/main/"), File.join(CONFIG["root"],"/private/")
|
13
12
|
@main_git = Git.open(@main_path) if File.exist?(@main_path)
|
14
13
|
@pri_git = Git.open(@pri_path)if File.exist?(@pri_path)
|
15
14
|
|
@@ -18,14 +17,13 @@ module Yac
|
|
18
17
|
return unless init
|
19
18
|
end
|
20
19
|
@all_result = []
|
21
|
-
help && exit if args.empty?
|
20
|
+
(help && exit) if args.empty?
|
22
21
|
case args.first
|
23
22
|
when "show" then show(args[1,args.size])
|
24
23
|
when "name" then search(args[1,args.size],"name")
|
25
24
|
when "content" then search(args[1,args.size],"content")
|
26
25
|
when "update" then update(args[1,args.size])
|
27
|
-
when
|
28
|
-
when "edit" then edit(args[1,args.size])
|
26
|
+
when /^(add|edit)$/ then edit(args[1,args.size])
|
29
27
|
when "help" then help
|
30
28
|
when "shell" then shell(args[1,args.size])
|
31
29
|
when "rm" then rm(args[1,args.size])
|
@@ -33,6 +31,7 @@ module Yac
|
|
33
31
|
else show(args)
|
34
32
|
end
|
35
33
|
show_possible_result
|
34
|
+
rescue
|
36
35
|
end
|
37
36
|
|
38
37
|
def show(args)
|
@@ -45,15 +44,15 @@ module Yac
|
|
45
44
|
|
46
45
|
def update(args)
|
47
46
|
begin
|
48
|
-
|
49
|
-
@main_path.pull if args.to_s =~ /main/
|
47
|
+
unless args.empty?
|
50
48
|
@pri_git.pull if args.to_s =~ /pri/
|
49
|
+
@main_git.pull if args.to_s =~ /main/
|
51
50
|
else
|
52
|
-
@
|
51
|
+
@main_git.pull
|
53
52
|
@pri_git.pull
|
54
53
|
end
|
55
54
|
rescue
|
56
|
-
puts "ERROR: can not update
|
55
|
+
puts "ERROR: can not update the repository,"
|
57
56
|
puts $!
|
58
57
|
end
|
59
58
|
end
|
@@ -61,7 +60,6 @@ module Yac
|
|
61
60
|
def edit(args)
|
62
61
|
args.each {|x| edit_single(x)}
|
63
62
|
end
|
64
|
-
alias add edit
|
65
63
|
|
66
64
|
def rm(args)
|
67
65
|
args.each {|x| rm_single(x)}
|
@@ -71,14 +69,15 @@ module Yac
|
|
71
69
|
format_file(File.dirname(__FILE__)+"/../README.rdoc")
|
72
70
|
end
|
73
71
|
|
74
|
-
def shell(args
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
72
|
+
def shell(args)
|
73
|
+
case args.to_s
|
74
|
+
when /main/
|
75
|
+
puts "\033[31m Welcome To The Main Yac Repository \033[0m"
|
76
|
+
system "cd #{@main_path}; sh"
|
77
|
+
else
|
78
|
+
puts "\033[31m Welcome To The Private Yac Repository \033[0m"
|
79
|
+
system "cd #{@pri_path}; sh"
|
80
|
+
end
|
82
81
|
end
|
83
82
|
|
84
83
|
protected
|
@@ -122,12 +121,10 @@ module Yac
|
|
122
121
|
|
123
122
|
def edit_single(args)
|
124
123
|
full_path(args)
|
124
|
+
prepare_dir
|
125
125
|
system("#{editor} #{@file_path}")
|
126
|
-
|
127
|
-
|
128
|
-
@working_git.commit_all(" #{args.sub(/^@/,"")}.ch Updated")
|
129
|
-
rescue
|
130
|
-
end
|
126
|
+
@working_git.add
|
127
|
+
@working_git.commit_all(" #{args.sub(/^@/,"")}.ch Updated")
|
131
128
|
end
|
132
129
|
|
133
130
|
def editor
|
@@ -234,4 +231,9 @@ module Yac
|
|
234
231
|
@pri_git = Git.open(@pri_path)if File.exist?(@pri_path)
|
235
232
|
puts "Repository init done."
|
236
233
|
end
|
234
|
+
|
235
|
+
def prepare_dir
|
236
|
+
dirseparator = @file_path.rindex(File::Separator)+1
|
237
|
+
FileUtils.mkdir_p(@file_path[0,dirseparator])
|
238
|
+
end
|
237
239
|
end
|
data/yac.gemspec
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
GEM = "yac"
|
2
|
-
VER = "0.0.
|
2
|
+
VER = "0.0.3"
|
3
|
+
DATE = %q{2008-10-11}
|
3
4
|
AUTHOR = "Jinzhu Zhang"
|
4
5
|
EMAIL = "wosmvp@gmail.com"
|
5
6
|
HOMEPAGE = "http://www.zhangjinzhu.com"
|
@@ -13,7 +14,7 @@ Gem::Specification.new do |s|
|
|
13
14
|
s.name = GEM
|
14
15
|
s.version = VER
|
15
16
|
s.author = AUTHOR
|
16
|
-
s.date =
|
17
|
+
s.date = DATE
|
17
18
|
s.email = EMAIL
|
18
19
|
s.homepage = HOMEPAGE
|
19
20
|
s.summary = SUMMARY
|
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
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jinzhu Zhang
|
@@ -9,7 +9,7 @@ autorequire: yac
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-10-
|
12
|
+
date: 2008-10-11 00:00:00 +08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|