Class: MKBrut::AppOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/mkbrut/app_options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app_name:, app_id: nil, prefix: nil, dry_run: nil, organization: nil, demo: false, versions: nil, **rest) ⇒ AppOptions

Returns a new instance of AppOptions.



4
5
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/mkbrut/app_options.rb', line 4

def initialize(
  app_name:,
  app_id: nil,
  prefix: nil,
  dry_run: nil,
  organization: nil,
  demo: false,
  versions: nil,
  **rest
)
  if app_name.nil?
    raise ArgumentError, "app_name is required"
  end

  @app_name     =   app_name
  @app_id       =   app_id       || MKBrut::AppId.from_app_name(@app_name)
  @prefix       =   prefix       || MKBrut::Prefix.from_app_id(@app_id)
  @organization =   organization || @app_id
  @dry_run      = !!dry_run
  @demo         = !!demo
  @versions     =   versions
  @segments     = rest.map { |key,value|
    if key =~ /^segment-(.+)$/ && value
      $1
    else
      nil
    end
  }.compact
end

Instance Attribute Details

#app_idObject (readonly)

Returns the value of attribute app_id.



2
3
4
# File 'lib/mkbrut/app_options.rb', line 2

def app_id
  @app_id
end

#app_nameObject (readonly)

Returns the value of attribute app_name.



2
3
4
# File 'lib/mkbrut/app_options.rb', line 2

def app_name
  @app_name
end

#demoObject (readonly)

Returns the value of attribute demo.



2
3
4
# File 'lib/mkbrut/app_options.rb', line 2

def demo
  @demo
end

#organizationObject (readonly)

Returns the value of attribute organization.



2
3
4
# File 'lib/mkbrut/app_options.rb', line 2

def organization
  @organization
end

#prefixObject (readonly)

Returns the value of attribute prefix.



2
3
4
# File 'lib/mkbrut/app_options.rb', line 2

def prefix
  @prefix
end

#segmentsObject (readonly)

Returns the value of attribute segments.



2
3
4
# File 'lib/mkbrut/app_options.rb', line 2

def segments
  @segments
end

#versionsObject (readonly)

Returns the value of attribute versions.



2
3
4
# File 'lib/mkbrut/app_options.rb', line 2

def versions
  @versions
end

Instance Method Details

#demo?Boolean

Returns:

  • (Boolean)


35
# File 'lib/mkbrut/app_options.rb', line 35

def demo?    = @demo

#dry_run?Boolean

Returns:

  • (Boolean)


34
# File 'lib/mkbrut/app_options.rb', line 34

def dry_run? = @dry_run