Class: Brut::CLI::Apps::New::Segments::Heroku

Inherits:
Base
  • Object
show all
Defined in:
lib/brut/cli/apps/new/segments/heroku.rb

Instance Attribute Summary

Attributes inherited from Base

#project_root

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#create!

Constructor Details

#initialize(project_root:, templates_dir:) ⇒ Heroku

Returns a new instance of Heroku.



5
6
7
8
# File 'lib/brut/cli/apps/new/segments/heroku.rb', line 5

def initialize(project_root:, templates_dir:)
  @project_root  = project_root
  @templates_dir = templates_dir / "segments" / "Heroku"
end

Class Method Details

.friendly_nameObject



2
# File 'lib/brut/cli/apps/new/segments/heroku.rb', line 2

def self.friendly_name = "Heroku-based Deployment"

.segment_nameObject



3
# File 'lib/brut/cli/apps/new/segments/heroku.rb', line 3

def self.segment_name = "heroku"

Instance Method Details

#<=>(other) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/brut/cli/apps/new/segments/heroku.rb', line 22

def <=>(other)
  if self.class == other.class
    0
  elsif other.class == Brut::CLI::Apps::New::Segments::Sidekiq
    # If both herkou and sidekiq segments are activated, we want to do heroku first,
    # since Sidekiq will need to modify it.
    -1
  else
    1
  end
end

#add!Object



10
11
12
13
14
15
16
17
# File 'lib/brut/cli/apps/new/segments/heroku.rb', line 10

def add!
  operations = copy_files(@templates_dir, @project_root) + 
               other_operations

  operations.each do |operation|
    operation.call
  end
end

#other_operationsObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/brut/cli/apps/new/segments/heroku.rb', line 34

def other_operations
  [
    Brut::CLI::Apps::New::Ops::InsertIntoFile.new(
      file: @project_root / "Dockerfile.dx",
      content: %{
# Installs the Heroku CLI, per Heroku docs at 
# https://devcenter.heroku.com/articles/heroku-cli#install-with-ubuntu-debian-apt-get
RUN curl https://cli-assets.heroku.com/install-ubuntu.sh | sh
},
      before_line: "# Up to now, RUN directives ran as the root user.  When using this container"
    ),
    Brut::CLI::Apps::New::Ops::AppendToFile.new(
      file: @project_root / ".gitignore",
      content: %{
# These are generated by bin/deploy
deploy/Dockerfile.*
}
    ),
  ]
end

#output_post_add_messaging(stdout:) ⇒ Object



19
20
# File 'lib/brut/cli/apps/new/segments/heroku.rb', line 19

def output_post_add_messaging(stdout:)
end