torckapi 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b2132ac0c587ca136fb4e0069018f02973d6d5e6
4
- data.tar.gz: d72518b11c78f359da5857dfdc6491e96a636604
3
+ metadata.gz: e63d158cc83bd620b0e3f2671cbdc39e500404b1
4
+ data.tar.gz: 11b49a8e0d6b610f868197176be4abb2b4554c0b
5
5
  SHA512:
6
- metadata.gz: cdd4f816b4e1526dc975cc8439a9e64cf17897fd1406343b5c202076bb724c38ca44e487d5a43aabe1f0158c68172b9b7df6b3caf52de1b07d6ad03b3dc7d099
7
- data.tar.gz: 89779cb521dfa7e3497909e11c9713dcb7ef650d44a85e17cc318a4e820be1db8243b8960262d554757c0f3077a5734bb8fe3039cc23116683696e33d94f4ef3
6
+ metadata.gz: b122efcf5a5f877563e00a5de5ef64beb4b654792306ab83753514e415a25e7e6efe8a991144594af87d76ba58c38bce4403aaafbaaf9348f614f94482dc547a
7
+ data.tar.gz: 45b10ca430ede0a93ebfe6a239601daab5ff38e12f50f2f4d6fa7a649a6333cce0954591e86c59724f00a6f75626f2434ac347efc93534f3b91d2450446eae83
@@ -19,6 +19,8 @@ module Torckapi
19
19
  # @param data [String] UDP response data (omit action and transaction_id)
20
20
  # @return [Torckapi::Response::Announce] response
21
21
  def self.from_udp info_hash, data
22
+ return new(info_hash, nil, nil, []) unless data
23
+
22
24
  leechers, seeders = data[0..7].unpack('L>2')
23
25
 
24
26
  new info_hash, leechers, seeders, peers_from_compact(data[8..-1], leechers + seeders)
@@ -30,6 +32,8 @@ module Torckapi
30
32
  # @param compact [true, false] is peer data in compact format?
31
33
  # @return [Torckapi::Response::Announce] response
32
34
  def self.from_http info_hash, data, compact=true
35
+ return new(info_hash, nil, nil, []) unless data
36
+
33
37
  bdecoded_data = BEncode.load(data)
34
38
  leechers, seeders = bdecoded_data.values_at("incomplete", "complete")
35
39
 
@@ -11,6 +11,8 @@ module Torckapi
11
11
  # @param data [String] UDP response data (omit action and transaction_id)
12
12
  # @return [Torckapi::Response::Scrape] response
13
13
  def self.from_udp info_hashes, data
14
+ return new({}) unless data
15
+
14
16
  new Hash[info_hashes.zip(data.unpack('a12' * (info_hashes.count)).map { |i| Hash[[:seeders, :completed, :leechers].zip i.unpack('L>3').map(&:to_i)] })]
15
17
  end
16
18
 
@@ -1,3 +1,3 @@
1
1
  module Torckapi
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torckapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Krupenik