Module: BangBang::ServiceConfig::ClassMethods
- Includes:
- EnvMethods
- Defined in:
- lib/bang-bang/service_config.rb
Instance Attribute Summary collapse
-
#app_config ⇒ Object
Returns the value of attribute app_config.
- #named_routes ⇒ Object (also: #uris)
-
#root_dir ⇒ Object
Returns the value of attribute root_dir.
- #views_class ⇒ Object
Instance Method Summary collapse
- #init(params = {}) ⇒ Object
- #lib_dir ⇒ Object
- #plugins ⇒ Object
- #register_controller(controller) ⇒ Object
- #register_service(path, &block) ⇒ Object
- #remove_generated_files ⇒ Object
- #service_dirs ⇒ Object
- #service_subdirectory_dirs(relative_directory) ⇒ Object
- #services ⇒ Object
- #services_by_root_dir ⇒ Object
- #services_by_url_prefix ⇒ Object
- #services_dir ⇒ Object
- #stylesheets_dirs ⇒ Object
- #vendor_dir ⇒ Object
Methods included from EnvMethods
Instance Attribute Details
#app_config ⇒ Object
Returns the value of attribute app_config.
6 7 8 |
# File 'lib/bang-bang/service_config.rb', line 6 def app_config @app_config end |
#named_routes ⇒ Object Also known as: uris
20 21 22 |
# File 'lib/bang-bang/service_config.rb', line 20 def named_routes @named_routes || (app_config && app_config.named_routes) || nil end |
#root_dir ⇒ Object
Returns the value of attribute root_dir.
6 7 8 |
# File 'lib/bang-bang/service_config.rb', line 6 def root_dir @root_dir end |
#views_class ⇒ Object
26 27 28 |
# File 'lib/bang-bang/service_config.rb', line 26 def views_class @views_class || (app_config && app_config.views_class) || nil end |
Instance Method Details
#init(params = {}) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/bang-bang/service_config.rb', line 11 def init(params={}) self.app_config = params[:app_config] self.root_dir = params[:root_dir] self.named_routes = params[:named_routes] self.views_class = params[:views_class] plugins.init end |
#lib_dir ⇒ Object
69 70 71 |
# File 'lib/bang-bang/service_config.rb', line 69 def lib_dir File.join(root_dir, "lib") end |
#plugins ⇒ Object
65 66 67 |
# File 'lib/bang-bang/service_config.rb', line 65 def plugins @plugins ||= ::BangBang::Plugins::Set.new(self) end |
#register_controller(controller) ⇒ Object
30 31 32 |
# File 'lib/bang-bang/service_config.rb', line 30 def register_controller(controller) controller.config = self end |
#register_service(path, &block) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/bang-bang/service_config.rb', line 34 def register_service(path, &block) unless service_dirs.include?(path) service = Service.new(self, path) services << service service.init(&block) end end |
#remove_generated_files ⇒ Object
92 93 94 95 96 97 |
# File 'lib/bang-bang/service_config.rb', line 92 def remove_generated_files Dir["#{root_dir}/**/public/**/*.generated"].each do |generated_path| FileUtils.rm_f(File.join(File.dirname(generated_path), File.basename(generated_path, ".generated"))) FileUtils.rm_f(generated_path) end end |
#service_dirs ⇒ Object
42 43 44 45 46 |
# File 'lib/bang-bang/service_config.rb', line 42 def service_dirs services.map do |service| service.root_dir end end |
#service_subdirectory_dirs(relative_directory) ⇒ Object
85 86 87 88 89 90 |
# File 'lib/bang-bang/service_config.rb', line 85 def service_subdirectory_dirs(relative_directory) service_dirs.flatten.map do |service_path| full_path = File.join(service_path, relative_directory) full_path if File.directory?(full_path) end.compact end |
#services ⇒ Object
48 49 50 |
# File 'lib/bang-bang/service_config.rb', line 48 def services @services ||= [] end |
#services_by_root_dir ⇒ Object
58 59 60 61 62 63 |
# File 'lib/bang-bang/service_config.rb', line 58 def services_by_root_dir services.inject({}) do |memo, service| memo[service.root_dir] = service memo end end |
#services_by_url_prefix ⇒ Object
52 53 54 55 56 |
# File 'lib/bang-bang/service_config.rb', line 52 def services_by_url_prefix services.group_by do |service| service.url_prefix end end |
#services_dir ⇒ Object
81 82 83 |
# File 'lib/bang-bang/service_config.rb', line 81 def services_dir File.join(root_dir, "services") end |
#stylesheets_dirs ⇒ Object
73 74 75 |
# File 'lib/bang-bang/service_config.rb', line 73 def stylesheets_dirs service_subdirectory_dirs "app/stylesheets" end |
#vendor_dir ⇒ Object
77 78 79 |
# File 'lib/bang-bang/service_config.rb', line 77 def vendor_dir File.join(root_dir, "vendor") end |