Class: Actir::Initializer
- Inherits:
-
Object
- Object
- Actir::Initializer
- Defined in:
- lib/actir/initializer.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
config content.
Instance Method Summary collapse
-
#initialize(project_path) ⇒ Initializer
constructor
A new instance of Initializer.
- #load_components ⇒ Object
- #load_config ⇒ Object
- #load_dmm ⇒ Object
- #load_elements ⇒ Object
- #load_item ⇒ Object
- #load_pages ⇒ Object
- #load_user ⇒ Object
Constructor Details
#initialize(project_path) ⇒ Initializer
Returns a new instance of Initializer.
9 10 11 12 13 14 |
# File 'lib/actir/initializer.rb', line 9 def initialize project_path $project_path ||= project_path $:.unshift($project_path) $config = load_config load_elements end |
Instance Attribute Details
#config ⇒ Object
config content
7 8 9 |
# File 'lib/actir/initializer.rb', line 7 def config @config end |
Instance Method Details
#load_components ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/actir/initializer.rb', line 65 def load_components @components_path = File.join(@elements_path, 'components') @list = Dir.glob(File.join @components_path, '**', '*.rb').select {|p| p =~ /\.rb$/}.sort @list.each do |c| puts c if $debug require "#{c}" end #each end |
#load_config ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/actir/initializer.rb', line 34 def load_config @config_path = File.join($project_path, 'config') @config = {} Dir.glob(File.join @config_path, '**', '*.yaml').select{ |c| c =~ /\.yaml$/ }.each do |config| puts "#{config}" if $debug #获取配置文件名字 config =~ /config\/(.*)\.yaml/ config_name = $1 @config.store(config_name, Actir::Config.get_content(config)) end @config end |
#load_dmm ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/actir/initializer.rb', line 25 def load_dmm @dmm_path = File.join(@elements_path, 'dmm') @list = Dir.glob(File.join @dmm_path, '**', '*.rb').select {|p| p =~ /\.rb$/}.sort @list.each do |d| puts d if $debug require "#{d}" end #each end |
#load_elements ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/actir/initializer.rb', line 16 def load_elements @elements_path = File.join($project_path, 'elements') load_item load_components load_user load_pages load_dmm end |
#load_item ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/actir/initializer.rb', line 47 def load_item @item_path = File.join(@elements_path, 'item') @list = Dir.glob(File.join @item_path, '**', '*.rb').select {|p| p =~ /\.rb$/}.sort @list.each do |i| puts i if $debug require "#{i}" end #each end |
#load_pages ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/actir/initializer.rb', line 74 def load_pages @pages_path = File.join(@elements_path, 'pages') @list = Dir.glob(File.join @pages_path, '**', '*.rb').select { |p| p =~ /\.rb$/ }.sort @list.each do |page| puts "#{page}"if $debug require "#{page}" end #each end |
#load_user ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/actir/initializer.rb', line 56 def load_user @user_path = File.join(@elements_path, 'user') @list = Dir.glob(File.join @user_path, '**', '*.rb').select {|p| p =~ /\.rb$/}.sort @list.each do |u| puts u if $debug require "#{u}" end #each end |