class Diffend::IntegrationRepository
Repository
for integrations
Constants
Attributes
command[R]
name[R]
repository[R]
Public Class Methods
new(command, name)
click to toggle source
@param command [String] command executed via bundler @param name [String] repository name
# File lib/diffend/integration_repository.rb, line 26 def initialize(command, name) @command = command @name = name @repository = Diffend::Repository.new(command, name) end
Public Instance Methods
config?(path)
click to toggle source
@param path [String] path to the repository
# 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_name()
click to toggle source
@return [String] full name of the repository with command
# File lib/diffend/integration_repository.rb, line 33 def full_name "#{command}_#{name}" end
install_plugin(path)
click to toggle source
@param path [String] path to the repository
# 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
Private Instance Methods
add_plugin_to_gemfile(path)
click to toggle source
@param path [String] path to the repository
# File lib/diffend/integration_repository.rb, line 74 def add_plugin_to_gemfile(path) gemfile_path = File.join(path, GEMFILE_FILE_NAME) FileUtils.mv(gemfile_path, File.join(path, GEMFILE_BACKUP_FILE_NAME)) file = File.open(gemfile_path, 'w') source_detected = nil File.readlines( File.join(path, GEMFILE_BACKUP_FILE_NAME) ).each do |line| if line.start_with?('source') && source_detected.nil? source_detected = true elsif source_detected source_detected = false file.write("\n#{GEMFILE_PLUGIN_ENTRY}\n") end file.write(line) end file.close FileUtils.rm(File.join(path, GEMFILE_BACKUP_FILE_NAME)) end
switch_plugin_to_development(path, stdout)
click to toggle source
@param path [String] path to the repository @param stdout [String] stdout from plugin install command
# File lib/diffend/integration_repository.rb, line 64 def switch_plugin_to_development(path, stdout) installed_version = stdout.scan(/Installing diffend (\d*\.\d*\.\d*)/)[0][0] diffend_working_path = File.expand_path('..', Bundler.bin_path) bundler_plugins_path = File.join(path, '.bundle/plugin/gems') bundler_diffend_plugin_path = File.join(bundler_plugins_path, "diffend-#{installed_version}") FileUtils.mv(bundler_diffend_plugin_path, "#{bundler_diffend_plugin_path}-") FileUtils.ln_s(diffend_working_path, bundler_diffend_plugin_path) end