pqdl 0.1.0 → 0.2.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 +11 -6
  2. metadata +3 -3
data/bin/pqdl CHANGED
@@ -7,6 +7,11 @@ require "zip/zip"
7
7
 
8
8
  CONFIG_PATH = File.expand_path("~/.pqdl.yml")
9
9
 
10
+ trap "INT" do
11
+ $session.close if $session and $session.open?
12
+ exit 1
13
+ end
14
+
10
15
  def usage
11
16
  $stderr.puts "Usage: pqdl list"
12
17
  $stderr.puts " pqdl download [guid]"
@@ -26,9 +31,8 @@ def configure
26
31
 
27
32
  File.open(CONFIG_PATH, "w") do |f|
28
33
  f.write({ "username" => ARGV[1], "password" => ARGV[2] }.to_yaml)
34
+ f.chmod(0700)
29
35
  end
30
-
31
- File.new(CONFIG_PATH).chmod(0700)
32
36
  end
33
37
 
34
38
  def read_config
@@ -96,7 +100,8 @@ def pocket_query_select
96
100
 
97
101
  loop do
98
102
  pocket_queries.each_with_index do |pocket_query, i|
99
- puts " (#{i + 1}) #{pocket_query.name}"
103
+ puts " (%d) %s [%s]" % [i + 1, pocket_query.name,
104
+ pocket_query.generated_at.strftime("%c")]
100
105
  end
101
106
 
102
107
  printf "Pocket Query to download: "
@@ -124,7 +129,7 @@ def download
124
129
  tempfile = Tempfile.new(guid)
125
130
  tempfile.write(pq)
126
131
 
127
- Zip::ZipFile.foreach(tempfile) do |entry|
132
+ Zip::ZipFile.foreach(tempfile.path) do |entry|
128
133
  if entry.name =~ /(\d+)\.gpx$/
129
134
  filename = "#{$1}.gpx"
130
135
  File.open(filename, "w") do |f|
@@ -141,14 +146,14 @@ def download
141
146
  puts "Pocket Query written to #{filename}"
142
147
  end
143
148
 
144
- usage unless ARGV.size > 0 or %w(list download configure).include?(ARGV.first)
149
+ usage if ARGV.size > 0 and not %w(list download configure).include?(ARGV.first)
145
150
 
146
151
  unless ARGV.first == "configure"
147
152
  read_config
148
153
  open_session
149
154
  end
150
155
 
151
- send(ARGV.first)
156
+ send(ARGV.first || "download")
152
157
 
153
158
  begin
154
159
  $session.close if $session
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: pqdl
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Thomas Cyron
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-30 00:00:00 +02:00
13
+ date: 2011-05-11 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -35,7 +35,7 @@ dependencies:
35
35
  version: "0"
36
36
  type: :runtime
37
37
  version_requirements: *id002
38
- description: Download Pocket Queries from your command line
38
+ description: Download Geocaching.com Pocket Queries from your command line
39
39
  email: thomas@thcyron.de
40
40
  executables:
41
41
  - pqdl