module Fig::Statement::Asset

Some sort of file to be included in a package.

Attributes

location[R]

Public Class Methods

included(class_included_into) click to toggle source
# File lib/fig/statement/asset.rb, line 14
def self.included(class_included_into)
  class_included_into.extend(ClassMethods)

  return
end

Public Instance Methods

glob_if_not_url?() click to toggle source
# File lib/fig/statement/asset.rb, line 20
def glob_if_not_url?()
  return @glob_if_not_url
end
is_asset?() click to toggle source
# File lib/fig/statement/asset.rb, line 28
def is_asset?()
  return true
end
minimum_grammar_for_emitting_input() click to toggle source
# File lib/fig/statement/asset.rb, line 48
def minimum_grammar_for_emitting_input()
  return minimum_grammar_for_value location
end
minimum_grammar_for_publishing() click to toggle source
# File lib/fig/statement/asset.rb, line 52
def minimum_grammar_for_publishing()
  return minimum_grammar_for_value asset_name
end
requires_globbing?() click to toggle source
# File lib/fig/statement/asset.rb, line 32
def requires_globbing?()
  return glob_if_not_url? && ! Fig::URL.is_url?(location())
end
standard_asset_name() click to toggle source
# File lib/fig/statement/asset.rb, line 36
def standard_asset_name()
  # Not so hot of an idea if the location is a URL and has query parameters
  # in it, but not going to fix this now.
  basename = location().split('/').last

  if Fig::URL.is_url? location
    return CGI.unescape basename
  end

  return basename
end
urls() click to toggle source
# File lib/fig/statement/asset.rb, line 24
def urls()
  return [location()]
end

Private Instance Methods

minimum_grammar_for_value(value) click to toggle source
# File lib/fig/statement/asset.rb, line 58
def minimum_grammar_for_value(value)
  return [0] if value.nil?

  if value =~ /\s/
    return [1, 'contains whitespace']
  end

  # Can't have octothorpes anywhere in v0 due to comment stripping via
  # regex.
  if value =~ /#/
    return [1, 'contains a "#" character']
  end

  if ! glob_if_not_url? && value =~ / ( [*?\[\]{}] ) /x
    return [
      1, %Q<contains a glob character ("#{$1}") which should not be globbed>
    ]
  end

  if value =~ / ( ["'<>|] ) /x
    return [1, %Q<contains a "#{$1}" character>]
  end

  return [0]
end