Class: YMDP::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ymdp/base.rb

Overview

Defines the global configuration options for all YMDP classes. This is the class that knows about local settings such as server names, server application_ids, and configuration options such as when compression or validation is required on a view.

Configuration

Set configuration options as a block with the configure command.

YMDP::Base.configure do |config|
  config.username = "malreynolds"
  config.password = "firefly2591"
  config.default_server = "staging"
  config.host = "host"
  config.production_server = "www"
  config.growl = true
  config.verbose = false
  config.compress = @compress
  config.validate = @validate

  config.add_path(:base_path, @base_path)
  config.servers = @servers

  config.load_content_variables('content')
end

These options are still evolving.

Direct Known Subclasses

Compiler::Domains, Compiler::Template::Base

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.base_pathObject



67
68
69
# File 'lib/ymdp/base.rb', line 67

def self.base_path
  configuration.paths[:base_path]
end

.configurationObject



34
35
36
# File 'lib/ymdp/base.rb', line 34

def self.configuration
  @@configuration ||= YMDP::Configuration::Setter.new
end

.configure {|configuration| ... } ⇒ Object

Configures global YMDP settings. Sends a YMDP::Configuration::Setter instance to the block, which is used to define global settings.

Yields:



49
50
51
# File 'lib/ymdp/base.rb', line 49

def self.configure
  yield configuration
end

.display_path(path) ⇒ Object

Parses out the base_path setting from a path to display it in a less verbose way.



78
79
80
81
# File 'lib/ymdp/base.rb', line 78

def self.display_path(path)
  path = File.expand_path(path)
  path.gsub(base_path.to_s, "")
end

Instance Method Details

#base_pathObject



71
72
73
# File 'lib/ymdp/base.rb', line 71

def base_path
  self.class.base_path
end

#configurationObject



42
43
44
# File 'lib/ymdp/base.rb', line 42

def configuration
  @@configuration
end

#content_variablesObject



38
39
40
# File 'lib/ymdp/base.rb', line 38

def content_variables
  configuration.content_variables
end

#display_path(path) ⇒ Object



83
84
85
# File 'lib/ymdp/base.rb', line 83

def display_path(path)
  self.class.display_path(path)
end

#pathsObject

Returns the paths definition hash as an instance variable, making it available to instances of any class derived from YMDP::Base.



63
64
65
# File 'lib/ymdp/base.rb', line 63

def paths
  configuration.paths
end

#serversObject

Returns the server definition hash as an instance variable, making it available to instances of any class derived from YMDP::Base.



56
57
58
# File 'lib/ymdp/base.rb', line 56

def servers
  configuration.servers
end