pqdl 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/bin/pqdl +15 -11
  2. metadata +4 -23
data/bin/pqdl CHANGED
@@ -92,19 +92,19 @@ def pocket_query_select
92
92
  end
93
93
 
94
94
  if pocket_queries.size == 0
95
- puts "There are not Pocket Queries available for download"
95
+ $stderr.puts "There are not Pocket Queries available for download"
96
96
  exit
97
97
  end
98
98
 
99
- puts "Select the Pocket Query you want to download:"
99
+ $stderr.puts "Select the Pocket Query you want to download:"
100
100
 
101
101
  loop do
102
102
  pocket_queries.each_with_index do |pocket_query, i|
103
- puts " (%d) %s [%s]" % [i + 1, pocket_query.name,
103
+ $stderr.puts " (%d) %s [%s]" % [i + 1, pocket_query.name,
104
104
  pocket_query.generated_at.strftime("%c")]
105
105
  end
106
106
 
107
- printf "Pocket Query to download: "
107
+ $stderr.printf "Pocket Query to download: "
108
108
  id = $stdin.gets.to_i
109
109
  break if id > 0 and id <= pocket_queries.size
110
110
  end
@@ -116,7 +116,8 @@ def download
116
116
  guid = ARGV[1] || pocket_query_select
117
117
  fatal "Oops" unless guid
118
118
 
119
- puts "Downloading Pocket Query..."
119
+ download_to_stdout = !$stdout.isatty
120
+ puts "Downloading Pocket Query..." unless download_to_stdout
120
121
 
121
122
  pq = begin
122
123
  $session.download_pocket_query_by_guid(guid)
@@ -132,18 +133,21 @@ def download
132
133
 
133
134
  Zip::ZipFile.foreach(tempfile.path) do |entry|
134
135
  if entry.name =~ /(\d+)\.gpx$/
135
- filename = "#{$1}.gpx"
136
- File.open(filename, "w") do |f|
137
- f.write(entry.get_input_stream.read)
136
+ if download_to_stdout
137
+ $stdout.write(entry.get_input_stream.read)
138
+ else
139
+ filename = "#{$1}.gpx"
140
+ File.open(filename, "w") do |f|
141
+ f.write(entry.get_input_stream.read)
142
+ end
138
143
  end
144
+
139
145
  break
140
146
  end
141
147
  end
142
148
 
143
149
  tempfile.unlink
144
-
145
- fatal "Oops" unless filename
146
- puts "Pocket Query written to #{filename}"
150
+ puts "Pocket Query written to #{filename}" unless download_to_stdout
147
151
  end
148
152
 
149
153
  usage if ARGV.size > 0 and not %w(list download configure).include?(ARGV.first)
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pqdl
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 2
9
- - 1
10
- version: 0.2.1
4
+ prerelease:
5
+ version: 0.3.0
11
6
  platform: ruby
12
7
  authors:
13
8
  - Thomas Cyron
@@ -15,7 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-05-15 00:00:00 +02:00
13
+ date: 2011-05-24 00:00:00 +02:00
19
14
  default_executable:
20
15
  dependencies:
21
16
  - !ruby/object:Gem::Dependency
@@ -26,11 +21,6 @@ dependencies:
26
21
  requirements:
27
22
  - - ">="
28
23
  - !ruby/object:Gem::Version
29
- hash: 63
30
- segments:
31
- - 0
32
- - 8
33
- - 0
34
24
  version: 0.8.0
35
25
  type: :runtime
36
26
  version_requirements: *id001
@@ -42,9 +32,6 @@ dependencies:
42
32
  requirements:
43
33
  - - ">="
44
34
  - !ruby/object:Gem::Version
45
- hash: 3
46
- segments:
47
- - 0
48
35
  version: "0"
49
36
  type: :runtime
50
37
  version_requirements: *id002
@@ -72,23 +59,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
72
59
  requirements:
73
60
  - - ">="
74
61
  - !ruby/object:Gem::Version
75
- hash: 3
76
- segments:
77
- - 0
78
62
  version: "0"
79
63
  required_rubygems_version: !ruby/object:Gem::Requirement
80
64
  none: false
81
65
  requirements:
82
66
  - - ">="
83
67
  - !ruby/object:Gem::Version
84
- hash: 3
85
- segments:
86
- - 0
87
68
  version: "0"
88
69
  requirements: []
89
70
 
90
71
  rubyforge_project:
91
- rubygems_version: 1.3.7
72
+ rubygems_version: 1.5.0
92
73
  signing_key:
93
74
  specification_version: 3
94
75
  summary: Geocaching.com Pocket Query Downloader