Sha256: 545f4af68653518522579bf6cbe3092aa421b841c40fc1eeafc02d16e47276b8

Contents?: true

Size: 883 Bytes

Versions: 17

Compression:

Stored size: 883 Bytes

Contents

class Environment

  def initialize(project, environment_name)
    @project = project
    @environment_name = environment_name
  end

  attr_reader :project, :environment_name

  def last_deploy
    @last_deploy ||= project.deploys.completed.to(environment_name).first
  end

  def head
    return (environment_name == "Production" ? "c7c7380" : "98318a3") if Rails.env.development?
    @head ||= last_deploy.try(:commit)
  end

  def read_file(path)
    project.read_file(path, commit: head) if head
  rescue Houston::Adapters::VersionControl::CommitNotFound
    nil
  end



  def dependency_version(dependency)
    lockfile = read_file("Gemfile.lock")
    return nil unless lockfile

    dependency = dependency.to_s
    locked_gems = Bundler::LockfileParser.new(lockfile)
    spec = locked_gems.specs.find { |spec| spec.name == dependency }
    spec.version if spec
  end



end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
houston-core-0.8.0.pre app/models/environment.rb
houston-core-0.7.0 app/models/environment.rb
houston-core-0.7.0.beta4 app/models/environment.rb
houston-core-0.7.0.beta3 app/models/environment.rb
houston-core-0.7.0.beta2 app/models/environment.rb
houston-core-0.7.0.beta app/models/environment.rb
houston-core-0.6.3 app/models/environment.rb
houston-core-0.6.2 app/models/environment.rb
houston-core-0.6.1 app/models/environment.rb
houston-core-0.6.0 app/models/environment.rb
houston-core-0.5.6 app/models/environment.rb
houston-core-0.5.5 app/models/environment.rb
houston-core-0.5.4 app/models/environment.rb
houston-core-0.5.3 app/models/environment.rb
houston-core-0.5.2 app/models/environment.rb
houston-core-0.5.1 app/models/environment.rb
houston-core-0.5.0 app/models/environment.rb