Class: Brief::Apps

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

Class Method Summary collapse

Class Method Details

.app_pathsObject



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

Returns:

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



40
41
42
# File 'lib/brief/apps.rb', line 40

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

.create_namespacesObject



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_pathObject



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_pathObject



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_pathsObject



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