Class: Pakyow::Assets::External Private

Inherits:
Object
  • Object
show all
Defined in:
lib/pakyow/assets/external.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: Downloader

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, version:, package:, files:, config:) ⇒ External

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of External.



11
12
13
14
15
# File 'lib/pakyow/assets/external.rb', line 11

def initialize(name, version:, package:, files:, config:)
  @name, @version, @config = name, version, config
  @package = package || name
  @files = files || []
end

Instance Attribute Details

#nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



9
10
11
# File 'lib/pakyow/assets/external.rb', line 9

def name
  @name
end

#packageObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



9
10
11
# File 'lib/pakyow/assets/external.rb', line 9

def package
  @package
end

#versionObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



9
10
11
# File 'lib/pakyow/assets/external.rb', line 9

def version
  @version
end

Instance Method Details

#exist?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/pakyow/assets/external.rb', line 17

def exist?
  if @files.empty?
    Dir.glob(File.join(@config.externals.path, "#{@name}*.js")).any?
  else
    !@files.any? { |file|
      if File.basename(file, File.extname(file)) == @name.to_s
        Dir.glob(File.join(@config.externals.path, "#{@name}*.js")).empty?
      else
        Dir.glob(File.join(@config.externals.path, "#{@name}*__#{File.basename(file, File.extname(file))}.js")).empty?
      end
    }
  end
end

#fetch!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
34
35
36
37
38
39
# File 'lib/pakyow/assets/external.rb', line 31

def fetch!
  if @files.empty?
    fetch_file!(nil)
  else
    @files.each do |file|
      fetch_file!(file)
    end
  end
end