Module: Cup::Server::VisualSpecs

Defined in:
lib/cup/server/visual_specs.rb

Overview

not a member of Cup::Directory incase we ever want to search for visuals in arbitrary directories

Defined Under Namespace

Classes: VisualSpec

Class Method Summary collapse

Class Method Details

.get(directory = Cup::Directory.current.path + 'spec' + 'visual') ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/cup/server/visual_specs.rb', line 14

def get(directory = Cup::Directory.current.path + 'spec' + 'visual')

  visuals = {}

  Dir["#{File.expand_path(directory)}/**/*.slim"].select { |path| File.file?(path) }.each do |full_path|
    
    href = '/' + File.relative_path(Cup::Directory.current.path, full_path).match(/(.*)\.slim$/)[1]
    name = File.relative_path(File.expand_path(directory), full_path).match(/(.*)\.slim$/)[1]
    
    visuals[name] = VisualSpec.new.tap do |v|
      v.href, v.name, v.full_path = href, name, full_path
    end
  end

  visuals
end