Class: Lm2doc::Resource::Compass

Inherits:
Lm2doc::Resource show all
Defined in:
lib/lm2doc/resource/compass.rb

Instance Attribute Summary collapse

Attributes inherited from Lm2doc::Resource

#file

Instance Method Summary collapse

Constructor Details

#initialize(scss_pathname) ⇒ Compass

Returns a new instance of Compass.



13
14
15
# File 'lib/lm2doc/resource/compass.rb', line 13

def initialize(scss_pathname)
  self.scss_pathname = scss_pathname
end

Instance Attribute Details

#scss_pathnameObject

Returns the value of attribute scss_pathname.



11
12
13
# File 'lib/lm2doc/resource/compass.rb', line 11

def scss_pathname
  @scss_pathname
end

Instance Method Details

#write(dir, options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/lm2doc/resource/compass.rb', line 17

def write(dir, options = {})
  Lm2doc.mktmpdir do |tmppath|
    tmpdir = Pathname.new(tmppath)
    ::Compass.configuration.sass_path = self.scss_pathname.to_s
    ::Compass.configuration.css_path = tmpdir.to_s
    
    update_project = ::Compass::Commands::UpdateProject.new(Lm2doc.root.join("tmp").to_s, { quiet: true })
    update_project.perform
    
    tmpdir.children.each do |child|
      relative_pathname = child.relative_path_from(tmpdir)
      FileUtils.cp(child, File.join(dir, relative_pathname))
    end
  end
end