lib/right_publish/repos/gem.rb in right_publish-0.3.0 vs lib/right_publish/repos/gem.rb in right_publish-0.4.0
- old
+ new
@@ -1,38 +1,42 @@
module RightPublish
- class GemRepo
- include RightPublish::Repo
-
+ class GemRepo < Repo
DEFAULT_GEM_DIR = 'gems/'
REPO_KEY = :gem_repo
- REPO_OPTIONS = {:subdir=>DEFAULT_GEM_DIR}
+ REPO_OPTIONS = {:subdir=>DEFAULT_GEM_DIR, :prune=>false}
GEMS_SUBDIRECTORY = 'gems'
GEM_EXT = 'gem'
- def publish(file_or_dir, target)
+ def add(file_or_dir, target)
gems_list = get_pkg_list(file_or_dir, GEM_EXT)
- # Synchronize the upstream source to our local cache
- fetch
-
# Copy gem files to the repository
destination = File.join(repo_config[:subdir], GEMS_SUBDIRECTORY)
gems_list.each do |path|
- do_in_subdir(destination) { prune_all("#{pkg_parts(path)[:name]}-*.gem") }
+ # RubyGems repos do not normally prune; it must be explicitly enabled.
+ if repo_config[:prune]
+ do_in_subdir(destination) { prune_all("#{pkg_parts(path)[:name]}-*.gem") }
+ end
+
install_file(path, destination)
end
# Rebuild the gem index
Profile.log("Rebuilding Gem Index...")
do_in_subdir(repo_config[:subdir]) do
indexed = system('gem generate_index 2>&1 >/dev/null') # requires 'builder' gem to be installed
raise Exception, "gem generate_index failed; cannot continue publishing" unless indexed
end
+ end
- # Commit back to remote storage
- store
+ def annotate(options={})
+ options[:subdir] ||= File.join(repo_config[:subdir], 'gems')
+ options[:filter] = ['*.gem']
+ super(options)
end
+
+ protected
def pkg_parts(name)
result = {:name=>nil, :version=>nil}
result[:name], result[:version] = /([A-Za-z0-9\-_]+)-([0-9\.]+)\.#{GEM_EXT}\Z/.match(name).captures
result