Class: Vnews
- Inherits:
-
Object
- Object
- Vnews
- Defined in:
- lib/vnews.rb,
lib/vnews/sql.rb,
lib/vnews/feed.rb,
lib/vnews/opml.rb,
lib/vnews/config.rb,
lib/vnews/folder.rb,
lib/vnews/display.rb,
lib/vnews/version.rb,
lib/vnews/constants.rb,
lib/vnews/exceptions.rb,
lib/vnews/autodiscoverer.rb
Defined Under Namespace
Modules: Autodiscoverer, Config Classes: AutodiscoveryFailed, Display, Feed, Folder, Opml, Sql, SubscribeFailed
Constant Summary collapse
- VERSION =
'0.4.6'
- TIMEOUT =
Timeout limit for fetching feeds
25
- POOLSIZE =
size of thread pool for fetching feeds
10
Class Method Summary collapse
Class Method Details
.sql_client ⇒ Object
7 8 9 |
# File 'lib/vnews/config.rb', line 7 def self.sql_client $sql_client ||= Config.load_config end |
.start ⇒ Object
9 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 37 38 39 40 41 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 |
# File 'lib/vnews.rb', line 9 def self.start ["tidy", "fmt"].each do |x| if `which #{x}` == '' puts "Before you can run Vnews, you need to install #{x}." exit end end if ! File.exists?(File.(Vnews::Config::CONFIGPATH)) puts "Missing #{Vnews::Config::CONFIGPATH}" # generate this file puts "Generating stub config file at #{Vnews::Config::CONFIGPATH}" File.open(Vnews::Config::CONFIGPATH, 'w') {|f| f.write(Config.stub_config)} puts "Please edit this file and then run `vnews --create-db` to create your Vnews MySQL database." exit end if ['--version', '-v', "--help", "-h"].include?(ARGV.first) puts "vnews #{Vnews::VERSION}" puts "by Daniel Choi [email protected]" puts puts <<-END --- Usage: vnews When you run Vnews for the first time, a .vnewsrc configuration file will be generated in your home directory. You must edit this file to match your MySQL settings, and then run `vnews --create-db`. After that you can run `vnews` to read your feeds. Specific options: -u, --update Update all feeds and folders before starting vnews -U Update all feeds and folders without starting vnews session --opml [opml file] Import feeds from an OPML file --create-db Create MySQL database configured in .vnewrc -v, --version Show version -h, --help Show this message Please visit http://danielchoi.com/software/vnews.html for more help. --- END exit end if ARGV.first == "--create-db" c = File.read(Vnews::Config::CONFIGPATH) top, bottom = c.split(/^\s*$/,2) dbconfig = YAML::load(top) puts "Creating database: #{dbconfig['database']}" Vnews::Sql.create_db dbconfig puts "OK if everything went ok, you can create your feeds and folders with `vnews -u`." exit end if ARGV.first == "--opml" require 'vnews/opml' # opml file must be second arg puts "Importing OPML file #{ARGV[1]}" Vnews::Opml.import File.read(ARGV[1]) # rewrite .vnewsrc config puts "Rewriting config file #{Vnews::Config::CONFIGPATH} to reflect changes." Vnews::Config.rewrite_config puts "Done." end if ['--update', '-u', '-U'].include?(ARGV.first) Vnews::Config.update_folders if ARGV.first == '-U' exit end end puts "Starting vnews #{Vnews::VERSION}" Vnews.sql_client # loads the config vim = ENV['VNEWS_VIM'] || 'vim' vimscript = File.join(File.dirname(__FILE__), "vnews.vim") vim_command = "#{vim} -S #{vimscript} " STDERR.puts vim_command system(vim_command) if vim == 'mvim' DRb.thread.join end end |