Class: Thegarage::Gitx::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/thegarage/gitx/configuration.rb

Constant Summary collapse

DEFAULT_CONFIG =
{
  'aggregate_branches' => %w( staging prototype ),
  'reserved_branches' => %w( HEAD master next_release staging prototype ),
  'taggable_branches' => %w( master staging )
}
CONFIG_FILE =
'.gitx.yml'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_dir) ⇒ Configuration

Returns a new instance of Configuration.



15
16
17
18
19
20
21
# File 'lib/thegarage/gitx/configuration.rb', line 15

def initialize(root_dir)
  @config = Thor::CoreExt::HashWithIndifferentAccess.new(DEFAULT_CONFIG)
  config_file_path = File.join(root_dir, CONFIG_FILE)
  if File.exists?(config_file_path)
    @config.merge!(::YAML::load_file(config_file_path))
  end
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



13
14
15
# File 'lib/thegarage/gitx/configuration.rb', line 13

def config
  @config
end

Instance Method Details

#aggregate_branch?(branch) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/thegarage/gitx/configuration.rb', line 26

def aggregate_branch?(branch)
  aggregate_branches.include?(branch)
end

#aggregate_branchesObject



23
24
25
# File 'lib/thegarage/gitx/configuration.rb', line 23

def aggregate_branches
  config[:aggregate_branches]
end

#reserved_branch?(branch) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/thegarage/gitx/configuration.rb', line 34

def reserved_branch?(branch)
  reserved_branches.include?(branch)
end

#reserved_branchesObject



30
31
32
# File 'lib/thegarage/gitx/configuration.rb', line 30

def reserved_branches
  config[:reserved_branches]
end

#taggable_branch?(branch) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/thegarage/gitx/configuration.rb', line 42

def taggable_branch?(branch)
  taggable_branches.include?(branch)
end

#taggable_branchesObject



38
39
40
# File 'lib/thegarage/gitx/configuration.rb', line 38

def taggable_branches
  config[:taggable_branches]
end