yac 0.0.2 → 0.0.3

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/README.cn +1 -1
  2. data/README.rdoc +1 -1
  3. data/lib/yac.rb +25 -23
  4. data/yac.gemspec +3 -2
  5. metadata +2 -2
data/README.cn CHANGED
@@ -27,7 +27,7 @@
27
27
  $ yac update 全部更新
28
28
  === 帮助
29
29
  $ yac help
30
- === 打开仓库shell => Comming Soon :)
30
+ === 打开仓库shell
31
31
  $ yac shell main 打开主仓库的shell
32
32
  $ yac shell 打开个人仓库的shell
33
33
  === 文档格式
data/README.rdoc CHANGED
@@ -27,7 +27,7 @@
27
27
  $ yac update => Update All
28
28
  === Help
29
29
  $ yac help
30
- === Shell => Comming Soon :)
30
+ === Shell
31
31
  $ yac shell main => Open the main repository's shell
32
32
  $ yac shell => Open the private repository's shell
33
33
  === Documents format
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 "add" then add(args[1,args.size])
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
- if args
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
- @main_path.pull
51
+ @main_git.pull
53
52
  @pri_git.pull
54
53
  end
55
54
  rescue
56
- puts "ERROR: can not update #{args}"
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 = "pri")
75
- puts "Comming Soon :)"
76
- #case args.to_s
77
- #when /main/
78
- # system("cd #{@main_path}")
79
- #when /pri/
80
- # system("cd #{@pri_path}")
81
- #end
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
- begin
127
- @working_git.add
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"
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 = %q{2008-10-10}
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.2
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-10 00:00:00 +08:00
12
+ date: 2008-10-11 00:00:00 +08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency