Sha256: e3bce441466380db5fb987198d6d29f16cd5be55036b4f633a8dc3a0a5cc6bd8

Contents?: true

Size: 928 Bytes

Versions: 4

Compression:

Stored size: 928 Bytes

Contents

module Rails4Upgrade
  GemIncompatibility = Struct.new(:dependency, :path)

  class IncompatibleGems
    def initialize(gemfile)
      @gemfile = gemfile
    end

    def incompatibilities
      @gemfile.dependencies.reject(&:rails?).inject([]) { |incompatibilities, dependency|
        incompatibilities.concat(incompatibilities_for(dependency))
        incompatibilities
      }
    end

    private

    def incompatibilities_for(gem, dependency_path = [])
      dependency_path += [gem]

      gem.dependencies.inject([]) do |incompatibilities, dependency|
        if dependency.rails?
          if !dependency.satisfied_by_rails4?
            incompatibilities << GemIncompatibility.new(dependency, dependency_path)
          end
        elsif gem = @gemfile[dependency.name]
          incompatibilities.concat(incompatibilities_for(gem, dependency_path))
        end

        incompatibilities
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails4_upgrade-0.0.4 lib/rails4_upgrade/incompatible_gems.rb
rails4_upgrade-0.0.3 lib/rails4_upgrade/incompatible_gems.rb
rails4_upgrade-0.0.2 lib/rails4_upgrade/incompatible_gems.rb
rails4_upgrade-0.0.1 lib/rails4_upgrade/incompatible_gems.rb