Class: Diffend::IntegrationRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/diffend/integration_repository.rb

Overview

Repository for integrations

Constant Summary collapse

GEMFILE_PLUGIN_ENTRY =

Plugin code entry in Gemfile

'plugin \'diffend\''
GEMFILE_FILE_NAME =

Gemfile file name

'Gemfile'
GEMFILE_BACKUP_FILE_NAME =

Gemfile backup file name

'Gemfile.backup'
PLUGIN_INSTALL_COMMAND =

Plugin install command

[
  'bundle',
  "_#{Bundler::VERSION}_",
  'plugin',
  'install',
  'diffend',
  '--source https://rubygems.org'
].join(' ').freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, name) ⇒ IntegrationRepository

Returns a new instance of IntegrationRepository.

Parameters:

  • command (String)

    command executed via bundler

  • name (String)

    repository name



26
27
28
29
30
# File 'lib/diffend/integration_repository.rb', line 26

def initialize(command, name)
  @command = command
  @name = name
  @repository = Diffend::Repository.new(command, name)
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



22
23
24
# File 'lib/diffend/integration_repository.rb', line 22

def command
  @command
end

#nameObject (readonly)

Returns the value of attribute name.



22
23
24
# File 'lib/diffend/integration_repository.rb', line 22

def name
  @name
end

#repositoryObject (readonly)

Returns the value of attribute repository.



22
23
24
# File 'lib/diffend/integration_repository.rb', line 22

def repository
  @repository
end

Instance Method Details

#config?(path) ⇒ Boolean

Parameters:

  • path (String)

    path to the repository

Returns:

  • (Boolean)


38
39
40
41
42
43
44
# File 'lib/diffend/integration_repository.rb', line 38

def config?(path)
  # check if .diffend.yml exists
  return if File.exist?(File.join(path, Diffend::Config::FILENAME))

  puts "Diffend configuration does not exist for #{command} #{name}"
  exit 1
end

#full_nameString

Returns full name of the repository with command.

Returns:

  • (String)

    full name of the repository with command



33
34
35
# File 'lib/diffend/integration_repository.rb', line 33

def full_name
  "#{command}_#{name}"
end

#install_plugin(path) ⇒ Object

Parameters:

  • path (String)

    path to the repository



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/diffend/integration_repository.rb', line 47

def install_plugin(path)
  cmd = Diffend::Shell.call_in_path(path, PLUGIN_INSTALL_COMMAND)

  unless cmd[:exit_code].zero?
    puts "#{PLUGIN_INSTALL_COMMAND} failed"
    puts cmd[:stderr]
    exit 1
  end

  switch_plugin_to_development(path, cmd[:stdout])
  add_plugin_to_gemfile(path)
end