Module: MagikkuHelpers

Included in:
MagikkuFFI
Defined in:
lib/magikku/convenience.rb

Instance Method Summary collapse

Instance Method Details

#check_syntax(fname, params = {}) ⇒ Object

A convenience method for checking syntax of magicdb files.

Note: syntax errors and warnings may be displayed on stderr.

Parameters:

  • String

    fname Filename or directory to compile

  • Hash

    params A hash of parameters to Magikku.new()

Returns:

  • true,false



14
15
16
17
18
19
20
21
# File 'lib/magikku/convenience.rb', line 14

def check_syntax(fname, params={})
  m=new(params)
  begin
    return m.check_syntax(fname)
  ensure
    m.close()
  end
end

#compile(fname, params = {}) ⇒ Object

A convenience method for compiling magicdb files.

Parameters:

  • String

    fname Filename or directory to compile

  • Hash

    params A hash of parameters to Magikku.new()

Returns:

  • true

Raises:

  • Magikku::CompileError if an error occurs



34
35
36
37
38
39
40
41
# File 'lib/magikku/convenience.rb', line 34

def compile(fname, params={})
  m=new(params)
  begin
    return m.compile(fname)
  ensure
    m.close()
  end
end

#file(fname, params = {}) ⇒ Object

A convenience method for identifying file contents

Parameters:

  • String

    fname Filename to identify

  • Hash

    params A hash of parameters to Magikku.new()

Returns:

  • String Identification of the file contents.



53
54
55
56
57
58
59
60
# File 'lib/magikku/convenience.rb', line 53

def file(fname, params={})
  m=new(params)
  begin
    return m.file(fname)
  ensure
    m.close()
  end
end

#string(buf, params = {}) ⇒ Object

A convenience method for identifying string contents

Parameters:

  • String

    buf String contents to identify

  • Hash

    params A hash of parameters to Magikku.new()

Returns:

  • String Identification of the string.



72
73
74
75
76
77
78
79
# File 'lib/magikku/convenience.rb', line 72

def string(buf, params={})
  m=new(params)
  begin
    return m.string(buf)
  ensure
    m.close()
  end
end