Class: Brut::CLI::Apps::New::AddSegment

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

Instance Method Summary collapse

Constructor Details

#initialize(current_dir:, add_segment_options:, out:, err:) ⇒ AddSegment

Returns a new instance of AddSegment.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/brut/cli/apps/new/add_segment.rb', line 6

def initialize(current_dir:, add_segment_options:, out:, err:)
  @out = out
  @add_segment_options = add_segment_options

  @out.puts "Adding #{@add_segment_options.segment_name} to this app"

  if @add_segment_options.dry_run?
    @out.puts "Dry Run"
    Brut::CLI::Apps::New::Ops::BaseOp.dry_run = true
  end

  templates_dir = Pathname(
    Gem::Specification.find_by_name("brut").gem_dir
  ) / "templates"

  @segment = if @add_segment_options.segment_name == "sidekiq"
               Brut::CLI::Apps::New::Segments::Sidekiq.new(
                 project_root: add_segment_options.project_root,
                 templates_dir:
               )
             elsif @add_segment_options.segment_name == "heroku"
               Brut::CLI::Apps::New::Segments::Heroku.new(
                 project_root: add_segment_options.project_root,
                 templates_dir:
               )
             end
end

Instance Method Details

#add!Object



34
35
36
# File 'lib/brut/cli/apps/new/add_segment.rb', line 34

def add!
  @segment.add!
end