Module: Utils

Defined in:
ext/sass/utils.rb

Overview

The Utils module.

Class Method Summary collapse

Class Method Details

.captureObject



7
8
9
10
11
12
13
14
15
# File 'ext/sass/utils.rb', line 7

def capture(...)
  require 'open3'

  stdout, stderr, status = Open3.capture3(...)

  raise stderr unless status.success?

  stdout
end

.fetch_https(source_uri) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'ext/sass/utils.rb', line 17

def fetch_https(source_uri)
  require 'rubygems/remote_fetcher'

  source_uri = begin
    Gem::Uri.parse!(source_uri)
  rescue NoMethodError
    URI.parse(source_uri)
  end

  Gem::RemoteFetcher.fetcher.fetch_https(source_uri)
end

.windows_system_directoryObject



29
30
31
32
33
34
35
36
37
38
# File 'ext/sass/utils.rb', line 29

def windows_system_directory
  path = capture('powershell.exe',
                 '-NoLogo',
                 '-NoProfile',
                 '-NonInteractive',
                 '-Command',
                 '[Environment]::GetFolderPath([Environment+SpecialFolder]::System) | Write-Host -NoNewline')

  File.absolute_path(path)
end