pirate_bay_ruby 0.0.5 → 0.0.6

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.
@@ -1,42 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'commander/import'
4
-
5
3
  require 'pirate_bay_ruby'
6
-
7
- HighLine.track_eof = false # Fix for built-in Ruby
8
4
  Signal.trap("INT") {} # Suppress backtrace when exiting command
9
5
 
10
- program :version, PirateBayRuby::VERSION
11
- program :description, 'A command-line interface for searching the pirate bay'
12
-
13
- program :help, 'Author', 'Kevin Johnson <kevinejohn@gmail.com>'
14
- program :help, 'Website', 'https://github.com/kevinejohn'
15
- program :help_formatter, :compact
16
-
17
- default_command :help
18
-
19
- command :search do |c|
20
- c.syntax = 'pirate_bay_ruby search "Ubuntu"'
21
- c.summary = 'Searches the pirate bay'
22
- c.description = ''
23
-
24
- c.example 'description', 'pirate_bay_ruby search "Ubuntu'
25
-
26
- c.action do |args, options|
27
- say_error "One or more arguments required" and abort if args.empty?
28
-
29
- @environment = options.environment.downcase.to_sym rescue :development
30
- say_error "Invalid environment,'#{@environment}' (should be either :development or :production)" and abort unless [:development, :production].include?(@environment)
31
-
32
- if args.count == 1
33
- PirateBayRuby.search(args[0])
34
- elsif args.count == 2
35
- PirateBayRuby.search(args[0], args[1])
36
- else
37
- say_error "Invalid number of arguments" and abort
38
- end
39
-
40
- say_ok "Done"
41
- end
42
- end
6
+ if ARGV.empty? or ARGV.length > 2
7
+ puts "Examples:\nSearch: #{File.basename(__FILE__)} \"Ubuntu\"\nDownload: #{File.basename(__FILE__)} \"Ubuntu\" 1"
8
+ exit
9
+ else
10
+ PirateBayRuby.search(ARGV[0], ARGV[1])
11
+ end
@@ -7,10 +7,11 @@ module PirateBayRuby
7
7
  #module_function
8
8
 
9
9
  def self.search(name, number=0)
10
+ return if name.nil?
10
11
  number = number.to_i
11
12
 
12
13
  doc = Nokogiri::HTML(open("http://thepiratebay.sx/search/#{URI.escape(name)}/0/7/0"))
13
-
14
+
14
15
  cnt = 1
15
16
  doc.xpath('//*[@id="searchResult"]').search('tr').each do |row|
16
17
  name = row.search('a.detLink')
@@ -43,7 +44,7 @@ module PirateBayRuby
43
44
  `open #{magnet_link}`
44
45
  break
45
46
  end
46
-
47
+
47
48
  cnt = cnt + 1
48
49
  end
49
50
 
@@ -1,3 +1,3 @@
1
1
  module PirateBayRuby
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pirate_bay_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-16 00:00:00.000000000 Z
12
+ date: 2013-08-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -105,18 +105,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
105
  - - ! '>='
106
106
  - !ruby/object:Gem::Version
107
107
  version: '0'
108
- segments:
109
- - 0
110
- hash: 3182293004420740528
111
108
  required_rubygems_version: !ruby/object:Gem::Requirement
112
109
  none: false
113
110
  requirements:
114
111
  - - ! '>='
115
112
  - !ruby/object:Gem::Version
116
113
  version: '0'
117
- segments:
118
- - 0
119
- hash: 3182293004420740528
120
114
  requirements: []
121
115
  rubyforge_project:
122
116
  rubygems_version: 1.8.25