Module: Ditto::DSL

Defined in:
lib/ditto/dsl.rb

Instance Method Summary collapse

Instance Method Details

#add(version, &block) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/ditto/dsl.rb', line 13

def add (version, &block)
  unless block
	src = Thread.current.backtrace[1].split(':')[0..1]
	raise Error.new(src), "add method missing block (use {} not do/end)"
  end
  [:add, check_versions(version), block]
end

#check_versions(version) ⇒ Object

Check the version hash and convert targets to Gem::Requirements



29
30
31
32
33
34
35
36
# File 'lib/ditto/dsl.rb', line 29

def check_versions version
  begin
	version.each {|k,v| version[k] = Gem::Requirement.new(v)}
  rescue
	src = $!.backtrace[9].split(':')[0..1]
	raise Error.new(src), $!.message
  end
end

#delete(version, &block) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/ditto/dsl.rb', line 20

def delete (version, &block)
  unless block
	src = Thread.current.backtrace[1].split(':')[0..1]
	raise Error.new(src), "delete method missing block (use {} not do/end)"
  end
  [:delete, check_versions(version), block]
end

#entity(name, version, opts, *methods) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/ditto/dsl.rb', line 6

def entity (name, version, opts, *methods)
  unless methods.size > 0
	src = Thread.current.backtrace[1].split(':')[0..1]
	raise Error.new(src), "#{name}: entity missing map method!"
  end
  Ditto::Entity.new(name,version,opts,methods)
end