Class: Brief::Apps
- Inherits:
-
Object
- Object
- Brief::Apps
- Defined in:
- lib/brief/apps.rb
Class Method Summary collapse
- .app_paths ⇒ Object
- .available?(app_name) ⇒ Boolean
- .available_apps ⇒ Object
- .create_namespaces ⇒ Object
- .default_path ⇒ Object
- .find_namespace(app_name) ⇒ Object
- .home_apps_path ⇒ Object
- .path_for(app_name) ⇒ Object
- .search_paths ⇒ Object
Class Method Details
.app_paths ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/brief/apps.rb', line 24 def self.app_paths search_paths.map do |base| base.children.select do |child| child.join("config.rb").exist? end end.flatten end |
.available?(app_name) ⇒ Boolean
32 33 34 |
# File 'lib/brief/apps.rb', line 32 def self.available?(app_name) available_apps.include?(app_name.to_s) end |
.available_apps ⇒ Object
40 41 42 |
# File 'lib/brief/apps.rb', line 40 def self.available_apps app_paths.map(&:basename).map(&:to_s) end |
.create_namespaces ⇒ Object
44 45 46 47 48 |
# File 'lib/brief/apps.rb', line 44 def self.create_namespaces available_apps.map(&:camelize).each do |namespace| const_set(namespace, Module.new) end end |
.default_path ⇒ Object
3 4 5 |
# File 'lib/brief/apps.rb', line 3 def self.default_path Brief.lib_root.join("..","apps") end |
.find_namespace(app_name) ⇒ Object
50 51 52 |
# File 'lib/brief/apps.rb', line 50 def self.find_namespace(app_name) Brief::Apps.const_get(app_name.to_s.camelize) end |
.home_apps_path ⇒ Object
7 8 9 |
# File 'lib/brief/apps.rb', line 7 def self.home_apps_path Brief.home.join("apps") end |
.path_for(app_name) ⇒ Object
36 37 38 |
# File 'lib/brief/apps.rb', line 36 def self.path_for(app_name) app_paths.detect {|b| b.basename.to_s == app_name } end |
.search_paths ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/brief/apps.rb', line 11 def self.search_paths paths = [default_path] paths << home_apps_path if home_apps_path.exist? if custom_path = ENV['BRIEF_APPS_PATH'] custom_path = custom_path.to_s.to_pathname paths << custom_path if (custom_path.exist? rescue nil) end paths end |