class Snapdragon::FileBase

Public Class Methods

new(path) click to toggle source
# File lib/snapdragon/file_base.rb, line 5
def initialize(path)
  @path = path
end

Public Instance Methods

relative_url_path() click to toggle source
# File lib/snapdragon/file_base.rb, line 9
def relative_url_path
  ::File.join('/', @path.path)
end
require_files() click to toggle source
# File lib/snapdragon/file_base.rb, line 29
def require_files
  files = []
  require_paths.each do |require_path|
    files << Snapdragon::RequireFile.new(Snapdragon::Path.new(require_path))
  end
  return files
end
require_paths() click to toggle source
# File lib/snapdragon/file_base.rb, line 13
def require_paths
  f = ::File.open(::File.expand_path(@path.path), 'r')
  lines = f.readlines
  f.close

  require_paths = []

  lines.each do |line|
    if line =~ /\/\/+\s+require_relative\(['"](.+)['"]\).*$/
      require_paths << ::File.join(::File.dirname(@path.path), $1)
    end
  end

  return require_paths
end