This is an automated email from the git hooks/post-receive script. js pushed a commit to tag 0.91 in repository libcatmandu-perl.
commit 14b117a0f53e7ba3e8f1ebb96e8f18bde44e6dae Author: Patrick Hochstenbach <patrick.hochstenb...@ugent.be> Date: Sun May 18 10:46:20 2014 +0200 Deleted the -d debug options. Log::Any::Adapter is not part of our dependencies... --- README.md | 268 +++++++++++++++++++++++++++++----------------------- bin/catmandu | 8 +- lib/Catmandu/CLI.pm | 7 -- 3 files changed, 151 insertions(+), 132 deletions(-) diff --git a/README.md b/README.md index d5a7315..7fb932d 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,38 @@ Catmandu - a data toolkit +# SYNOPSIS + + use Catmandu -all; + use Catmandu qw(config store); + use Catmandu -load; + use Catmandu -all -load => [qw(/config/path' '/another/config/path)]; + + # If you have Catmandu::OAI and Catmandu::MongoDB installed + my $importer = Catmandu->importer('OAI',url => 'https://biblio.ugent.be/oai') + my $store = Catmandu->exporter('MongoDB',database_name => 'test'); + + # Import all the OAI records into MongoDB + $store->add_many($importer); + + # Export all the MongoDB records to YAML and apply some fixes + # myfixes.txt: + # upcase(title.*) + # remove_field(_metadata) + # join_field(creator,'; ') + # join_field(subject,'-- ') + my $fixer = Catmandu->fixer('myfixes.txt'); + my $exporter = Catmandu->exporter('YAML'); + + $exporter->add_many( + $fixer->fix($store) + ); + $exporter->commit; + + # Or be very lazy and do this via the command line + $ catmandu import OAI --url https://biblio.ugent.be/oai to MongoDB --database_name test + $ catmandu export MongoDB --database_name test --fix myfixes.txt to YAML + # DESCRIPTION Importing, transforming, storing and indexing data should be easy. @@ -22,112 +54,24 @@ Read an in depth introduction into Catmandu programming at # ONE STEP INSTALL -To install all Catmandu components in one easy step: +To install all Catmandu components in one step: cpan Task::Catmandu # or cpanm --interactive Task::Catmandu -or read our wiki for more installation hints: +Read our wiki for more installation hints: https://github.com/LibreCat/Catmandu/wiki/Install -# SYNOPSIS - - use Catmandu; - - Catmandu->load; - Catmandu->load('/config/path', '/another/config/path'); - - Catmandu->store->bag('projects')->count; - - Catmandu->config; - Catmandu->config->{foo} = 'bar'; - - use Catmandu -all; - use Catmandu qw(config store); - use Catmandu -load; - use Catmandu -all -load => [qw(/config/path' '/another/config/path)]; - -# CONFIG - -Catmandu configuration options can be stored in files in the root directory of -your programming project. The file can be YAML, JSON or Perl and is called -`catmandu.yml`, `catmandu.json` or `catmandu.pl`. In this file you can set -the default Catmandu stores and exporters to be used. Here is an example of a -`catmandu.yml` file: - - store: - default: - package: ElasticSearch - options: - index_name: myrepository - - exporter: - default: - package: YAML - -## Split config - -For large configs it's more convenient to split the config into several files. -You can do so by having multiple config files starting with catmandu\*. - - catmandu.general.yml - catmandu.db.yml - ... - -Split config files are processed and merged by [Config::Onion](https://metacpan.org/pod/Config::Onion). - -## Deeply nested config structures - -Config files can indicate a path under which their keys will be nested. This -makes your configuration more readable by keeping indentation to a minimum. - -A config file containing - - _prefix: - foo: - bar: - baz: 1 - -will be loaded as - - foo: - bar: - baz: 1 - -See [Config::Onion](https://metacpan.org/pod/Config::Onion) for more information on how this works. - # METHODS ## log Return the current logger (the [Log::Any::Adapter](https://metacpan.org/pod/Log::Any::Adapter) for category [Catmandu::Env](https://metacpan.org/pod/Catmandu::Env)). See [Log::Any#Logging](https://metacpan.org/pod/Log::Any#Logging) for how to send messages to the -logger. - -E.g. turn on Log4perl logging in your application; - - package main; - use Catmandu; - use Log::Any::Adapter; - use Log::Log4perl; - - Log::Log4perl::init('./log4perl.conf'); - Log::Any::Adapter->set('Log4perl'); - - my $importer = Catmandu::Importer::JSON->new(...); - ... - -With log4perl.conf something like: - - log4perl.rootLogger=DEBUG,STDOUT - log4perl.appender.STDOUT=Log::Log4perl::Appender::Screen - log4perl.appender.STDOUT.stderr=1 - log4perl.appender.STDOUT.utf8=1 - - log4perl.appender.STDOUT.layout=PatternLayout - log4perl.appender.STDOUT.layout.ConversionPattern=%d [%P] - %p %l time=%r : %m%n +logger. Read our [https://github.com/LibreCat/Catmandu/wiki/Cookbook](https://github.com/LibreCat/Catmandu/wiki/Cookbook) +"See some debug messages" for some hints on logging. ## default\_load\_path('/default/path') @@ -136,6 +80,7 @@ Set the location of the default configuration file to a new path. ## load Load all the configuration options in the catmandu.yml configuration file. +See CONFIG below for extended examples of configuration options. ## load('/path', '/another/path') @@ -143,6 +88,8 @@ Load all the configuration options stored at alternative paths. A load path `':up'` will search upwards from your program for configuration. +See CONFIG below for extended examples of configuration options. + ## roots Returns an ARRAYREF of paths where configuration was found. Note that this list @@ -163,8 +110,11 @@ Return the name of the default store. ## store(\[NAME\]) -Return an instance of [Catmandu::Store](https://metacpan.org/pod/Catmandu::Store) with name NAME or use the default store -when no name is provided. The NAME is set in the configuration file. E.g. +Return an instance of [Catmandu::Store](https://metacpan.org/pod/Catmandu::Store). The NAME is a name of a [Catmandu::Store](https://metacpan.org/pod/Catmandu::Store) or the +name of a store configured in a catmandu.yml configuration file. When no NAME is given, the +'default' store in the configuration file will be used. + +E.g. if the configuration file 'catmandu.yml' contains: store: default: @@ -174,13 +124,25 @@ when no name is provided. The NAME is set in the configuration file. E.g. test: package: Mock -In your program: +then in your program: # This will use ElasticSearch - Catmandu->store->bag->each(sub { ... }); - Catmandu->store('default')->bag->each(sub { ... }); + my $store = Catmandu->store('ElasticSearch', index_name => 'blog'); + + # or because we have a 'default' set in the configuration file + + my $store = Catmandu->store('default'); + + # or because 'default' will be used when no name was provided + + my $store = Catmandu->store; + # This will use Mock - Catmandu->store('test')->bag->search(...); + my $store = Catmandu->store('test'); + +Configuration settings can be overwritten by the store command: + + my $store2 = Catmandu->store('default', index_name => 'test2'); ## default\_fixer @@ -188,20 +150,35 @@ Return the name of the default fixer. ## fixer(NAME) -Return an instance of [Catmandu::Fix](https://metacpan.org/pod/Catmandu::Fix) with name NAME (or 'default' when no -name is given). The NAME is set in the config. E.g. +## fixer(FIX,FIX) + +## fixer(\[FIX\]) + +Return an instance of [Catmandu::Fix](https://metacpan.org/pod/Catmandu::Fix). NAME can be the name of a fixer section +in a catmandu.yml file. Or, one or more [Catmandu::Fix](https://metacpan.org/pod/Catmandu::Fix)-es can be provided inline. + +E.g. if the configuration file 'catmandu.yml' contains: fixer: default: - do_this() - do_that() -In your program: +then in your program al these lines below will create the same fixer: + + my $fixer = Catmandu->fixer('do_this()', 'do_that()'); + my $fixer = Catmandu->fixer(['do_this()', 'do_that()']); + my $fixer = Catmandu->fixer('default'); + my $fixer = Catmandu->fixer(); # The default name is 'default' + +FIX-es can be also written to a Fix script. E.g. if myfixes.txt contains: + + do_this() + do_that() + +then the above code will even be equivalent to: - my $clean_data = Catmandu->fixer('cleanup')->fix($data); - # or inline - my $clean_data = Catmandu->fixer('do_this()', 'do_that()')->fix($data); - my $clean_data = Catmandu->fixer(['do_this()', 'do_that()'])->fix($data); + my $fixer = Catmandu->fixer('myfixes.txt'); ## default\_importer @@ -214,25 +191,27 @@ package name is given in the config or as a param. ## importer(NAME) -Return an instance of a [Catmandu::Importer](https://metacpan.org/pod/Catmandu::Importer) with name NAME -(or the default when no name is given). -The NAME is set in the configuration file. E.g. +Return an instance of [Catmandu::Importer](https://metacpan.org/pod/Catmandu::Importer). The NAME is a name of a [Catmandu::Importer](https://metacpan.org/pod/Catmandu::Importer) or the +name of a importer configured in a catmandu.yml configuration file. When no NAME is given, the +'default' importer in the configuration file will be used. + +E.g. if the configuration file 'catmandu.yml' contains: importer: - oai: + default: package: OAI options: url: http://www.instute.org/oai/ - feed: - package: Atom - options: - url: http://www.mysite.org/blog/atom -In your program: +then in your program all these lines will be equivalent: + + my $importer = Catmandu->importer('OAI', url => 'http://www.instute.org/oai/'); + my $importer = Catmandu->importer('default'); + my $importer = Catmandu->importer(); # The default name is 'default' + +Configuration settings can be overwritten by the importer command: - Catmandu->importer('oai')->each(sub { ... } ); - Catmandu->importer('oai', url => 'http://override')->each(sub { ... } ); - Catmandu->importer('feed')->each(sub { ... } ); + my $importer2 = Catmandu->importer('default', url => 'http://other.institute.org'); ## default\_exporter @@ -310,9 +289,62 @@ Export data using a default or named exporter to a string. # is the same as Catmandu->load('/config/path'); +# CONFIG + +Catmandu configuration options can be stored in files in the root directory of +your programming project. The file can be YAML, JSON or Perl and is called +`catmandu.yml`, `catmandu.json` or `catmandu.pl`. In this file you can set +the default Catmandu stores and exporters to be used. Here is an example of a +`catmandu.yml` file: + + store: + default: + package: ElasticSearch + options: + index_name: myrepository + + exporter: + default: + package: YAML + +## Split config + +For large configs it's more convenient to split the config into several files. +You can do so by having multiple config files starting with catmandu\*. + + catmandu.general.yml + catmandu.db.yml + ... + +Split config files are processed and merged by [Config::Onion](https://metacpan.org/pod/Config::Onion). + +## Deeply nested config structures + +Config files can indicate a path under which their keys will be nested. This +makes your configuration more readable by keeping indentation to a minimum. + +A config file containing + + _prefix: + foo: + bar: + baz: 1 + +will be loaded as + + foo: + bar: + baz: 1 + +See [Config::Onion](https://metacpan.org/pod/Config::Onion) for more information on how this works. + # SEE ALSO -[https://github.com/LibreCat/Catmandu/wiki](https://github.com/LibreCat/Catmandu/wiki). +[https://github.com/LibreCat/Catmandu/wiki](https://github.com/LibreCat/Catmandu/wiki), +[Catmandu::Importer](https://metacpan.org/pod/Catmandu::Importer), +[Catmandu::Exporter](https://metacpan.org/pod/Catmandu::Exporter), +[Catmandu::Store](https://metacpan.org/pod/Catmandu::Store), +[Catmandu::Fix](https://metacpan.org/pod/Catmandu::Fix) # AUTHOR diff --git a/bin/catmandu b/bin/catmandu index e8c59f1..040127e 100755 --- a/bin/catmandu +++ b/bin/catmandu @@ -13,7 +13,7 @@ catmandu - LibreCat command line tools =head1 SYNOPSIS - catmandu [-d] [-I path] [-L path] [COMMAND] [-?hqv] [long options...] [ARGS] + catmandu [-I path] [-L path] [COMMAND] [-?hqv] [long options...] [ARGS] catmandu help @@ -149,12 +149,6 @@ Verbose output. Display the help screen. -=item --debug - -=item -d - -Display debug messages. - =item --lib-path PATH =item -I diff --git a/lib/Catmandu/CLI.pm b/lib/Catmandu/CLI.pm index 3f0365a..374a224 100644 --- a/lib/Catmandu/CLI.pm +++ b/lib/Catmandu/CLI.pm @@ -3,7 +3,6 @@ package Catmandu::CLI; use Catmandu::Sane; use App::Cmd::Setup -app; use Catmandu::Util; -use Log::Any::Adapter; use Catmandu; sub VERSION { @@ -16,7 +15,6 @@ sub global_opt_spec { ( ['load_path|L=s@', ""], ['lib_path|I=s@', ""], - ['debug|d',""], ); } @@ -29,7 +27,6 @@ sub run { my $load_path = $global_opts->{load_path} || []; my $lib_path = $global_opts->{lib_path} || []; - my $debug = $global_opts->{debug}; Catmandu->load(@$load_path); @@ -37,10 +34,6 @@ sub run { Catmandu::Util::use_lib(@$lib_path); } - if (defined $debug) { - Log::Any::Adapter->set('Stderr'); - } - my $self = ref $class ? $class : $class->new; $self->set_global_options($global_opts); my ($cmd, $opts, @args) = $self->prepare_command(@$argv); -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcatmandu-perl.git _______________________________________________ Pkg-perl-cvs-commits mailing list Pkg-perl-cvs-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits