Commits

Marcin Kasperski committed 1c07e80

Further setup work. No real code still

Comments (0)

Files changed (6)

 my $builder = Module::Build->new(
     module_name         => 'WebService::BitBucket',
     license             => 'perl',
-    dist_author         => q{Marcin Kasperski <Marcin.Kasperski@google.me>},
-    dist_version_from   => 'lib/WebService/BitBucket.pm',
+    dynamic_config      => 1,
+
     build_requires => {
+        'Module::Build' => '0.36',
         'Test::More' => 0,
+        'Test::Pod::Coverage' => '1.0',
+        'Pod::Readme' => 0,
+    },
+    configure_requires => {
+        'Module::Build' => '0.36',
     },
     requires => {
         'perl' => 5.006,
     },
+
+    create_makefile_pl => 'traditional',
     add_to_cleanup      => [ 'WebService-BitBucket-*' ],
-    create_makefile_pl => 'traditional',
+
+    create_readme       => 1,
+    dist_author         => q{Marcin Kasperski <Marcin.Kasperski@mekk.waw.pl>},
+    dist_version_from   => 'lib/WebService/BitBucket.pm',
+    meta_merge => {
+        keywords => [ qw/ passwords security secure-storage keyring KDE PWSafe3 / ],
+        resources => {
+            license     => 'http://dev.perl.org/licenses/',
+            homepage    => 'http://bitbucket.org/Mekk/perl-webservice_bitbucket',
+            repository => 'http://bitbucket.org/Mekk/perl-webservice_bitbucket',
+            bugtracker => 'https://bitbucket.org/Mekk/perl-webservice_bitbucket/issues',
+        },
+    },
 );
 
 $builder->create_build_script();
+WebService::BitBucket
+
+WebService::BitBucket wraps BitBucket API, making it easier to 
+use it from perl.
+
+INSTALLATION
+
+To install this module, run the following commands:
+
+	perl Build.PL
+	./Build
+	./Build test
+	./Build install
+
+SUPPORT AND DOCUMENTATION
+
+After installing, you can find documentation for this module with the
+perldoc command.
+
+    perldoc WebService::BitBucket
+
+You can also look for information at:
+
+    https://bitbucket.org/Mekk/perl-webservice_bitbucket
+
+LICENSE AND COPYRIGHT
+
+Copyright (C) 2012 Marcin Kasperski
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of either: the GNU General Public License as published
+by the Free Software Foundation; or the Artistic License.
+
+See http://dev.perl.org/licenses/ for more information.
+
+
+#!start included /usr/share/perl/5.14/ExtUtils/MANIFEST.SKIP
+# Avoid version control files.
+\bRCS\b
+\bCVS\b
+\bSCCS\b
+,v$
+\B\.svn\b
+\B\.git\b
+\B\.gitignore\b
+\b_darcs\b
+\B\.cvsignore$
+
+# Avoid VMS specific MakeMaker generated files
+\bDescrip.MMS$
+\bDESCRIP.MMS$
+\bdescrip.mms$
+
+# Avoid Makemaker generated and utility files.
+\bMANIFEST\.bak
+\bMakefile$
+\bblib/
+\bMakeMaker-\d
+\bpm_to_blib\.ts$
+\bpm_to_blib$
+\bblibdirs\.ts$         # 6.18 through 6.25 generated this
+
+# Avoid Module::Build generated and utility files.
+\bBuild$
+\b_build/
+\bBuild.bat$
+\bBuild.COM$
+\bBUILD.COM$
+\bbuild.com$
+
+# Avoid temp and backup files.
+~$
+\.old$
+\#$
+\b\.#
+\.bak$
+\.tmp$
+\.#
+\.rej$
+
+# Avoid OS-specific files/dirs
+# Mac OSX metadata
+\B\.DS_Store
+# Mac OSX SMB mount metadata files
+\B\._
+
+# Avoid Devel::Cover and Devel::CoverX::Covered files.
+\bcover_db\b
+\bcovered\b
+
+# Avoid MYMETA files
+^MYMETA\.
+#!end included /usr/share/perl/5.14/ExtUtils/MANIFEST.SKIP
+
+# Avoid configuration metadata file
+^MYMETA\.
+
+# Avoid Module::Build generated and utility files.
+\bBuild$
+\bBuild.bat$
+\b_build
+\bBuild.COM$
+\bBUILD.COM$
+\bbuild.com$
+^MANIFEST\.SKIP
+
+# Avoid archives of this distribution
+\bPasswd-Keyring-PWSafe3-[\d\.\_]+
+
+# Repo-related
+^\.hg
+^\.bitbucket\.url
+^version_hook\.py
+^ignore\.txt
+^experiments
+^make_release\.pl
+/nytprof/
+/nytprof\.out

README

-WebService-BitBucket
-
-The README is used to introduce the module and provide instructions on
-how to install the module, any machine dependencies it may have (for
-example C compilers and installed libraries) and any other information
-that should be provided before the module is installed.
-
-A README file is required for CPAN modules since CPAN extracts the README
-file from a module distribution so that people browsing the archive
-can use it to get an idea of the module's uses. It is usually a good idea
-to provide version information here so that people can decide whether
-fixes for the module are worth downloading.
-
-
-INSTALLATION
-
-To install this module, run the following commands:
-
-	perl Build.PL
-	./Build
-	./Build test
-	./Build install
-
-SUPPORT AND DOCUMENTATION
-
-After installing, you can find documentation for this module with the
-perldoc command.
-
-    perldoc WebService::BitBucket
-
-You can also look for information at:
-
-    RT, CPAN's request tracker (report bugs here)
-        http://rt.cpan.org/NoAuth/Bugs.html?Dist=WebService-BitBucket
-
-    AnnoCPAN, Annotated CPAN documentation
-        http://annocpan.org/dist/WebService-BitBucket
-
-    CPAN Ratings
-        http://cpanratings.perl.org/d/WebService-BitBucket
-
-    Search CPAN
-        http://search.cpan.org/dist/WebService-BitBucket/
-
-
-LICENSE AND COPYRIGHT
-
-Copyright (C) 2012 Marcin Kasperski
-
-This program is free software; you can redistribute it and/or modify it
-under the terms of either: the GNU General Public License as published
-by the Free Software Foundation; or the Artistic License.
-
-See http://dev.perl.org/licenses/ for more information.
-

examples/.todo

Empty file added.
+# -*- coding: utf-8 -*-
+
+"""
+Updating version number on "hg tag".
+
+To use:
+
+  [hooks]
+  pre-tag=python:version_hook.py:version_update
+
+Note: pre-tag, not pretag! In the latter the changeset being tagged
+is already set.
+"""
+
+VERSION = "0.1001"
+
+UPDATED_FILES = [
+    "lib/WebService/BitBucket.pm",
+    ]
+
+def _patch_perl_files(ui, new_version_no):
+    """
+    Patches all perl files to new version number, returns modified files.
+    """
+    import os, re
+    version_regexps = [
+        re.compile(r"^(?P<pfx>our +\$VERSION *= *').*?(?P<sfx>'.*)$"),
+        re.compile(r"^(?P<pfx>Version +)\d+\.\d+(\.\d+)?(?P<sfx>\.? *)$"),
+        ]
+
+    location = os.path.dirname(__file__)
+    updated_files = []
+    for candidate in UPDATED_FILES:
+        full_name = os.path.join(location, candidate)
+        changes = 0
+        file_lines = []
+        ui.note("Checking file %s\n" % candidate)
+        with open(full_name, "r") as input:
+            for line in input.readlines():
+                m = None
+                for rgxp in version_regexps:
+                    m = rgxp.search(line)
+                    if m:
+                        ui.note("Patching line %s" % line)
+                        break
+                if m:
+                    file_lines.append(
+                        m.group('pfx') + new_version_no + m.group('sfx') + "\n")
+                    changes += 1
+                else:
+                    file_lines.append(line)
+        if changes:
+            ui.status("Version updater: Replacing old version number with {0:>s} in {1}\n".format(new_version_no, full_name))
+            with open(full_name, "w") as output:
+                output.writelines(file_lines)
+            updated_files.append(full_name)
+    return updated_files
+    
+def version_update(repo, ui, hooktype, pats, opts, **kwargs):
+    """
+    Method used in mercurial version-update hook. Don't call directly.
+    """
+    import re
+    import mercurial.commands
+
+    # Regexps for handled version number syntaxes
+    tag_regexps = [
+        # something_1-2, something-1.2 and similar
+        re.compile(r"[^-_0-9][-_](?P<major>[0-9]+)[-_\.](?P<minor>[0-9]+)$"),
+        # 1.2, 1-2, 1_2
+        re.compile(r"^(?P<major>[0-9]+)[-_\.](?P<minor>[0-9]+)$"),
+        ]
+
+    if opts.get('local'):
+        ui.note("Version updater: ignoring local tag\n")
+        return
+    if opts.get('remove'):
+        ui.note("Version updater: ignoring tag removal\n")
+        return
+    if opts.get('rev'):
+        ui.note("Version updater: ignoring tag placed by rev\n")
+        return
+
+    if len(pats) != 1:
+        ui.warn("Version updater: unexpected arguments, pats=%s\n" % pats)
+        return True # means fail
+
+    tag_name = pats[0]
+
+    version_no = None
+    for tag_regexp in tag_regexps:
+        m = tag_regexp.search(tag_name)
+        if m:
+            version_no = "{major:>s}.{minor:>s}".format(**m.groupdict())
+            break
+    if not version_no:
+        ui.warn("Version updater: Given tag does not seem to be versioned. Please make proper tags (1.2, xxxx_1-2, xaear-aera-1.2 or similar\n")
+        return True # means fail
+
+    if version_no == VERSION:
+        ui.note("Version updater: version number {0:>s} is already correct\n".format(version_no))
+        return False # means OK
+
+    # Regexp for VERSION= line
+    py_version_regexp = re.compile(r"^VERSION *= *")
+
+    my_name = __file__
+    if my_name.endswith(".pyc") or my_name.endswith(".pyo"):
+        my_name = my_name[:-1]
+
+    ui.status("Version updater: Replacing old version number {0:>s} with {1:>s} in {2}\n".format(
+        VERSION, version_no, my_name))
+
+    file_lines = []
+    changes = 0
+    with open(my_name, "r") as input:
+        for line in input.readlines():
+            if py_version_regexp.search(line):
+                file_lines.append('VERSION = "%s"\n' % version_no)
+                changes += 1
+            else:
+                file_lines.append(line)
+    if not changes:
+        ui.warn("Version updater: Line starting with VERSION= not found in {0:>s}.\nPlease correct this file and retry\n".format(my_name))
+        return True #means fail
+    with open(my_name, "w") as output:
+        output.writelines(file_lines)
+
+    updated_perl_files = _patch_perl_files(ui, version_no)
+
+    ui.note("Commiting updated version number\n")
+    mercurial.commands.commit(
+        ui, repo,
+        my_name,
+        *updated_perl_files,
+        message="Version number set to %s" % version_no)
+    return False #means ok