Class: AppUp::Hooks::RailsUp

Inherits:
Hook
  • Object
show all
Defined in:
lib/app_up/hooks/rails_up.rb

Constant Summary collapse

BUNDLE_COMMAND =
"bundle --local || bundle"

Instance Attribute Summary

Attributes inherited from Hook

#files, #options, #shell

Instance Method Summary collapse

Methods inherited from Hook

run

Constructor Details

#initialize(*args) ⇒ RailsUp

Returns a new instance of RailsUp.



8
9
10
11
# File 'lib/app_up/hooks/rails_up.rb', line 8

def initialize(*args)
  @commands = {}
  super(*args)
end

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/app_up/hooks/rails_up.rb', line 13

def run
  shell.notify( "Running RailsUp\n----------")

  files.each do |file|
    exploded_path = Utils::Path.split(file)

    # allow rebundle on only Gemfile edit, in case you're
    # upping a gem, which probably doesn't have the Gemfile.lock
    # checked in
    if exploded_path.last.match(/Gemfile(\.lock)?|gemspec$/)
      add_command(:bundle, dir: exploded_path[0..-2])
    end

    if exploded_path.include?("migrate")
      last_db_index =  exploded_path.rindex("db")
      add_command(:migrate, dir: exploded_path[0...last_db_index])
    end
  end

  enqueue_commands
end