Sha256: f5efc0b0aaf58969030335952a38464c8e51d4c71f81c6b3c122530d55281b71

Contents?: true

Size: 1007 Bytes

Versions: 2

Compression:

Stored size: 1007 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.name != dependency.name
          if gem_dependency = @gemfile[dependency.name]
            incompatibilities.concat(incompatibilities_for(gem_dependency, dependency_path))
          end
        end

        incompatibilities
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails4_upgrade-0.5.0 lib/rails4_upgrade/incompatible_gems.rb
rails4_upgrade-0.0.5 lib/rails4_upgrade/incompatible_gems.rb