class RuGUI::Configuration

Defines configurations for a RuGUI application.

Attributes

application[RW]

A hash of application specific configurations.

automatically_register_conventionally_named_views[RW]

Automatically register conventionally named views. Defaults to true.

builder_files_paths[RW]

An array of paths for builder files.

environment[RW]

The environment for this application.

framework_adapter[RW]

The framework adapter to be used for this application. Defaults to GTK. For now it can only be GTK.

gems[RW]

An array of gems that this RuGUI application depends on. RuGUI will automatically load these gems during installation, and allow you to install any missing gems with:

rake gems:install

You can add gems with the gem method.

load_paths[RW]

An array of paths which should be automaticaly loaded.

logger[RW]

The specific logger to use. By default, a logger will be created and initialized using log_path and log_level, but a programmer may specifically set the logger to use via this accessor and it will be used directly.

queue_timeout[RW]

The timeout for queued calls. Useful when performing long tasks.

root_path[R]

The application root path, defined by ::APPLICATION_ROOT

styles_paths[RW]

An array of paths which should be searched for gtkrc styles files.

It searchs for files which have the ‘.rc’ extension or files which have the string ‘gtkrc’ in its filename.

The order in which the files are loaded is random, so do not rely on it.

If you need to use absolute paths in a gtkrc file, such as set the pixmap path, you can use “{ROOT_PATH}”, which will be substituted by the application root path when the file is read.

Public Class Methods

new() click to toggle source
# File lib/rugui/configuration.rb, line 58
def initialize
  set_root_path!

  self.environment = default_environment
  self.framework_adapter = default_framework_adapter
  self.load_paths = default_load_paths
  self.builder_files_paths = default_builder_files_paths
  self.styles_paths = default_styles_paths
  self.queue_timeout = default_queue_timeout
  self.automatically_register_conventionally_named_views = default_automatically_register_conventionally_named_views
  self.gems = default_gems
  self.logger = {}
  self.application = {}
end

Public Instance Methods

environment_path() click to toggle source

The path to the current environment’s file (development.rb, etc.). By default the file is at config/environments/#{environment}.rb.

# File lib/rugui/configuration.rb, line 75
def environment_path
  root_path.join('config', 'environments', "#{environment}.rb")
end
gem(name, options = {}) click to toggle source

Adds a single Gem dependency to the RuGUI application. By default, it will require the library with the same name as the gem. Use :lib to specify a different name.

# gem 'aws-s3', '>= 0.4.0'
# require 'aws/s3'
config.gem 'aws-s3', :lib => 'aws/s3', :version => '>= 0.4.0', \
  :source => "http://code.whytheluckystiff.net"

To require a library be installed, but not attempt to load it, pass :lib => false

config.gem 'qrp', :version => '0.4.1', :lib => false
# File lib/rugui/configuration.rb, line 97
def gem(name, options = {})
  @gems << RuGUI::GemDependency.new(name, options)
end
set_root_path!() click to toggle source
# File lib/rugui/configuration.rb, line 79
def set_root_path!
  raise 'APPLICATION_ROOT is not set' unless defined?(::APPLICATION_ROOT)
  raise 'APPLICATION_ROOT is not a directory' unless File.directory?(::APPLICATION_ROOT)

  @root_path = Pathname.new(File.expand_path(::APPLICATION_ROOT))
end

Private Instance Methods

default_automatically_register_conventionally_named_views() click to toggle source
# File lib/rugui/configuration.rb, line 136
def default_automatically_register_conventionally_named_views
  true
end
default_builder_files_paths() click to toggle source
# File lib/rugui/configuration.rb, line 124
def default_builder_files_paths
  []
end
default_environment() click to toggle source
# File lib/rugui/configuration.rb, line 102
def default_environment
  ::RUGUI_ENV
end
default_framework_adapter() click to toggle source
# File lib/rugui/configuration.rb, line 106
def default_framework_adapter
  'GTK'
end
default_gems() click to toggle source
# File lib/rugui/configuration.rb, line 140
def default_gems
  []
end
default_load_paths() click to toggle source
# File lib/rugui/configuration.rb, line 110
def default_load_paths
  paths = []

  paths.concat %w(
    app
    app/models
    app/controllers
    app/views
    app/views/helpers
    config
    lib
  ).map { |dir| root_path.join(dir) }.select { |dir| File.directory?(dir) }
end
default_queue_timeout() click to toggle source
# File lib/rugui/configuration.rb, line 132
def default_queue_timeout
  50
end
default_styles_paths() click to toggle source
# File lib/rugui/configuration.rb, line 128
def default_styles_paths
  [root_path.join('app', 'resources', 'styles')]
end