Class: Snapdragon::FileBase

Inherits:
Object
  • Object
show all
Defined in:
lib/snapdragon/file_base.rb

Direct Known Subclasses

RequireFile, SpecFile

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FileBase

Returns a new instance of FileBase.



5
6
7
# File 'lib/snapdragon/file_base.rb', line 5

def initialize(path)
  @path = path
end

Instance Method Details

#relative_url_pathObject



9
10
11
# File 'lib/snapdragon/file_base.rb', line 9

def relative_url_path
  ::File.join('/', @path.path)
end

#require_filesObject



29
30
31
32
33
34
35
# 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_pathsObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 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