Class: PrChangelog::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/pr_changelog/config.rb

Overview

Loads the configuration

Constant Summary collapse

DEFAULTS =
{
  format: 'plain',
  strategy: 'merge',
  tags: [
    {
      prefix: 'feature',
      emoji: '⭐️',
      title: 'New features'
    },
    {
      prefix: 'fix',
      emoji: '🐛',
      title: 'Fixes'
    },
    {
      prefix: 'improvement',
      emoji: '💎',
      title: 'Improvements'
    },
    {
      prefix: 'internal',
      emoji: '👨‍💻',
      title: 'Internal'
    },
    {
      prefix: 'unclassified',
      emoji: '',
      title: 'Unclassified'
    }
  ]
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(file = nil) ⇒ Config

Returns a new instance of Config.



40
41
42
43
44
45
46
47
# File 'lib/pr_changelog/config.rb', line 40

def initialize(file = nil)
  @file = file || '.pr_changelog.json'
  @loaded_data = {}

  return unless File.exist?(@file)

  @loaded_data = JSON.parse(File.read(@file), symbolize_names: true)
end

Instance Method Details

#default_formatObject



49
50
51
# File 'lib/pr_changelog/config.rb', line 49

def default_format
  loaded_data[:format] || DEFAULTS[:format]
end

#default_strategyObject



53
54
55
# File 'lib/pr_changelog/config.rb', line 53

def default_strategy
  loaded_data[:strategy] || DEFAULTS[:strategy]
end

#tagsObject



57
58
59
# File 'lib/pr_changelog/config.rb', line 57

def tags
  loaded_data[:tags] || DEFAULTS[:tags]
end