Module: ReleaseMe::Adapter

Included in:
BumpVersion
Defined in:
lib/release_me/adapter.rb

Instance Method Summary collapse

Instance Method Details

#adapter_config(project_path = Dir.pwd) ⇒ Hash

Returns - adapter config.

Parameters:

  • - (String)

    path to the directory in which you want to check

Returns:

  • (Hash)
    • adapter config



10
11
12
13
14
15
16
17
18
# File 'lib/release_me/adapter.rb', line 10

def adapter_config(project_path = Dir.pwd)
  path = project_path || Dir.pwd
  config = local_config(path) || detect_adapter_config(path)
  raise 'Cannot find config' if config.nil?
  adapter = OpenStruct.new(config)
  adapter.version_file = version_file(path, adapter.version_file_relative_path)
  adapter.current_version = current_version(adapter, adapter.version_file)
  adapter
end

#adapter_listObject



20
21
22
# File 'lib/release_me/adapter.rb', line 20

def adapter_list
  adapters.keys
end

#local_config(path = Dir.pwd) ⇒ Hash

Returns adapter settings found in the project directory.

Parameters:

  • - (String)

    path to the directory in which you want to check

Returns:

  • (Hash)

    adapter settings found in the project directory



26
27
28
29
30
31
32
# File 'lib/release_me/adapter.rb', line 26

def local_config(path = Dir.pwd)
  file = File.join(path, '.release_me.yaml')
  if File.exist?(file)
    data = load_adapter(file)
    data.fetch('adapter', nil)
  end
end

#version_file(project_path, version_path) ⇒ String

Returns path to version file.

Parameters:

  • project_path (String)
    • path to the directory in which you want to check

  • version_path (String)
    • path to the version file or glob of version file

Returns:

  • (String)

    path to version file



37
38
39
# File 'lib/release_me/adapter.rb', line 37

def version_file(project_path, version_path)
  Dir.glob(File.join(project_path, version_path)).first
end