cdb-crawlr 0.1.1 → 0.2.0
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.
- data/bin/cdb +13 -12
- data/lib/cdb-crawlr.rb +1 -1
- data/lib/cdb/cli.rb +5 -10
- data/lib/cdb/struct.rb +1 -0
- metadata +3 -3
data/bin/cdb
CHANGED
@@ -14,7 +14,6 @@ end
|
|
14
14
|
|
15
15
|
@global = OptionParser.new do |opts|
|
16
16
|
opts.banner = "Usage: cdb [-h|--help] [-v|--version] <command> [<args>]"
|
17
|
-
|
18
17
|
opts.on("-h", "--help", "Display this screen"){ print_help }
|
19
18
|
opts.on("-v", "--version", "Show version information") do
|
20
19
|
puts "cdb #{CDB::VERSION}"; exit
|
@@ -22,20 +21,13 @@ end
|
|
22
21
|
end
|
23
22
|
|
24
23
|
@search = OptionParser.new do |opts|
|
25
|
-
opts.banner = "Usage: cdb search [-h|--help]
|
26
|
-
|
24
|
+
opts.banner = "Usage: cdb search [-h|--help] <type> <query>"
|
27
25
|
opts.on("-h", "--help", "Display this screen"){ print_help opts }
|
28
|
-
opts.on("-s", "--scope=<type>", "Specify type of search. Default: all") do |v|
|
29
|
-
begin
|
30
|
-
$cli[:scope] = v
|
31
|
-
rescue
|
32
|
-
print_help opts, "invalid scope: #{v}"
|
33
|
-
end
|
34
|
-
end
|
35
26
|
end
|
36
27
|
|
37
28
|
@command_opts = {
|
38
|
-
'search' => @search
|
29
|
+
'search' => @search,
|
30
|
+
'show' => nil # stub
|
39
31
|
}
|
40
32
|
|
41
33
|
# Parse global flags
|
@@ -62,7 +54,16 @@ rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e
|
|
62
54
|
print_help command_opt, e
|
63
55
|
end
|
64
56
|
|
65
|
-
# Pop and verify
|
57
|
+
# Pop and verify type
|
58
|
+
begin
|
59
|
+
type = ARGV.shift
|
60
|
+
$cli[:type] = type
|
61
|
+
rescue
|
62
|
+
error = "invalid type: #{type}" unless type.to_s.empty?
|
63
|
+
print_help command_opt, error
|
64
|
+
end
|
65
|
+
|
66
|
+
# Verify args
|
66
67
|
begin
|
67
68
|
$cli[:args] = ARGV.join(' ')
|
68
69
|
rescue => e
|
data/lib/cdb-crawlr.rb
CHANGED
data/lib/cdb/cli.rb
CHANGED
@@ -3,7 +3,7 @@ require 'pp'
|
|
3
3
|
module CDB
|
4
4
|
class CLI
|
5
5
|
COMMANDS = %w[search]
|
6
|
-
|
6
|
+
TYPES = %w[series issue issues]
|
7
7
|
|
8
8
|
def initialize(options={})
|
9
9
|
@options = options
|
@@ -19,9 +19,9 @@ module CDB
|
|
19
19
|
when :command
|
20
20
|
v = v.downcase
|
21
21
|
raise unless COMMANDS.include?(v)
|
22
|
-
when :
|
22
|
+
when :type
|
23
23
|
v = v.downcase.gsub(/^=/, '')
|
24
|
-
raise unless
|
24
|
+
raise unless TYPES.include?(v)
|
25
25
|
when :args
|
26
26
|
if self[:command] == 'search'
|
27
27
|
raise "invalid search query" if v.empty?
|
@@ -37,15 +37,10 @@ module CDB
|
|
37
37
|
private
|
38
38
|
|
39
39
|
def search
|
40
|
-
case self[:
|
41
|
-
when 'all'
|
42
|
-
CDB.search(self[:args]).each do |key, res|
|
43
|
-
puts key.to_s.capitalize+':'
|
44
|
-
res.each{|r| puts ' '+r.to_json}
|
45
|
-
end
|
40
|
+
case self[:type]
|
46
41
|
when 'series'
|
47
42
|
CDB::Series.search(self[:args]).each{|r| puts r.to_json}
|
48
|
-
when 'issue'
|
43
|
+
when 'issue', 'issues'
|
49
44
|
CDB::Issue.search(self[:args]).each{|r| puts r.to_json}
|
50
45
|
end
|
51
46
|
end
|
data/lib/cdb/struct.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cdb-crawlr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-11-03 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
16
|
-
requirement: &
|
16
|
+
requirement: &18869830 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *18869830
|
25
25
|
description: cdb-crawlr is a Ruby gem and command-line tool for querying ComicBookDB.com
|
26
26
|
email:
|
27
27
|
- sgt.floydpepper@gmail.com
|