Top Level Namespace

Defined Under Namespace

Modules: Rutt Classes: Array

Instance Method Summary collapse

Instance Method Details

#mainObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'bin/rutt', line 42

def main

  Rutt::DB::Config.make_table!
  Rutt::DB::Feed.make_table!
  Rutt::DB::Item.make_table!

  options = {}
  OptionParser.new do |opts|
    opts.banner = "Usage: rutt.rb [options]"

    opts.on('-a', '--add FEED', "Add a feed") do |url|
      Rutt::DB::Feed::add(url)
      exit
    end

    opts.on('-r', '--refresh', "Refresh feeds.") do
      Rutt::DB::Feed::refresh
      exit
    end

    opts.on('-o', '--import-opml FILE', "Import opml") do |file|
      urls = Rutt::Opml::get_urls(file)

      urls.each do |url|
        puts "Adding #{url}"
        Rutt::DB::Feed::add(url, false)
      end

      exit
    end

    opts.on('-s', '--set-key', "Set config") do |key, value|
      Rutt::DB::Config.set(ARGV[0], ARGV[1])
      exit
    end

    opts.on('-k', '--kindle FEED', 'Export feed to kindle.') do |feed_id|
      feed = {
        'id' => feed_id.to_i
      }

      Rutt::Share::Kindle.new(feed)

      exit
    end
#    opts.on('-l', '--list-feeds', action='store_true', help="List the feeds")

  end.parse!

  consumer_key    = Rutt::DB::Config.get("instapaper.consumer-key")
  consumer_secret = Rutt::DB::Config.get("instapaper.consumer-secret")
  username        = Rutt::DB::Config.get("instapaper.username")
  password        = Rutt::DB::Config.get("instapaper.password")

  $instapaper = Rutt::Instapaper::API.new(consumer_key, consumer_secret)
  $instapaper.authorize(username, password)

  start_screen
end

#start_screenObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'bin/rutt', line 25

def start_screen
  stdscr = Ncurses.initscr()

  Ncurses.start_color();
  Ncurses.cbreak();
  Ncurses.noecho();
  Ncurses.keypad(stdscr, true);

  stdscr.clear

  feed_screen = Rutt::Screen::Feed.new(stdscr)
  feed_screen.loop
ensure
  Ncurses.endwin()
end