module RubyNews

Constants

MAJOR
MINOR
PATCH
VERSION

Public Class Methods

banner() click to toggle source
main( args=ARGV ) click to toggle source
# File lib/rubynews/tool.rb, line 125
def self.main( args=ARGV )

  dbpath = "#{Env.home}/.news/news.db"
  #  puts "dbpath: >#{dbpath}<"

  FileUtils.mkdir_p( File.dirname(dbpath) )     ## make sure path exists!!

  News.config.database = { adapter:   'sqlite3',
                           database:  dbpath }

  tool =  Tool.new

  if args.empty? && News.items.count == 0    ## on first-time auto-update
    puts
    puts
    tool.banner
    puts
    puts ">> TIP: Type > rubynews update < to update all news feeds. <<"
    puts
    puts "First time? Do you want to update all news feeds now?"
    puts
    print ">> Press y for yes; press any key to continue. <<"
    ch = STDIN.getch
    print "\r"
    print "                                                   "
    print "\n"

    if ch == 'y' or ch == 'Y'
      tool.update
      puts
      puts
    end

    tool.list
  else

    if args.include?( 'u' ) ||
       args.include?( 'up' )  ||
       args.include?( 'update' )
       puts
       puts
       tool.banner
       puts
       tool.update
    else
      puts
      puts ">> TIP: Type > rubynews update < to update all news feeds. <<"
      puts
      puts
      ## todo/fix:  add Last update on ??? --
      ##  add to News module use News.date ?
      ##                   or use News.last_updated / last_update / last_fetch / fetched

      tool.banner
      puts
      tool.list
    end
  end
end
root() click to toggle source
# File lib/rubynews/version.rb, line 16
def self.root
  "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
end
version() click to toggle source
# File lib/rubynews/version.rb, line 8
def self.version
  VERSION
end