Class: LaPack::CtanProvider
Instance Method Summary collapse
- #init(dbdir) ⇒ Object
-
#initialize(env, params = {}) ⇒ CtanProvider
constructor
A new instance of CtanProvider.
- #install(to_dir, *packages) ⇒ Object
- #list ⇒ Object
- #remove(*packages) ⇒ Object
- #show(package) ⇒ Object
- #update ⇒ Object
Methods inherited from Provider
Constructor Details
#initialize(env, params = {}) ⇒ CtanProvider
Returns a new instance of CtanProvider.
5 6 7 8 9 10 11 12 |
# File 'lib/providers/ctan.rb', line 5 def initialize(env, params = {}) super env, 'ctan', params ## Here is where package index stored @package_list = 'http://ctan.org/json/packages' ## Here you can find info about package @package_info = 'http://ctan.org/json/pkg/%s' end |
Instance Method Details
#init(dbdir) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/providers/ctan.rb', line 14 def init(dbdir) # dbdir path @dbdir = dbdir # dbdir name @packages = File.join(dbdir, 'pkg') # Package index @index = File.join(dbdir, "#{@name}.json") # Ctan archive fetch @ctan_fetch = 'http://mirrors.ctan.org%s' FileUtils.mkdir_p(@packages) unless File.exists?(@packages) raise "Can't write to #{@packages}. Not a directory" unless File.directory?(@packages) end |
#install(to_dir, *packages) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/providers/ctan.rb', line 42 def install(to_dir, *packages) packages.each do |package| LaPack.log("Installing #{package.blue.bold}") if list.select{|p| p[:name].eql?(package)}.empty? raise "No such package #{package.white.bold}" else install_package(package, to_dir) end end end |
#list ⇒ Object
33 34 35 36 |
# File 'lib/providers/ctan.rb', line 33 def list raise "Update db first" unless File.exists?(@index) File.open(@index, "r") {|f| JSON.parse(f.read, symbolize_names: true)} end |
#remove(*packages) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/providers/ctan.rb', line 53 def remove(*packages) packages.each do |package| LaPack.log("Removing #{package.blue.bold}") if list.select{|p| p[:name].eql?(package)}.empty? raise "No such package #{package.white.bold}" else ctan_remove(package) end end end |