Class: Bently::RubyRecipe

Inherits:
Recipe
  • Object
show all
Defined in:
lib/bently/recipe_class/ruby.rb

Direct Known Subclasses

Foreman, RailsRecipe

Defined Under Namespace

Classes: Gem

Constant Summary collapse

GEMFILE =
'Gemfile'

Instance Method Summary collapse

Methods inherited from Recipe

#append, breakdown, category, #code, #create, description, homepage, #insert, #modify, #operate, #operations, #prepend, #remove, #requirement, #run, #say, title, #todo, #usage, version, #warn

Instance Method Details

#bundleObject



57
58
59
# File 'lib/bently/recipe_class/ruby.rb', line 57

def bundle
  run 'bundle install'
end

#gem(*args) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/bently/recipe_class/ruby.rb', line 14

def gem(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  name, version = args

  # Set the message to be shown in logs. Uses the git repo if one is given,
  # otherwise use name (version).
  parts, message = [ name.inspect ], name
  if version ||= options.delete(:version)
    parts   << version.inspect
    message << " (#{version})"
  end
  message = options[:git] if options[:git]

  options.each do |option, value|
    parts << "#{option}: #{value.inspect}"
  end

  str = "gem #{parts.join(", ")}"
  str = "  " + str if @in_group
  str = "\n" + str

  if @in_group
    @gems = @gems.to_s + str
  else
    operate Gem, GEMFILE, str, message
  end
end

#gem_group(*names, &block) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/bently/recipe_class/ruby.rb', line 42

def gem_group(*names, &block)
  name = names.map(&:inspect).join(", ")

  str = "\ngroup #{name} do"

  @in_group = true
  instance_eval(&block)
  @in_group = false

  str += @gems
  str += "\nend\n"

  operate Gem, GEMFILE, str
end