Class: SourceMonitor::Setup::ProcfilePatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/source_monitor/setup/procfile_patcher.rb

Constant Summary collapse

JOBS_ENTRY =
"jobs: bundle exec rake solid_queue:start"

Instance Method Summary collapse

Constructor Details

#initialize(path: "Procfile.dev") ⇒ ProcfilePatcher

Returns a new instance of ProcfilePatcher.



10
11
12
# File 'lib/source_monitor/setup/procfile_patcher.rb', line 10

def initialize(path: "Procfile.dev")
  @path = Pathname.new(path)
end

Instance Method Details

#patchObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/source_monitor/setup/procfile_patcher.rb', line 14

def patch
  if path.exist?
    content = path.read
    return false if content.match?(/^jobs:/)

    path.open("a") { |f| f.puts("", JOBS_ENTRY) }
  else
    path.write("web: bin/rails server -p 3000\n#{JOBS_ENTRY}\n")
  end
  true
end