class Jekyll::Site
Public Instance Methods
make_torrent()
click to toggle source
# File lib/jekyll-torrent.rb, line 15 def make_torrent # The torrent file is written at the root of the site file = "#{dest}/#{torrent['file']}" tracker = [torrent['announce']].flatten tracker = random_tracker if tracker.include? 'random' trackers = tracker.join(' --tracker ') # Delete existing file File.delete(file) if File.exists?(file) puts "Generating torrent file at #{file}" # TODO usar popen3 command = "#{torrent['bin']} --tracker #{trackers} --outfile \"#{file}\" #{torrent['flags']} \"#{dest}\"" puts command puts `#{command}` end
process_with_torrent()
click to toggle source
# File lib/jekyll-torrent.rb, line 9 def process_with_torrent # Original Site.process method process_without_torrent self.make_torrent end
Also aliased as: process
random_tracker()
click to toggle source
# File lib/jekyll-torrent.rb, line 32 def random_tracker open('https://ngosang.github.io/trackerslist/trackers_best.txt') do |l| l.read end.split("\n\n").sample(3) end
Private Instance Methods
torrent()
click to toggle source
Merges config with default values
# File lib/jekyll-torrent.rb, line 44 def torrent @torrent_config ||= { 'announce' => 'udp://tracker.opentrackr.org:1337/announce', 'file' => 'site.torrent', 'flags' => '', 'bin' => 'transmission-create' }.merge(config.fetch('torrent', {})) end