about summary refs log tree commit homepage
path: root/lib/dtas/xs.rb
blob: 968865debe52b4abc492bf2200485bffb722903b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors
# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
require_relative '../dtas'
require 'shellwords'

# We always escape binary strings because paths on POSIX filesystems are
# encoding agnostic.  Shellwords.split does give UTF-8 strings, but nothing
# cares at that point if the encoding isn't valid (and it's right to not care,
# again, filesystems can use any byte value in names except '\0'.
module DTAS::XS # :nodoc:
  def xs(ary)
    Shellwords.join(ary.map { |s| s.b })
  end
end