Sha256: 5b465061761a9849108b0da52e406d9e798f7430971c1d1431bed987199b69ec
Contents?: true
Size: 1.46 KB
Versions: 4
Compression:
Stored size: 1.46 KB
Contents
# -*- coding: UTF-8 -*- # # Copyright 2013 whiteleaf. All rights reserved. # require_relative "../localsetting" module Command class Browser < CommandBase def initialize super("<target> [<target2> ...]") @opt.separator <<-EOS ・指定した小説の掲載ページをブラウザで開きます。 Example: narou browser n9669bk narou browser musyoku EOS @opt.on("-v", "--vote", "指定した小説の投票・感想を投稿するページを表示する") { @options["vote"] = true } end def execute(argv) super if argv.empty? puts @opt.help return end argv.each do |target| data = Downloader.get_data_by_target(target) unless data warn "#{target} は存在しません" next end toc_url = data["toc_url"] if @options["vote"] # TODO: 最新話の場所をAPIで取得する data_dir = Downloader.get_novel_data_dir_by_target(data["id"]) latest_index = YAML.load_file(File.join(data_dir, Downloader::TOC_FILE_NAME))["subtitles"].last["index"] open_url = "#{toc_url + latest_index}/#f_cr" else open_url = toc_url end Helper.open_url_by_browser(open_url) puts open_url end end def oneline_help "小説の掲載ページをブラウザで開きます" end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
narou-1.1.1 | lib/command/browser.rb |
narou-1.1.0 | lib/command/browser.rb |
narou-1.1.0.rc2 | lib/command/browser.rb |
narou-1.1.0.rc1 | lib/command/browser.rb |