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_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
53 54 55 56 57 58 59 |
# File 'lib/actir/initializer.rb', line 53 def load_components @components_path = File.join(@elements_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_config ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/actir/initializer.rb', line 24 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_elements ⇒ Object
16 17 18 19 20 21 22 |
# 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 end |
#load_item ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/actir/initializer.rb', line 37 def load_item @item_path = File.join(@elements_path, 'item') Dir.glob(File.join @item_path, '**', '*.rb').select {|p| p =~ /\.rb$/}.each do |i| puts i if $debug require "#{i}" end #each end |
#load_pages ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/actir/initializer.rb', line 61 def load_pages @pages_path = File.join(@elements_path, 'pages') Dir.glob(File.join @pages_path, '**', '*.rb').select { |p| p =~ /\.rb$/ }.each do |page| puts "#{page}"if $debug require "#{page}" end #each end |
#load_user ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/actir/initializer.rb', line 45 def load_user @user_path = File.join(@elements_path, 'user') Dir.glob(File.join @user_path, '**', '*.rb').select {|p| p =~ /\.rb$/}.each do |u| puts u if $debug require "#{u}" end #each end |