Module: Confection::Current

Included in:
Confection
Defined in:
lib/confection/current.rb

Overview

Current mixin extends the Confection module. Primarily is provides class methods for working with the current project’s configurations.

Instance Method Summary collapse

Instance Method Details

#bootstrapObject



29
30
31
# File 'lib/confection/current.rb', line 29

def bootstrap
  $properties = current_project.properties
end

#clear!Object



49
50
51
# File 'lib/confection/current.rb', line 49

def clear!
  current_project.store.clear!
end

#controller(scope, tool, *options) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/confection/current.rb', line 15

def controller(scope, tool, *options)
  params = (Hash === options.last ? options.pop : {})
  params[:profile] = options.shift unless options.empty?

  if from = params[:from]
    projects[from] ||= Project.load(from)
    projects[from].controller(scope, tool, params)
  else
    bootstrap if $properties.nil?  # TODO: better way to go about this?
    current_project.controller(scope, tool, params)
  end
end

#current_directoryObject



39
40
41
# File 'lib/confection/current.rb', line 39

def current_directory
  @current_directory ||= Dir.pwd
end

#current_projectObject



44
45
46
# File 'lib/confection/current.rb', line 44

def current_project
  projects[current_directory] ||= Project.lookup(current_directory)
end

#each(&block) ⇒ Object



59
60
61
# File 'lib/confection/current.rb', line 59

def each(&block)
  current_project.each(&block)
end

#profiles(tool) ⇒ Object



54
55
56
# File 'lib/confection/current.rb', line 54

def profiles(tool)
  current_project.profiles(tool)
end

#projectsObject



34
35
36
# File 'lib/confection/current.rb', line 34

def projects
  @projects ||= {}
end

#propertiesObject

Project properties.



71
72
73
# File 'lib/confection/current.rb', line 71

def properties
  current_project.properties
end

#sizeObject



64
65
66
# File 'lib/confection/current.rb', line 64

def size
  current_project.size
end