Sha256: 5c1850425fe76d4fc30b7a927ea764f66c4edbaba6015d981224fcc7208a1ee6

Contents?: true

Size: 984 Bytes

Versions: 2

Compression:

Stored size: 984 Bytes

Contents

module Rda
  class Rvm < Thor
    include Thor::Actions

    def self.source_root
      File.dirname(__FILE__)
    end

    desc "setup", "Setup RVM for rails application"
    def setup
      if installed?
        template('templates/rvmrc', rvmrc_path)
      else
        $stderr.puts "ERROR: RVM is not found. Please make sure that RVM is installed."
      end
    end

    desc "discard", "Discard RVM settings for rails application"
    def discard
      if File.exists?(rvmrc_path)
        remove_file(rvmrc_path)
      else
        $stderr.puts "ERROR: #{rvmrc_path} not found."
      end
    end

    private
    def installed?
      rvm_path && File.directory?(rvm_path)
    end

    def rvm_path
      ENV['rvm_path']
    end

    def gemset_name
      "ruby-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}@#{Rda::Rails.app_name}"
    end

    def gemset_env
      "#{rvm_path}/environments/#{gemset_name}"
    end

    def rvmrc_path
      "#{Rda::Rails.root}/.rvmrc"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rda-0.3.3 lib/rda/rvm.rb
rda-0.3.2 lib/rda/rvm.rb