Class: Pirka::App::Lib

Inherits:
Object
  • Object
show all
Includes:
Subcommand
Defined in:
app/lib.rb

Constant Summary collapse

PROGRAM_NAME =
"lib"
DESCRIPTION =
_("Show library infomation")

Instance Method Summary collapse

Methods included from Subcommand

included, #initialize

Instance Method Details

#run(argv) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/lib.rb', line 10

def run(argv)
  # show all
  # show remote repos
  # show data dirs
  # show data home
  # show books
  # show book metadata

  no_dir_file_length = Library::SUBDIR_LENGTH + Library::EXT.length
  Library.directories.each do |dir|
    next unless dir.directory?

    dir.each_child do |child|
      if child.to_path.length < no_dir_file_length && child.extname != Library::EXT
        show_info child
        next
      end
      next unless child.directory?
      next unless child.basename.to_path.length == Library::SUBDIR_LENGTH
      child.each_child do |lib|
        next unless lib.extname == Library::EXT
        next unless lib.file?
        show_info lib
      end
    end
  end
end

#show_info(path) ⇒ Object



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

def show_info(path)
  $stdout.puts Library.load_file(path)..to_yaml
  $stdout.puts "library: %{path}" % {path: path}
end