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 plugin install diffend'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, name) ⇒ IntegrationRepository



19
20
21
22
23
# File 'lib/diffend/integration_repository.rb', line 19

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.



15
16
17
# File 'lib/diffend/integration_repository.rb', line 15

def command
  @command
end

#nameObject (readonly)

Returns the value of attribute name.



15
16
17
# File 'lib/diffend/integration_repository.rb', line 15

def name
  @name
end

#repositoryObject (readonly)

Returns the value of attribute repository.



15
16
17
# File 'lib/diffend/integration_repository.rb', line 15

def repository
  @repository
end

Instance Method Details

#config?(path) ⇒ Boolean



31
32
33
34
35
36
37
# File 'lib/diffend/integration_repository.rb', line 31

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



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

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

#install_plugin(path) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/diffend/integration_repository.rb', line 40

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