Class: LanGrove::FakeConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/langrove/ext/fake_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFakeConfig

Returns a new instance of FakeConfig.



17
18
19
20
21
# File 'lib/langrove/ext/fake_config.rb', line 17

def initialize

  flush

end

Instance Attribute Details

#applicationObject

Returns the value of attribute application.



11
12
13
# File 'lib/langrove/ext/fake_config.rb', line 11

def application
  @application
end

#daemonsObject

Returns the value of attribute daemons.



15
16
17
# File 'lib/langrove/ext/fake_config.rb', line 15

def daemons
  @daemons
end

#pluginsObject

Returns the value of attribute plugins.



13
14
15
# File 'lib/langrove/ext/fake_config.rb', line 13

def plugins
  @plugins
end

#systemObject

for easy spec setup



9
10
11
# File 'lib/langrove/ext/fake_config.rb', line 9

def system
  @system
end

Instance Method Details

#[](key) ⇒ Object



32
33
34
35
36
# File 'lib/langrove/ext/fake_config.rb', line 32

def []( key )

  return self.send( key )

end

#create(daemon_name, module_name, module_class, module_config = {}) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/langrove/ext/fake_config.rb', line 75

def create( daemon_name, module_name, module_class, module_config = {} )

  init_daemon_config( daemon_name )

  @daemons[daemon_name][module_name] = {

    :class => module_class

  }

  @daemons[daemon_name][module_name].merge!( module_config )
  

end

#create_behaviour(daemon, behaviour, plugin, trigger = :handler_after_receive, action = nil) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/langrove/ext/fake_config.rb', line 53

def create_behaviour( daemon, behaviour, plugin, trigger = :handler_after_receive, action = nil )

  init_daemon_config( daemon )

  @daemons[daemon][:server][:behaviours] = {} if 
    @daemons[daemon][:server][:behaviours].nil?

  behaviours = @daemons[daemon][:server][:behaviours]

  behaviours[behaviour] = {} if 
    behaviours[behaviour].nil?

  this = behaviours[behaviour]

  this[:plugin] = plugin

  this[:at] = { 
    trigger => action
  }

end

#flushObject



23
24
25
26
27
28
29
30
# File 'lib/langrove/ext/fake_config.rb', line 23

def flush

  @system = 'system'
  @application = 'application'
  @plugins = {}
  @daemons = {}

end

#get_plugin(name) ⇒ Object



96
97
98
99
100
101
# File 'lib/langrove/ext/fake_config.rb', line 96

def get_plugin( name )

  config = LanGrove::Config::Base.new( ROOT, hash, LOG )
  config.get_plugin( name )

end

#get_plugin_config(name) ⇒ Object



90
91
92
93
94
# File 'lib/langrove/ext/fake_config.rb', line 90

def get_plugin_config( name )

  @plugins[ name ]

end

#hashObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/langrove/ext/fake_config.rb', line 38

def hash

  config = {

    :system => 'system',
    :application => 'application',
    :plugins => @plugins,
    :daemons => @daemons

  }

  return config

end