Class: PrettyDoc::Resource::Scss

Inherits:
PrettyDoc::Resource show all
Defined in:
lib/pretty_doc/resources/scss.rb

Overview

Scss resource

Instance Attribute Summary collapse

Attributes inherited from PrettyDoc::Resource

#file

Instance Method Summary collapse

Constructor Details

#initialize(scss_pathname) ⇒ Scss

Returns a new instance of Scss.



12
13
14
# File 'lib/pretty_doc/resources/scss.rb', line 12

def initialize(scss_pathname)
  self.scss_pathname = scss_pathname
end

Instance Attribute Details

#scss_pathnameObject

Returns the value of attribute scss_pathname.



10
11
12
# File 'lib/pretty_doc/resources/scss.rb', line 10

def scss_pathname
  @scss_pathname
end

Instance Method Details

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



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/pretty_doc/resources/scss.rb', line 16

def write(dir, options = {})
  PrettyDoc.mktmpdir do |tmppath|
    tmpdir = Pathname.new(tmppath)
    ::Compass.configuration.sass_path = scss_pathname.to_s
    ::Compass.configuration.css_path = tmpdir.to_s

    update_project = ::Compass::Commands::UpdateProject.new(
      PrettyDoc.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