Sha256: 128293f120a7968eef27528192a30edb9dd8798d80df626867d5e4ea6962f975

Contents?: true

Size: 716 Bytes

Versions: 2

Compression:

Stored size: 716 Bytes

Contents

# encoding: utf-8

require "rbconfig"

class SimpleTemplater
  module Helpers
    extend self

    def shebang(executable = rubypath, *args)
      if RUBY_PLATFORM.match(/darwin/)
        self.env_shebang(executable, args)
      else
        self.plain_shebang(executable, args)
      end
    end

    def plain_shebang(executable = rubypath, *args)
      "#!#{executable} #{args.join(" ")}".chomp(" ")
    end

    def env_shebang(executable = ruby_basename, *args)
      "#!/usr/bin/env #{executable} #{args.join(" ")}".chomp(" ")
    end

    def rubypath
      File.join(RbConfig::CONFIG["bindir"], self.ruby_basename)
    end

    def ruby_basename
      RbConfig::CONFIG["RUBY_INSTALL_NAME"]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simple-templater-0.0.1.4 lib/simple-templater/helpers.rb
simple-templater-0.1.pre lib/simple-templater/helpers.rb