Sha256: 771cdeb68d6a7c8b4df5a1f9ac3cb1038a75310229d0ec55befd380fd9617a7a

Contents?: true

Size: 1004 Bytes

Versions: 14

Compression:

Stored size: 1004 Bytes

Contents

class EroGetter
  autoload :Base, 'ero_getter/base'
  autoload :Utils, 'ero_getter/utils'

  def detect(url)
    self.class.url_mapping.each_pair do |regex, klazz|
      return klazz if url.match regex
    end
    nil
  end

  def download(url)
    klazz = detect(url)
    raise unless klazz
    klazz.new(url).run
  end


  class << self
    def directory
      path = File.join ENV['HOME'], 'ero_getter'
      puts path unless Dir.exists?(path)
      path
    end

    def mkdir(path)
      unless File.exists?(path)
        basedir = File.dirname(path)
        mkdir(basedir) unless File.exists?(basedir)
        Dir.mkdir(path)
      end
    end

    def url_mapping
      @url_mapping ||= {}
    end

    def add_mapping(regex, strategy)
      url_mapping[regex] = strategy
    end

    def clean
      @url_mapping = {}
    end
  end
end

Dir.glob(File.expand_path(File.dirname(__FILE__) + '/downloader/*.rb')) do |file|
  begin
    require file
  rescue
    puts "Load error in #{file}"
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ero_getter-1.3.8 lib/ero_getter.rb
ero_getter-1.3.7 lib/ero_getter.rb
ero_getter-1.3.6 lib/ero_getter.rb
ero_getter-1.3.5 lib/ero_getter.rb
ero_getter-1.3.4 lib/ero_getter.rb
ero_getter-1.3.3 lib/ero_getter.rb
ero_getter-1.3.2 lib/ero_getter.rb
ero_getter-1.3.1 lib/ero_getter.rb
ero_getter-1.3.0 lib/ero_getter.rb
ero_getter-1.2.0 lib/ero_getter.rb
ero_getter-1.1.2 lib/ero_getter.rb
ero_getter-1.1.1 lib/ero_getter.rb
ero_getter-1.1.0 lib/ero_getter.rb
ero_getter-1.0.0 lib/ero_getter.rb