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.safe_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.



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

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

Instance Method Details

#detectObject



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

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