Class: Putpaws::ApplicationConfig

Inherits:
Struct
  • Object
show all
Defined in:
lib/putpaws/application_config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#build_log_group_prefixObject

Returns the value of attribute build_log_group_prefix

Returns:

  • (Object)

    the current value of build_log_group_prefix



5
6
7
# File 'lib/putpaws/application_config.rb', line 5

def build_log_group_prefix
  @build_log_group_prefix
end

#build_projectObject

Returns the value of attribute build_project

Returns:

  • (Object)

    the current value of build_project



5
6
7
# File 'lib/putpaws/application_config.rb', line 5

def build_project
  @build_project
end

#build_regionObject

Returns the value of attribute build_region

Returns:

  • (Object)

    the current value of build_region



5
6
7
# File 'lib/putpaws/application_config.rb', line 5

def build_region
  @build_region
end

#clusterObject

Returns the value of attribute cluster

Returns:

  • (Object)

    the current value of cluster



5
6
7
# File 'lib/putpaws/application_config.rb', line 5

def cluster
  @cluster
end

#ecs_regionObject

Returns the value of attribute ecs_region

Returns:

  • (Object)

    the current value of ecs_region



5
6
7
# File 'lib/putpaws/application_config.rb', line 5

def ecs_region
  @ecs_region
end

#log_group_prefixObject

Returns the value of attribute log_group_prefix

Returns:

  • (Object)

    the current value of log_group_prefix



5
6
7
# File 'lib/putpaws/application_config.rb', line 5

def log_group_prefix
  @log_group_prefix
end

#log_regionObject

Returns the value of attribute log_region

Returns:

  • (Object)

    the current value of log_region



5
6
7
# File 'lib/putpaws/application_config.rb', line 5

def log_region
  @log_region
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



5
6
7
# File 'lib/putpaws/application_config.rb', line 5

def name
  @name
end

#regionObject

Returns the value of attribute region

Returns:

  • (Object)

    the current value of region



5
6
7
# File 'lib/putpaws/application_config.rb', line 5

def region
  @region
end

#schedulesObject

Returns the value of attribute schedules

Returns:

  • (Object)

    the current value of schedules



5
6
7
# File 'lib/putpaws/application_config.rb', line 5

def schedules
  @schedules
end

#serviceObject

Returns the value of attribute service

Returns:

  • (Object)

    the current value of service



5
6
7
# File 'lib/putpaws/application_config.rb', line 5

def service
  @service
end

#task_name_prefixObject

Returns the value of attribute task_name_prefix

Returns:

  • (Object)

    the current value of task_name_prefix



5
6
7
# File 'lib/putpaws/application_config.rb', line 5

def task_name_prefix
  @task_name_prefix
end

Class Method Details

.allObject



21
22
23
24
25
26
# File 'lib/putpaws/application_config.rb', line 21

def self.all
  load.map{|k,v|
    data = v.slice(*self.members)
    new(data.merge(name: k.to_s))
  }
end

.find(name) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/putpaws/application_config.rb', line 28

def self.find(name)
  application_data = load
  data = application_data[name.to_sym]
  return nil unless data
  data = data.slice(*self.members)
  new(data.merge({name: name.to_s}))
end

.load(path_prefix: '.putpaws') ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/putpaws/application_config.rb', line 12

def self.load(path_prefix: '.putpaws')
  @application_data ||= begin
    path = Pathname.new(path_prefix).join("application.json").to_s
    data = File.exist?(path) ?
      JSON.parse(File.read(path), symbolize_names: true).to_h :
      {}
  end
end

Instance Method Details

#build_log_command_paramsObject



52
53
54
55
56
57
# File 'lib/putpaws/application_config.rb', line 52

def build_log_command_params
  {
    region: build_region || region,
    log_group_prefix: build_log_group_prefix,
  }
end

#ecs_command_paramsObject



36
37
38
39
40
41
42
43
# File 'lib/putpaws/application_config.rb', line 36

def ecs_command_params
  {
    region: ecs_region || region,
    cluster: cluster,
    # service: service,
    task_name_prefix: task_name_prefix,
  }
end

#log_command_paramsObject



45
46
47
48
49
50
# File 'lib/putpaws/application_config.rb', line 45

def log_command_params
  {
    region: log_region || region,
    log_group_prefix: log_group_prefix,
  }
end