New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

directory_template

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

directory_template

  • 1.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

README

Summary

Lets you generate directory structures from a template, optionally processing paths (variables in the path) and contents (e.g., render ERB templates).

Features

  • Generate directories and files
  • Use a directory structure as template, or store the template in a YAML file
  • Interpolate variables in directory- and filenames
  • Render ERB and Markdown templates
  • Write & use your own processors

Installation

gem install directory_template

Usage

The examples given below are working examples. The templates are part of the gem and can be found in the directory 'examples'.

Create a template from an existing structure and materialize it (create directories & files):

require 'directory_template'
variables = {
  namespace:    'Namespace',
  version:      '1.2.3',
  gem_name:     'gem-name',
  require_name: 'require_name',
  description:  "The description",
  summary:      "The summary"
}
template = DirectoryTemplate.directory('examples/dir_gem_template')
template.materialize('new_project', variables: variables)

Create a template from a YAML file:

require 'directory_template'
variables = {
  namespace:    'Namespace',
  version:      '1.2.3',
  gem_name:     'gem-name',
  require_name: 'require_name',
  description:  "The description",
  summary:      "The summary"
}
template = DirectoryTemplate.yaml_file('examples/yaml_gem_template.yaml')
template.materialize('new_project', variables: variables)

Description

DirectoryTemplate is a library which lets you generate directory structures and files from a template structure. The template structure can be a real directory structure on the filesystem, or it can be stored in a yaml file. Take a look at the examples directory in the gem to get an idea, how a template can look.

When generating a new directory structure from a template, DirectoryTemplate will process the pathname of each directory and file using the DirectoryTemplate#path_processor. It will also process the contents of each file with all processors that apply to a given file. The standard path processor allows you to use %{variables} in pathnames. The gem comes with a .erb (renders ERB templates) and .html.markdown processor (renders markdown to html). You can use the existing processors or define your own ones.

Also take a look at the {file:documentation/ContentProcessors.markdown Content Processors Guide} and the {file:documentation/ContentProcessors.markdown Path Processors Guide}.

  • Online API Documentation
  • Public Repository
  • Bug Reporting
  • RubyGems Site

Credits

  • Daniel Schärli, for proofreading the docs

License

You can use this code under the {file:LICENSE.txt BSD-2-Clause License}, free of charge. If you need a different license, please ask the author.

FAQs

Package last updated on 03 May 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc