Sha256: 376ed1962aeee87aef2721f0966c51c810c7aff9ef33d1766510efd9d3041ef1

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

require "active_support/concern"
require "find"
$root = File.expand_path("../../", __FILE__)
$lib = File.join($root, 'lib')
$LOAD_PATH.unshift $root
$LOAD_PATH.unshift $lib
require "ro_commands/helpers/bash"

module RoHelpers

  module SetEnvsHelper
    extend ActiveSupport::Concern

    included do
    end

    module ClassMethods
      include Bash

      def bin_ruby
        File.join(ENV['HOME'], ".rbenv/versions/", rb_ver, "/bin/ruby")
      end

      def bashrc
        File.join(gem, 'ro_commands.sh')
      end

      def get_bin(bin)
        #Dir.chdir File.join($root)
        #bash "rake install"
        rbenv(bin)
      end

      def ro_client
        get_bin("ro_client")
      end

      def ro_server
        get_bin("ro_server")
      end

      def rbenv(bin)
        File.join(gem, "/bin/#{bin}")
      end

      def gem
        File.join(ENV['HOME'], ".rbenv/versions/", rb_ver, "lib/ruby/gems/#{RUBY_VERSION}/gems/", gem_ver)
      end

      def rb_ver
        r = bashc("ruby -v").match(%r{\d.\d.\dp\d+})[0]
        r.gsub(%r{p}) do |m|
          "-p"
        end

      end

      def rb_ver_num
        if rb_ver
          rb_ver.match(%r{\d+\.\d+\.\d+})[0]
        end
      end

      def gem_ver
        r = bashc("gem list ro_commands").match(%r{\((?<version>\d.\d.\d)\)})[:version]
        "ro_commands-#{r}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ro_commands-0.0.2 lib/set_envs_helper.rb