Class: Saber::Task::Make
Overview
Usage
Task["make"].invoke(:make, ["bib", "a.epub", "b.epub"])
> create a.epub.torrent and send it to local and remote watch directory.
> create b.epub.torrent ..
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#make(tracker_name, *files) ⇒ Object
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 |
# File 'lib/saber/task/make.rb', line 16 def make(tracker_name, *files) Saber.ui.error! "You need set #{tracker_name}.announce_url in ~/.saberrc first" unless Rc._has_key?("#{tracker_name}.announce_url") files.each { |file| torrent_file = "#{file}.torrent" if Pa.exists?(torrent_file) if ["force"] Pa.rm torrent_file else Saber.ui.say "Skip make: #{file} (torrent alreay exists. use -f to overwrite it.)" next end end system "mktorrent -p -a #{Rc[tracker_name].announce_url} #{file.shellescape}", show_cmd: true # cp tororent file to watch directory. Pa.cp_f torrent_file, Rc.p.watch, show_cmd: true if Rc.p._has_key?(:watch) if Rc.p._has_key?(:remote_watch) require "saber/task/send" Task["send"].invoke(:send, [torrent_file, Rc.p.remote_watch]) end Saber.ui.say "" } end |