Sha256: 038bb90467d6ab6a9f15fe7091bbc0e775cf5c104d632998cb54a9aef43698a1

Contents?: true

Size: 887 Bytes

Versions: 21

Compression:

Stored size: 887 Bytes

Contents

# lib/aia/tools/editor.rb
# This is the default editor setup in the
# system environment variable EDITOR


class AIA::Editor < AIA::Tools

  meta(
    name:     'editor',
    role:     :editor,
    desc:     "Your default system $EDITOR",
    url:      "unknown",
    install:  "should already be installed",
  )

  DEFAULT_PARAMETERS = ""
  
  attr_accessor :command


  def initialize(file: "")    
    @file     = file

    discover_editor

    build_command
  end


  def discover_editor
    editor = ENV['EDITOR']  # This might be nil

    if editor.nil?
      @name         = "echo"
      @description  = "You have no default editor"
      @install      = "Set your system environment variable EDITOR"
    else
      @name = editor
    end    
  end


  def build_command
    @command = "#{meta.name} #{DEFAULT_PARAMETERS} #{@file}"
  end

  
  def run
    `#{command}`
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
aia-0.5.18 lib/aia/tools/editor.rb
aia-0.5.16 lib/aia/tools/editor.rb
aia-0.5.15 lib/aia/tools/editor.rb
aia-0.5.14 lib/aia/tools/editor.rb
aia-0.5.13 lib/aia/tools/editor.rb
aia-0.5.12 lib/aia/tools/editor.rb
aia-0.5.11 lib/aia/tools/editor.rb
aia-0.5.10 lib/aia/tools/editor.rb
aia-0.5.9 lib/aia/tools/editor.rb
aia-0.5.8 lib/aia/tools/editor.rb
aia-0.5.7 lib/aia/tools/editor.rb
aia-0.5.6 lib/aia/tools/editor.rb
aia-0.5.3 lib/aia/tools/editor.rb
aia-0.5.2 lib/aia/tools/editor.rb
aia-0.5.1 lib/aia/tools/editor.rb
aia-0.5.0 lib/aia/tools/editor.rb
aia-0.4.4 lib/aia/tools/editor.rb
aia-0.4.3 lib/aia/tools/editor.rb
aia-0.4.2 lib/aia/tools/editor.rb
aia-0.4.1 lib/aia/tools/editor.rb