Class: RuGUI::Configuration

Inherits:
Object show all
Defined in:
lib/rugui/configuration.rb

Overview

Defines configurations for a RuGUI application.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# 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

Instance Attribute Details

#applicationObject

A hash of application specific configurations.



48
49
50
# File 'lib/rugui/configuration.rb', line 48

def application
  @application
end

#automatically_register_conventionally_named_viewsObject

Automatically register conventionally named views. Defaults to true.



45
46
47
# File 'lib/rugui/configuration.rb', line 45

def automatically_register_conventionally_named_views
  @automatically_register_conventionally_named_views
end

#builder_files_pathsObject

An array of paths for builder files.



24
25
26
# File 'lib/rugui/configuration.rb', line 24

def builder_files_paths
  @builder_files_paths
end

#environmentObject

The environment for this application.



11
12
13
# File 'lib/rugui/configuration.rb', line 11

def environment
  @environment
end

#framework_adapterObject

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



15
16
17
# File 'lib/rugui/configuration.rb', line 15

def framework_adapter
  @framework_adapter
end

#gemsObject

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.



56
57
58
# File 'lib/rugui/configuration.rb', line 56

def gems
  @gems
end

#load_pathsObject

An array of paths which should be automaticaly loaded.



27
28
29
# File 'lib/rugui/configuration.rb', line 27

def load_paths
  @load_paths
end

#loggerObject

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.



21
22
23
# File 'lib/rugui/configuration.rb', line 21

def logger
  @logger
end

#queue_timeoutObject

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



42
43
44
# File 'lib/rugui/configuration.rb', line 42

def queue_timeout
  @queue_timeout
end

#root_pathObject (readonly)

The application root path, defined by ::APPLICATION_ROOT



8
9
10
# File 'lib/rugui/configuration.rb', line 8

def root_path
  @root_path
end

#styles_pathsObject

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.



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

def styles_paths
  @styles_paths
end

Instance Method Details

#environment_pathObject

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



75
76
77
# File 'lib/rugui/configuration.rb', line 75

def environment_path
  root_path.join('config', 'environments', "#{environment}.rb")
end

#gem(name, options = {}) ⇒ Object

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


97
98
99
# File 'lib/rugui/configuration.rb', line 97

def gem(name, options = {})
  @gems << RuGUI::GemDependency.new(name, options)
end

#set_root_path!Object



79
80
81
82
83
84
# 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