Class: Cany::Specification::DSL

Inherits:
Object
  • Object
show all
Includes:
Mixins::DependMixin
Defined in:
lib/cany/specification/dsl.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mixins::DependMixin

#create_dep

Constructor Details

#initialize(specification) ⇒ DSL

Returns a new instance of DSL.



4
5
6
# File 'lib/cany/specification/dsl.rb', line 4

def initialize(specification)
  @specification = specification
end

Class Method Details

.delegate(*methods) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/cany/specification/dsl.rb', line 12

def self.delegate(*methods)
  methods.each do |method|
    module_eval(<<-EOS, __FILE__, __LINE__)
      def #{method}(*args, &block)
        @specification.send :'#{method}=', *args, &block
      end
      EOS
  end
end

Instance Method Details

#binary(&block) ⇒ Object



53
54
55
# File 'lib/cany/specification/dsl.rb', line 53

def binary(&block)
  @specification.binary = block
end

#build(&block) ⇒ Object



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

def build(&block)
  @specification.build = block
end

#clean(&block) ⇒ Object



45
46
47
# File 'lib/cany/specification/dsl.rb', line 45

def clean(&block)
  @specification.clean = block
end

#depend(*args) ⇒ Object



62
63
64
# File 'lib/cany/specification/dsl.rb', line 62

def depend(*args)
  @specification.dependencies << create_dep(*args)
end

#exec(&block) ⇒ Object



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

def exec(&block)
  instance_eval(&block)
end

#prepare(&block) ⇒ Object



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

def prepare(&block)
  @specification.prepare = block
end

#require_cany(version) ⇒ Object

This directive ensures that Cany is used in a specific version. It will pass if the version match or raise an exception if it is an unsupported version.

Parameters:

  • version (String)

    The version constrain the must be satisfied by Cany.

Raises:

  • Cany::UnsupportedVersion on version mismatch



28
29
30
31
32
33
# File 'lib/cany/specification/dsl.rb', line 28

def require_cany(version)
  unless Gem::Requirement.create(version).satisfied_by? Gem::Version.new(Cany::VERSION.to_s)
    raise UnsupportedVersion.new version
  end
  @specification.cany_version_constraint = version
end

#use(name, &block) ⇒ Object

This include the given recipe into the build process.

Parameters:

  • name (Symbol)

    The name of the recipe as symbol.



37
38
39
# File 'lib/cany/specification/dsl.rb', line 37

def use(name, &block)
  @specification.recipes << Cany::Recipe.from_name(name).new(@specification, &block)
end