Class: Cran::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/cran/repository.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Repository

Returns a new instance of Repository.



6
7
8
# File 'lib/cran/repository.rb', line 6

def initialize(options = {})
  @options = Cran::Config.get(:repository).merge(options)
end

Instance Attribute Details

#indexObject

Returns the value of attribute index.



3
4
5
# File 'lib/cran/repository.rb', line 3

def index
  @index
end

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/cran/repository.rb', line 4

def options
  @options
end

Instance Method Details

#file_map(url) ⇒ Object



21
22
23
# File 'lib/cran/repository.rb', line 21

def file_map(url)
  lambda{|f| URI.join(url, f.text).to_s}
end

#new_filesObject



32
33
34
35
36
# File 'lib/cran/repository.rb', line 32

def new_files
  files = (index - Cran::Db.list)
  logger.info "News files : #{files.count}"
  files
end

#updateObject



25
26
27
28
29
30
# File 'lib/cran/repository.rb', line 25

def update
  Parallel.each(new_files, :in_processes => @options.fetch(:processes), :progress => "Indexing") do |f|
    package = Cran::Package.new(f)
    package.save
  end
end