Class: Bowndler::Commands::Autohook

Inherits:
Object
  • Object
show all
Defined in:
lib/bowndler/commands/autohook.rb

Constant Summary collapse

HOOK =
<<-HOOK

# BEGIN Autogenerated by bowndler, do not edit
if ENV['ENABLE_BOWNDLER_HOOK']
  at_exit do
    require "bowndler"
    Bowndler.hook
  end
end
# END Autogenerated by bowndler
HOOK

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gemfile) ⇒ Autohook

Returns a new instance of Autohook.



20
21
22
# File 'lib/bowndler/commands/autohook.rb', line 20

def initialize(gemfile)
  @gemfile = gemfile
end

Instance Attribute Details

#gemfileObject (readonly)

Returns the value of attribute gemfile.



18
19
20
# File 'lib/bowndler/commands/autohook.rb', line 18

def gemfile
  @gemfile
end

Instance Method Details

#callObject



24
25
26
27
28
29
# File 'lib/bowndler/commands/autohook.rb', line 24

def call
  File.open(gemfile, 'a+') do |f|
    contents = f.read
    f << HOOK unless contents.include?(HOOK)
  end
end