Module: Tiqbi

Extended by:
Tiqbi, Utils
Included in:
Tiqbi
Defined in:
lib/tiqbi.rb,
lib/tiqbi/qiita.rb,
lib/tiqbi/utils.rb,
lib/tiqbi/version.rb,
lib/tiqbi/view/base.rb,
lib/tiqbi/view/cursor.rb,
lib/tiqbi/view/main_view.rb,
lib/tiqbi/view/collection.rb,
lib/tiqbi/view_controller.rb,
lib/tiqbi/view/detail_view.rb,
lib/tiqbi/view/command_view.rb

Defined Under Namespace

Modules: Qiita, Utils, View Classes: ViewController

Constant Summary collapse

F_YELLOW_B_BLACK =
1
F_RED_B_BLACK =
2
F_BLUE_B_BLACK =
3
VERSION =
"0.0.2"

Constants included from Utils

Utils::ENTITY_MAP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

format_str, split_str_with_width, unescape_entity

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



15
16
17
# File 'lib/tiqbi.rb', line 15

def options
  @options
end

#view_controllerObject

Returns the value of attribute view_controller.



15
16
17
# File 'lib/tiqbi.rb', line 15

def view_controller
  @view_controller
end

Instance Method Details

#cacheObject



43
44
45
# File 'lib/tiqbi.rb', line 43

def cache
  @cache ||=  ActiveSupport::Cache::MemoryStore.new
end

#configure_cursesObject



51
52
53
54
55
56
57
58
59
# File 'lib/tiqbi.rb', line 51

def configure_curses
  Curses.init_screen
  Curses.start_color
  Curses.init_pair F_YELLOW_B_BLACK, Curses::COLOR_YELLOW, Curses::COLOR_BLACK
  Curses.init_pair F_BLUE_B_BLACK, Curses::COLOR_RED, Curses::COLOR_BLACK
  Curses.init_pair F_RED_B_BLACK, Curses::COLOR_BLUE, Curses::COLOR_BLACK
  Curses.cbreak
  Curses.noecho
end

#loggerObject



47
48
49
# File 'lib/tiqbi.rb', line 47

def logger
  @logger ||= Logger.new root.join('logs/app.log')
end

#rootObject



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

def root
  Pathname.new(File.dirname(__FILE__)).join("..")
end

#run(options) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/tiqbi.rb', line 21

def run(options)
  # initialize console
  self.options = options
  configure_curses
  curses_screen = Curses.stdscr
  self.view_controller = ViewController.new(curses_screen)

  # event loop
  begin
    loop {
      ch = view_controller.current_view.getch
      view_controller.on_input(ch)
    }
  ensure
    Curses.close_screen
  end
end