Class: Dato::Dump::SsgDetector

Inherits:
Object
  • Object
show all
Defined in:
lib/dato/dump/ssg_detector.rb

Constant Summary collapse

RUBY =
%w(middleman jekyll nanoc).freeze
NODE =
%w(brunch assemble ember-cli hexo metalsmith react-scripts
roots docpad wintersmith gatsby harp grunt gulp).freeze
PYTHON =
%w(mkdocs pelican cactus).freeze
HUGO =
[
  {
    file: 'config.toml',
    loader: ->(content) { TOML::Parser.new(content).parsed }
  },
  {
    file: 'config.yaml',
    loader: ->(content) { YAML.load(content) }
  },
  {
    file: 'config.json',
    loader: ->(content) { JSON.parse(content) }
  }
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ SsgDetector

Returns a new instance of SsgDetector.



33
34
35
# File 'lib/dato/dump/ssg_detector.rb', line 33

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



9
10
11
# File 'lib/dato/dump/ssg_detector.rb', line 9

def path
  @path
end

Instance Method Details

#detectObject



37
38
39
40
41
42
43
# File 'lib/dato/dump/ssg_detector.rb', line 37

def detect
  ruby_generator ||
    node_generator ||
    python_generator ||
    hugo ||
    'unknown'
end