Module: Shibby

Defined in:
lib/shibby.rb,
lib/version.rb

Overview

Shibby

Constant Summary collapse

VERSION =
'0.2'

Class Method Summary collapse

Class Method Details

.executable?(path) ⇒ Boolean

Retrieve a file’s executable permissions.

Assumes file exists.

Returns:

  • (Boolean)


33
34
35
# File 'lib/shibby.rb', line 33

def self.executable?(path)
  File.stat(path).executable?
end

.shebang(path) ⇒ Object

Retrieve a file’s shebang line, if any

Assumes file exists.



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/shibby.rb', line 14

def self.shebang(path)
  File.open(path) do |f|
    line = f.readline

    if line =~ /^#!/
      line.chomp
    else
      nil
    end
  end
end

.status(path) ⇒ Object

Query shebang status

Assumes file exists.



44
45
46
47
48
49
# File 'lib/shibby.rb', line 44

def self.status(path)
  {
    shebang: shebang(path),
    executable: executable?(path)
  }
end