Class: MarkdownRecord::Configuration

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/markdown_record/configuration.rb

Constant Summary collapse

RENDER_STRATEGIES =
[:full, :directory, :file]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/markdown_record/configuration.rb', line 27

def initialize
  @content_root = Rails.root.join("markdown_record","content")
  @rendered_content_root = Rails.root.join("markdown_record","rendered")
  @layout_directory = Rails.root.join("markdown_record","layouts")
  @html_render_options = {}
  @markdown_extensions = { :fenced_code_blocks => true, :disable_indented_code_blocks => true, :no_intra_emphasis => true}
  @concatenated_layout_path = "_concatenated_layout.html.erb"
  @file_layout_path = "_file_layout.html.erb"
  @global_layout_path = "_global_layout.html.erb"
  @public_layout = "layouts/application"
  @render_strategy = :full
  @always_concatenate_json = true
  @html_routes = [:show]
  @json_routes = [:show]
  @content_routes = [:show]
  @mount_path = "mdr"
  @render_content_fragment_json = true
  @render_controller = nil
  @ignore_numeric_prefix = true
  @filename_sorter = MarkdownRecord::FileSorting::Base.new
end

Instance Attribute Details

#always_concatenate_jsonObject

Returns the value of attribute always_concatenate_json.



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

def always_concatenate_json
  @always_concatenate_json
end

#concatenated_layout_pathObject

Returns the value of attribute concatenated_layout_path.



8
9
10
# File 'lib/markdown_record/configuration.rb', line 8

def concatenated_layout_path
  @concatenated_layout_path
end

#content_rootObject

Returns the value of attribute content_root.



5
6
7
# File 'lib/markdown_record/configuration.rb', line 5

def content_root
  @content_root
end

#content_routesObject

Returns the value of attribute content_routes.



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

def content_routes
  @content_routes
end

#file_layout_pathObject

Returns the value of attribute file_layout_path.



9
10
11
# File 'lib/markdown_record/configuration.rb', line 9

def file_layout_path
  @file_layout_path
end

#filename_sorterObject

Returns the value of attribute filename_sorter.



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

def filename_sorter
  @filename_sorter
end

#global_layout_pathObject

Returns the value of attribute global_layout_path.



10
11
12
# File 'lib/markdown_record/configuration.rb', line 10

def global_layout_path
  @global_layout_path
end

#html_render_optionsObject

Returns the value of attribute html_render_options.



12
13
14
# File 'lib/markdown_record/configuration.rb', line 12

def html_render_options
  @html_render_options
end

#html_routesObject

Returns the value of attribute html_routes.



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

def html_routes
  @html_routes
end

#ignore_numeric_prefixObject

Returns the value of attribute ignore_numeric_prefix.



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

def ignore_numeric_prefix
  @ignore_numeric_prefix
end

#json_routesObject

Returns the value of attribute json_routes.



16
17
18
# File 'lib/markdown_record/configuration.rb', line 16

def json_routes
  @json_routes
end

#layout_directoryObject

Returns the value of attribute layout_directory.



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

def layout_directory
  @layout_directory
end

#markdown_extensionsObject

Returns the value of attribute markdown_extensions.



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

def markdown_extensions
  @markdown_extensions
end

#mount_pathObject

Returns the value of attribute mount_path.



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

def mount_path
  @mount_path
end

#public_layoutObject

Returns the value of attribute public_layout.



13
14
15
# File 'lib/markdown_record/configuration.rb', line 13

def public_layout
  @public_layout
end

#render_content_fragment_jsonObject

Returns the value of attribute render_content_fragment_json.



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

def render_content_fragment_json
  @render_content_fragment_json
end

#render_controllerObject

Returns the value of attribute render_controller.



20
21
22
# File 'lib/markdown_record/configuration.rb', line 20

def render_controller
  @render_controller
end

#render_strategyObject

Returns the value of attribute render_strategy.



14
15
16
# File 'lib/markdown_record/configuration.rb', line 14

def render_strategy
  @render_strategy
end

#rendered_content_rootObject

Returns the value of attribute rendered_content_root.



6
7
8
# File 'lib/markdown_record/configuration.rb', line 6

def rendered_content_root
  @rendered_content_root
end

Instance Method Details

#render_strategy_options(strategy = nil) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/markdown_record/configuration.rb', line 49

def render_strategy_options(strategy = nil)
  strat = strategy || @render_strategy

  unless RENDER_STRATEGIES.include?(strat)
    raise ::ArgumentError.new("Invalide render strategy.")
  end

  case strategy || @render_strategy
  when :full
    {:concat => true, :deep => true}
  when :directory
    {:concat => true, :deep => false}
  when :file
    {:concat => false, :deep => true}
  end
end

#routingObject



66
67
68
# File 'lib/markdown_record/configuration.rb', line 66

def routing
  { :html => html_routes, :json => json_routes, :content => content_routes}
end