Module: Brief

Defined in:
lib/brief.rb,
lib/brief/dsl.rb,
lib/brief/apps.rb,
lib/brief/data.rb,
lib/brief/model.rb,
lib/brief/version.rb,
lib/brief/document.rb,
lib/brief/briefcase.rb,
lib/brief/repository.rb,
lib/brief/configuration.rb,
lib/brief/server/socket.rb,
lib/brief/model/definition.rb,
lib/brief/model/persistence.rb,
lib/brief/document/rendering.rb,
lib/brief/document/structure.rb,
lib/brief/document/attachments.rb,
lib/brief/document/transformer.rb,
lib/brief/document/front_matter.rb,
lib/brief/briefcase/documentation.rb,
lib/brief/document/content_extractor.rb,
lib/brief/cli/01_extensions.rb

Defined Under Namespace

Modules: Adapters, DSL, Data, DocumentMapper, Model, Util Classes: Apps, Briefcase, Configuration, Document, Repository, Server

Constant Summary collapse

VERSION =
'1.9.13'

Class Method Summary collapse

Class Method Details

.activate_adapter(identifier) ⇒ Object

Adapters for Rails, Middleman, or Jekyll apps



98
99
100
101
102
103
# File 'lib/brief.rb', line 98

def self.activate_adapter(identifier)
  require "brief/adapters/#{ identifier }"
  (Brief::Adapters.const_get(identifier.camelize) rescue nil).tap do |adapter|
    raise "Invalid adapter: #{ identifier }" unless adapter
  end
end

.apps_pathObject



65
66
67
# File 'lib/brief.rb', line 65

def self.apps_path
  lib_root.join("..","apps")
end

.case(fire = false) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/brief.rb', line 32

def self.case(fire=false)
  if @briefcase.is_a?(Brief::Briefcase)
    @briefcase
  elsif fire && @briefcase.respond_to?(:call)
    @briefcase = @briefcase.call()
  else
    @briefcase
  end
end

.case=(value) ⇒ Object



26
27
28
# File 'lib/brief.rb', line 26

def self.case=(value)
  @briefcase = value
end

.casesObject



22
23
24
# File 'lib/brief.rb', line 22

def self.cases
  @cases ||= {}
end

.configurationObject



57
58
59
# File 'lib/brief.rb', line 57

def self.configuration
  Brief::Configuration.instance
end

.default_cli_options(c) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/brief/cli/01_extensions.rb', line 34

def self.default_cli_options(c)
  c.option '--root DIRECTORY', String, 'The root for the briefcase'
  c.option '--config FILE', String, 'Path to the config file for this briefcase'
  c.option '--config-filename', String, 'The default filename for a briefcase config: brief.rb'
  c.option '--output FILE', String, 'Save the output in the specified path'
  c.option '--format FORMAT', String, 'How to format the CLI output: defaults to printed, accepts printed,json'
  c.option '--prefix-output CONTENT', String, 'Prefix the generated output with the following content'
end

.default_model_classObject



82
83
84
85
86
87
88
# File 'lib/brief.rb', line 82

def self.default_model_class
  if defined?(Brief::DefaultModel)
    Brief::DefaultModel
  else
    Brief.const_set(:DefaultModel, Class.new { include Brief::Model; def self.type_alias; "default"; end })
  end
end

.environment_infoObject



46
47
48
49
50
51
52
53
54
55
# File 'lib/brief.rb', line 46

def self.environment_info
  {
    VERSION: Brief::VERSION,
    lib_root: Brief.lib_root.to_s,
    apps: {
      search_paths: Brief::Apps.search_paths.map(&:to_s),
      available: Brief::Apps.available_apps
    }
  }
end

.lib_rootObject



61
62
63
# File 'lib/brief.rb', line 61

def self.lib_root
  Pathname(File.dirname(__FILE__))
end

.load_commandsObject



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/brief.rb', line 69

def self.load_commands
  Dir[lib_root.join('brief', 'cli', '**/*.rb')].each { |f| require(f) }

  # Each Brief::Model can define certain "actions" which can be called on the documents.
  #
  # The Brief CLI interface lets users dispatch these actions to the documents specified by the PATH args.
  Brief::Model.classes.each do |klass|
    Array(klass.defined_actions).uniq.each do |action|
      Brief::Util.create_method_dispatcher_command_for(action, klass)
    end
  end
end

.load_modules_from(folder) ⇒ Object



90
91
92
93
94
95
# File 'lib/brief.rb', line 90

def self.load_modules_from(folder)
  Dir[folder.join('**/*.rb')].each do |f|
    #puts "Loading model from #{ f }"
    require(f)
  end
end

.pwdObject

When packaging this up through the traveling ruby system Dir.pwd is not accurate because of the wrapper. We shim it by setting a special ENV variable in that file



18
19
20
# File 'lib/brief.rb', line 18

def self.pwd
  ENV.fetch('BRIEF_PWD') { Dir.pwd }
end

.viewsObject



42
43
44
# File 'lib/brief.rb', line 42

def self.views
  @views ||= {}
end