Class: Module
- Inherits:
-
Object
- Object
- Module
- Defined in:
- lib/terraspace/ext/core/module.rb
Instance Method Summary collapse
-
#include_dir(dir) ⇒ Object
Include all modules within the relative folder.
- #include_plugin_helpers ⇒ Object
- #include_project_level_helpers ⇒ Object
Instance Method Details
#include_dir(dir) ⇒ Object
Include all modules within the relative folder. IE: for dsl/syntax/mod/*
include Common
include Provider
# etc
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/terraspace/ext/core/module.rb', line 8 def include_dir(dir) calling_file = caller[0].split(':').first # IE: /home/ec2-user/environment/terraspace/lib/terraspace/compiler/dsl/syntax/mod.rb parent_dir = File.dirname(calling_file) full_dir = "#{parent_dir}/#{dir}" Dir.glob("#{full_dir}/**/*").each do |path| regexp = Regexp.new(".*/lib/") klass = path.sub(regexp, '').sub('.rb','').camelize include klass.constantize end end |
#include_plugin_helpers ⇒ Object
30 31 32 33 34 |
# File 'lib/terraspace/ext/core/module.rb', line 30 def include_plugin_helpers Terraspace::Plugin.helper_classes.each do |klass| include klass # IE: TerraspacePluginAws::Interfaces::Helper end end |
#include_project_level_helpers ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/terraspace/ext/core/module.rb', line 20 def include_project_level_helpers full_dir = "#{Terraspace.root}/config/helpers" Dir.glob("#{full_dir}/**/*").each do |path| regexp = Regexp.new(".*/config/helpers/") klass = path.sub(regexp, '').sub('.rb','').camelize klass = "Terraspace::Project::#{klass}" include klass.constantize end end |