Module: Yac

Extended by:
Yac
Included in:
Yac
Defined in:
lib/yac.rb

Constant Summary collapse

YACRC =
File.join("#{ENV['HOME']}",".yacrc")
CONFIG =
YAML.load_file(File.join(ENV['HOME'],".yacrc"))

Instance Method Summary collapse

Instance Method Details

#edit(args) ⇒ Object Also known as: add



61
62
63
# File 'lib/yac.rb', line 61

def edit(args)
  args.each {|x| edit_single(x)}
end

#helpObject



70
71
72
# File 'lib/yac.rb', line 70

def help
  format_file(File.dirname(__FILE__)+"/../README.rdoc")
end

#new(args) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/yac.rb', line 16

def new(args)
  unless File.exist?(@main_path) && File.exist?(@pri_path)
    return unless init
  end
  @all_result = []
  help && exit if args.empty?
  case args.first
  when "show" then show(args[1,args.size])
  when "name" then search(args[1,args.size],"name")
  when "content" then search(args[1,args.size],"content")
  when "update" then update(args[1,args.size])
  when "add" then add(args[1,args.size])
  when "edit" then edit(args[1,args.size])
  when "help" then help
  when "shell" then shell(args[1,args.size])
  when "rm" then rm(args[1,args.size])
  when "init" then init
  else show(args)
  end
  show_possible_result
end

#rm(args) ⇒ Object



66
67
68
# File 'lib/yac.rb', line 66

def rm(args)
  args.each {|x| rm_single(x)}
end

#search(args, type = "name") ⇒ Object



42
43
44
# File 'lib/yac.rb', line 42

def search(args,type = "name")
  args.each {|x| search_single(x,type)}
end

#shell(args = "pri") ⇒ Object



74
75
76
77
78
79
80
81
82
# File 'lib/yac.rb', line 74

def shell(args = "pri")
  puts "Comming Soon :)"
  #case args.to_s
  #when /main/
  #  system("cd #{@main_path}")
  #when /pri/
  #  system("cd #{@pri_path}")
  #end
end

#show(args) ⇒ Object



38
39
40
# File 'lib/yac.rb', line 38

def show(args)
  args.each {|x| show_single(x)}
end

#update(args) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/yac.rb', line 46

def update(args)
  begin
    if args
      @main_path.pull if args.to_s =~ /main/
      @pri_git.pull if args.to_s =~ /pri/
    else
      @main_path.pull
      @pri_git.pull
    end
  rescue
    puts "ERROR: can not update #{args}"
    puts $!
  end
end