Sha256: dde89007608779c86c37ed4fcdfd87d399f12cc460f64d16d79ba89ac8e02831

Contents?: true

Size: 1.6 KB

Versions: 7

Compression:

Stored size: 1.6 KB

Contents

# frozen_string_literal: true

require "cable_ready/installer"

hash = gemfile_hash

# run bundle only when gems are waiting to be added or removed
add = add_gem_list.exist? ? add_gem_list.readlines.map(&:chomp) : []
remove = remove_gem_list.exist? ? remove_gem_list.readlines.map(&:chomp) : []

if add.present? || remove.present?
  lines = gemfile_path.readlines

  remove.each do |name|
    index = lines.index { |line| line =~ /gem ['"]#{name}['"]/ }
    if index
      if /^[^#]*gem ['"]#{name}['"]/.match?(lines[index])
        lines[index] = "# #{lines[index]}"
        say "✅ #{name} gem has been disabled"
      else
        say "⏩ #{name} gem is already disabled. Skipping."
      end
    end
  end

  add.each do |package|
    matches = package.match(/(.+)@(.+)/)
    name, version = matches[1], matches[2]

    index = lines.index { |line| line =~ /gem ['"]#{name}['"]/ }
    if index
      if !lines[index].match(/^[^#]*gem ['"]#{name}['"].*#{version}['"]/)
        lines[index] = "\ngem \"#{name}\", \"#{version}\"\n"
        say "✅ #{name} gem has been installed"
      else
        say "⏩ #{name} gem is already installed. Skipping."
      end
    else
      lines << "\ngem \"#{name}\", \"#{version}\"\n"
    end
  end

  gemfile_path.write lines.join

  bundle_command("install --quiet", "BUNDLE_IGNORE_MESSAGES" => "1") if hash != gemfile_hash
end

FileUtils.cp(development_working_path, development_path)
say "✅ development environment configuration installed"

FileUtils.cp(action_cable_initializer_working_path, action_cable_initializer_path)
say "✅ Action Cable initializer installed"

complete_step :bundle

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cable_ready-5.0.3 lib/install/bundle.rb
cable_ready-5.0.2 lib/install/bundle.rb
cable_ready-5.0.1 lib/install/bundle.rb
cable_ready-5.0.0 lib/install/bundle.rb
cable_ready-5.0.0.rc2 lib/install/bundle.rb
cable_ready-5.0.0.rc1 lib/install/bundle.rb
cable_ready-5.0.0.pre10 lib/install/bundle.rb