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
- .path_for(app_name) ⇒ Object
- .search_paths ⇒ Object
Class Method Details
.app_paths ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/brief/apps.rb', line 18 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
26 27 28 |
# File 'lib/brief/apps.rb', line 26 def self.available?(app_name) available_apps.include?(app_name.to_s) end |
.available_apps ⇒ Object
34 35 36 |
# File 'lib/brief/apps.rb', line 34 def self.available_apps app_paths.map(&:basename).map(&:to_s) end |
.create_namespaces ⇒ Object
38 39 40 41 42 |
# File 'lib/brief/apps.rb', line 38 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.gem_root.join("..","apps") end |
.find_namespace(app_name) ⇒ Object
44 45 46 |
# File 'lib/brief/apps.rb', line 44 def self.find_namespace(app_name) Brief::Apps.const_get(app_name.to_s.camelize) end |
.path_for(app_name) ⇒ Object
30 31 32 |
# File 'lib/brief/apps.rb', line 30 def self.path_for(app_name) app_paths.detect {|b| b.basename.to_s == app_name } end |
.search_paths ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/brief/apps.rb', line 7 def self.search_paths paths = [default_path] 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 |