Module: GS
- Includes:
- Options
- Defined in:
- lib/gs-ruby.rb,
lib/gs-ruby/command.rb,
lib/gs-ruby/options.rb,
lib/gs-ruby/version.rb,
lib/gs-ruby/configuration.rb
Overview
GS Ruby is a simple wrapper for the Ghostscript command - it's assumed that you have the gs
command already installed.
Usage
Typical usage might look like:
GS.run('input.ps', GS::OUTPUT_FILE => 'output.pdf')
Or using a block to work with the command before it's run:
GS.run('input.ps') do |command|
command.option(GS::OUTPUT_FILE, 'output.pdf')
end
Configuration
Global configuration is possible:
GS.configure do |config|
config.bin_path = '/path/to/gs'
end
Logging
By default all output is logged to $stdout, but the logger can be configured:
# For a single command instance.
GS.run('input.ps') do |command|
command.logger = # ...
end
# For all command instances.
GS.configure do |config|
config.logger = # ...
end
Defined Under Namespace
Modules: Options Classes: Command, Configuration
Constant Summary collapse
- VERSION =
'0.1.0'
Constants included from Options
Options::BATCH, Options::DEVICE, Options::NO_PAUSE, Options::OUTPUT_FILE, Options::PDFA, Options::PDFA_COMPATIBILITY_POLICY, Options::PROCESS_COLOR_MODEL
Class Method Summary collapse
-
.configuration ⇒ Configuration
Gets the configuration object.
-
.configure {|configuration| ... } ⇒ Object
Allows for configuring the library using a block.
-
.run(input, options = {}) {|command| ... } ⇒ Process::Status
Instantiates a new command object with any provided options and runs it with the provided input.
Class Method Details
.configuration ⇒ Configuration
Gets the configuration object.
If none was set, a new configuration object is instantiated and returned.
57 58 59 |
# File 'lib/gs-ruby.rb', line 57 def configuration @configuration ||= Configuration.new end |
.configure {|configuration| ... } ⇒ Object
Allows for configuring the library using a block.
67 68 69 |
# File 'lib/gs-ruby.rb', line 67 def configure yield(configuration) if block_given? end |
.run(input, options = {}) {|command| ... } ⇒ Process::Status
Instantiates a new command object with any provided options and runs it with the provided input.
86 87 88 89 90 |
# File 'lib/gs-ruby.rb', line 86 def run(input, = {}) command = Command.new(options: ) yield(command) if block_given? command.run(input) end |