Sha256: b3fc65f9de8635832f77785e013c7ca7a090d4baf13562bae2a2068b2e0f6f4e

Contents?: true

Size: 851 Bytes

Versions: 8

Compression:

Stored size: 851 Bytes

Contents

# frozen_string_literal: true

require 'nito'

module Getch
  module Gentoo
    class Use
      include NiTo

      def initialize(pkg = nil)
        @use_dir = "#{OPTIONS[:mountpoint]}/etc/portage/package.use"
        @pkg = pkg
        @file = @pkg ? @pkg.match(/[\w]+$/) : nil
        @make = "#{OPTIONS[:mountpoint]}/etc/portage/make.conf"
      end

      def add(*flags)
        @flags = flags.join(' ')
        write
      end

      def add_global(*flags)
        @flags = flags
        write_global
      end

      private

      def write
        content = "#{@pkg} #{@flags}\n"
        echo "#{@use_dir}/#{@file}", content
      end

      def write_global
        list = []
        @flags.each { |f| list << f unless grep?(@make, f) }
        use = list.join(' ')
        echo_a @make, "USE=\"${USE} #{use}\""
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
getch-0.7.3 lib/getch/gentoo/use.rb
getch-0.7.0 lib/getch/gentoo/use.rb
getch-0.5.0 lib/getch/gentoo/use.rb
getch-0.3.6 lib/getch/gentoo/use.rb
getch-0.3.5 lib/getch/gentoo/use.rb
getch-0.3.4 lib/getch/gentoo/use.rb
getch-0.3.3 lib/getch/gentoo/use.rb
getch-0.3.0 lib/getch/gentoo/use.rb