Module: Scriptster

Defined in:
lib/scriptster.rb,
lib/scriptster/logger.rb,
lib/scriptster/version.rb,
lib/scriptster/shellcmd.rb,
lib/scriptster/configuration.rb

Overview

The public interface of scriptster is simple. It consists of two functions, cmd and log. The module can be used directly or included in your class.

Defined Under Namespace

Modules: ColourThemes, Logger Classes: Configuration, ShellCmd

Constant Summary collapse

VERSION =

The version of this library

"0.2.2"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cmd(*args) ⇒ Object

Execute a shell command

See Also:


53
54
55
# File 'lib/scriptster.rb', line 53

def self.cmd(*args)
  ShellCmd.new *args
end

.configure {|c| ... } ⇒ Object

Use this method to reconfigure the library.

Examples:

Scriptster::configure do |conf|
  conf.name = "my-script"
  conf.colours = :light
  conf.timestamps = false
end

Yields:

See Also:


75
76
77
78
79
# File 'lib/scriptster.rb', line 75

def self.configure
  c = Configuration.new
  yield c
  c.apply
end

.log(*args) ⇒ Object

Pass a message to the logger.


39
40
41
# File 'lib/scriptster.rb', line 39

def self.log(*args)
  Logger::log *args
end

.parse_args(docopt_string, argv = nil) ⇒ Array

Process command line arguments using docopt and return the array of options.


86
87
88
# File 'lib/scriptster.rb', line 86

def self.parse_args(docopt_string, argv=nil)
  do_parse_args docopt_string, argv
end

Instance Method Details

#cmd(*args) ⇒ Object

The same as cmd.

See Also:


60
61
62
# File 'lib/scriptster.rb', line 60

def cmd(*args)
  ShellCmd.new *args
end

#log(*args) ⇒ Object

The same as log.

See Also:


46
47
48
# File 'lib/scriptster.rb', line 46

def log(*args)
  Logger::log *args
end

#parse_args(docopt_string, argv = nil) ⇒ Object

The same as parse_args.

See Also:


93
94
95
# File 'lib/scriptster.rb', line 93

def parse_args(docopt_string, argv=nil)
  do_parse_args docopt_string, argv
end