kat 2.0.7 → 2.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d6336ceffa5cab8bb90a2da89817ef8fa0dbde1a
4
- data.tar.gz: 29c43873af002dc18a1851ec2eeb40cbe27a6643
3
+ metadata.gz: 02227de36b428b2074dc46c055988ed4a7616814
4
+ data.tar.gz: 35ce5e20a8cc5daa1625a426250e198f3bf2eb38
5
5
  SHA512:
6
- metadata.gz: 103598e8673733f1cab5bf2431aebb1c4378b4ddf52c51feac5c0b2e61b0d4cfba8927107bfad7494325033770f4928c8cda3c6ced8d0099f7520f8672c49e51
7
- data.tar.gz: c9f4120a505e4e17829e5d038ccfe14c4dc7b3c06afa13c76e2f7ba6552f1211f4c3379d19329d29a2dd58ac6ac0b5299251475a1bb687948c699b980db75757
6
+ metadata.gz: b0d6a7a02378661db65b1d8637ca7fdafa04c9656dc087840f1f6515cafb8b794c4fac653f65b8a8eba5551653dfc38a4e43b828652d2c3aa72334b6e40c443e
7
+ data.tar.gz: f466f1d2a7f7fc39451c8f30f35c2a7cfb72c3db93e92fd20d7b9642ea6cbab860a556d586275445053a2ee43ec3ff1335bcbb56a851aa690d508c46827f3029
@@ -1,3 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.0.0
4
+ - 2.2.0
data/bin/kat CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require File.dirname(__FILE__) + '/../lib/kat/app'
3
+ require_relative '../lib/kat/app'
4
4
 
5
5
  Kat.app
@@ -23,5 +23,4 @@ Gem::Specification.new do |s|
23
23
  s.add_runtime_dependency 'nokogiri', '~> 1.6'
24
24
  s.add_runtime_dependency 'highline', '~> 1.6'
25
25
  s.add_runtime_dependency 'trollop', '~> 2.0'
26
- s.add_runtime_dependency 'andand', '~> 1.3'
27
26
  end
data/lib/kat.rb CHANGED
@@ -1 +1 @@
1
- require File.dirname(__FILE__) + '/kat/search'
1
+ require_relative 'kat/search'
@@ -1,9 +1,10 @@
1
- require File.dirname(__FILE__) + '/../kat'
2
- require File.dirname(__FILE__) + '/options'
3
- require File.dirname(__FILE__) + '/colour'
1
+ require_relative '../kat'
2
+ require_relative 'options'
3
+ require_relative 'colour'
4
4
 
5
5
  require 'highline'
6
6
  require 'yaml'
7
+ require 'io/console'
7
8
 
8
9
  module Kat
9
10
  #
@@ -94,7 +95,9 @@ module Kat
94
95
  # Get the width of the terminal window
95
96
  #
96
97
  def set_window_width
97
- @window_width = @h.terminal_size[0]
98
+ # Highline 1.7's terminal_size cannot be trusted to return the values in
99
+ # the correct order so just use IO.console.winsize directly
100
+ @window_width = IO.console.winsize[1]
98
101
  end
99
102
 
100
103
  #
@@ -1,5 +1,5 @@
1
- require File.dirname(__FILE__) + '/field_map'
2
- require File.dirname(__FILE__) + '/version'
1
+ require_relative 'field_map'
2
+ require_relative 'version'
3
3
  require 'trollop'
4
4
 
5
5
  module Kat
@@ -1,8 +1,7 @@
1
- require File.dirname(__FILE__) + '/version'
2
- require File.dirname(__FILE__) + '/field_map'
1
+ require_relative 'version'
2
+ require_relative 'field_map'
3
3
  require 'nokogiri'
4
4
  require 'net/http'
5
- require 'andand'
6
5
 
7
6
  module Kat
8
7
  BASE_URL = 'http://kickass.to'
@@ -130,10 +129,6 @@ module Kat
130
129
  build_query
131
130
  end
132
131
 
133
- def sort?
134
- sorts.any? { |k, v| @options[:sort] && k == @options[:sort].intern }
135
- end
136
-
137
132
  #
138
133
  # Perform the search, supplying an optional page number to search on. Returns
139
134
  # a result set limited to the 25 results Kickass Torrents returns itself. Will
@@ -150,7 +145,6 @@ module Kat
150
145
  if res.code == '301'
151
146
  path = Net::HTTP::Get.new(res.header['location'])
152
147
  res = Net::HTTP.start(uri.host) { |http| http.request path }
153
- @message = { message: 'Sort is not functioning' } if sort?
154
148
  end
155
149
 
156
150
  @pages = 0 and return if res.code == '404'
@@ -158,10 +152,10 @@ module Kat
158
152
  doc = Nokogiri::HTML(res.body)
159
153
 
160
154
  @results[page] = doc.xpath('//table[@class="data"]/tr[position()>1]/td[1]').map do |node|
161
- { path: node.css('a.torType').first.andand.attr('href'),
155
+ { path: href_of(node, 'a.torType'),
162
156
  title: node.css('a.cellMainLink').text,
163
- magnet: node.css('a.imagnet').first.andand.attr('href'),
164
- download: node.css('a.idownload').last.andand.attr('href'),
157
+ magnet: href_of(node, 'a.imagnet'),
158
+ download: href_of(node, 'a.idownload'),
165
159
  size: (node = node.next_element).text,
166
160
  files: (node = node.next_element).text.to_i,
167
161
  age: (node = node.next_element).text,
@@ -320,5 +314,15 @@ module Kat
320
314
  !(@results.empty? || @results.first.empty?) &&
321
315
  (@results.first.first[method] || @results.first.first[method[0..-2].intern]) || super
322
316
  end
317
+
318
+ #
319
+ # tries to find the first <selector> in <scope> and read its href
320
+ # attribute, returns nil elsewise
321
+ #
322
+ def href_of(scope, selector)
323
+ if node = scope.css(selector).first
324
+ node.attr('href')
325
+ end
326
+ end
323
327
  end
324
328
  end
@@ -1,6 +1,6 @@
1
1
  module Kat
2
2
  NAME = 'Kickass Torrents Search'
3
- VERSION = '2.0.7'
3
+ VERSION = '2.0.9'
4
4
  MALEVOLENT_DICTATOR_FOR_LIFE = 'Fission Xuiptz'
5
5
  AUTHOR = MALEVOLENT_DICTATOR_FOR_LIFE
6
6
  VERSION_STR = "#{ NAME } #{ VERSION } (c) 2013 #{ MALEVOLENT_DICTATOR_FOR_LIFE }"
@@ -1,5 +1,5 @@
1
1
  require 'minitest/autorun'
2
- require File.dirname(__FILE__) + '/../../lib/kat/app'
2
+ require_relative '../../lib/kat/app'
3
3
 
4
4
  app = Kat::App.new %w(aliens -c movies -o .)
5
5
  app.kat.go(1).go(app.kat.pages - 1)
@@ -1,5 +1,5 @@
1
1
  require 'minitest/autorun'
2
- require File.dirname(__FILE__) + '/../../lib/kat/colour'
2
+ require_relative '../../lib/kat/colour'
3
3
 
4
4
  describe Kat::Colour do
5
5
  let(:colours) { %i(black red green yellow blue magenta cyan white) }
@@ -1,5 +1,5 @@
1
1
  require 'minitest/autorun'
2
- require File.dirname(__FILE__) + '/../../lib/kat/options'
2
+ require_relative '../../lib/kat/options'
3
3
 
4
4
  describe Kat::Options do
5
5
 
@@ -1,10 +1,12 @@
1
1
  require 'minitest/autorun'
2
- require File.dirname(__FILE__) + '/../../lib/kat/search'
3
-
4
- blue_peter = Kat.search
5
- blue_peter.go.go 1
2
+ require_relative '../../lib/kat/search'
6
3
 
7
4
  describe Kat::Search do
5
+ let(:blue_peter) do
6
+ Kat.search do |k|
7
+ k.go.go 1
8
+ end
9
+ end
8
10
 
9
11
  let(:kat) { Kat.search 'test' }
10
12
  let(:kat_opts) { Kat.search 'test', category: 'books' }
@@ -39,13 +41,16 @@ describe Kat::Search do
39
41
  end
40
42
 
41
43
  it 'responds to result fields after a search' do
44
+ blue_peter.search # trigger page parse?
42
45
  %i(titles files).each do |s|
43
46
  blue_peter.respond_to?(s).must_equal true
44
47
  end
45
48
  end
46
49
 
47
50
  it 'returns identical result sets' do
48
- blue_peter.results[0].must_equal blue_peter.search
51
+ called = blue_peter.search
52
+ first_page = blue_peter.results[0]
53
+ first_page.must_equal called
49
54
  end
50
55
 
51
56
  it 'returns a full result set' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kat
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.7
4
+ version: 2.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fission Xuiptz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-11 00:00:00.000000000 Z
11
+ date: 2015-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.0'
55
- - !ruby/object:Gem::Dependency
56
- name: andand
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.3'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.3'
69
55
  description: A Ruby interface to Kickass Torrents
70
56
  email: fissionxuiptz@softwaremojo.com
71
57
  executables:
@@ -112,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
98
  version: '0'
113
99
  requirements: []
114
100
  rubyforge_project:
115
- rubygems_version: 2.2.2
101
+ rubygems_version: 2.4.5
116
102
  signing_key:
117
103
  specification_version: 4
118
104
  summary: Kickass Torrents Interface