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.

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.



13
14
15
16
17
# File 'lib/pakyow/assets/external.rb', line 13

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.



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

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.



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

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.



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

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)


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

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.



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

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