Class: Brief::Apps

Inherits:
Object
  • Object
show all
Defined in:
lib/brief/apps.rb

Class Method Summary collapse

Class Method Details

.app_pathsObject



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

Returns:

  • (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_appsObject



34
35
36
# File 'lib/brief/apps.rb', line 34

def self.available_apps
  app_paths.map(&:basename).map(&:to_s)
end

.create_namespacesObject



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_pathObject



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_pathsObject



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