Sha256: 167888f3ee8fc09ff04b16e786a3abc4a9fbd439e5a50ebdfa4723e58a07ea59

Contents?: true

Size: 580 Bytes

Versions: 1

Compression:

Stored size: 580 Bytes

Contents

require 'open3'

module Noty
  module Helpers
    module_function

    def edit(file_path)
      editor = ENV['EDITOR'] || 'vi'.freeze
      system "#{editor} #{file_path}"
    end

    def copy(text)
      case RUBY_PLATFORM
      when /darwin/
        Open3.capture2('pbcopy', stdin_data: text)
      when /linux/
        Open3.capture2('xsel --clipboard --input', stdin_data: text)
      end
    end

    def open_url(url)
      case RUBY_PLATFORM
      when /darwin/
        system "open #{url}"
      when /linux/
        system "xdg-open #{url}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
noty-0.1.1 lib/noty/helpers.rb