class Locomotive::Wagon::CLI::Generate

Public Instance Methods

content_type(name, *fields) click to toggle source
# File lib/locomotive/wagon/cli.rb, line 78
def content_type(name, *fields)
  force_color_if_asked(options)

  say('The fields are missing', :red) and return false if fields.empty?

  if path = check_path!
    Locomotive::Wagon.generate :content_type, [name, fields, path], self.options
  end
end
page(fullpath) click to toggle source
# File lib/locomotive/wagon/cli.rb, line 125
def page(fullpath)
  force_color_if_asked(options)

  if path = check_path!
    self.options[:default_locales] = self.site_config(path)['locales']
    Locomotive::Wagon.generate :page, [fullpath, path], self.options
  end
end
public_form() click to toggle source
# File lib/locomotive/wagon/cli.rb, line 171
def public_form
  force_color_if_asked(options)

  if path = check_path!
    Locomotive::Wagon.generate :public_form, [path], self.options
  end
end
relationship(source, type, target) click to toggle source
# File lib/locomotive/wagon/cli.rb, line 103
def relationship(source, type, target)
  force_color_if_asked(options)

  if path = check_path!
    Locomotive::Wagon.generate :relationship, [source, type, target, path], self.options
  end
end
section(slug, *settings) click to toggle source
# File lib/locomotive/wagon/cli.rb, line 162
def section(slug, *settings)
  force_color_if_asked(options)

  if path = check_path!
    Locomotive::Wagon.generate :section, [slug, settings, path], self.options
  end
end
site_metafields() click to toggle source
# File lib/locomotive/wagon/cli.rb, line 180
def site_metafields
  force_color_if_asked(options)

  if path = check_path!
    Locomotive::Wagon.generate :site_metafields, [path], self.options
  end
end
snippet(slug) click to toggle source
# File lib/locomotive/wagon/cli.rb, line 142
def snippet(slug)
  force_color_if_asked(options)

  if path = check_path!
    locales = self.site_config(path)['locales']
    Locomotive::Wagon.generate :snippet, [slug, locales, path], self.options
  end
end
webpack() click to toggle source
# File lib/locomotive/wagon/cli.rb, line 189
def webpack
  force_color_if_asked(options)

  if path = check_path!
    Locomotive::Wagon.generate :webpack, [path], self.options
  end
end

Protected Instance Methods

site_config(path = nil) click to toggle source

Read the YAML config file of a Locomotive site. The path should be returned by the check_path! method first.

@param [ String ] path The full path to a Locomotive site.

@return [ Hash ] The site

# File lib/locomotive/wagon/cli.rb, line 206
def site_config(path = nil)
  YAML.load_file(File.join(path, 'config', 'site.yml'))
end