Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'milla'

  • Loading branch information...
commit 19fb7b987bf91afff202fdb5b2decd121487db9e 2 parents 7f9e257 + 0ea7a59
@miyagawa authored
View
9 .gitignore
@@ -1,10 +1,7 @@
META.yml
MYMETA.*
-Makefile
-inc/
-pm_to_blib
-blib
*~
.*
-!.gitignore
-!.shipit
+/Module-CPANfile-*
+/.build
+!META.json
View
2  .shipit
@@ -1,2 +0,0 @@
-steps = FindVersion, ChangeAllVersions, CheckChangeLog, DistTest, Commit, Tag, MakeDist, UploadCPAN
-git.push_to = origin
View
3  Build.PL
@@ -0,0 +1,3 @@
+use 5.006;
+use Module::Build::Tiny 0.013;
+Build_PL();
View
5 Changes
@@ -1,4 +1,7 @@
-Revision history for Perl extension Module::Install::CPANfile
+Revision history for Module::Install::CPANfile
+
+{{$NEXT}}
+ - Convert to Milla
0.9021 Sat Mar 23 09:11:46 PDT 2013
- added mymeta-cpanfile utility script for migration from Makefile.PL/Build.PL
View
12 MANIFEST
@@ -1,12 +0,0 @@
-Changes
-lib/cpanfile-faq.pod
-lib/cpanfile.pod
-lib/Module/CPANfile.pm
-Makefile.PL
-MANIFEST This list of files
-README.md
-script/mymeta-cpanfile
-t/from_prereqs.t
-t/merge.t
-t/parse.t
-t/Utils.pm
View
22 MANIFEST.SKIP
@@ -1,22 +0,0 @@
-\bRCS\b
-\bCVS\b
-^MANIFEST\.
-^Makefile$
-~$
-^#
-\.old$
-^blib/
-^pm_to_blib
-^MakeMaker-\d
-\.gz$
-\.cvsignore
-^t/9\d_.*\.t
-^t/perlcritic
-^tools/
-\.svn/
-^[^/]+\.yaml$
-^[^/]+\.pl$
-^\.shipit$
-\.git
-nytprof/
-MYMETA
View
48 META.json
@@ -0,0 +1,48 @@
+{
+ "abstract" : "Parse cpanfile",
+ "author" : [
+ "Tatsuhiko Miyagawa <miyagawa@bulknews.net>"
+ ],
+ "dynamic_config" : 0,
+ "generated_by" : "Dist::Zilla version 4.300031, CPAN::Meta::Converter version 2.120921",
+ "license" : [
+ "perl_5"
+ ],
+ "meta-spec" : {
+ "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
+ "version" : "2"
+ },
+ "name" : "Module-CPANfile",
+ "prereqs" : {
+ "configure" : {
+ "requires" : {
+ "Module::Build::Tiny" : "0.013"
+ }
+ },
+ "develop" : {
+ "requires" : {
+ "Test::Pod" : "1.41"
+ }
+ },
+ "runtime" : {
+ "requires" : {
+ "CPAN::Meta" : "2.12091",
+ "CPAN::Meta::Prereqs" : "2.12091"
+ }
+ }
+ },
+ "release_status" : "stable",
+ "resources" : {
+ "bugtracker" : {
+ "web" : "https://github.com/miyagawa/cpanfile/issues"
+ },
+ "homepage" : "https://github.com/miyagawa/cpanfile",
+ "repository" : {
+ "type" : "git",
+ "url" : "https://github.com/miyagawa/cpanfile.git",
+ "web" : "https://github.com/miyagawa/cpanfile"
+ }
+ },
+ "version" : "0.9021"
+}
+
View
14 Makefile.PL
@@ -1,14 +0,0 @@
-use ExtUtils::MakeMaker;
-
-WriteMakefile(
- NAME => 'Module::CPANfile',
- VERSION_FROM => 'lib/Module/CPANfile.pm',
- ABSTRACT => 'A format for describing CPAN dependencies of Perl applications',
- CONFIGURE_REQUIRES => {
- 'ExtUtils::MakeMaker' => 6.31,
- },
- EXE_FILES => [ 'script/mymeta-cpanfile' ],
- MIN_PERL_VERSION => '5.008001',
- AUTHOR => 'Tatsuhiko Miyagawa',
- LICENSE => "perl",
-);
View
112 README.md
@@ -1,53 +1,103 @@
# NAME
-cpanfile - A format for describing CPAN dependencies for Perl applications
+Module::CPANfile - Parse cpanfile
# SYNOPSIS
- requires 'Catalyst', '5.8000';
- requires 'Catalyst::View::JSON', '>= 0.30, < 0.40';
+ use Module::CPANfile;
- recommends 'JSON::XS', '2.0';
- conflicts 'JSON', '< 1.0';
+ my $file = Module::CPANfile->load("cpanfile");
+ my $prereqs = $file->prereqs; # CPAN::Meta::Prereqs object
- on 'test' => sub {
- requires 'Test::More', '>= 0.96, < 2.0';
- recommends 'Test::TCP', '1.12';
- };
+ $file->merge_meta('MYMETA.json');
- on 'develop' => sub {
- recommends 'Devel::NYTProf';
- };
+# DESCRIPTION
-# VERSION
+Module::CPANfile is a tool to handle [cpanfile](http://search.cpan.org/perldoc?cpanfile) format to load application
+specific dependencies, not just for CPAN distributions.
-0.9000
+# METHODS
-# DESCRIPTION
+- load
-`cpanfile` describes CPAN dependencies required to execute associated
-Perl code.
+ $file = Module::CPANfile->load;
+ $file = Module::CPANfile->load('cpanfile');
-Place the `cpanfile` in the root of the directory containing the
-associated code. For instance, in a Catalyst application, place the
-`cpanfile` in the same directory as `myapp.conf`.
+ Load and parse a cpanfile. By default it tries to load `cpanfile` in
+ the current directory, unless you pass the path to its argument.
-Tools supporting `cpanfile` format (e.g. [cpanm](http://search.cpan.org/perldoc?cpanm) and [carton](http://search.cpan.org/perldoc?carton)) will
-automatically detect the file and install dependencies for the code to
-run.
+- from\_prereqs
-# AUTHOR
+ $file = Module::CPANfile->from_prereqs({
+ runtime => { requires => { DBI => '1.000' } },
+ });
-Tatsuhiko Miyagawa
+ Creates a new Module::CPANfile object from prereqs hash you can get
+ via [CPAN::Meta](http://search.cpan.org/perldoc?CPAN::Meta)'s `prereqs`, or [CPAN::Meta::Prereqs](http://search.cpan.org/perldoc?CPAN::Meta::Prereqs)'
+ `as_string_hash`.
+
+ # read MYMETA, then feed the prereqs to create Module::CPANfile
+ my $meta = CPAN::Meta->load_file('MYMETA.json');
+ my $file = Module::CPANfile->from_prereqs($meta->prereqs);
+
+ # load cpanfile, then recreate it with round-trip
+ my $file = Module::CPANfile->load('cpanfile');
+ $file = Module::CPANfile->from_prereqs($file->prereq_specs);
+ # or $file->prereqs->as_string_hash
+
+- prereqs
+
+ Returns [CPAN::Meta::Prereqs](http://search.cpan.org/perldoc?CPAN::Meta::Prereqs) object out of the parsed cpanfile.
+
+- prereq\_specs
+
+ Returns a hash reference that should be passed to `CPAN::Meta::Prereqs->new`.
+
+- to\_string($include\_empty)
+
+ $file->to_string;
+ $file->to_string(1);
+
+ Returns a canonical string (code) representation for cpanfile. Useful
+ if you want to convert [CPAN::Meta::Prereqs](http://search.cpan.org/perldoc?CPAN::Meta::Prereqs) to a new cpanfile.
-# ACKNOWLEDGEMENTS
+ # read MYMETA's prereqs and print cpanfile representation of it
+ my $meta = CPAN::Meta->load_file('MYMETA.json');
+ my $file = Module::CPANfile->from_prereqs($meta->prereqs);
+ print $file->to_sring;
-The format (DSL syntax) is inspired by [Module::Install](http://search.cpan.org/perldoc?Module::Install) and
-[Module::Build::Functions](http://search.cpan.org/perldoc?Module::Build::Functions).
+ By default, it omits the phase where there're no modules
+ registered. If you pass the argument of a true value, it will print
+ them as well.
-`cpanfile` specification (this document) is based on Ruby's
-[Gemfile](http://gembundler.com/man/gemfile.5.html) specification.
+- save
+
+ $file->save('cpanfile');
+
+ Saves the currently loaded prereqs as a new `cpanfile` by calling
+ `to_string`. Beware __this method will overwrite the existing
+ cpanfile without any warning or backup__. Taking a backup or giving
+ warnings to users is a caller's responsibility.
+
+ # Read MYMETA.json and creates a new cpanfile
+ my $meta = CPAN::Meta->load_file('MYMETA.json');
+ my $file = Module::CPANfile->from_prereqs($meta->prereqs);
+ $file->save('cpanfile');
+
+- merge\_meta
+
+ $file->merge_meta('META.yml');
+ $file->merge_meta('MYMETA.json', '2.0');
+
+ Merge the effective prereqs with Meta speicifcation loaded from the
+ given META file, using CPAN::Meta. You can specify the META spec
+ version in the second argument, which defaults to 1.4 in case the
+ given file is YAML, and 2 if it is JSON.
+
+# AUTHOR
+
+Tatsuhiko Miyagawa
# SEE ALSO
-[CPAN::Meta::Spec](http://search.cpan.org/perldoc?CPAN::Meta::Spec) [Module::Install](http://search.cpan.org/perldoc?Module::Install) [Carton](http://search.cpan.org/perldoc?Carton)
+[cpanfile](http://search.cpan.org/perldoc?cpanfile), [CPAN::Meta](http://search.cpan.org/perldoc?CPAN::Meta), [CPAN::Meta::Spec](http://search.cpan.org/perldoc?CPAN::Meta::Spec)
View
3  cpanfile
@@ -0,0 +1,3 @@
+requires 'CPAN::Meta', 2.12091;
+requires 'CPAN::Meta::Prereqs', 2.12091;
+
View
2  dist.ini
@@ -0,0 +1,2 @@
+name = Module-CPANfile
+[@Milla]
Please sign in to comment.
Something went wrong with that request. Please try again.