Class: Ppl::Application::Bootstrap

Inherits:
Object
  • Object
show all
Defined in:
lib/ppl/application/bootstrap.rb

Instance Method Summary collapse

Instance Method Details

#command_suiteObject



27
28
29
30
31
32
33
34
# File 'lib/ppl/application/bootstrap.rb', line 27

def command_suite
  suite = Ppl::Application::CommandSuite.new
  commands.each do |command|
    suite.add_command(command)
  end
  suite.find_command("help").command_suite = suite
  return suite
end

#commandsObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ppl/application/bootstrap.rb', line 4

def commands
  commands = [
    Ppl::Command::Init.new,
    Ppl::Command::Bday.new,
    Ppl::Command::Help.new,
    Ppl::Command::Add.new,
    Ppl::Command::Rm.new,
    Ppl::Command::Ls.new,
    Ppl::Command::Mutt.new,
    Ppl::Command::Mv.new,
    Ppl::Command::Show.new,
    Ppl::Command::Name.new,
    Ppl::Command::Email.new,
    Ppl::Command::Org.new,
    Ppl::Command::Phone.new,
    Ppl::Command::Post.new,
  ]
  commands.each do |command|
    command.storage = storage_adapter
  end
  return commands
end

#configurationObject



36
37
38
39
# File 'lib/ppl/application/bootstrap.rb', line 36

def configuration
  config = Ppl::Application::Configuration.new
  return config
end

#inputObject



41
42
43
44
# File 'lib/ppl/application/bootstrap.rb', line 41

def input
  input = Ppl::Application::Input.new(ARGV.dup)
  return input
end

#outputObject



46
47
48
49
# File 'lib/ppl/application/bootstrap.rb', line 46

def output
  output = Ppl::Application::Output.new($stdout, $stderr)
  return output
end

#routerObject



51
52
53
54
55
# File 'lib/ppl/application/bootstrap.rb', line 51

def router
  router = Ppl::Application::Router.new(command_suite)
  router.default = "help"
  return router
end

#shellObject



57
58
59
60
61
# File 'lib/ppl/application/bootstrap.rb', line 57

def shell
  shell = Ppl::Application::Shell.new
  shell.router = router
  return shell
end

#storage_adapterObject



63
64
65
66
67
68
69
70
71
72
# File 'lib/ppl/application/bootstrap.rb', line 63

def storage_adapter
  config = configuration

  directory = Dir.new(config.address_book_path)
  factory   = Ppl::Adapter::Storage::Factory.new(vcard_adapter)
  storage   = factory.load_adapter(directory)

  storage.vcard_adapter = vcard_adapter
  return storage
end

#vcard_adapterObject



74
75
76
77
# File 'lib/ppl/application/bootstrap.rb', line 74

def vcard_adapter
  vcard = Ppl::Adapter::Vcard::Vpim.new
  return vcard
end