jgm-cloudlib 0.3.5 → 0.3.8

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.
Files changed (4) hide show
  1. data/bin/cloudlib +15 -4
  2. data/cloudlib.gemspec +2 -2
  3. data/lib/cloudlib.rb +2 -2
  4. metadata +6 -2
data/bin/cloudlib CHANGED
@@ -99,7 +99,7 @@ def menu(items)
99
99
  while true
100
100
  commands = ["find KEYWORDS", "quit"]
101
101
  if items.length > 0
102
- then commands = ["bib NUM", "get NUM", "del NUM", "mod NUM"] + commands
102
+ then commands = ["bib NUM", "get NUM", "del NUM", "mod NUM", "url NUM"] + commands
103
103
  end
104
104
  choices = commands.join(' | ')
105
105
  ans = ask("#{choices} ? ", String) { |q| q.readline = true; q.case = :downcase }
@@ -116,7 +116,7 @@ def menu(items)
116
116
  query = $1
117
117
  token, items = Cloudlib::Entry.query(query, NUMITEMS)
118
118
  show_items(items, more=(not token.empty?))
119
- elsif ans =~ /^(get|del|mod|bib) *(\d+)$/
119
+ elsif ans =~ /^(get|del|mod|bib|url) *(\d+)$/
120
120
  num = $2.to_i
121
121
  if (num < 0) || (num >= items.length)
122
122
  next
@@ -134,6 +134,9 @@ def menu(items)
134
134
  item.delete
135
135
  when "bib":
136
136
  puts item.to_bibtex
137
+ when "url":
138
+ validminutes = ask("How long (in minutes) should the link be valid? ", Integer) { |q| q.default = 10; q.readline = true; }
139
+ puts item.url(validminutes)
137
140
  else
138
141
  raise "Unknown command."
139
142
  end
@@ -191,7 +194,11 @@ if ARGV.length >= 1
191
194
  end
192
195
  if ARGV[0] == "list"
193
196
  STDERR.puts "Generating list of entries (this may take a while)..."
194
- dummy, entries = Cloudlib::Entry.query("", nil)
197
+ token, entries = Cloudlib::Entry.query("",100)
198
+ while not (token.empty?)
199
+ token, next_entries = Cloudlib::Entry.query("", 100, token)
200
+ entries += next_entries
201
+ end
195
202
  total_size = entries.inject(0) do |accum, e|
196
203
  size = e.attributes['size'][0].to_i / (1024.0 * 1024.0)
197
204
  printf "%7.2f MB %s\n", size, e.to_s
@@ -205,7 +212,11 @@ if ARGV.length >= 1
205
212
  if ARGV[0] == "dump"
206
213
  path = ARGV[1] || ask("Dump to which directory? ", String) { |q| q.default = "."; q.echo = true }
207
214
  new_entries = 0
208
- dummy, entries = Cloudlib::Entry.query("", nil)
215
+ token, entries = Cloudlib::Entry.query("",100)
216
+ while not (token.empty?)
217
+ token, next_entries = Cloudlib::Entry.query("", 100, token)
218
+ entries += next_entries
219
+ end
209
220
  total_size = entries.inject(0) {|accum, e| accum + e.attributes['size'][0].to_i}
210
221
  printf("Total size is %.2f megabytes.\n", (total_size / (1024.0 * 1024.0)))
211
222
  open("#{path}/#{ENV['CLOUDLIB_LIBRARY_NAME']}.db", 'w') do |file|
data/cloudlib.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cloudlib"
3
- s.version = "0.3.5"
4
- s.date = "2008-12-29"
3
+ s.version = "0.3.8"
4
+ s.date = "2009-04-26"
5
5
  s.summary = "Tools for maintaining a library of books and articles in Amazon S3 and SimpleDB"
6
6
  s.email = "jgm@berkeley.edu"
7
7
  s.homepage = "http://github.com/jgm/cloudlib"
data/lib/cloudlib.rb CHANGED
@@ -366,8 +366,8 @@ class Entry
366
366
  Entry.fields(entry_type)
367
367
  end
368
368
 
369
- def url
370
- AWS::S3::S3Object.find(self.name, @@bucket).url(:expires_in => 60 * 10) # expires in 10 min
369
+ def url(minutes = 10)
370
+ AWS::S3::S3Object.url_for(self.name, @@bucket, :expires_in => 60 * minutes)
371
371
  end
372
372
 
373
373
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jgm-cloudlib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - John MacFarlane
@@ -9,11 +9,12 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-29 00:00:00 -08:00
12
+ date: 2009-04-26 00:00:00 -07:00
13
13
  default_executable: cloudlib
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: aws-s3
17
+ type: :runtime
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
@@ -23,6 +24,7 @@ dependencies:
23
24
  version:
24
25
  - !ruby/object:Gem::Dependency
25
26
  name: aws-sdb
27
+ type: :runtime
26
28
  version_requirement:
27
29
  version_requirements: !ruby/object:Gem::Requirement
28
30
  requirements:
@@ -32,6 +34,7 @@ dependencies:
32
34
  version:
33
35
  - !ruby/object:Gem::Dependency
34
36
  name: sinatra
37
+ type: :runtime
35
38
  version_requirement:
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
@@ -41,6 +44,7 @@ dependencies:
41
44
  version:
42
45
  - !ruby/object:Gem::Dependency
43
46
  name: highline
47
+ type: :runtime
44
48
  version_requirement:
45
49
  version_requirements: !ruby/object:Gem::Requirement
46
50
  requirements: