Class: Lazyman::Initializer

Inherits:
Object
  • Object
show all
Defined in:
lib/lazyman/lazy_initializer.rb

Instance Method Summary collapse

Constructor Details

#initialize(root, app_name) ⇒ Initializer

Returns a new instance of Initializer.



3
4
5
6
7
8
9
10
11
# File 'lib/lazyman/lazy_initializer.rb', line 3

def initialize root, app_name
	@root ||= root
	@app_name ||= app_name
	load_config
	load_app_page_and_navigator
	load_all_components
	load_all_pages
	generate_pathes
end

Instance Method Details

#generate_pathesObject



41
42
43
44
45
# File 'lib/lazyman/lazy_initializer.rb', line 41

def generate_pathes
	$root = @root
	$pages = @pages_path
	$components = @components_path
end

#load_all_componentsObject



20
21
22
23
24
25
26
# File 'lib/lazyman/lazy_initializer.rb', line 20

def load_all_components
	@components_path = File.join(@pages_path, 'components')
	Dir.glob(File.join @components_path, '**', '*.rb').select {|p| p =~ /\.rb$/}.each do |c|
		puts c if $debug
		require "#{c}" 
	end #each
end

#load_all_pagesObject



28
29
30
31
32
33
# File 'lib/lazyman/lazy_initializer.rb', line 28

def load_all_pages
	Dir.glob(File.join @pages_path, '**', '*.rb').select { |p| p =~ /page\.rb$/ }.each do |page|
		puts "#{page}" if $debug
		require "#{page}"
	end #each
end

#load_app_page_and_navigatorObject



13
14
15
16
17
18
# File 'lib/lazyman/lazy_initializer.rb', line 13

def load_app_page_and_navigator
	@pages_path = File.join(@root, 'app', 'pages')
	$:.unshift(@pages_path)
	require File.join(@pages_path, "#{@app_name}_page")
	require File.join(@pages_path, "#{@app_name}_navigator")
end

#load_configObject



35
36
37
38
39
# File 'lib/lazyman/lazy_initializer.rb', line 35

def load_config
	# hard code config file name here
	@config_file = File.join @root, 'config', 'config.yml'
	$config = Config.new(@config_file).content  
end