Sha256: 5bb7ab8c4cf458145ed978d82f9942345d4c40ca1b3d82610d77b6a1604c43a5

Contents?: true

Size: 972 Bytes

Versions: 7

Compression:

Stored size: 972 Bytes

Contents

module Gondler
  class Env
    class << self
      def accessor(name, source)
        define_method(name) do
          @environments[source]
        end

        define_method("#{name}=") do |val|
          val = val.to_s
          ENV[source.to_s] = val
          @environments[source] = val
        end
      end
    end

    def initialize
      reload!
    end

    def reload!
      @environments = {}
      `go env`.each_line do |define|
        matched = define.match(/\A([A-Z]+)="(.*)"\Z/)
        @environments[matched[1].to_sym] = matched[2] if matched
      end
    end

    accessor :arch, :GOARCH
    accessor :bin, :GOBIN
    accessor :char, :GOCHAR
    accessor :exe, :GOEXE
    accessor :host_arch, :GOHOSTARCH
    accessor :host_os, :GOHOSTOS
    accessor :os, :GOOS
    accessor :path, :GOPATH
    accessor :race, :GORACE
    accessor :root, :GOROOT
    accessor :tool_dir, :GOTOOLDIR
    accessor :cc, :CC
    accessor :gcc_flags, :GOGCCGLAGS
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gondler-0.1.3 lib/gondler/env.rb
gondler-0.1.2 lib/gondler/env.rb
gondler-0.1.1 lib/gondler/env.rb
gondler-0.1.0 lib/gondler/env.rb
gondler-0.0.3 lib/gondler/env.rb
gondler-0.0.2 lib/gondler/env.rb
gondler-0.0.1 lib/gondler/env.rb