Module: Diecut

Defined in:
lib/diecut.rb,
lib/diecut/cli.rb,
lib/diecut/mill.rb,
lib/diecut/errors.rb,
lib/diecut/linter.rb,
lib/diecut/report.rb,
lib/diecut/mediator.rb,
lib/diecut/mustache.rb,
lib/diecut/template.rb,
lib/diecut/ui-config.rb,
lib/diecut/ui-applier.rb,
lib/diecut/configurable.rb,
lib/diecut/template-set.rb,
lib/diecut/plugin-loader.rb,
lib/diecut/context-handler.rb,
lib/diecut/template-reducer.rb,
lib/diecut/plugin-description.rb,
lib/diecut/caller-locations-polyfill.rb,
lib/diecut/plugin-description/option.rb,
lib/diecut/plugin-description/context-default.rb

Defined Under Namespace

Modules: CallerLocationsPolyfill Classes: CommandLine, Configurable, ContextHandler, Error, InvalidConfig, KindCli, Linter, Mediator, Mill, Mustache, OverriddenDefault, PluginDescription, PluginLoader, Report, ReportFormatter, Template, TemplateReducer, TemplateSet, UIApplier, UIConfig, UnusedDefault

Class Method Summary collapse

Class Method Details

.clear_pluginsObject



15
16
17
# File 'lib/diecut.rb', line 15

def clear_plugins
  @plugin_loader = nil
end

.kindsObject



39
40
41
42
43
# File 'lib/diecut.rb', line 39

def kinds
  plugins.reduce([]) do |list, plugin|
    list + plugin.kinds
  end.uniq
end

.load_plugins(prerelease = false) ⇒ Object



19
20
21
# File 'lib/diecut.rb', line 19

def load_plugins(prerelease = false)
  plugin_loader.load_plugins(prerelease)
end

.mediator(kind) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/diecut.rb', line 45

def mediator(kind)
  Mediator.new.tap do |med|
    plugins.each do |plug|
      next unless plug.has_kind?(kind)
      med.add_plugin(plug)
    end
  end
end

.plugin(name) {|description| ... } ⇒ Object

Used in a ‘diecut_plugin.rb` file (either in the `lib/` of a gem, or at the local `~/.config/diecut/diecut_plugin.rb` to register a new plugin.

Parameters:

  • name (String, Symbol)

    Names the plugin so that it can be toggled later

Yield Parameters:

  • description (PluginDescription)

    The description object to configure the plugin with.



35
36
37
# File 'lib/diecut.rb', line 35

def plugin(name, &block)
  plugin_loader.describe_plugin(name, &block)
end

.plugin_loaderObject



7
8
9
# File 'lib/diecut.rb', line 7

def plugin_loader
  @plugin_loader ||= PluginLoader.new
end

.plugin_loader=(loader) ⇒ Object



11
12
13
# File 'lib/diecut.rb', line 11

def plugin_loader=(loader)
  @plugin_loader = loader
end

.pluginsObject



23
24
25
# File 'lib/diecut.rb', line 23

def plugins
  plugin_loader.plugins
end