Class: Tetra::Package

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Scriptable, Speccable
Defined in:
lib/tetra/packages/package.rb

Overview

represents a Java project packaged in tetra

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Scriptable

#_to_script, #aliases

Methods included from Speccable

#_to_spec

Methods included from Generatable

#generate, #template_path

Constructor Details

#initialize(project, pom_path = nil, filter = nil, patches = []) ⇒ Package

Returns a new instance of Package.



22
23
24
25
26
27
28
# File 'lib/tetra/packages/package.rb', line 22

def initialize(project, pom_path = nil, filter = nil, patches = [])
  @project = project
  @kit = Tetra::KitPackage.new(project)
  @pom = Tetra::Pom.new(pom_path)
  @filter = filter
  @patches = patches.map { |f| File.basename(f) }
end

Instance Attribute Details

#patchesObject (readonly)

Returns the value of attribute patches.



10
11
12
# File 'lib/tetra/packages/package.rb', line 10

def patches
  @patches
end

Instance Method Details

#artifact_idsObject



30
31
32
# File 'lib/tetra/packages/package.rb', line 30

def artifact_ids
  @pom.modules.any? ? @pom.modules : [@pom.artifact_id]
end

#cleanup_description(raw, max_length) ⇒ Object



51
52
53
54
55
56
57
58
# File 'lib/tetra/packages/package.rb', line 51

def cleanup_description(raw, max_length)
  raw
    .gsub(/[\s]+/, " ")
    .strip
    .slice(0..max_length - 1)
    .sub(/\s\w+$/, "")
    .sub(/\.+$/, "")
end

#descriptionObject

a long summary from the POM



40
41
42
# File 'lib/tetra/packages/package.rb', line 40

def description
  cleanup_description(@pom.description, 1500)
end

#outputsObject

files produced by this package



45
46
47
48
49
# File 'lib/tetra/packages/package.rb', line 45

def outputs
  @project.produced_files.select do |file|
    File.fnmatch?(@filter, File.basename(file))
  end
end

#summaryObject

a short summary from the POM



35
36
37
# File 'lib/tetra/packages/package.rb', line 35

def summary
  cleanup_description(@pom.description, 60)
end

#to_scriptObject



64
65
66
# File 'lib/tetra/packages/package.rb', line 64

def to_script
  _to_script(@project)
end

#to_specObject



60
61
62
# File 'lib/tetra/packages/package.rb', line 60

def to_spec
  _to_spec(@project, name, "package.spec", @project.packages_dir)
end