Sha256: ed8b26b49f1919889710505ff2acb49cf8273c124732dacee2e5929cb85d9bdc

Contents?: true

Size: 808 Bytes

Versions: 2

Compression:

Stored size: 808 Bytes

Contents

class TransmissionApi::ClientFake < TransmissionApi::Client

  attr_reader :torrents

  def initialize(opts)
    super
    torrents_path = opts[:torrents_path] || "#{File.dirname(__FILE__)}/../torrents_fake.json"
    @torrents = JSON.parse(File.read(torrents_path))
  end

  def all
    torrents
  end

  def find(id)
    torrents.select { |e| e["hashString"] == id }.first
  end

  def create(filename)
    torrent = {
      "files" => [],
      "hashString" => "77831ec368308f1031434c5581a76fd0c3e06cfd",
      "name" => "No Media Kings - Ghosts With Shit Jobs trailer",
      "percentDone" => 0,
      "rateUpload" => 0,
      "rateDownload" => 0,
      "totalSize" => 100
    }

    torrents << torrent

    torrent
  end

  def destroy(id)
    torrents.delete_if { |e| e["hashString"] == id }
  end

end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
huginn_transmission_agent-0.1 lib/transmission_api/client_fake.rb
transmission_api-0.0.7 lib/transmission_api/client_fake.rb