GithubHelp home page GithubHelp logo

mojolicious-plugin-configdir's Introduction

NAME

Mojolicious::Plugin::ConfigDir - Perl-ish configuration plugin for directories

SYNOPSIS # myapp.conf.d/ # main.conf { foo => "bar", music_dir => app->home->rel_dir('music') };

  #    extras.conf
  {
   extra => "baz"
  }

  # Mojolicious
  my $config = $self->plugin('ConfigDir');

  # Mojolicious::Lite
  my $config = plugin 'Config';

  # foo.html.ep
  %= $config->{foo}

  # The configuration is available application wide
  my $config = app->config;

  # Everything can be customized with options
  my $config = plugin Config => {file => '/etc/myapp.stuff.d/'};

DESCRIPTION Mojolicious::Plugin::ConfigDir is a Perl-ish configuration plugin.

The application object can be accessed via $app or the "app" function,
strict, warnings and Perl 5.10 features are automatically enabled. You
can extend the normal configuration "myapp.conf.d" with "mode" specific
ones like "myapp.$mode.conf.d". A default configuration directoryname
will be generated by decamelizing the application class with
"decamelize" in Mojo::Util or from the application filename.

The code of this plugin is a good example for learning to build new
plugins, you're welcome to fork it.

OPTIONS Mojolicious::Plugin::ConfigDir supports the following options.

"default" # Mojolicious::Lite plugin ConfigDir => {default => {foo => 'bar'}};

Default configuration, making configuration files optional.

"ext" # Mojolicious::Lite plugin ConfigDir => {ext => 'stuff'};

File extension for generated configuration filenames, defaults to
"conf".

"file" # Mojolicious::Lite plugin ConfigDir => {dir => 'myapp.conf.d/'}; plugin ConfigDir => {dir => '/etc/foo.stuff.d/'};

Full path to configuration file, defaults to the value of the
"MOJO_CONFIG" environment variable or "myapp.conf" in the application
home directory.

METHODS Mojolicious::Plugin::ConfigDir inherits all methods from Mojolicious::Plugin and implements the following new ones.

"load" $plugin->load($dir, $conf, $app);

Loads configuration file and passes the content to "parse".

  sub load {
    my ($self, $dir, $conf, $app) = @_;
    ...
    return $self->parse($content, $file, $conf, $app);
  }

"parse" $plugin->parse($contents, $conf, $app);

Parse configuration file.

  sub parse {
    my ($self, $content, $file, $conf, $app) = @_;
    ...
    return $hash;
  }

"register" my $config = $plugin->register(Mojolicious->new); my $config = $plugin->register(Mojolicious->new, {dir => '/etc/app.conf.d/'});

Register plugin in Mojolicious application.

SEE ALSO Mojolicious, Mojolicious::Guides, http://mojolicio.us.

mojolicious-plugin-configdir's People

Contributors

andreas-marschke avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.