Module: Capigen::Plugins::Profiles

Defined in:
lib/capigen/plugins/profiles.rb

Constant Summary collapse

ProfileDir =
File.dirname(__FILE__) + "/../../profiles"

Instance Method Summary collapse

Instance Method Details

#choose(prefix = "") ⇒ Object



9
10
11
12
13
14
15
# File 'lib/capigen/plugins/profiles.rb', line 9

def choose(prefix = "")
  profile = HighLine.new.choose(*recipes(prefix)) do |menu|
    menu.header = "Choose recipe profile"
  end
  
  "#{ProfileDir}/#{profile}.rb"
end

#get(var) ⇒ Object

More helpful fetch



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/capigen/plugins/profiles.rb', line 18

def get(var)
  begin
    result = fetch(var.to_sym)
  rescue
    puts <<-EOS
    
    Please set :#{var} variable in your Capfile or profile.
    
    EOS
    raise "Please set :#{var} in your Capfile or profile."
  end
  result
end

#recipes(prefix = "") ⇒ Object



5
6
7
# File 'lib/capigen/plugins/profiles.rb', line 5

def recipes(prefix = "")
  Dir[ProfileDir + "/#{prefix}*.rb"].collect { |file| File.basename(file).gsub(File.extname(file), "") }
end