module Torba

@since 0.1.0

Public Class Methods

cache_path() click to toggle source

@return [String] root path to downloaded yet unprocessed asset packages. By default

it's "cache" within {.home_path}.

@note use “TORBA_CACHE_PATH” env variable to override default value

# File lib/torba.rb, line 29
def self.cache_path
  @cache_path ||= ENV["TORBA_CACHE_PATH"] || File.join(home_path, "cache")
end
cache_path=(val) click to toggle source

Override cache path with a new value @param val [String] new cache path @return [void] @since 0.6.0

# File lib/torba.rb, line 37
def self.cache_path=(val)
  @cache_path = val
end
digest(string) click to toggle source

@return [String] unique short fingerprint/hash for given string @param [String] string to be hashed

@example

Torba.digest("path/to/hash") #=> "23e3e63c"
# File lib/torba.rb, line 77
def self.digest(string)
  Digest::SHA1.hexdigest(string)[0..7]
end
find_packages_by_name(name) click to toggle source

@see Manifest#find_packages_by_name @since 0.7.0

# File lib/torba.rb, line 83
def self.find_packages_by_name(name)
  manifest.find_packages_by_name(name)
end
home_path() click to toggle source

@return [String] root path to prepared asset packages. By default it's “.torba” within

your OS home directory (i.e. packages are shared between projects).

@note use “TORBA_HOME_PATH” env variable to override default value

# File lib/torba.rb, line 15
def self.home_path
  @home_path ||= ENV["TORBA_HOME_PATH"] || File.join(Dir.home, ".torba")
end
home_path=(val) click to toggle source

Override home path with a new value @param val [String] new home path @return [void]

# File lib/torba.rb, line 22
def self.home_path=(val)
  @home_path = val
end
load_path() click to toggle source

@see Manifest#load_path

# File lib/torba.rb, line 57
def self.load_path
  manifest.load_path
end
manifest() click to toggle source

@return [Manifest]

# File lib/torba.rb, line 47
def self.manifest
  @manifest ||= Manifest.build
end
non_js_css_logical_paths() click to toggle source

@see Manifest#non_js_css_logical_paths @since 0.3.0

# File lib/torba.rb, line 63
def self.non_js_css_logical_paths
  manifest.non_js_css_logical_paths
end
pack() click to toggle source

@see Manifest#pack

# File lib/torba.rb, line 52
def self.pack
  manifest.pack
end
pretty_errors() { || ... } click to toggle source

@yield a block, converts common exceptions into useful messages

# File lib/torba.rb, line 88
def self.pretty_errors
  yield
rescue Errors::MissingPackages => e
  ui.error "Your Torba is not packed yet."
  ui.error "Missing packages:"
  e.packages.each do |package|
    ui.error "  * #{package.name}"
  end
  ui.suggest "Run `bundle exec torba pack` to install missing packages."
  exit(false)
rescue Errors::ShellCommandFailed => e
  ui.error "Couldn't execute command '#{e.message}'"
  exit(false)
rescue Errors::NothingToImport => e
  ui.error "Couldn't import an asset(-s) '#{e.path}' from import list in '#{e.package}'."
  ui.suggest "Check for typos."
  ui.suggest "Make sure that the path has trailing '/' if its a directory."
  exit(false)
rescue Errors::AssetNotFound => e
  ui.error "Unknown asset to process with path '#{e.message}'."
  ui.suggest "Make sure that you've imported all image/font assets mentioned in a stylesheet(-s)."
  exit(false)
end
ui() click to toggle source

@return [Ui]

# File lib/torba.rb, line 42
def self.ui
  @ui ||= Ui.new
end
verify() click to toggle source

@see Manifest#verify

# File lib/torba.rb, line 68
def self.verify
  manifest.verify
end