lib/gemfury/command/app.rb in gemfury-0.4.11 vs lib/gemfury/command/app.rb in gemfury-0.4.12
- old
+ new
@@ -1,7 +1,8 @@
class Gemfury::Command::App < Thor
include Gemfury::Command::Authorization
+ PackageExtensions = %w(gem egg tar.gz tgz)
# Impersonation
class_option :as, :desc => 'Access an account other than your own'
map "-v" => :version
@@ -20,42 +21,42 @@
shell.say %Q(You are logged in as "#{me}"), :green
end
end
end
- desc "push GEM", "Upload a new version of a gem"
+ desc "push FILE", "Upload a new version of a package"
def push(*gems)
with_checks_and_rescues do
push_files(:push, gems)
end
end
- desc "list", "List your gems on Gemfury"
+ desc "list", "List your packages"
def list
with_checks_and_rescues do
gems = client.list
- shell.say "\n*** GEMFURY GEMS ***\n\n"
+ shell.say "\n*** GEMFURY PACKAGES ***\n\n"
gems.each do |g|
desc, version = g['name'], g.path('latest_version.version')
desc << " (#{version ? version : 'beta'})"
shell.say desc
end
end
end
- desc "versions GEM", "List all the available gem versions"
+ desc "versions NAME", "List all the package versions"
def versions(gem_name)
with_checks_and_rescues do
versions = client.versions(gem_name)
shell.say "\n*** #{gem_name.capitalize} Versions ***\n\n"
versions.each do |v|
shell.say v['version']
end
end
end
- desc "yank GEM", "Delete a gem version"
+ desc "yank NAME", "Delete a package version"
method_options %w(version -v) => :required
def yank(gem_name)
with_checks_and_rescues do
version = options[:version]
client.yank_version(gem_name, version)
@@ -108,28 +109,28 @@
shell.say "Removed #{username} as a collaborator"
end
end
### MIGRATION (Pushing directories) ###
- desc "migrate DIR", "Upload all gems within a directory"
+ desc "migrate DIR", "Upload all packages within a directory"
def migrate(*paths)
with_checks_and_rescues do
gem_paths = Dir.glob(paths.map do |p|
if File.directory?(p)
- "#{p}/**/*.gem"
+ PackageExtensions.map { |ext| "#{p}/**/*.#{ext}" }
elsif File.file?(p)
p
else
nil
end
- end.compact)
+ end.flatten.compact)
if gem_paths.empty?
- shell.say "Problem: No valid gems found", :red
+ shell.say "Problem: No valid packages found", :red
help(:migrate)
else
- shell.say "Found the following RubyGems:"
+ shell.say "Found the following packages:"
gem_paths.each { |p| shell.say " #{File.basename(p)}" }
if shell.yes? "Upload these files to Gemfury? [yN]", :green
push_files(:migrate, gem_paths)
end
end
@@ -145,12 +146,12 @@
end
def with_checks_and_rescues(&block)
with_authorization(&block)
rescue Gemfury::InvalidGemVersion => e
- shell.say "You have a deprecated Gemfury gem", :red
- if shell.yes? "Would you like to update this gem now? [yN]"
+ shell.say "You have a deprecated Gemfury client", :red
+ if shell.yes? "Would you like to update it now? [yN]"
exec("gem update gemfury")
else
shell.say %q(No problem. You can also run "gem update gemfury")
end
rescue Gemfury::Forbidden => e
@@ -166,11 +167,11 @@
files = gem_paths.map do |g|
g.is_a?(String) ? File.new(g) : g rescue nil
end.compact
if files.empty?
- shell.say "Problem: No valid gems found", :red
+ shell.say "Problem: No valid packages found", :red
help(command)
return
end
# Let's get uploading
@@ -178,10 +179,10 @@
begin
shell.say "Uploading #{File.basename(file.path)} "
client.push_gem(file)
shell.say "- done"
rescue Gemfury::CorruptGemFile
- shell.say "- problem processing this gem", :red
+ shell.say "- problem processing this package", :red
rescue Gemfury::TimeoutError, Errno::EPIPE
shell.say "- this file is too much to handle", :red
shell.say " Visit http://www.gemfury.com/large-package for more info"
rescue => e
shell.say "- oops", :red
\ No newline at end of file