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/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/front_matter.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.6'

Class Method Summary collapse

Class Method Details

.activate_adapter(identifier) ⇒ Object

Adapters for Rails, Middleman, or Jekyll apps



85
86
87
88
89
90
# File 'lib/brief.rb', line 85

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



54
55
56
# File 'lib/brief.rb', line 54

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



46
47
48
# File 'lib/brief.rb', line 46

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



69
70
71
72
73
74
75
# File 'lib/brief.rb', line 69

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

.lib_rootObject



50
51
52
# File 'lib/brief.rb', line 50

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

.load_commandsObject



58
59
60
61
62
63
64
65
66
67
# File 'lib/brief.rb', line 58

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

  # the instance methods which get defined with the helper
  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



77
78
79
80
81
82
# File 'lib/brief.rb', line 77

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