Class: DropGit::App

Inherits:
Object
  • Object
show all
Defined in:
lib/dropgit.rb

Instance Method Summary collapse

Constructor Details

#initializeApp

Constructor



18
19
20
# File 'lib/dropgit.rb', line 18

def initialize
  DropGit.settings = Settings.new
end

Instance Method Details

#git(name) ⇒ Object



33
34
35
# File 'lib/dropgit.rb', line 33

def git(name)
  repo = DropGit.settings.repositories.select { |data| data['name'] == name }
end

#helpObject

Show usage



23
24
# File 'lib/dropgit.rb', line 23

def help
end

#init(remote) ⇒ Object

Initialize repository for current directory



27
28
29
30
31
# File 'lib/dropgit.rb', line 27

def init(remote)
  raise "Specify a remote repository" unless remote
  new_repo = Repository.create(Dir.pwd, remote)
  DropGit.settings.add_repo new_repo
end

#listObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/dropgit.rb', line 37

def list
  repos = DropGit.settings.repositories
  length = {}
  repos.each do |repo|
    repo.each do |key, val|
      if length[key]
        if val.length > length[key]
          length[key] = val.length
        end
      else
        length[key] = val.length
      end
    end
  end
  head = "|"
  length.each do |key, val|
    head << " " << key.ljust(val + 2) << "|"
  end
  puts "-" * head.length
  puts head
  puts "-" * head.length
  repos.each do |repo|
    line = "|"
    repo.each do |key, val|
      line << " " << val.ljust(length[key] + 2) << "|"
    end
    puts line
  end
end

#runObject

debug daemon



73
74
75
# File 'lib/dropgit.rb', line 73

def run
  Daemon.new.run
end

#startObject

start daemon



68
69
70
# File 'lib/dropgit.rb', line 68

def start
  Daemon.new.start
end

#stopObject



77
78
79
# File 'lib/dropgit.rb', line 77

def stop
  Daemon.new.stop
end