Add source as input param. Refs #1

This commit is contained in:
Pavel Chipiga 2011-12-13 15:27:14 +02:00
parent 27668c7546
commit aceccae830
1 changed files with 3 additions and 2 deletions

View File

@ -4,12 +4,13 @@ require 'open-uri'
namespace :import do namespace :import do
desc "Load projects" desc "Load projects"
task :projects => :environment do task :projects => :environment do
source = ENV['SOURCE'] || 'http://dl.dropbox.com/u/984976/package_list.txt'
owner = User.find_by_uname(ENV['OWNER_UNAME']) || Group.find_by_uname(ENV['OWNER_UNAME']) || User.first owner = User.find_by_uname(ENV['OWNER_UNAME']) || Group.find_by_uname(ENV['OWNER_UNAME']) || User.first
platform = Platform.find_by_name(ENV['PLATFORM_NAME']) # 'mandriva2011' platform = Platform.find_by_name(ENV['PLATFORM_NAME']) # 'mandriva2011'
repo = platform.repositories.first rescue nil repo = platform.repositories.first rescue nil
say "START import projects for '#{owner.uname}'.#{repo ? " To repo '#{platform.name}/#{repo.name}'." : ''}" say "START import projects from '#{source}' for '#{owner.uname}'.#{repo ? " To repo '#{platform.name}/#{repo.name}'." : ''}"
ask 'Press enter to continue' ask 'Press enter to continue'
open('http://dl.dropbox.com/u/984976/package_list.txt').readlines.each do |name| open(source).readlines.each do |name|
name.chomp!; name.strip! #; name.downcase! name.chomp!; name.strip! #; name.downcase!
# name = name.match(/^([a-z\d_\-\+\.]+?)-(\d[a-z\d\-\.]+)\.src\.rpm$/)[1] # parse # name = name.match(/^([a-z\d_\-\+\.]+?)-(\d[a-z\d\-\.]+)\.src\.rpm$/)[1] # parse
print "Import '#{name}'..." print "Import '#{name}'..."