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/cli/01_extensions.rb,
lib/brief/model/persistence.rb,
lib/brief/document/rendering.rb,
lib/brief/document/structure.rb,
lib/brief/document/front_matter.rb,
lib/brief/document/content_extractor.rb

Defined Under Namespace

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

Constant Summary collapse

VERSION =
'1.8.10'

Class Method Summary collapse

Class Method Details

.activate_adapter(identifier) ⇒ Object

Adapters for Rails, Middleman, or Jekyll apps



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

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



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

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

.caseObject



29
30
31
# File 'lib/brief.rb', line 29

def self.case
  @briefcase
end

.case=(value) ⇒ Object



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

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

.casesObject



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

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

.cli_action(c, &block) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'lib/brief/cli/01_extensions.rb', line 2

def self.cli_action(c, &block)
  c.action do |args, options|
    options.default(root: Brief.pwd)

    Brief.case = Brief::Briefcase.new(root: Pathname(options.root))

    block.call(args, options)
  end
end

.configurationObject



37
38
39
# File 'lib/brief.rb', line 37

def self.configuration
  Brief::Configuration.instance
end

.default_cli_options(c) ⇒ Object



12
13
14
15
# File 'lib/brief/cli/01_extensions.rb', line 12

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'
end

.default_model_classObject



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

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



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

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

.load_commandsObject



49
50
51
52
53
54
55
56
57
58
# File 'lib/brief.rb', line 49

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



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

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



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

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

.viewsObject



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

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