Class: Vedeu::TestApplication

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/distributed/test_application.rb

Overview

Create a test application as a string.

Examples:

test_app = TestApplication.build do |app|
  app.borders       = ''
  app.configuration = ''
  app.events        = ''
  app.geometries    = ''
  app.interfaces    = ''
  app.keymaps       = ''
  app.menus         = ''
  app.views         = ''
end

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ TestApplication

Returns a new instance of Vedeu::TestApplication.

Parameters:

  • attributes (Hash<Symbol => String>) (defaults to: {})

Options Hash (attributes):

  • borders (String)
  • configuration (String)
  • events (String)
  • geometries (String)
  • interfaces (String)
  • keymaps (String)
  • menus (String)
  • views (String)


67
68
69
70
71
# File 'lib/vedeu/distributed/test_application.rb', line 67

def initialize(attributes = {})
  @attributes = defaults.merge!(attributes)

  @attributes.each { |k, _| instance_variable_set("@#{k}", @attributes[k]) }
end

Instance Attribute Details

#bordersString

Returns:

  • (String)


20
21
22
# File 'lib/vedeu/distributed/test_application.rb', line 20

def borders
  @borders
end

#configurationString

Returns:

  • (String)


24
25
26
# File 'lib/vedeu/distributed/test_application.rb', line 24

def configuration
  @configuration
end

#eventsString

Returns:

  • (String)


28
29
30
# File 'lib/vedeu/distributed/test_application.rb', line 28

def events
  @events
end

#geometriesString

Returns:

  • (String)


32
33
34
# File 'lib/vedeu/distributed/test_application.rb', line 32

def geometries
  @geometries
end

#interfacesString

Returns:

  • (String)


36
37
38
# File 'lib/vedeu/distributed/test_application.rb', line 36

def interfaces
  @interfaces
end

#keymapsString

Returns:

  • (String)


40
41
42
# File 'lib/vedeu/distributed/test_application.rb', line 40

def keymaps
  @keymaps
end

Returns:

  • (String)


44
45
46
# File 'lib/vedeu/distributed/test_application.rb', line 44

def menus
  @menus
end

#viewsString

Returns:

  • (String)


48
49
50
# File 'lib/vedeu/distributed/test_application.rb', line 48

def views
  @views
end

Class Method Details

.build(attributes = {}, &block) ⇒ Object

Parameters:

  • attributes (Hash<Symbol => String>) (defaults to: {})


51
52
53
# File 'lib/vedeu/distributed/test_application.rb', line 51

def self.build(attributes = {}, &block)
  new(attributes).build(&block)
end

Instance Method Details

#build(&block) ⇒ String

Parameters:

  • block (Proc)

Returns:

  • (String)


75
76
77
78
79
# File 'lib/vedeu/distributed/test_application.rb', line 75

def build(&block)
  instance_eval(&block) if block_given?

  Vedeu::Template.parse(self, template)
end

#defaultsHash (private)

TODO:

Don’t like all this file reading.

Returns:

  • (Hash)


96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/vedeu/distributed/test_application.rb', line 96

def defaults
  {
    borders:       read('default_borders.vedeu'),
    configuration: read('default_configuration.vedeu'),
    events:        read('default_events.vedeu'),
    geometries:    read('default_geometries.vedeu'),
    interfaces:    read('default_interfaces.vedeu'),
    keymaps:       read('default_keymaps.vedeu'),
    menus:         read('default_menus.vedeu'),
    views:         read('default_views.vedeu'),
  }
end

#lib_dirString

Returns:

  • (String)


82
83
84
# File 'lib/vedeu/distributed/test_application.rb', line 82

def lib_dir
  File.dirname(__FILE__) + '/../../../lib'
end

#read(filename) ⇒ String (private)

Returns:

  • (String)


110
111
112
# File 'lib/vedeu/distributed/test_application.rb', line 110

def read(filename)
  File.read(File.dirname(__FILE__) + '/templates/' + filename)
end

#templateString (private)

Returns:

  • (String)


89
90
91
# File 'lib/vedeu/distributed/test_application.rb', line 89

def template
  File.dirname(__FILE__) + '/templates/default_application.vedeu'
end