lib/s3repo/repo.rb in s3repo-0.0.3 vs lib/s3repo/repo.rb in s3repo-0.1.0
- old
+ new
@@ -6,16 +6,29 @@
class Repo < Base
def initialize(params = {})
super
end
- def add_package(file)
- upload!(file)
+ def build_packages(paths)
+ paths.each do |path|
+ dir = File.dirname(path)
+ puts "Building #{File.basename(dir)}"
+ Dir.chdir(dir) { run 'makepkg -f' }
+ end
end
+ def add_packages(paths)
+ paths.each do |path|
+ key = File.basename(path)
+ next if include? key
+ client.upload!(key, path)
+ end
+ metadata.add_packages(paths)
+ end
+
def packages
- meta_cache.cache { parse_packages }
+ package_cache.cache { parse_packages }
end
def include?(key)
!packages.find { |x| x.key == key }.nil?
end
@@ -25,23 +38,15 @@
file_cache.serve(key, refresh)
end
private
- def file_cache
- @file_cache ||= Cache.new(client: client, tmpdir: @options[:tmpdir])
+ def metadata
+ @metadata ||= Metadata.new(client: client, file_cache: file_cache)
end
- def meta_cache
- @meta_cache ||= BasicCache::TimeCache.new lifetime: 600
- end
-
- def upload!(file)
- client.put_object(
- bucket: bucket,
- key: file,
- body: File.open(file) { |fh| fh.read }
- )
+ def package_cache
+ @package_cache ||= BasicCache::TimeCache.new lifetime: 600
end
def parse_packages
client.list_objects(bucket: bucket).contents.select do |x|
x.key.match(/.*\.pkg\.tar\.xz$/)