Class: Torba::Manifest

Inherits:
Object
  • Object
show all
Defined in:
lib/torba/manifest.rb

Overview

Represents Torbafile.

Since:

  • 0.1.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeManifest

Returns a new instance of Manifest

Since:

  • 0.1.0



28
29
30
# File 'lib/torba/manifest.rb', line 28

def initialize
  @packages = []
end

Instance Attribute Details

#packagesObject (readonly)

all packages defined in Torbafile

Since:

  • 0.1.0



9
10
11
# File 'lib/torba/manifest.rb', line 9

def packages
  @packages
end

Class Method Details

.self.build(file_path) ⇒ Manifest .self.buildManifest

Reads Torbafile and evaluates it.

Overloads:

  • .self.build(file_path) ⇒ Manifest

    Parameters:

    • file_path (String)

      absolute path to Torbafile

  • .self.buildManifest

    Reads Torbafile from current directory

Returns:

Since:

  • 0.1.0



19
20
21
22
23
24
25
26
# File 'lib/torba/manifest.rb', line 19

def self.build(file_path = nil)
  file_path ||= File.join(Dir.pwd, "Torbafile")

  manifest = new
  content = File.read(file_path)
  manifest.instance_eval(content, file_path)
  manifest
end

Instance Method Details

#gh_release(name, options = {}) ⇒ Object

Since:

  • 0.1.0



40
41
42
43
44
45
# File 'lib/torba/manifest.rb', line 40

def gh_release(name, options = {})
  source = options.fetch(:source)
  tag = options.fetch(:tag)
  remote_source = RemoteSources::GithubRelease.new(source, tag)
  packages << Package.new(name, remote_source, options)
end

#load_pathArray<String>

Returns list of paths to each prepared asset package. It should be appended to the Sprockets' load_path.

Returns:

  • (Array<String>)

    list of paths to each prepared asset package. It should be appended to the Sprockets' load_path.

Since:

  • 0.1.0



55
56
57
# File 'lib/torba/manifest.rb', line 55

def load_path
  packages.map(&:load_path)
end

#packvoid

This method returns an undefined value.

Builds all #packages

Since:

  • 0.1.0



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

def pack
  packages.each(&:build)
end

#verifyvoid

This method returns an undefined value.

Verifies all #packages

Since:

  • 0.1.0



61
62
63
# File 'lib/torba/manifest.rb', line 61

def verify
  packages.each(&:verify)
end

#zip(name, options = {}) ⇒ Object

Since:

  • 0.1.0



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

def zip(name, options = {})
  url = options.fetch(:url)
  remote_source = RemoteSources::Zip.new(url)
  packages << Package.new(name, remote_source, options)
end