Module: Torba

Defined in:
lib/torba.rb,
lib/torba/ui.rb,
lib/torba/cli.rb,
lib/torba/rails.rb,
lib/torba/package.rb,
lib/torba/manifest.rb,
lib/torba/import_list.rb,
lib/torba/remote_sources/zip.rb,
lib/torba/remote_sources/common.rb,
lib/torba/css_url_to_erb_asset_path.rb,
lib/torba/remote_sources/github_release.rb

Overview

Since:

  • 0.1.0

Defined Under Namespace

Modules: Errors, RemoteSources Classes: Cli, CssUrlToErbAssetPath, Engine, ImportList, Manifest, Package, Ui

Class Method Summary collapse

Class Method Details

.cache_pathString

Note:

use “TORBA_CACHE_PATH” env variable to override default value

Returns root path to downloaded yet unprocessed asset packages. By default it's “cache” within home_path.

Returns:

  • (String)

    root path to downloaded yet unprocessed asset packages. By default it's “cache” within home_path.

Since:

  • 0.1.0


25
26
27
# File 'lib/torba.rb', line 25

def self.cache_path
  @cache_path ||= ENV["TORBA_CACHE_PATH"] || File.join(home_path, "cache")
end

.digest(string) ⇒ String

Returns unique short fingerprint/hash for given string

Examples:

Torba.digest("path/to/hash") #=> "23e3e63c"

Parameters:

  • string (String)

    to be hashed

Returns:

  • (String)

    unique short fingerprint/hash for given string

Since:

  • 0.1.0


59
60
61
# File 'lib/torba.rb', line 59

def self.digest(string)
  Digest::SHA1.hexdigest(string)[0..7]
end

.home_pathString

Note:

use “TORBA_HOME_PATH” env variable to override default value

Returns root path to prepared asset packages. By default it's “.torba” within your OS home directory (i.e. packages are shared between projects).

Returns:

  • (String)

    root path to prepared asset packages. By default it's “.torba” within your OS home directory (i.e. packages are shared between projects).

Since:

  • 0.1.0


11
12
13
# File 'lib/torba.rb', line 11

def self.home_path
  @home_path ||= ENV["TORBA_HOME_PATH"] || File.join(Dir.home, ".torba")
end

.home_path=(val) ⇒ void

This method returns an undefined value.

Override home path with a new value

Parameters:

  • val (String)

    new home path

Since:

  • 0.1.0


18
19
20
# File 'lib/torba.rb', line 18

def self.home_path=(val)
  @home_path = val
end

.load_pathObject

See Also:

Since:

  • 0.1.0


45
46
47
# File 'lib/torba.rb', line 45

def self.load_path
  manifest.load_path
end

.manifestManifest

Returns:

Since:

  • 0.1.0


35
36
37
# File 'lib/torba.rb', line 35

def self.manifest
  @manifest ||= Manifest.build
end

.packObject

See Also:

Since:

  • 0.1.0


40
41
42
# File 'lib/torba.rb', line 40

def self.pack
  manifest.pack
end

.pretty_errors { ... } ⇒ Object

Yields:

  • a block, converts common exceptions into useful messages

Since:

  • 0.1.0


64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/torba.rb', line 64

def self.pretty_errors
  yield
rescue Torba::Errors::UnbuiltPackage
  ui.error "Your Torba is not packed yet."
  ui.suggest "Run `bundle exec torba pack` to install missing packages."
  exit(false)
rescue Torba::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 Torba::Errors::AssetNotFound => e
  ui.error "Couldn't found an asset with path '#{e.message}'."
  ui.suggest "Make sure that you've imported all image assets mentioned in a stylesheet(-s)."
  exit(false)
end

.uiUi

Returns:

Since:

  • 0.1.0


30
31
32
# File 'lib/torba.rb', line 30

def self.ui
  @ui ||= Ui.new
end

.verifyObject

See Also:

Since:

  • 0.1.0


50
51
52
# File 'lib/torba.rb', line 50

def self.verify
  manifest.verify
end