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 "---\nUsage: vnews \n\nWhen you run Vnews for the first time, a .vnewsrc configuration file will be\ngenerated in your home directory. You must edit this file to match your MySQL\nsettings, and then run `vnews --create-db`.\n\nAfter that you can run `vnews` to read your feeds.\n\nSpecific options:\n\n-u, --update Update all feeds and folders before starting vnews\n-U Update all feeds and folders without starting vnews session\n--opml [opml file] Import feeds from an OPML file\n--create-db Create MySQL database configured in .vnewrc \n-v, --version Show version\n-h, --help Show this message\n\nPlease visit http://danielchoi.com/software/vnews.html for more help.\n\n--- \n END\n exit\n end\n\n\n if ARGV.first == \"--create-db\"\n c = File.read(Vnews::Config::CONFIGPATH) \n top, bottom = c.split(/^\\s*$/,2)\n dbconfig = YAML::load(top)\n puts \"Creating database: \#{dbconfig['database']}\"\n Vnews::Sql.create_db dbconfig\n puts \"OK if everything went ok, you can create your feeds and folders with `vnews -u`.\"\n exit\n end\n\n if ARGV.first == \"--opml\"\n require 'vnews/opml'\n # opml file must be second arg\n puts \"Importing OPML file \#{ARGV[1]}\"\n Vnews::Opml.import File.read(ARGV[1])\n # rewrite .vnewsrc config\n puts \"Rewriting config file \#{Vnews::Config::CONFIGPATH} to reflect changes.\"\n Vnews::Config.rewrite_config\n puts \"Done.\"\n end\n\n if ['--update', '-u', '-U'].include?(ARGV.first)\n Vnews::Config.update_folders\n if ARGV.first == '-U'\n exit\n end\n end\n\n puts \"Starting vnews \#{Vnews::VERSION}\"\n Vnews.sql_client # loads the config\n\n vim = ENV['VNEWS_VIM'] || 'vim'\n vimscript = File.join(File.dirname(__FILE__), \"vnews.vim\")\n vim_command = \"\#{vim} -S \#{vimscript} \"\n STDERR.puts vim_command\n system(vim_command)\n if vim == 'mvim'\n DRb.thread.join\n end\nend\n" |