Module: Kanrisuru::Core::Apt

Extended by:
OsPackage::Define
Defined in:
lib/kanrisuru/core/apt.rb,
lib/kanrisuru/core/apt/types.rb,
lib/kanrisuru/core/apt/parsers/base.rb,
lib/kanrisuru/core/apt/parsers/list.rb,
lib/kanrisuru/core/apt/parsers/show.rb,
lib/kanrisuru/core/apt/commands/list.rb,
lib/kanrisuru/core/apt/commands/show.rb,
lib/kanrisuru/core/apt/commands/clean.rb,
lib/kanrisuru/core/apt/commands/purge.rb,
lib/kanrisuru/core/apt/parsers/search.rb,
lib/kanrisuru/core/apt/commands/remove.rb,
lib/kanrisuru/core/apt/commands/search.rb,
lib/kanrisuru/core/apt/commands/update.rb,
lib/kanrisuru/core/apt/commands/install.rb,
lib/kanrisuru/core/apt/commands/upgrade.rb,
lib/kanrisuru/core/apt/commands/autoclean.rb,
lib/kanrisuru/core/apt/commands/autoremove.rb,
lib/kanrisuru/core/apt/commands/full_upgrade.rb

Defined Under Namespace

Modules: Parser Classes: PackageDetail, PackageOverview, Source

Instance Method Summary collapse

Methods included from OsPackage::Define

extended, os_define

Instance Method Details

#apt(action, opts = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/kanrisuru/core/apt.rb', line 14

def apt(action, opts = {})
  case action
  when 'list'
    apt_list(opts)
  when 'update'
    apt_update(opts)
  when 'upgrade'
    apt_upgrade(opts)
  when 'full-upgrade', 'full_upgrade'
    apt_full_upgrade(opts)
  when 'install'
    apt_install(opts)
  when 'remove'
    apt_remove(opts)
  when 'purge'
    apt_purge(opts)
  when 'autoremove'
    apt_autoremove(opts)
  when 'search'
    apt_search(opts)
  when 'show'
    apt_show(opts)
  when 'clean'
    apt_clean(opts)
  when 'autoclean'
    apt_autoclean(opts)
  end
end

#apt_autoclean(_opts) ⇒ Object



6
7
8
9
10
# File 'lib/kanrisuru/core/apt/commands/autoclean.rb', line 6

def apt_autoclean(_opts)
  command = Kanrisuru::Command.new('apt-get autoclean')
  execute_shell(command)
  Kanrisuru::Result.new(command)
end

#apt_autoremove(_opts) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/kanrisuru/core/apt/commands/autoremove.rb', line 6

def apt_autoremove(_opts)
  command = Kanrisuru::Command.new('apt-get autoremove')
  command.append_flag('-y')

  execute_shell(command)
  Kanrisuru::Result.new(command)
end

#apt_clean(_opts) ⇒ Object



6
7
8
9
10
# File 'lib/kanrisuru/core/apt/commands/clean.rb', line 6

def apt_clean(_opts)
  command = Kanrisuru::Command.new('apt-get clean')
  execute_shell(command)
  Kanrisuru::Result.new(command)
end

#apt_full_upgrade(_opts) ⇒ Object



6
7
8
9
10
11
# File 'lib/kanrisuru/core/apt/commands/full_upgrade.rb', line 6

def apt_full_upgrade(_opts)
  command = Kanrisuru::Command.new('apt full-upgrade')
  command.append_flag('-y')
  execute_shell(command)
  Kanrisuru::Result.new(command)
end

#apt_install(opts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/kanrisuru/core/apt/commands/install.rb', line 6

def apt_install(opts)
  command = Kanrisuru::Command.new('apt-get install')
  command.append_flag('-y')

  command.append_flag('--no-upgrade', opts[:no_upgrade])
  command.append_flag('--only-upgrade', opts[:only_upgrade])
  command.append_flag('--reinstall', opts[:reinstall])

  packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
  command << packages

  execute_shell(command)
  Kanrisuru::Result.new(command)
end

#apt_list(opts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/kanrisuru/core/apt/commands/list.rb', line 6

def apt_list(opts)
  command = Kanrisuru::Command.new('apt list')
  command.append_flag('--installed', opts[:installed])
  command.append_flag('--upgradeable', opts[:upgradeable])
  command.append_flag('--all-versions', opts[:all_versions])
  command.append_arg('-a', opts[:package_name])

  execute_shell(command)

  Kanrisuru::Result.new(command) do |cmd|
    Parser::List.parse(cmd)
  end
end

#apt_purge(opts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/kanrisuru/core/apt/commands/purge.rb', line 6

def apt_purge(opts)
  command = Kanrisuru::Command.new('apt-get purge')
  command.append_flag('-y')

  packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
  command << packages

  execute_shell(command)
  Kanrisuru::Result.new(command)
end

#apt_remove(opts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/kanrisuru/core/apt/commands/remove.rb', line 6

def apt_remove(opts)
  command = Kanrisuru::Command.new('apt-get remove')
  command.append_flag('-y')

  packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
  command << packages

  execute_shell(command)
  Kanrisuru::Result.new(command)
end

#apt_search(opts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/kanrisuru/core/apt/commands/search.rb', line 6

def apt_search(opts)
  command = Kanrisuru::Command.new('apt search')
  command << opts[:query]

  execute_shell(command)

  Kanrisuru::Result.new(command) do |cmd|
    Parser::Search.parse(cmd)
  end
end

#apt_show(opts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/kanrisuru/core/apt/commands/show.rb', line 6

def apt_show(opts)
  command = Kanrisuru::Command.new('apt show')
  command.append_flag('-a')

  packages = Kanrisuru::Util.array_join_string(opts[:packages], ' ')
  command << packages

  execute_shell(command)

  Kanrisuru::Result.new(command) do |cmd|
    Parser::Show.parse(cmd)
  end
end

#apt_update(_opts) ⇒ Object



6
7
8
9
10
11
# File 'lib/kanrisuru/core/apt/commands/update.rb', line 6

def apt_update(_opts)
  command = Kanrisuru::Command.new('apt-get update')
  command.append_flag('-y')
  execute_shell(command)
  Kanrisuru::Result.new(command)
end

#apt_upgrade(_opts) ⇒ Object



6
7
8
9
10
11
# File 'lib/kanrisuru/core/apt/commands/upgrade.rb', line 6

def apt_upgrade(_opts)
  command = Kanrisuru::Command.new('apt-get upgrade')
  command.append_flag('-y')
  execute_shell(command)
  Kanrisuru::Result.new(command)
end