Class: Cany::Specification

Inherits:
Object
  • Object
show all
Defined in:
lib/cany/specification.rb,
lib/cany/specification/dsl.rb

Defined Under Namespace

Classes: DSL

Constant Summary collapse

EXT =
'canspec'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dsl = Cany::Specification::DSL, &block) ⇒ Specification

Returns a new instance of Specification.



12
13
14
15
16
# File 'lib/cany/specification.rb', line 12

def initialize(dsl=Cany::Specification::DSL, &block)
  @recipes = []
  @dependencies = []
  setup dsl, &block
end

Instance Attribute Details

#base_dirObject

Returns the value of attribute base_dir.



9
10
11
# File 'lib/cany/specification.rb', line 9

def base_dir
  @base_dir
end

#binaryObject

Returns the value of attribute binary.



10
11
12
# File 'lib/cany/specification.rb', line 10

def binary
  @binary
end

#buildObject

Returns the value of attribute build.



10
11
12
# File 'lib/cany/specification.rb', line 10

def build
  @build
end

#cany_version_constraintObject

Returns the value of attribute cany_version_constraint.



9
10
11
# File 'lib/cany/specification.rb', line 9

def cany_version_constraint
  @cany_version_constraint
end

#cleanObject

Returns the value of attribute clean.



10
11
12
# File 'lib/cany/specification.rb', line 10

def clean
  @clean
end

#dependenciesObject

Returns the value of attribute dependencies.



9
10
11
# File 'lib/cany/specification.rb', line 9

def dependencies
  @dependencies
end

#descriptionObject

Returns the value of attribute description.



8
9
10
# File 'lib/cany/specification.rb', line 8

def description
  @description
end

#licenceObject

Returns the value of attribute licence.



8
9
10
# File 'lib/cany/specification.rb', line 8

def licence
  @licence
end

#maintainer_emailObject

Returns the value of attribute maintainer_email.



8
9
10
# File 'lib/cany/specification.rb', line 8

def maintainer_email
  @maintainer_email
end

#maintainer_nameObject

Returns the value of attribute maintainer_name.



8
9
10
# File 'lib/cany/specification.rb', line 8

def maintainer_name
  @maintainer_name
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/cany/specification.rb', line 8

def name
  @name
end

#prepareObject

Returns the value of attribute prepare.



10
11
12
# File 'lib/cany/specification.rb', line 10

def prepare
  @prepare
end

#recipesObject

Returns the value of attribute recipes.



9
10
11
# File 'lib/cany/specification.rb', line 9

def recipes
  @recipes
end

#versionObject

Returns the value of attribute version.



8
9
10
# File 'lib/cany/specification.rb', line 8

def version
  @version
end

#websiteObject

Returns the value of attribute website.



8
9
10
# File 'lib/cany/specification.rb', line 8

def website
  @website
end

Instance Method Details

#build_dependenciesArray<Dependency>

Return all dependencies needed to build this package

Returns:



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

def build_dependencies
  dependencies.select(&:build?)
end

#runtime_dependenciesArray<Dependency>

Return all dependencies needed to build this package

Returns:



32
33
34
# File 'lib/cany/specification.rb', line 32

def runtime_dependencies
  dependencies.select(&:runtime?)
end

#setup(dsl = Cany::Specification::DSL, &block) ⇒ Object



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

def setup(dsl=Cany::Specification::DSL, &block)
  dsl.new(self).exec(&block)
end

#setup_recipesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method creates recipe instances for all required recipes from the given spec.



55
56
57
58
59
60
61
62
# File 'lib/cany/specification.rb', line 55

def setup_recipes
  last_recipe = nil
  recipes.reverse.each do |recipe|
    recipe.inner = last_recipe unless last_recipe.nil?
    last_recipe = recipe
  end
  recipes.map(&:prepare)
end

#system_recipeRecipe

Return the system recipe for this specification.

Returns:

  • (Recipe)

    The system reciep

Raises:



48
49
50
51
# File 'lib/cany/specification.rb', line 48

def system_recipe
  raise NoSystemRecipe.new unless @system_recipe
  @system_recipe
end

#system_recipe=(recipe) ⇒ Object

Define the given recipe instance as system recipe. It can be accessed by other recipes under the system name and it is added as last recipe and do system specific things. At the moment the only recipe designed to work as system recipe is the DebHelperRecipe The attribute should be set after all recipe changes are over.

Parameters:

  • recipe (Recipe)

    the system recipe instance



41
42
43
44
# File 'lib/cany/specification.rb', line 41

def system_recipe=(recipe)
  @system_recipe = recipe
  @recipes << recipe
end

#to_sObject Also known as: inspect



64
65
66
# File 'lib/cany/specification.rb', line 64

def to_s
  "Cany::Specification<#{object_id}>(name=#{name}, recipes=[#{recipes.map(&:name).join(', ')}]"
end