Module: NanDoc::Config

Extended by:
Config
Included in:
Config
Defined in:
lib/nandoc/core/config.rb

Defined Under Namespace

Modules: Accessors

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#orphan_surrogate_filenameObject

Returns the value of attribute orphan_surrogate_filename.



70
71
72
# File 'lib/nandoc/core/config.rb', line 70

def orphan_surrogate_filename
  @orphan_surrogate_filename
end

#proto_pathObject

Returns the value of attribute proto_path.



78
79
80
# File 'lib/nandoc/core/config.rb', line 78

def proto_path
  @proto_path
end

Instance Method Details

#colorize?Boolean

TODO:

in the future make this smarter. i don’t like now nanoc handles color

Whether to output cli output in color. Without color probably doesn’t work (a command line argument?) There should be an autodetect, and/or set last setting in sticky json file; or however it is it is done.

Returns:

  • (Boolean)


14
15
16
# File 'lib/nandoc/core/config.rb', line 14

def colorize?
  true
end

#diff_stylesheetObject

everybody wants to look like git



21
22
23
24
25
26
27
28
# File 'lib/nandoc/core/config.rb', line 21

def diff_stylesheet
  @diff_stylesheet ||= {
    :header => [:bold, :yellow],
    :add    => [:bold, :green],
    :remove => [:bold, :red],
    :range  => [:bold, :magenta]
  }
end

#file_utilsObject

some FileUtils actions are wrapped with this proxy to allow formatting and customizations from the typical FileUtils actions, to indent and colorize the notice stream sorta like nanoc does



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/nandoc/core/config.rb', line 36

def file_utils
  @file_utils ||= begin
    Treebis::FileUtilsProxy.new do |fu|
      fu.pretty!
      fu.color?{ NanDoc::Config.colorize? }
      fu.prefix = ' ' * 6 # like nanoc
      fu.ui = proc{ $stdout }
      # it's normally $stderr, it needs to be reference-like
      # so that capture3 will work!
    end
  end
end

#option_prefixObject



61
62
63
64
65
# File 'lib/nandoc/core/config.rb', line 61

def option_prefix
  colorize? ?
    option_prefix_colorized :
    option_prefix_no_color
end

#option_prefix_colorizedObject

Give some visual distinction of what options for a given command are a nanDoc hack



53
54
55
# File 'lib/nandoc/core/config.rb', line 53

def option_prefix_colorized
  "(\e[35mnanDoc\e[0m) "
end

#option_prefix_no_colorObject



57
58
59
# File 'lib/nandoc/core/config.rb', line 57

def option_prefix_no_color
  '(nanDoc hack) '
end