[
  {
    "path": ".gitignore",
    "content": "*.gem\n*.swp\nrdoc/\npkg/\n"
  },
  {
    "path": ".rvmrc",
    "content": "rvm use --create default@ticgit\n"
  },
  {
    "path": "LICENSE_GPL",
    "content": "This license applies ONLY to code authored by Jeff Welling. All\nother code contributions until now have been under the MIT license.\nTo see the MIT license, see the LICENSE_MIT file.\nFor information on how to find out which code was authored by whom,\nsee http://www.kernel.org/pub/software/scm/git/docs/git-blame.html\n\n\n                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<http://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<http://www.gnu.org/philosophy/why-not-lgpl.html>.\n"
  },
  {
    "path": "LICENSE_MIT",
    "content": "The MIT License\n\nPortions, Copyright (c) 2008 Scott Chacon\nOther portions, Copyright (c) 2011 Jeff Welling\nOther portions, Copyright of their respective authors.\n\nThis MIT license and notice pertains ONLY to code NOT authored by Jeff Welling. \nContributions by Jeff Welling are licensed under GPLv3, a copy of \nwhich is included with the source code.  For information on determining \nwhich code was authored by whom, see \nhttp://www.kernel.org/pub/software/scm/git/docs/git-blame.html\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "README.mkd",
    "content": "## TicGit-ng ##\n\nThis project provides a ticketing system built on Git that is kept in a\nseparate branch in your projects Git repository. Originally called TicGit,\nit is now known as TicGit-ng to continue development and avoid namespace\nclashes.\n\n### About ###\n\nTicGit-ng is a simple ticketing system, roughly similar to the Lighthouse model, that is based in git. It provides a command line client that uses the ‘git’ gem to keep its ticketing information in a separate branch (called ‘ticgit-ng’) within your existing git repository. All the data is file based and rarely changing, decreasing the likelihood of a merge issue. Right now, ticket branch merges need to be done manually and separately, but work is being done on a `ti sync` command to make this easier and more intuitive.\n\nThe idea is that it keeps your tickets in the same repository, but without mucking up your working tree. By using its own seperate branch to store its information it keeps the working trees in all your other branches untouched.\n\nThere are two interfaces available, the command line `ti` command and the `ticgitweb` web interface, though `ticgitweb` has many more prerequisites than `ti`.\n\nIt will automatically create the new branch the first time you use it, and it caches all the data (another working directory and index file) in your ~/.ticgit-ng directory by default. If you delete that directory, it will just create it again the next time, you will lose no data (except some of your saved preferences).\n\nTicGit-ng is currently using itself to store its feature requests and bug reports.\n\n### Prerequisites ###\n\nThere are two sets of prerequisites, those for people who intend to just run `ti`, and another set for those who wish to run `ticgitweb` as well. `ticgitweb` has additional dependancies that aren't required for `ti`'s use.\n\n**ti**\n\nRequired Packages: git, ruby, rubygems\n\nRequired Ruby Gems: git\n\nTo install these packages on a Debian system, or a Debian based system like Ubuntu, do\n\n    sudo aptitude install git ruby rubygems\n    sudo gem install git\n\n**ticgitweb**\n\nRequired Packages: git, ruby, rubygems\n\nRequired Ruby Gems: git, sinatra, haml, sass\n\nTo install these packages on a Debian system, or a Debian based system like Ubuntu, do\n\n    sudo aptitude install git ruby rubygems\n    sudo gem install git sinatra haml sass\n\n\n\n\n**A Note about rubygems**\n\nWhile the version of rubygems available from the repositories on Debian 5.0.5 stable will work just fine for using the command line `ti` program, using `ticgitweb` requires some extra effort.\nOlder versions of rubygems, such as the one available on Debian 5.0.5, will not work out of the box with the new gem repositories because the .deb in stable relies on rubyforge rather than rubygems for its operations. See [this bug](http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=558251) for an example. If you are running an older version of rubygems, you may need to get the latest rubygems package from http://rubygems.org/ or [apt](http://jaqque.sbih.org/kplug/apt-pinning.html) [pinning](http://jeffwelling.github.com//2010/09/05/Apt-Pinning.html) before being able to properly install the git and ticgit gems.\n\n**A Note About The Git Gem**\n\nThe git gem requires a git version of 1.6.0.0 or later, but on Debian stable, git-core is currently (Sept 6th 2010) at 1.5.6.5.  This isn't a fatal problem and we can continue using version 1.5.6.5 with the git gem, but you will see notices like this if you do\n\n    [WARNING] The git gem requires git 1.6.0.0 or later, but only found 1.5.6.5. You should probably upgrade.\n    Please specify at least one action to execute.\n\nIf these annoy you as they do me and you've set up [apt](http://jaqque.sbih.org/kplug/apt-pinning.html) [pinning](http://jeffwelling.github.com//2010/09/05/Apt-Pinning.html), you can do\n\n    $ sudo aptitude -t testing install git-core\n\nAnd those notices should go away.\n\n**A Note About Coloured Git Output**\n\nIf you use `[color] ui = always` instead of `[color] ui = true` then you will encounter a problem with the deprecated git gem parsing the color codes. Because it doesn't strip the color codes before parsing the output, it chokes and makes everything explode. \n\nSince time spent working on monkeypatching the git gem would soon be rendered fruitless by the eventual planned upgrade away from it, for the time being the suggested solution is to use `[color] ui = true`. \n\n### Installing ##\nInstallation on a Debian stable system.  Note that the command line interface for TicGit-ng can be run from Debian stable, but some of the gems required for the web interface may require you to use [apt](http://jaqque.sbih.org/kplug/apt-pinning.html) [pinning](http://jeffwelling.github.com//2010/09/05/Apt-Pinning.html) to run without errors.  See below\n\nTo install TicGit-ng on your system, you can go one of two ways,\n\n    $ gem install TicGit-ng\n\nor, you can install it from source by downloading this repository building your own gem (see below).\n\n### Usage ###\n\nTo get a list of all commands with short description:\n\n    > ti --help\n    Usage: ti COMMAND [FLAGS] [ARGS]\n     \n    Options for help command:\n     \n    The available TicGit-ng commands are:\n        recent                           List recent activities\n        checkout                         Checkout a ticket\n        tag                              Modify tags of a ticket\n        comment                          Comment on a ticket\n        milestone                        List and modify milestones\n        assign                           Assings a ticket to someone\n        points                           Assign points to a ticket\n        state                            Change state of a ticket\n        show                             Show a ticket\n        new                              Create a new ticket\n        attach                           Attach file to ticket\n        list                             List tickets\n     \n    Common options:\n        -v, --version                    Show the version number\n        -h, --help                       Display this help\n    \"help\" is not a command\n\n\nTo get help about a specific command:\n\n    > ti <command> --help\n    ## for example\n    > ti assign --help\n    Usage: ti assign [options] [ticket_id]\n     \n    Options for assign command:\n        -c, --checkout TICKET            Checkout this ticket\n        -u, --user USER                  Assign the ticket to this user\n     \n    Common options:\n        -v, --version                    Show the version number\n        -h, --help                       Display this help\n\n\nThe available commands are:\n\n    ti list     - show all tickets\n    ti show     - show details of a specific ticket\n    ti new      - create a new ticket\n    ti checkout - checkout a ticket\n    ti state    - change a ticket state (open, resolved, invalid, hold)\n    ti comment  - add a comment to a ticket\n    ti tag      - add or delete a tag from a ticket\n    ti assign   - change to whom a ticket is assigned\n\n\n### Usage Examples ###\n\nThe first time you use any command in Ticgit-ng, it will create a new branch in your repo called ‘ticgit-ng’ and setup a caching area in ~/.ticgit-ng.\n\nIf you run it without arguments, it will tell you what is available to run\n\n    $ ti\n    Please specify at least one action to execute.\n\n    Usage: ti COMMAND [FLAGS] [ARGS]\n     \n    The available TicGit-ng commands are:\n        recent                           List recent activities\n        checkout                         Checkout a ticket\n        tag                              Modify tags of a ticket\n        comment                          Comment on a ticket\n        milestone                        List and modify milestones\n        assign                           Assings a ticket to someone\n        points                           Assign points to a ticket\n        state                            Change state of a ticket\n        show                             Show a ticket\n        new                              Create a new ticket\n        attach                           Attach file to ticket\n        list                             List tickets\n     \n    Common options:\n        -v, --version                    Show the version number\n        -h, --help                       Display this help\n\nThe first time you run `ti list`, it will show an empty list.\n\n    $ ti list\n    I, [2010-09-06T15:47:52.075485 #4820]  INFO -- : creating ticgit repo branch\n\n       TicId  Title                             State Date  Assgn    Tags                \n    -----------------------------------------------------------------------------------------\n\nTo add a new ticket you can use `ti new -t 'Title of ticket'` and give it a title in one command line.\n\n    $ ti new -t 'my new ticket'\n    $ ti list\n\n       TicId  Title                             State Date  Assgn    Tags                \n    -----------------------------------------------------------------------------------------\n       d7f2d8 my new ticket                     open  09/06 \n\nFor the ‘comment’ and ‘new’ commands, if you don’t specify a ‘-m’ for the message, it puts you into $EDITOR  to write it. The ‘new’ action is especially useful with this, because you can also tag it and give it an initial comment when you create it this way:\n\n    \n    # ---\n    # tags:\n    # # first line will be the title of the tic, the rest will be the first comment\n    # # if you would like to add initial tags, put them on the 'tags:' line, comma delim\n    #\n\nTo edit a ticket, such as assigning a tag to the new ticket we created, we first checkout the ticket and then use `ti tag`.\nAlways checkout the ticket you intend to edit.  Some commands allow you to include a tic_id argument but that can get confusing to keep track of and most of the time several edits will be done to the same ticket anyway, so it is suggested you use `ti checkout` for convenience if nothing else.\n\n    #ti checkout can checkout tickets based on the TicId or based on it's place in the list\n    $ ti checkout 1\n    #checks out the first ticket, or to do the same thing by using the TicId\n    $ ti checkout d7f2d8\n    #then assign the tag\n    $ ti tag 'bug'\n    #and view the result..\n    $ ti list\n\n       TicId  Title                                           State Date  Assgn    Tags                \n    -------------------------------------------------------------------------------------------------------\n    *  d7f2d8 my new ticket                                   open  09/06          bug               \n\n\nTo assign the ticket to someone, use the `ti assign` command.  I assign the ticket to myself below.\n\n    $ ti assign -u 'jeff.welling@gmail.com'\n    $ ti list\n\n       TicId  Title                                              State Date  Assgn    Tags                \n    ----------------------------------------------------------------------------------------------------------\n    *  d7f2d8 my new ticket                                      open  09/06 jeff.we… bug  \n\n\nTo change the state of a ticket, such as to change it from 'open' to 'hold' or 'resolved', use `ti state`. There are 4 valid states: hold, invalid, open, and resolved.\n\n    $ ti state hold\n    $ ti list\n\n       TicId  Title                                              State Date  Assgn    Tags                \n    ----------------------------------------------------------------------------------------------------------\n\n*Dramatic Gasp!*\nWhere did all of our tickets go?  Don't worry, this isn't a bug and your tickets aren't gone.  \n\n    $ ti list --states open,hold\n\n       TicId  Title                                              State Date  Assgn    Tags                \n    ----------------------------------------------------------------------------------------------------------\n    *  d7f2d8 my new ticket                                      hold  09/06 jeff.we… bug                 \n\nBy default `ti list` doesn't show tickets with a state of 'hold', so we have to specify that we want to see those tickets with an argument.  Now you can see, out `ti state hold` command changed the state of that ticket to on hold. This can also be done without checking out the ticket by using `ti state 1 hold`.\n\nWhere ticgit expects a ticket id, it will take either the number of the ticket on the last ‘list’ you did, or it will take the partial sha each ticket is assigned when it is created – that number never changes for the life of the ticket, even across repositories, so you can email that number to someone else working on the project so they can identify it. If nothing is specified, it will use the currently checked out ticket.\n\n    $ ti comment -m \"I'm a new comment\"\n    $ ti show\n    Title: my new ticket\n    TicId: d7f2d8f6d6ec3da1a1800a33fb090d590a533bac\n\n    Assigned: jeff.welling@gmail.com\n    Opened: Mon Sep 06 15:52:03 -0700 2010 (0 days)\n    State: OPEN\n    Points: no estimate\n    Tags: bug\n\n    Comments (1):\n      * Added 09/06 18:34 by jeff.welling@gmail.com\n      I'm a new comment\n\n`ti show` also has a '-f' argument to be able to see comments that are longer than 3 lines, which would normally be truncated.\n\nThe `ti list` command can also be sorted and filtered.\n\n    $ ti list --help\n    Usage: ti list [options]\n     \n    Options for list command:\n        -l, --list                       Show the saved queries\n        -S, --saveas SAVENAME            Save this list as a saved name\n        -a, --assigned ASSIGNED          List only tickets assigned to someone\n        -s, --states STATE[,STATE]       List only tickets in a specific state(s)\n                                         Prefix the state with '-' to negate\n        -t, --tags TAG[,TAG]             List only tickets with specific tag(s)\n                                         Prefix the tag with '-' to negate\n        -o, --order ORDER                Field to order by - one of : assigned,state,date,title\n     \n    Common options:\n        -v, --version                    Show the version number\n        -h, --help                       Display this help\n\nSo if you wanted to see a list of all your tickets that have the ‘feature’ tag, assigned to ‘jeff.welling@gmail.com’ and are ‘open’, ordered by date opened descending, and save that view as ‘not_mine’, you can run this:\n\n    $ ti list -t feature -s open -a jeff.welling@gmail.com -o date.desc -S not_mine\n\nThen if you want to later list tickets with the same options as you used above, use\n\n    $ ti list not_mine\n\n## Collaboration ##\n\nIf you have cloned a repository and would like to get the ticgit-ng branch for that repo (presuming they have one), do this.\n\n    $git branch ticgit-ng origin/ticgit-ng\n\nThis will create a ticgit-ng branch in your local repo based on the ticgit-ng branch in origin.  Now you can run `ti list` and it will show you the ticgit-ng tickets for that repository.\n\n### Getting the TicGit-ng ticgit-ng branch ##\n\nTo download your own copy of the TicGit-ng ticgit branch after cloning the repo, so that you can add or alter a bug yourself, follow these instructions.\n\nThis will checkout a ticgit-ng branch and set it to track the ticgit-ng branch upstream in origin, and then checks out the master branch.  You must checkout the master branch because TicGit-ng gets confused if you are already in the ticgit-ng branch when running TicGit-ng.\n\n    $ git checkout origin/ticgit-ng\n    $ git checkout -b ticgit-ng\n    $ git checkout master\n\nThis will show you all of the bugs in TicGit-ng's ticgit-ng branch.\n\n    $ ti list\n\nTo submit your changes back to the upstream maintainer, push the bugs in your ticgit-ng branch to your public repo on Github\n    \n    $ git push origin ticgit-ng\n\nThen contact the upstream maintainer by sending a Pull Request or Email and ask them to review and accept your bug changes.\n\n### Sharing your tickets with others ###\n\nSharing your ticgit tickets with other people is as easy as asking them either creating their ticgit-ng branch based on yours if they haven't already started their own ticgit-ng branch, or pulling your ticgit-ng branch into theirs.\n\nIf you host your repositories on [Github](http://www.github.com) as I do then this process is simplified some because you don't have to worry about hosting your repository somewhere where other people can access it to pull your ticgit-ng branch.\n\nFor example, when I want my friend wnight to have the changes I made to my tickets in my ticgit-ng repository, I do a\n\n    $ git push origin\n\nto update all my remote branches with my current ones, and then I ask him to do a\n\n    $ git checkout ticgit-ng\n    $ git pull git@github.com:jeffWelling/ticgit.git ticgit-ng\n    $ git checkout master\n\nto pull my changes into his ticgit-ng branch and then switch back to his master branch.  Now when he does `ti list` it will show the changes I made to the tickets on my system.\n\n\n### Incorporating other peoples changes into your ticgit-ng branch ###\n\nThe process is much the same as above, except the rolls are reversed.  Once you know they have published their changes and you have a URL to do a git pull from, you simply do\n\n    $ git checkout ticgit-ng\n    $ git pull SOURCE_URL ticgit-ng\n    $ git checkout master\n\nReplacing SOURCE_URL with the URL you were told to pull from, now you can see the changes they made, in your ticgit-ng branch.  You can easily publish these changes with a `git push origin` so anyone following your work can also see these changes.\n\n\n### Next generation collaboration ###\n\nChanges made by [Bruno Santos](http://github.com/pheres) to add a [`ti sync`](http://github.com/jeffWelling/ticgit/commit/7388386fab4fb12c36e6eeb7d19eaa4e4b16b853) command were integrated on February 15th 2011.  You can now use the `ti sync [options]` command to sync your tickets with anyone else you've added with `git remote add`.  To use `ti sync`, all you need to do is first make sure you've already added the remote source with `git remote add`, and then do\n\n    $ ti sync --repo REMOTE_SOURCE\n\nif you want to pull their tickets into your ticgit-ng branch *and* push your tickets to their ticgit-ng branch, or\n\n    $ ti sync --repo REMOTE_SOURCE --no-push\n\nif you want to pull their tickets into your ticgit-ng branch without pushing your tickets to their branch.\n\nMore information on using ti sync can be gleemed from reviewing the [merge specs](https://github.com/jeffWelling/ticgit/blob/deving/spec/merging_spec.rb)\n\n### Ticgitweb ###\n\nTo run the Sinatra enabled web UI for your TicGit-ng repo, simply cd to your repository and run 'ticgitweb', or 'ticgitweb -p 3456' to change the port to something other than '4567', which is the Sinatra default.\n\nHere is what the Ticket listing looks like:\n\n<a href=\"http://www.flickr.com/photos/chacon/2359042481/\" title=\"TicGitWeb Ticket List by schacon, on Flickr\"><img src=\"http://farm4.static.flickr.com/3289/2359042481_065867a92e.jpg\" width=\"500\" height=\"258\" alt=\"TicGitWeb Ticket List\" /></a>\n\nAnd here is an individual ticket:\n\n<a href=\"http://www.flickr.com/photos/chacon/2359042513/\" title=\"TicGitWeb Ticket by schacon, on Flickr\"><img src=\"http://farm4.static.flickr.com/3240/2359042513_6d4bd069d0.jpg\" width=\"500\" height=\"275\" alt=\"TicGitWeb Ticket\" /></a>\n\n\n## Development ##\n\nThe original author had used rspec to write specs for ticgit-ng, but one of the maintainers since then switched it over to bacon[[1](http://www.ruby-forum.com/topic/137928)][[2](http://www.ruby-forum.com/topic/172139)][[3](http://testanything.org/wiki/index.php/Testing_with_Ruby)] and I haven't been too inclined to switch it back.\n\n### Prerequisites ###\n\nTo install the prerequisites on Debian stable for testing ticgit-ng, you will need [apt](http://jaqque.sbih.org/kplug/apt-pinning.html) [pinning](http://jeffwelling.github.com//2010/09/05/Apt-Pinning.html).\n\n    $ sudo aptitude -t testing install rubygems rake\n    $ sudo gem install yard bacon\n\nI pull rubygems from testing to avoid a problem with gherkin creating a syntactically incorrect gemspec which makes a lot of noise whenever `gem` is called. I ran into a problem when gem was installing yard, it had a problem with the documentation but thankfully the error wasn't fatal and was only about not being able to compile the documentation which I don't use, so it continued without trouble.\n\n\n### How To Test ###\n\nTo test your version of ticgit-ng, go to your ticgit-ng directory and run\n\n    rspec spec/*_spec.rb\n\n### How to generate a gem from your development copy of ticgit-ng ###\n\nTo create a gem from your development copy of ticgit-ng, go to your ticgit-ng directory and do\n\n    rake gem\n\nThis will create a pkg/ directory, which will contain a newly created ticgit-ng gem for you to install.\n\nMore information on developing TicGit-ng and collaborating with other TicGit-ng developers at [here](https://github.com/jeffWelling/ticgit/wiki/Development)\n\nMore information on developing TicGit-ng and collaborating with other TicGit-ng developers at [here](https://github.com/jeffWelling/ticgit/wiki/Development)\n\n### Alternatives ###\n\nditz \nbugs everywhere\ngit-issues\n\n\n## Authors ##\n\nOriginal Author:\nScott Chacon                (schacon@gmail.com)\n\nCurrent Active Maintainer:\nJeff Welling                (jeff.welling@gmail.com)\n\nFor a detailed list of contributors, use `git log`.\n"
  },
  {
    "path": "Rakefile",
    "content": "require 'rubygems'\nrequire 'rake'\nrequire 'rake/clean'\nrequire 'rake/rdoctask'\nrequire 'rspec/core/rake_task'\n\nCLEAN.include('**/*.gem')\n\ndesc \"Creates the TicGit-ng gem\"\ntask :create_gem => [:clean] do\n  spec = eval(IO.read('ticgit-ng.gemspec'))\n  gem = Gem::Builder.new(spec).build\n  Dir.mkdir(\"pkg\") unless Dir.exists? \"pkg\"\n  FileUtils.mv(\"#{File.dirname(__FILE__)}/#{gem}\", \"pkg\")\nend\n\ndesc \"Runs spec suite\"\nRSpec::Core::RakeTask.new(:spec) do |spec|\n  spec.pattern = 'spec/*_spec.rb'\n  spec.rspec_opts = ['--backtrace --colour']\nend\n\ndesc \"Creates rdoc documentation\"\nRake::RDocTask.new do |rdoc|\n  version = File.exist?('VERSION') ? File.read('VERSION').chomp : \"\"\n  rdoc.rdoc_dir = 'rdoc'\n  rdoc.title = \"TicGit-ng #{version}\"\n  rdoc.rdoc_files.include('README*')\n  rdoc.rdoc_files.include('lib/**/*.rb')\nend\n\ntask :default => :create_gem\n"
  },
  {
    "path": "bin/ti",
    "content": "#!/usr/bin/env ruby\nrequire 'rubygems'\nrequire 'fileutils'\n\n# Add the library from the source tree to the front of the load path.\n# This allows ti to run without first installing a ticgit gem, which is\n# important when testing multiple branches of development.\nif File.exist? File.join('lib', 'ticgit-ng.rb')\n    $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')\nend\nrequire 'ticgit-ng'\n\nTicGitNG::CLI.execute\n"
  },
  {
    "path": "bin/ticgitweb",
    "content": "#!/usr/bin/env ruby\n\n# starts a sinatra based web server that provides an interface to \n# your ticgit tickets\n# \n# some of the sinatra code borrowed from sr's git-wiki\n#\n# author : Scott Chacon (schacon@gmail.com)\n#\n\n# Add the library from the source tree to the front of the load path.\n# This allows ticgitweb to run without first installing a ticgit gem,\n# which is important when testing multiple branches of development.\n$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')\n\n%w(rubygems sinatra git ticgit-ng haml sass).each do |dependency|\n  begin\n    require dependency\n  rescue LoadError => e\n    puts \"You need to install #{dependency} before we can proceed\"\n  end\nend\n\n#This line is required to resolve this issue\n#https://github.com/jeffWelling/ticgit/issues/22\nenable :run\n\n# !! TODO : if ARGV[1] is a path to a git repo, use that\n# otherwise, look in ~/.ticgit\n\n$ticgit = TicGitNG.open('.')\n\nget('/_stylesheet.css') { Sass::Engine.new(File.read(__FILE__).gsub(/.*__END__/m, '')).render }\n\n# ticket list view\nget '/' do\n  @tickets = $ticgit.ticket_list(:order => 'date.desc')\n  haml(list('all'))\nend\n\nget '/fs/:state' do\n  @tickets = $ticgit.ticket_list(:state => params[:state], :order => 'date.desc')\n  haml(list(params[:state]))\nend\n\nget '/tag/:tag' do\n  @tickets = $ticgit.ticket_list(:tag => params[:tag], :order => 'date.desc')\n  haml(list(params[:tag]))\nend\n\nget '/sv/:saved_view' do\n  @tickets = $ticgit.ticket_list(:saved => params[:saved_view])\n  haml(list(params[:saved_view]))\nend\n\n# ticket single view\nget '/ticket/:ticket' do\n  @ticket = $ticgit.ticket_show(params[:ticket])\n  haml(show)\nend\n\n\n# add ticket\nget '/t/new' do\n  haml(new_ticket)\nend\n\n# add ticket finalize\npost '/t/new' do\n  title = params[:title].to_s.strip\n  if title.size > 1\n    tags = params[:tags].split(',').map { |t| t.strip } rescue nil  \n    t = $ticgit.ticket_new(title, {:comment => params[:comment].strip, :tags => tags})\n    redirect '/ticket/' + t.ticket_id.to_s\n  else\n    redirect '/t/new'\n  end\nend\n\n\n# add comment\npost '/a/add_comment/:ticket' do\n  t = $ticgit.ticket_comment(params[:comment], params[:ticket])\n  redirect '/ticket/' + params[:ticket]\nend\n\n# add tag\npost '/a/add_tags/:ticket' do\n  t = $ticgit.ticket_tag(params[:tags], params[:ticket])\n  redirect '/ticket/' + params[:ticket]\nend\n\n# change ticket state\nget '/a/change_state/:ticket/:state' do\n  $ticgit.ticket_change(params[:state], params[:ticket])\n  redirect '/ticket/' + params[:ticket]\nend\n\n\ndef layout(title, content)\n  @saved = $ticgit.config['list_options'].keys rescue []\n  %Q(\n%html\n  %head\n    %title #{title}\n    %link{:rel => 'stylesheet', :href => '/_stylesheet.css', :type => 'text/css', :media => 'screen'}\n    %meta{'http-equiv' => 'Content-Type', :content => 'text/html; charset=utf-8'}\n\n  %body\n    #navigation\n      %a{:href => '/'} All\n      %a{:href => '/fs/open'} Open\n      %a{:href => '/fs/resolved'} Resolved\n      %a{:href => '/fs/hold'} Hold\n      %a{:href => '/fs/invalid'} Invalid\n      - if !@saved.empty?\n        | Saved:\n        - @saved.each do |s|\n          %a{:href => \"/sv/\\#{s}\"}= s\n    #action\n      %a{:href => '/t/new'} New Ticket\n\n    #{content}\n  )\nend\n\ndef new_ticket\n  layout('New Ticket', %q{\n    %h1 Create a New Ticket\n    %form{:action => '/t/new', :method => 'POST'}\n      %table\n        %tr\n          %th Title\n          %td \n            %input{:type => 'text', :name => 'title', :size => 30}\n        %tr\n          %th Tags\n          %td\n            %input{:name => 'tags', :size => 30}\n            %small (comma delimited)\n        %tr\n          %th Comment\n          %td \n            %textarea{:name => 'comment', :rows => 15, :cols => 30}\n        %tr\n          %td\n          %td\n            %input{:type => 'submit', :value => 'Create Ticket'}\n  })\nend\n\ndef list(title = 'all')\n  @title = title\n  layout(title + ' tickets', %q{\n    %h1= \"#{@title} tickets\"\n    - if @tickets.empty?\n      %p No tickets found.\n    - else\n      %table.long\n        - c = 'even'\n        - @tickets.each do |t|\n          %tr{:class => (c == 'even' ? c = 'odd' : c = 'even') }\n            %td\n              %a{:href => \"/ticket/#{t.ticket_id}\" }\n                %code= t.ticket_id[0,6]\n            %td&= t.title\n            %td{:class => t.state}= t.state\n            %td= t.opened.strftime(\"%m/%d\")\n            %td= t.assigned_name\n            %td\n              - t.tags.each do |tag|\n                %a{:href => \"/tag/#{tag}\"}= tag\n  })\nend\n\ndef show\n  layout('ticket', %q{\n  %center\n    %h1&= @ticket.title\n  \n    %form{:action => \"/a/add_tags/#{@ticket.ticket_id}\", :method => 'POST'}\n      %table\n        %tr\n          %th TicId\n          %td\n            %code= @ticket.ticket_id\n        %tr\n          %th Assigned\n          %td= @ticket.assigned\n        %tr\n          %th Opened\n          %td= @ticket.opened\n        %tr\n          %th State\n          %td{:class => @ticket.state}\n            %table{:width => '300'}\n              %tr\n                %td{:width=>'90%'}= @ticket.state\n                - $ticgit.tic_states.select { |s| s != @ticket.state}.each do |st|\n                  %td{:class => st}\n                    %a{:href => \"/a/change_state/#{@ticket.ticket_id}/#{st}\"}= st[0,2]\n        %tr\n          %th Tags\n          %td\n            - @ticket.tags.each do |t|\n              %a{:href => \"/tag/#{t}\"}= t\n            %div.addtag\n              %input{:name => 'tags'}\n              %input{:type => 'submit', :value => 'add tag'}\n    \n    %h3 Comments\n    %form{:action => \"/a/add_comment/#{@ticket.ticket_id}\", :method => 'POST'}\n      %div\n        %textarea{:name => 'comment', :cols => 50}\n        %br\n        %input{:type => 'submit', :value => 'add comment'}\n        \n    %div.comments\n      - @ticket.comments.reverse.each do |t|\n        %div.comment\n          %span.head\n            Added\n            = t.added.strftime(\"%m/%d %H:%M\")\n            by\n            = t.user\n          %div.comment-text\n            = t.comment\n        %br\n  })\nend\n\n__END__\nbody\n  :font\n    family: Verdana, Arial, \"Bitstream Vera Sans\", Helvetica, sans-serif\n    color: black\n  line-height: 160%\n  background-color: white\n  margin: 2em\n\n#navigation\n  a\n    background-color: #e0e0e0\n    color: black\n    text-decoration: none\n    padding: 2px\n  padding: 5px\n  border-bottom: 1px black solid\n  \n#action\n  text-align: right\n  \n.addtag\n  padding: 5px 0\n  \nh1\n  display: block\n  padding-bottom: 5px\n\na\n  color: black\na.exists\n  font-weight: bold\na.unknown\n  font-style: italic\n\n.comments\n  margin: 10px 20px\n  .comment\n    .head\n      background: #eee\n      padding: 4px\n    .comment-text\n      padding: 10px\n      color: #333\n  \ntable.long\n  width: 100%\n  \ntable\n  tr.even\n    td\n      background: #eee\n  tr.odd\n    td\n      background: #fff\n      \ntable\n  tr\n    th\n      text-align: left\n      padding: 3px\n      vertical-align: top\n    td.open\n      background: #ada\n    td.resolved\n      background: #abd\n    td.hold\n      background: #dda\n    td.invalid\n      background: #aaa  \n      \n.submit\n  font-size: large\n  font-weight: bold\n\n.page_title\n  font-size: xx-large\n\n.edit_link\n  color: black\n  font-size: 14px\n  font-weight: bold\n  background-color: #e0e0e0\n  font-variant: small-caps\n  text-decoration: none\n\n"
  },
  {
    "path": "development.mkd",
    "content": "## Development ##\n\nThis document describes workflows currently used for various tasks (and other shenanigans if necessary).\nI try to follow [this git flow](http://nvie.com/posts/a-successful-git-branching-model/). \n\n### Testing ###\n\nTo test:\n\n    rspec spec/*_spec.rb\n\n\n### Hotfixes ###\n\nTo create a hotfix:\n\n    git checkout master\n    git checkout -b hotfix-VERSION\n    #Edit lib/ticgit-ng/version.rb to bump the version number\n    #Apply your changes\n    git checkout master\n    git merge --no-ff hotfix-VERSION\n    git tag VERSION\n\n### Creating a gem ###\n\nTo create a gem:\n\n   gem build ticgit-ng.gemspec\n\nThis produces `TicGit-ng-VERSION.gem`.\nTo push the gem, you would do `gem push TicGit-ng-VERSION.gem` but this would require an account on Rubygems, and would also require renaming the gem due to namespace conflicts.\n\n### Testing ###\n\nI'm a firm believer in testing.  If you are submitting a patch or pull request, please do your absolute best to include a test. I will write the test myself if I can, but this increases the time it takes to get the patch included and published. In some circumstances it is fine to not include a patch, eg difficult to test problems.\n"
  },
  {
    "path": "examples/post-commit",
    "content": "#!/usr/bin/env ruby\n\nrequire 'tempfile'\n\n\ncommit_log   = `git log -1`.chomp\nm, commit_id = * commit_log.match(/commit\\W*([A-Fa-f0-9]+)/)\n\nTempfile.open('ticgit_comment') do |tmp|\n  tmp.write commit_log\n  actions = {}\n\n  # comment on any tickets this commit references\n  commit_log.scan(/\\(\\W*[Rr]efs?\\W*:*\\W*\\#([a-fA-F0-9]+)\\W*\\)/).each do |ticked_id|\n    actions[ticket_id] = :ref\n  end\n\n  # close any tickets this commit solves\n  # overwrite any refs, as the commit log will still\n  # be added to the ticket as a comment, but will also be closed\n  commit_log.scan(/\\(\\W*[Cc]loses\\W*:*\\W*\\#([a-fA-F0-9]+)\\W*\\)/).each do |ticket_id|\n    actions[ticket_id] = :close\n  end\n\n  actions.each do |ticket_id, action|\n    `ti comment #{ticket_id} --file #{tmp.path}` if action\n    `ti state #{ticket_id} resolved`             if action == :close\n  end\nend\n"
  },
  {
    "path": "lib/ticgit-ng/attachment.rb",
    "content": "module TicGitNG\n    class Attachment\n        attr_reader :user, :added, :filename, :sha, :attachment_name\n        attr_reader :original_filename\n        alias :read :initialize\n\n        def initialize( fname )\n            #FIXME expect fname to be a raw filename that needs to be converted\n            #      into a properly formatted ticket name\n            @filename=fname\n            trailing_underscore= File.basename(fname)[/_$/] ? true : false\n            trailing_underscore=false\n            temp=File.basename(fname).split('_').reverse\n            @added=Time.at(temp.pop.to_i)\n            @user= temp.pop\n            @attachment_name= temp.reverse.join('_')\n            if trailing_underscore\n              @attachment_name << '_'\n            end\n        end\n\n        #Called when attaching a new attachment and when reading/opening attachments\n        #FIXME Make a 'read' and 'create' function to differentiate between\n        #      between creation of a ticket and reading an existing ticket.\n        def self.create raw_fname, ticket, time \n            #Attachment naming format:\n            #ticket_name/ATTACHMENTS/123456_jeff.welling@gmail.com_fubar.jpg\n            #raw_fname \"/home/guy/Desktop/fubar.jpg\"\n\n            #create attachment dir if first run\n            a_name= File.expand_path( File.join(\n                File.join( ticket.ticket_name, 'ATTACHMENTS' ), \n                ticket.create_attachment_name(raw_fname, time)\n            ))\n            #create new filename from ticket\n            if File.exist?( File.dirname( a_name )  ) && \n               !File.directory?( File.dirname(a_name) )\n\n                puts \"Could not create ATTACHMENTS directory\"\n                exit 1\n            elsif !File.exist?( File.dirname( a_name ) )\n                Dir.mkdir File.dirname( a_name )\n            end\n            #copy/link the raw_filename\n            Dir.chdir( File.dirname(a_name) ) do\n                FileUtils.cp( raw_fname, a_name )\n            end\n            #call init on the new file to properly populate the variables\n            a_name= File.join( \n                              File.basename( File.dirname( a_name ) ),\n                              File.basename( a_name )\n                             )\n            return Attachment.new( a_name )\n        end\n    end\nend\n"
  },
  {
    "path": "lib/ticgit-ng/base.rb",
    "content": "module TicGitNG\n  class NoRepoFound < StandardError;end\n  class Base\n\n    attr_reader :git, :logger\n    attr_reader :tic_working, :tic_index, :tic_dir\n    attr_reader :last_tickets, :current_ticket  # saved in state\n    attr_reader :config\n    attr_reader :state, :config_file\n\n    def initialize(git_dir, opts = {})\n      @git = Git.open(find_repo(git_dir))\n\n      begin\n        git.lib.full_log_commits :count => 1\n      rescue\n        puts \"Git error: please check your git repository, you must have at least one commit in git\"\n        exit 1\n      end\n\n      @logger = opts[:logger] || Logger.new(STDOUT)\n\n      #This is to accomodate for edge-cases where @logger.puts\n      #is called from debugging code.\n      if @logger.respond_to?(:puts) && !@logger.respond_to?(:info)\n        @logger.class.class_eval do\n          alias :info :puts\n        end\n      elsif @logger.respond_to?(:info) && !@logger.respond_to?(:puts)\n        @logger.class.class_eval do\n          alias :puts :info\n        end\n      end\n         \n      @last_tickets = []\n      @init=opts[:init]\n\n      proj = Ticket.clean_string(@git.dir.path)\n\n      #Use this hack instead of git itself because this is ridiculously faster then\n      #getting the same information from git\n      branches= Dir.entries( File.join(find_repo(git_dir),'.git/refs/heads/') ).delete_if {|i|\n        i=='.' || i=='..'\n      }\n      branch= branches.include?('ticgit-ng') ? ('ticgit-ng') : ('ticgit')\n\n      @tic_dir = opts[:tic_dir] ||\"~/.#{branch}\"\n      @tic_working = opts[:working_directory] || File.expand_path(File.join(@tic_dir, proj, 'working'))\n      @tic_index = opts[:index_file] || File.expand_path(File.join(@tic_dir, proj, 'index'))\n\n      @last_tickets = []\n\n      #expire @tic_index and @tic_working if it mtime is older than \n      #git log.  Otherwise, during testing, if you use the same temp\n      #directory with the same name, deleting it and recreating it\n      #to test something, ticgit would get confused by the cache from\n      #the previous instance of the temp dir.\n      if File.exist?(@tic_working)\n        cache_mtime=File.mtime(@tic_working)\n        begin\n          gitlog_mtime= File.mtime(File.join( find_repo('.'), \".git/refs/heads/#{branch}\" ))\n        rescue\n          reset_cache\n        end\n\n        #unless (cache_mtime > gitlog_mtime.-(20) and cache_mtime <= gitlog_mtime) or (cache_mtime > gitlog_mtime.+(30) and cache_mtime >= gitlog_mtime)\n        #FIXME break logic out into several lines\n        #FIXME don't bother resetting if gitlog_mtime.to_i == 0\n        if needs_reset?( cache_mtime, gitlog_mtime ) and !cache_mtime==gitlog_mtime\n          puts \"Resetting cache\" unless gitlog_mtime.to_i == 0\n          reset_cache\n        end\n\n      end\n\n      # load config file\n      @config_file = File.expand_path(File.join(@tic_dir, proj, 'config.yml'))\n      if File.exists?(config_file)\n        @config = YAML.load(File.read(config_file))\n      else\n        @config = {}\n      end\n\n      @state = File.expand_path(File.join(@tic_dir, proj, 'state'))\n\n      unless branches.include?(branch) && File.directory?(@tic_working)\n        if branches.include?(branch) and !File.exist?(@tic_working)\n          #branch exists but tic_working doesn't\n          #this could be because the dir was deleted or the repo itself\n          #was moved, so recreate the dir.\n          reset_ticgitng\n        elsif @init\n          puts \"Initializing TicGit-ng\"\n          init_ticgitng_branch( branches.include?(branch) )\n        else\n          puts \"Please run `ti init` to initialize TicGit-ng for this repository before running other ti commands.\"\n          exit\n        end\n      end\n\n      if File.file?(@state)\n        load_state\n      else\n        reset_ticgitng\n      end\n    end\n\n    def find_repo(dir)\n      full = File.expand_path(dir)\n      ENV[\"GIT_WORKING_DIR\"] || loop do\n        return full if File.directory?(File.join(full, \".git\"))\n        raise NoRepoFound if full == full=File.dirname(full)\n      end\n    end\n\n    # marshal dump the internals\n    # save config file\n    def save_state\n      state_list = [@last_tickets, @current_ticket]\n      unless File.exist? @state\n        FileUtils.mkdir_p( File.dirname(@state) )\n      end\n      File.open(@state, 'w+'){|io| Marshal.dump(state_list, io) }\n      File.open(@config_file, 'w+'){|io| io.write(config.to_yaml) }\n    end\n\n    # read in the internals\n    def load_state\n      state_list = File.open(@state){|io| Marshal.load(io) }\n      garbage_data=nil\n      if state_list.length == 2\n        @last_tickets, @current_ticket = state_list\n      else\n        #This was left behind so that people can continue load_state-ing\n        #without having to delete their ~/.ticgit directory when\n        #updating to this version (rename to ticgit-ng)\n        garbage_data, @last_tickets, @current_ticket = state_list\n      end\n    end\n\n    # returns new Ticket\n    def ticket_new(title, options = {}, time=nil)\n      t = TicGitNG::Ticket.create(self, title, options, time)\n      reset_ticgitng\n      TicGitNG::Ticket.open(self, t.ticket_name, tickets[t.ticket_name])\n    end\n\n    #This is a legacy function from back when ticgit-ng needed to have its\n    #cache reset in order to avoid cache corruption.\n    def reset_ticgitng\n      tickets\n      save_state\n    end\n\n    # returns new Ticket\n    def ticket_comment(comment, ticket_id = nil)\n      if t = ticket_revparse(ticket_id)\n        ticket = TicGitNG::Ticket.open(self, t, tickets[t])\n        ticket.add_comment(comment)\n        reset_ticgitng\n        ticket\n      end\n    end\n\n    # returns array of Tickets\n    def ticket_list(options = {})\n      reset_ticgitng\n      ts = []\n      @last_tickets = []\n      @config['list_options'] ||= {}\n\n      tickets.to_a.each do |name, t|\n        ts << TicGitNG::Ticket.open(self, name, t)\n      end\n\n      if name = options[:saved]\n         if c = config['list_options'][name]\n           options = c.merge(options)\n         end\n      end\n\n      if options[:list]\n        # TODO : this is a hack and i need to fix it\n        config['list_options'].each do |name, opts|\n          puts name + \"\\t\" + opts.inspect\n        end\n        return false\n      end\n\n      if options.size == 0\n        # default list\n        options[:state] = 'open'\n      end\n\n      # :tag, :state, :assigned\n      if t = options[:tags]\n        t = {false => Set.new, true => Set.new}.merge t.classify { |x| x[0,1] != \"-\" }\n        t[false].map! { |x| x[1..-1] }\n        ts = ts.reject { |tic| t[true].intersection(tic.tags).empty? } unless t[true].empty?\n        ts = ts.select { |tic| t[false].intersection(tic.tags).empty? } unless t[false].empty?\n      end\n      if s = options[:states]\n        s = {false => Set.new, true => Set.new}.merge s.classify { |x| x[0,1] != \"-\" }\n        s[true].map! { |x| Regexp.new(x, Regexp::IGNORECASE) }\n        s[false].map! { |x| Regexp.new(x[1..-1], Regexp::IGNORECASE) }\n        ts = ts.select { |tic| s[true].any? { |st| tic.state =~ st } } unless s[true].empty?\n        ts = ts.reject { |tic| s[false].any? { |st| tic.state =~ st } } unless s[false].empty?\n      end\n      if a = options[:assigned]\n        ts = ts.select { |tic| tic.assigned =~ Regexp.new(a, Regexp::IGNORECASE) }\n      end\n\n      # SORTING\n      if field = options[:order]\n        field, type = field.split('.')\n\n        case field\n        when 'assigned'; ts = ts.sort_by{|a| a.assigned }\n        when 'state';    ts = ts.sort_by{|a| a.state }\n        when 'date';     ts = ts.sort_by{|a| a.opened }\n        when 'title';    ts = ts.sort_by{|a| a.title }\n        end\n\n        ts = ts.reverse if type == 'desc'\n      else\n        # default list\n        ts = ts.sort_by{|a| a.opened }\n      end\n\n      if options.size == 0\n        # default list\n        options[:state] = 'open'\n      end\n\n      # :tag, :state, :assigned\n      if t = options[:tag]\n        ts = ts.select { |tag| tag.tags.include?(t) }\n      end\n      if s = options[:state]\n        ts = ts.select { |tag| tag.state =~ /#{s}/ }\n      end\n      if a = options[:assigned]\n        ts = ts.select { |tag| tag.assigned =~ /#{a}/ }\n      end\n\n      if save = options[:save]\n        options.delete(:save)\n        @config['list_options'][save] = options\n      end\n\n      @last_tickets = ts.map{|t| t.ticket_name }\n      # :save\n\n      save_state\n      ts\n    end\n\n    # returns single Ticket\n    def ticket_show(ticket_id = nil)\n      # ticket_id can be index of last_tickets, partial sha or nil => last ticket\n      reset_ticgitng\n      if t = ticket_revparse(ticket_id)\n        return TicGitNG::Ticket.open(self, t, tickets[t])\n      end\n    end\n\n    # returns recent ticgit-ng activity\n    # uses the git logs for this\n    def ticket_recent(ticket_id = nil)\n      if ticket_id\n        t = ticket_revparse(ticket_id)\n        return git.log.object(which_branch?).path(t)\n      else\n        return git.log.object(which_branch?)\n      end\n    end\n\n    def ticket_revparse(ticket_id)\n      if ticket_id\n        ticket_id = ticket_id.strip\n\n        if /^[0-9]*$/ =~ ticket_id && (t = @last_tickets[ticket_id.to_i - 1])\n          return t\n        elsif ticket_id.length > 4 # partial (5 characters or greater to be considered unique enough) or full sha\n          regex = /^#{Regexp.escape(ticket_id)}/\n          ch = tickets.select{|name, t|\n            t['files'].assoc('TICKET_ID')[1] =~ regex }\n          ch.first[0] if ch.first\n        end\n      elsif(@current_ticket)\n        return @current_ticket\n      end\n    end\n\n    def ticket_tag(tag, ticket_id = nil, options = OpenStruct.new)\n      if t = ticket_revparse(ticket_id)\n        ticket = TicGitNG::Ticket.open(self, t, tickets[t])\n        if options.remove\n          ticket.remove_tag(tag)\n        else\n          ticket.add_tag(tag)\n        end\n        reset_ticgitng\n        ticket\n      end\n    end\n\n    def ticket_change(new_state, ticket_id = nil)\n      if t = ticket_revparse(ticket_id)\n        if tic_states.include?(new_state)\n          ticket = TicGitNG::Ticket.open(self, t, tickets[t])\n          ticket.change_state(new_state)\n          reset_ticgitng\n          ticket\n        end\n      end\n    end\n\n    def ticket_assign(new_assigned = nil, ticket_id = nil)\n      if t = ticket_revparse(ticket_id)\n        ticket = TicGitNG::Ticket.open(self, t, tickets[t])\n        ticket.change_assigned(new_assigned)\n        reset_ticgitng\n        ticket\n      end\n    end\n\n    def ticket_points(new_points = nil, ticket_id = nil)\n      if t = ticket_revparse(ticket_id)\n        ticket = TicGitNG::Ticket.open(self, t, tickets[t])\n        ticket.change_points(new_points)\n        reset_ticgitng\n        ticket\n      end\n    end\n\n    def ticket_checkout(ticket_id)\n      if t = ticket_revparse(ticket_id)\n        ticket = TicGitNG::Ticket.open(self, t, tickets[t])\n        @current_ticket = ticket.ticket_name\n        save_state\n        ticket\n      end\n    end\n\n    def tic_states\n      ['open', 'resolved', 'invalid', 'hold']\n    end\n\n    def sync_tickets(repo='origin', push=true, verbose=true )\n      puts \"Fetching #{repo}\" if verbose\n      @git.fetch(repo)\n      puts \"Syncing tickets with #{repo}\" if verbose\n      remote_branches=@git.branches.remote.map{|b|\n        b.full.gsub('remotes/', '')[Regexp.new(\"^#{Regexp.escape(repo)}/.*\")]\n      }.compact\n      remote_branches.include?(\"#{repo}/ticgit-ng\") ? r_ticgit='ticgit-ng' : r_ticgit='ticgit'\n      in_branch(false) do\n        repo_g=git.remote(repo)\n        git.pull(repo_g, repo+'/'+r_ticgit)\n        git.push(repo_g, \"#{which_branch?}:\"+r_ticgit ) if push\n        puts \"Tickets synchronized.\" if verbose\n      end\n    end\n\n    def tickets\n      read_tickets\n    end\n\n    def read_tickets\n      tickets = {}\n\n      tree = git.lib.full_tree(which_branch?)\n      tree.each do |t|\n        data, file = t.split(\"\\t\")\n        mode, type, sha = data.split(\" \")\n        tic = file.split('/')\n        if tic.size == 2  # directory depth\n            ticket, info = tic\n            tickets[ticket] ||= { 'files' => [] }\n            tickets[ticket]['files'] << [info, sha]\n        elsif tic.size == 3\n            ticket, attch_dir, filename = tic\n            if filename\n                filename = 'ATTACHMENTS_' + filename\n                tickets[ticket] ||= { 'files' => [] }\n                tickets[ticket]['files'] << [filename, sha]\n            end\n        end\n      end\n      tickets\n    end\n\n    def init_ticgitng_branch(ticgitng_branch = false)\n      @logger << 'creating ticgit-ng repo branch'\n\n      in_branch(ticgitng_branch) do\n        #The .hold file seems to have little to no purpose aside from helping\n        #figure out if the branch should be checked out or not.  It is created\n        #when the ticgit branch is created, and seems to exist for the lifetime\n        #of the ticgit branch. The purpose seems to be, to be able to tell if\n        #the ticgit branch is already checked out and not check it out again if\n        #it is.  This might be superfluous after switching to grit.\n        new_file('.hold', 'hold')\n\n        unless ticgitng_branch\n          git.add \".hold\"\n          git.commit('creating the ticgit-ng branch')\n        end\n      end\n    end\n\n    # temporarlily switches to ticgit branch for tic work\n    def in_branch(branch_exists = true)\n      needs_checkout = false\n\n      unless File.directory?(@tic_working)\n        FileUtils.mkdir_p(@tic_working)\n        needs_checkout = true\n      end\n      needs_checkout = true unless File.file?('.hold')\n\n      old_current = git.lib.branch_current\n      begin\n        git.lib.change_head_branch(which_branch?)\n        git.with_index(@tic_index) do\n          git.with_working(@tic_working) do |wd|\n            git.lib.checkout(which_branch?) if needs_checkout &&\n              branch_exists\n            yield wd\n          end\n        end\n      ensure\n        git.lib.change_head_branch(old_current)\n      end\n    end\n\n    def new_file(name, contents)\n      File.open(name, 'w+'){|f| f.puts(contents) }\n    end\n\n    def which_branch?\n      #At present use the 'ticgit' branch for backwards compatibility\n      branches=@git.branches.local.map {|b| b.name}\n      if branches.include? 'ticgit-ng'\n        return 'ticgit-ng'\n      else\n        return 'ticgit'\n      end\n\n      #If has ~/.ticgit dir, and 'ticgit' branch\n      #If has ~/.ticgit-ng dir, and 'ticgit-ng' branch, and not ~/.ticgit dir and not 'ticgit' branch\n    end\n\n    def reset_cache\n      #@state, @tic_index, @tic_working\n      #A rescue is appended to the end of each line because it allows\n      #execution of others to continue upon failure, as opposed to\n      #a begin;rescue;end segment.\n      FileUtils.rm_r File.expand_path(@tic_working) rescue nil\n      FileUtils.rm File.expand_path(@state) rescue nil\n      FileUtils.rm File.expand_path(@tic_index) rescue nil\n      FileUtils.mkdir_p File.expand_path(@tic_working) rescue nil\n      @state=nil\n    end\n\n    def needs_reset? cache_mtime, gitlog_mtime\n      ((cache_mtime.to_i - gitlog_mtime.to_i) > 120) or ((gitlog_mtime.to_i - cache_mtime.to_i) > 120)\n    end\n    \n    def ticket_attach filename, ticket_id=nil, time=nil\n        t = ticket_revparse( ticket_id )\n        ticket= TicGitNG::Ticket.open( self, t, tickets[t] )\n        ticket.add_attach( self, filename, time )\n        reset_ticgitng\n        ticket\n    end\n\n    #ticket_get_attachment()\n    #file_id -      return the attachment identified by file_id\n    #new_filename - save the attachment as new_filename\n    #ticket_id -    get the attachment from ticket_id instead of current\n    def ticket_get_attachment file_id=nil, new_filename=nil, ticket_id=nil \n        if t = ticket_revparse(ticket_id)\n            ticket = Ticket.open( self, t, tickets[t] )\n            ticket.get_attach( file_id, new_filename )\n        end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/ticgit-ng/cli.rb",
    "content": "require 'ticgit-ng'\nrequire 'ticgit-ng/command'\n\n# used Cap as a model for this - thanks Jamis\n\nmodule TicGitNG\n  class CLI\n    def self.execute\n      parse(ARGV).execute!\n    end\n\n    def self.parse(args)\n      #new() calls initialize(...) below\n      cli = new(args)\n      cli.parse_options!\n      cli\n    end\n\n    attr_reader :action, :options, :args, :tic\n    attr_accessor :out\n\n    def initialize(args, path = '.', out = $stdout)\n      @args = args.dup\n\n      #set @init if one of the args is 'init'\n      #this needs to be done because initialization of the ticgit branch must be done before\n      #the branch is loaded, but because of the way commands are modularized this must be done\n      #outside of and before the init.rb file itself is called (init.rb is where we would\n      #normally put the code for such a command).\n      args.include?( 'init' ) ? (@init=true) : (@init=false)\n      #@init= ((args[0][/init/]=='init') rescue false)\n      #@init= ((args[0][/init/]=='init') or (args[1][/init/]=='init') rescue false)\n      \n      @tic = TicGitNG.open(path, {:keep_state => true, :init => @init, :logger  => out })\n      @options = OpenStruct.new\n      @out = out\n\n      @out.sync = true # so that Net::SSH prompts show up\n    rescue NoRepoFound\n      out.puts \"No repo found\"\n      exit\n    end\n\n    def execute!\n      if mod = Command.get(action)\n        extend(mod)\n\n        if respond_to?(:parser)\n          option_parser = Command.parser(action, &method(:parser))\n        else\n          option_parser = Command.parser(action)\n        end\n\n        option_parser.parse!(args)\n\n        execute if respond_to?(:execute)\n      else\n        puts usage\n\n        if args.empty? and !action\n          exit\n        else\n          puts('%p is not a command' % action)\n          exit 1\n        end\n      end\n    end\n\n    def parse_options! #:nodoc:\n      if args.empty?\n        puts \"Please specify at least one action to execute.\"\n        puts\n        puts usage(args)\n        exit 1\n      end\n\n      #FIXME\n      #this is a dirty hack that needs to be fixed\n      if args.include?('list') and args.include?('init')\n        @action = 'list'\n      else\n        @action = args.shift\n      end\n    end\n\n    def usage(args = nil)\n      old_args = args || [action, *self.args].compact\n\n      if respond_to?(:parser)\n        Command.parser('COMMAND', &method(:parser))\n        # option_parser.parse!(args)\n      else\n        Command.usage(old_args.first, old_args)\n      end\n    end\n\n    def get_editor_message(comments = nil)\n      message_file = Tempfile.new('ticgitng_message').path\n      File.open(message_file, 'w') { |f| f.puts comments } if comments\n\n      editor = ENV[\"EDITOR\"] || 'vim'\n      system(\"#{editor} #{message_file}\");\n      message = File.readlines(message_file)\n      message = message.select { |line| line[0, 1] != '#' } # removing comments\n      if message.empty?\n        return false\n      else\n        return message\n      end\n    end\n\n    def ticket_show(t, more=nil)\n        days_ago = ((Time.now - t.opened) / (60 * 60 * 24)).round\n\n        data = [\n            ['Title',    t.title],\n            ['TicId',    t.ticket_id],\n            '',\n            ['Assigned', t.assigned],\n            ['Opened',   \"#{t.opened} (#{days_ago} days)\"],\n            ['State',    t.state.upcase],\n            ['Points',   t.points || 'no estimate'],\n            ['Tags',     t.tags.join(', ')],\n            ''\n        ]\n\n        data.each do |(key, value)|\n            puts(value ? \"#{key}: #{value}\" : key)\n        end\n\n        #FIXME display attachments inline chronologically with comments\n        unless t.comments.empty? and t.attachments.empty?\n            comments_and_attachments= Hash.new\n            puts \"Comments and attachments (#{t.comments.size + t.attachments.size}):\"\n            t.comments.each do |c|\n                comments_and_attachments[c.added]=c\n            end\n            \n            t.attachments.each do |a|\n                comments_and_attachments[a.added]=a\n            end\n            comments_and_attachments.sort.each {|item|\n                if item[1].class==TicGitNG::Comment\n                    #print comment\n                    puts \"  * Added #{item[1].added.strftime('%m/%d %H:%M')} by #{item[1].user}\"\n\n                    wrapped = item[1].comment.split(\"\\n\").map{|line|\n                        line.length > 80 ? line.gsub(/(.{1,80})(\\s+|$)/, \"\\\\1\\n\").strip : line\n                    }.join(\"\\n\")\n\n                    wrapped = wrapped.split(\"\\n\").map{|line| \"\\t#{line}\" }\n\n                    if wrapped.size > 6 and more.nil?\n                        puts wrapped[0, 6].join(\"\\n\")\n                        puts \"\\t** more... **\"\n                    else\n                        puts wrapped.join(\"\\n\")\n                    end\n                    puts\n                else\n                    #print attachment\n                    puts \"  * Added #{item[1].added.strftime('%m/%d %H:%M')} by #{item[1].user}\"\n                    puts \"    Attachment: #{t.attachments.index(item[1]) }\"\n                    puts \"    Filename:   #{item[1].attachment_name}\"\n                    puts\n                end\n            }\n        end\n    end\n\n    class << self\n      attr_accessor :window_lines, :window_cols\n\n      TIOCGWINSZ_INTEL = 0x5413     # For an Intel processor\n      TIOCGWINSZ_PPC   = 0x40087468 # For a PowerPC processor\n      STDOUT_HANDLE    = 0xFFFFFFF5 # For windows\n\n      def reset_window_width\n        try_using(TIOCGWINSZ_PPC) ||\n        try_using(TIOCGWINSZ_INTEL) ||\n          try_windows ||\n          use_fallback\n      end\n\n      # Set terminal dimensions using ioctl syscall on *nix platform\n      # TODO: find out what is raised here on windows.\n      def try_using(mask)\n        buf = [0,0,0,0].pack(\"S*\")\n\n        if $stdout.ioctl(mask, buf) >= 0\n          self.window_lines, self.window_cols = buf.unpack(\"S2\")\n          true\n        end\n      rescue Errno::EINVAL, Errno::ENOTTY\n      end\n\n      def try_windows\n        lines, cols = windows_terminal_size\n        self.window_lines, self.window_cols = lines, cols if lines and cols\n      end\n\n      # Determine terminal dimensions on windows platform\n      def windows_terminal_size\n        m_GetStdHandle = Win32API.new(\n          'kernel32', 'GetStdHandle', ['L'], 'L')\n        m_GetConsoleScreenBufferInfo = Win32API.new(\n          'kernel32', 'GetConsoleScreenBufferInfo', ['L', 'P'], 'L' )\n        format = 'SSSSSssssSS'\n        buf = ([0] * format.size).pack(format)\n        stdout_handle = m_GetStdHandle.call(STDOUT_HANDLE)\n\n        m_GetConsoleScreenBufferInfo.call(stdout_handle, buf)\n        (bufx, bufy, curx, cury, wattr,\n         left, top, right, bottom, maxx, maxy) = buf.unpack(format)\n        return bottom - top + 1, right - left + 1\n      rescue NameError\n      end\n\n      def use_fallback\n        self.window_lines, self.window_cols = 25, 80\n      end\n    end\n\n    def window_lines\n      TicGitNG::CLI.window_lines\n    end\n\n    def window_cols\n      TicGitNG::CLI.window_cols\n    end\n\n    if ''.respond_to?(:chars)\n      # assume 1.9\n      def just(value, size = 10, side = :left)\n        value = value.to_s\n\n        if value.bytesize > size\n          sub_value = \"#{value[0, size - 1]}+\"\n        else\n          sub_value = value[0, size]\n        end\n\n        just_common(sub_value, size, side)\n      end\n    else\n      def just(value, size = 10, side = :left)\n        chars = value.to_s.scan(/./um)\n\n        if chars.size > size\n          sub_value = \"#{chars[0, size-1]}+\"\n        else\n          sub_value = chars.join\n        end\n\n        just_common(sub_value, size, side)\n      end\n    end\n\n    def just_common(value, size, side)\n      case side\n      when :r, :right\n        value.rjust(size)\n      when :l, :left\n        value.ljust(size)\n      end\n    end\n\n    def puts(*strings)\n      @out.puts(*strings)\n    end\n  end\nend\n\nTicGitNG::CLI.reset_window_width\nbegin\n    Signal.trap(\"SIGWINCH\") { TicGitNG::CLI.reset_window_width }\nrescue\n    TicGitNG::CLI.use_fallback\nend\n"
  },
  {
    "path": "lib/ticgit-ng/command/assign.rb",
    "content": "module TicGitNG\n  module Command\n    # Assigns a ticket to someone\n    #\n    # Usage:\n    # ti assign             (assign checked out ticket to current user)\n    # ti assign {1}         (assign ticket to current user)\n    # ti assign -c {1}      (assign ticket to current user and checkout the ticket)\n    # ti assign -u {name}   (assign ticket to specified user)\n    # ti assign -u {name} {1} (assign specified ticket to specified user)\n    module Assign\n      def parser(opts)\n        opts.banner = \"Usage: ti assign [options] [ticket_id]\\n\"+\n                      \"Note: to assign to nobody: ti assign -u ''\"\n        opts.on_head(\n          \"-u USER\", \"--user USER\", \"Assign the ticket to this user\"){|v|\n          options.user = v\n        }\n        opts.on_head(\n          \"-c TICKET\", \"--checkout TICKET\", \"Checkout this ticket\"){|v|\n          options.checkout = v\n        }\n      end\n      def execute\n        handle_ticket_assign\n      end\n      def handle_ticket_assign\n        tic.ticket_checkout(options.checkout) if options.checkout\n        if ARGV.length == 1  #ti assign\n          tic_id=nil\n        elsif ARGV.length == 2 #ti assign {ticid}\n          tic_id=ARGV[1]\n        elsif ARGV.length == 3 #ti assign -u/-c {user/ticid}\n          if options.user\n            tic_id=nil\n          else\n            tic_id=options.checkout\n          end\n        end\n        tic.ticket_assign((options.user rescue nil), tic_id)\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/ticgit-ng/command/attach.rb",
    "content": "module TicGitNG\n    module Command\n        # Attach a file to a ticket\n        #\n        # Usage:\n        # ti attach                             \n        # (print help for 'ti attach')\n        #\n        # ti attach {filename}\n        # (attach {filename} to current ticket)\n        #\n        # ti attach -i {ID} {filename}          \n        # (attach file {filename} to ticket with ID {ID})\n        #\n        # ti attach -g {f_id}\n        # (retrieve attached file {f_id}, place in current dir}\n        #\n        # ti attach -g {f_id} -n {new_filename}\n        # (retrieve attached file {f_id}, place as {new_filename})\n        module Attach\n            def parser(opts)\n                opts.banner = \"Usage: ti attach [options] [filename]\"\n\n                opts.on_head(\n                    \"-i TICKET_ID\", \"--id TICKET_ID\", \"Attach the file to this ticket\"){|v|\n                    options.ticket_id = v\n                }\n                opts.on_head(\n                    \"-g FILE_ID\", \"--get FILE_ID\", \"Retrieve the file FILE_ID\"){|v|\n                    puts \"Warning: ticket ID argument is not valid with the retrieve attachment argument\" if options.ticket_id\n                    options.get_file = v\n                }\n                opts.on_head(\n                    \"-n N_FILENAME\", \"--new-filename\", \"Use this filename for the retrieved attachment\"){|v|\n                    raise ArgumentError, \"Error: New filename argument is only valid with the retrieve arrachment argument\" unless options.get_file\n                    options.new_filename = v\n                }\n            end\n            def execute\n                if options.get_file\n                    tic.ticket_get_attachment( options.get_file, options.new_filename )\n                else\n                    tic.ticket_attach( args[0], options.ticket_id )\n                end\n            end\n        end\n    end\nend\n"
  },
  {
    "path": "lib/ticgit-ng/command/checkout.rb",
    "content": "module TicGitNG\n  module Command\n    module Checkout\n      def parser(opts)\n        opts.banner = \"ti checkout [ticid]\"\n      end\n\n      def execute\n        tid = args[0]\n        tic.ticket_checkout(tid)\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/ticgit-ng/command/comment.rb",
    "content": "module TicGitNG\n  module Command\n    module Comment\n      def parser(opts)\n        opts.banner = \"Usage: ti comment [tic_id] [options]\"\n        opts.on_head(\n          \"-m MESSAGE\", \"--message MESSAGE\",\n          \"Message you would like to add as a comment\"){|v|\n          options.message = v\n        }\n        opts.on_head(\n          \"-f FILE\", \"--file FILE\",\n          \"A file that contains the comment you would like to add\"){|v|\n          raise ArgumentError, \"Only 1 of -f/--file and -m/--message can be specified\" if options.message\n          raise ArgumentError, \"File #{v} doesn't exist\" unless File.file?(v)\n          raise ArgumentError, \"File #{v} must be <= 2048 bytes\" unless File.size(v) <= 2048\n          options.file = v\n        }\n      end\n\n      def execute\n        tid = args[0].strip if args[0]\n        message, file = options.message, options.file\n\n        if message\n          tic.ticket_comment(message, tid)\n        elsif file\n          tic.ticket_comment(File.read(file), tid)\n        else\n          return unless message = get_editor_message\n          tic.ticket_comment(message.join(''), tid)\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/ticgit-ng/command/help.rb",
    "content": "module TicGitNG\n  module Command\n    # Shows help for ticgit or a particular command\n    #\n    # Usage:\n    # ti help               (show help for ticgit)\n    # ti help {command}     (show help for specified command)\n    module Help\n      def parser(opts)\n        opts.banner = \"Usage: ti help [command]\\n\"\n      end\n      def execute\n        cli = CLI.new([])\n        if ARGV.length >= 2 # ti help {command}\n          action = ARGV[1]\n          if command = Command.get(action)\n            cli.extend(command)\n          else\n            puts \"Unknown command #{action}\\n\\n\"\n          end\n        end\n        puts cli.usage\n      end\n    end\n  end\nend\n\n"
  },
  {
    "path": "lib/ticgit-ng/command/init.rb",
    "content": "module TicGitNG\n  module Command\n    module Init\n      def parser o\n        o.banner= \"Usage: ti init\"\n      end\n      def execute\n        @tic.read_tickets\n=begin\n        #Initialization has to happen earlier in the code so this code stands\n        #as an example, when `ti init` is called, initialization is handled by\n        #base.rb:354 (at the time of writing this).\n        tic.base.init_ticgitng_branch(\n          git.lib.branches_all.map{|b| b.first }.include?(which_branch?)\n        )\n=end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/ticgit-ng/command/list.rb",
    "content": "module TicGitNG\n  module Command\n    # List tickets\n    module List\n      def parser(o)\n        o.banner = \"Usage: ti list [options]\"\n        o.on_head(\n          \"-o ORDER\", \"--order ORDER\",\n          \"Field to order by - one of : assigned,state,date,title [.desc for reverse order]\"){|v|\n          options.order = v\n        }\n\n        o.on_head(\n          \"-t TAG[,TAG]\", \"--tags TAG[,TAG]\", Array,\n          \"List only tickets with specific tag(s)\",\n          \"Prefix the tag with '-' to negate\"){|v|\n          options.tags ||= Set.new\n          options.tags.merge v\n        }\n\n        o.on_head(\n          \"-s STATE[,STATE]\", \"--states STATE[,STATE]\", Array,\n          \"List only tickets in a specific state(s)\",\n          \"Prefix the state with '-' to negate\"){|v|\n          options.states ||= Set.new\n          options.states.merge v\n        }\n\n        o.on_head(\n          \"-a ASSIGNED\", \"--assigned ASSIGNED\",\n          \"List only tickets assigned to someone\"){|v|\n          options.assigned = v\n        }\n\n        o.on_head(\"-S SAVENAME\", \"--saveas SAVENAME\",\n                     \"Save this list as a saved name\"){|v|\n          options.save = v\n        }\n\n        o.on_head(\"-l\", \"--list\", \"Show the saved queries\"){|v|\n          options.list = true\n        }\n      end\n\n      def execute\n        options.saved = args[0] if args[0]\n\n        if tickets = tic.ticket_list(options.to_hash)\n          counter = 0\n          cols = [80, window_cols].max\n\n          puts\n          puts [' ', just('#', 4, 'r'),\n            just('TicId', 6),\n            just('Title', cols - 56),\n            just('State', 5),\n            just('Date', 5),\n            just('Assgn', 8),\n            just('Tags', 20) ].join(\" \")\n\n          puts \"-\" * cols\n\n          tickets.each do |t|\n            counter += 1\n            tic.current_ticket == t.ticket_name ? add = '*' : add = ' '\n            puts [add, just(counter, 4, 'r'),\n              t.ticket_id[0,6],\n              just(t.title, cols - 56),\n              just(t.state, 5),\n              t.opened.strftime(\"%m/%d\"),\n              just(t.assigned_name, 8),\n              just(t.tags.join(','), 20) ].join(\" \")\n          end\n          puts\n        end\n\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/ticgit-ng/command/milestone.rb",
    "content": "module TicGitNG\n  module Command\n    # tic milestone\n    # tic milestone migration1 (list tickets)\n    # tic milestone -n migration1 3/4/08 (new milestone)\n    # tic milestone -a {1} (add ticket to milestone)\n    # tic milestone -d migration1 (delete)\n    module Milestone\n      def parser(opts)\n        opts.banner = \"Usage: ti milestone [milestone_name] [options] [date]\"\n\n        opts.on_head(\n          \"-n MILESTONE\", \"--new MILESTONE\",\n          \"Add a new milestone to this project\"){|v| options.new = v }\n\n        opts.on_head(\n          \"-a TICKET\", \"--new TICKET\",\n          \"Add a ticket to this milestone\"){|v| options.add = v }\n\n        opts.on_head(\n          \"-d MILESTONE\", \"--delete MILESTONE\",\n          \"Remove a milestone\"){|v| options.remove = v }\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/ticgit-ng/command/new.rb",
    "content": "module TicGitNG\n  module Command\n    module New\n      def parser(opts)\n        opts.banner = \"Usage: ti new [options]\"\n        opts.on_head(\n          \"-t TITLE\", \"--title TITLE\",\n          \"Title to use for the name of the new ticket\"){|v| options.title = v }\n      end\n\n      def execute\n        if title = options.title\n          ticket_show(tic.ticket_new(title, options.to_hash))\n        else\n          # interactive\n          prompt = \"\\n# ---\\ntags:\\n\"\n          prompt += \"# first line will be the title of the tic, the rest will be the first comment\\n\"\n          prompt += \"# if you would like to add initial tags, put them on the 'tags:' line, comma delim\"\n\n          if message = get_editor_message(prompt)\n            title = message.shift\n            if title && title.chomp.length > 0\n              title = title.chomp\n              if message.last[0, 5] == 'tags:'\n                tags = message.pop\n                tags = tags.gsub('tags:', '')\n                tags = tags.split(',').map { |t| t.strip }\n              end\n              if message.size > 0\n                comment = message.join(\"\")\n              end\n              ticket_show(tic.ticket_new(title, :comment => comment, :tags => tags))\n            else\n              puts \"You need to at least enter a title\"\n            end\n          else\n            puts \"It seems you wrote nothing\"\n          end\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/ticgit-ng/command/points.rb",
    "content": "module TicGitNG\n  module Command\n    # Assigns points to a ticket\n    #\n    # Usage:\n    # ti points {1} {points}   (assigns points to a specified ticket)\n    module Points\n      def parser(opts)\n        opts.banner = \"ti points [ticket_id] points\"\n      end\n\n      def execute\n        case args.size\n        when 1\n          new_points = args[0].to_i\n        when 2\n          tid = args[0]\n          new_points = args[1].to_i\n        else\n          puts usage\n          exit 1\n        end\n\n        tic.ticket_points(new_points, tid)\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/ticgit-ng/command/recent.rb",
    "content": "module TicGitNG\n  module Command\n    module Recent\n      def parser(opts)\n        opts.banner = 'Usage: ti recent'\n      end\n\n      def execute\n        # \"args[0]\" seems to be superfluous.  It's usage\n        # is undocumented, and supplying an argument\n        # doesn't seem to do anything.\n        #\n        # Im guessing the purpose of args[0] was to provide a\n        # specific ticket_id whos history would be looked up\n        # intead of looking up the history for all tickets.\n        #\n        # #FIXME Reimplement that functionality and updte\n        # docs to match\n        tic.ticket_recent(args[0]).each do |commit|\n          sha = commit.sha[0, 7]\n          date = commit.date.strftime(\"%m/%d %H:%M\")\n          message = commit.message\n\n          puts \"#{sha}  #{date}\\t#{message}\"\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/ticgit-ng/command/show.rb",
    "content": "module TicGitNG\n  module Command\n    module Show\n      def parser(opts)\n        opts.banner = \"Usage: ti show [--full] [ticid]\"\n        opts.on_head(\n          \"-f\", \"--full\", \"Show long comments in full, don't truncate after the 5th line\"){|v|\n          options.full= v\n        }\n      end\n\n      def execute\n        t = tic.ticket_show(args[0])\n        ticket_show(t, options.full ) if t\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/ticgit-ng/command/state.rb",
    "content": "module TicGitNG\n  module Command\n    module State\n      def parser(opts)\n        opts.banner = \"Usage: ti state [ticid] state\"\n      end\n\n      def execute\n        if args.size > 1\n          tid, new_state = args[0].strip, args[1].strip\n\n          if valid_state?(new_state)\n            tic.ticket_change(new_state, tid)\n          else\n            puts \"Invalid State - please choose from: #{joined_states}\"\n          end\n        elsif args.size > 0\n          # new state\n          new_state = args[0].chomp\n\n          if valid_state?(new_state)\n            tic.ticket_change(new_state)\n          else\n            puts \"Invalid State - please choose from: #{joined_states}\"\n          end\n        else\n          puts 'You need to at least specify a new state for the current ticket'\n          puts \"please choose from: #{joined_states}\"\n        end\n      end\n\n      def valid_state?(state)\n        available_states.include?(state)\n      end\n\n      def available_states\n        tic.tic_states.sort\n      end\n\n      def joined_states\n        available_states.join(', ')\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/ticgit-ng/command/sync.rb",
    "content": "module TicGitNG\n  module Command\n    module Sync\n      def parser(opts)\n        opts.banner = \"Usage: ti sync [options]\"\n        opts.on_head(\n          \"-r REPO\", \"--repo REPO\", \"Sync ticgit-ng branch with REPO\"){|v|\n          options.repo = v\n        }\n        opts.on_head(\n          \"-n\", \"--no-push\", \"Do not push to the remote repo\"){|v|\n          options.no_push = true\n        }\n      end\n\n      def execute\n        begin\n          if options.repo and options.no_push\n            tic.sync_tickets(options.repo, false)\n          elsif options.repo\n            tic.sync_tickets(options.repo)\n          elsif options.no_push\n            tic.sync_tickets('origin', false)\n          else\n            tic.sync_tickets()\n          end\n        rescue Git::GitExecuteError => e\n          if e.message[/does not appear to be a git repository/]\n            repo= e.message.split(\"\\n\")[0][/^[^:]+/][/\"\\w+\"/].gsub('\"','')\n            puts \"Could not sync because git returned the following error:\\n#{e.message.split(\"\\n\")[0][/[^:]+$/].strip}\"\n            exit\n          end\n        end \n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/ticgit-ng/command/tag.rb",
    "content": "module TicGitNG\n  module Command\n    module Tag\n      def parser(opts)\n        opts.banner = \"Usage: ti tag [tic_id] [options] [tag_name] \"\n        opts.on_head(\n          \"-d\", \"--delete\",\n          \"Remove this tag from the ticket\"){|v| options.remove = v }\n      end\n\n      def execute\n        if options.remove\n          puts 'remove'\n        end\n\n        if ARGV.size > 2 # `ti tag 1234abc tagname1`\n          tic.ticket_tag(ARGV[2], ARGV[1].chomp, options)\n        elsif ARGV.size == 2 # `ti tag tagname1`\n          tic.ticket_tag(ARGV[1], nil, options)\n        else\n          puts 'You need to at least specify one tag to add'\n          puts\n          puts usage\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/ticgit-ng/command.rb",
    "content": "module TicGitNG\n  module Command\n    COMMANDS = {}\n    DOC = {}\n\n    def self.register(mod_name, doc, *commands)\n      autoload(mod_name, \"ticgit-ng/command/#{mod_name.downcase}\")\n      DOC[commands] = doc\n      commands.each{|cmd| COMMANDS[cmd] = mod_name }\n    end\n\n    register 'Assign', 'Assings a ticket to someone', 'assign'\n    register 'Attach', 'Attach file to ticket', 'attach'\n    register 'Checkout', 'Checkout a ticket', 'checkout', 'co'\n    register 'Comment', 'Comment on a ticket', 'comment'\n    register 'Help', 'Show help for a ticgit command', 'help'\n    register 'List', 'List tickets', 'list'\n#    register 'Milestone', 'List and modify milestones', 'milestone'\n    register 'New', 'Create a new ticket', 'new'\n    register 'Points', 'Assign points to a ticket', 'points'\n    register 'Recent', 'List recent activities', 'recent'\n    register 'Show', 'Show a ticket', 'show'\n    register 'State', 'Change state of a ticket', 'state'\n    register 'Tag', 'Modify tags of a ticket', 'tag'\n    register 'Sync', 'Sync tickets', 'sync'\n    register 'Init', 'Initialize Ticgit-ng', 'init'\n\n    def self.get(command)\n      if mod_name = COMMANDS[command]\n        const_get(mod_name)\n      end\n    end\n\n    def self.usage(action, args)\n      option_parser = parser(action, &method(:default_usage))\n      option_parser.parse!(args)\n      option_parser\n    end\n\n    def self.default_usage(o)\n      o.banner = \"Usage: ti COMMAND [FLAGS] [ARGS]\"\n      o.top.append ' ', nil, nil\n      o.top.append 'The available ticgit commands are:', nil, nil\n\n      sorted_doc = DOC.sort_by do |cmds, doc|\n        cmds.sort_by{|cmd| cmd.size }.last\n      end\n      sorted_doc.each do |commands, doc|\n        # get the longest version\n        command = commands.sort_by{|cmd| cmd.size }.last\n        o.top.append(\"    %-32s %s\" % [command, doc], nil, nil)\n      end\n    end\n\n    def self.parser(action, &block)\n      OptionParser.new do |o|\n        o.banner = \"Usage: ti #{action} [FLAGS] [ARGS]\"\n\n        o.base.append ' ', nil, nil\n        o.base.append 'Common options:', nil, nil\n        o.on_tail('-v', '--version', 'Show the version number'){\n          puts TicGitNG::VERSION\n          exit\n        }\n        o.on_tail('-h', '--help', 'Display this help'){\n          puts o\n          exit\n        }\n\n        if block_given?\n          yield(o) if block_given?\n          unless o.top.list.empty?\n            if action\n              o.top.prepend \"Options for #{action} command:\", nil, nil\n              o.top.prepend ' ', nil, nil\n            end\n          end\n        end\n      end\n    end\n  end\nend\n"
  },
  {
    "path": "lib/ticgit-ng/comment.rb",
    "content": "module TicGitNG\n  class Comment\n    attr_accessor :base, :user, :added, :comment\n\n    def initialize( c, user, time=nil )\n      raise unless c\n      @comment= c\n      @user=user\n      @added= time.nil? ? Time.now : time\n      self\n    end\n\n    def self.read( base, file_name, sha )\n      type, date, user = file_name.split('_')\n\n      new( (base.git.gblob(sha).contents rescue nil), user, Time.at(date.to_i) )\n    end\n  end\nend\n"
  },
  {
    "path": "lib/ticgit-ng/ticket.rb",
    "content": "module TicGitNG\n  class Ticket\n\n    attr_reader :base, :opts\n    attr_accessor :ticket_id, :ticket_name\n    attr_accessor :title, :state, :milestone, :assigned, :opened, :points\n    attr_accessor :comments, :tags, :attachments # arrays\n\n    def initialize(base, options = {})\n      # FIXME: what/where/who/how changed config to hash?\n      if (cfg = base.git.config).is_a? Hash\n        options[:user_name] ||= cfg[\"user.name\"]\n        options[:user_email] ||= cfg[\"user.email\"]\n      else\n        options[:user_name] ||= cfg(\"user.name\")\n        options[:user_email] ||= cfg(\"user.email\")\n      end\n\n      @base = base\n      @opts = options || {}\n\n      @state = 'open' # by default\n      @comments = []\n      @tags = []\n      @attachments = []\n    end\n\n    def self.create(base, title, options = {}, time=nil)\n      t = Ticket.new(base, options)\n      t.title = title\n      t.ticket_name = self.create_ticket_name(title, time)\n      t.save_new\n      t\n    end\n\n    def self.open(base, ticket_name, ticket_hash, options = {})\n      tid = nil\n\n      t = Ticket.new(base, options)\n      t.ticket_name = ticket_name\n\n      title, date = self.parse_ticket_name(ticket_name)\n      t.opened = date\n\n      ticket_hash['files'].each do |fname, sha|\n        if fname == 'TICKET_ID'\n          tid = sha\n        elsif fname == 'TICKET_TITLE'\n          t.title = base.git.gblob(sha).contents\n        else\n          # matching\n          data = fname.split('_')\n\n          case data[0]\n          when 'ASSIGNED'\n            t.assigned = data[1..-1].join('_')\n          when 'ATTACHMENTS'\n              #Attachments dir naming format:\n              #ticket_name/ATTACHMENTS/123456_jeff.welling@gmail.com_fubar.jpg\n              #data[] format:\n              #\"ATTACHMENTS_1342116799_jeff.welling@gmail.com_Rakefile\".split('_')\n            filename=File.join( 'ATTACHMENTS', fname.gsub(/^ATTACHMENTS_/,'') )\n            t.attachments << TicGitNG::Attachment.new( filename )\n          when 'COMMENT'\n            t.comments << TicGitNG::Comment.read(base, fname, sha)\n          when 'POINTS'\n            t.points = base.git.gblob(sha).contents.to_i\n          when 'STATE'\n            t.state = data[1]\n          when 'TAG'\n            t.tags << data[1]\n          when 'TITLE'\n            t.title = base.git.gblob(sha).contents\n          end\n        end\n      end\n\n      if !t.attachments.class==NilClass and t.attachments.size > 1\n          t.attachments= t.attachments.sort {|a1, a2| a1.added <=> a2.added }\n      end\n      t.ticket_id = tid\n      t\n    end\n\n    def self.parse_ticket_name(name)\n      epoch, title, rand = name.split('_')\n      title = title.gsub('-', ' ')\n      return [title, Time.at(epoch.to_i)]\n    end\n\n    # write this ticket to the git database\n    def save_new\n      base.in_branch do |wd|\n        files=[]\n        t=nil\n        base.logger.puts \"saving #{ticket_name}\"\n\n        Dir.mkdir(ticket_name)\n        Dir.chdir(ticket_name) do\n          base.new_file('TICKET_ID', ticket_name)\n          files << File.join( ticket_name, 'TICKET_ID' )\n          base.new_file('TICKET_TITLE', title)\n          files << File.join( ticket_name, 'TICKET_TITLE' )\n          base.new_file( (t='ASSIGNED_'+email) , email)\n          files << File.join( ticket_name, t )\n          base.new_file( (t='STATE_'+state) , state)\n          files << File.join( ticket_name, t )\n          base.new_file('TITLE', title)\n          files << File.join( ticket_name, 'TITLE' )\n\n          # add initial comment\n          #COMMENT_080315060503045__schacon_at_gmail\n          if opts[:comment]\n            base.new_file(t=comment_name(email), opts[:comment])\n            files << File.join( ticket_name, t )\n          end\n\n          # add initial tags\n          if opts[:tags] && opts[:tags].size > 0\n            opts[:tags] = opts[:tags].map { |t| t.strip }.compact\n            opts[:tags].each do |tag|\n              if tag.size > 0\n                tag_filename = 'TAG_' + Ticket.clean_string(tag)\n                if !File.exists?(tag_filename)\n                  base.new_file(tag_filename, tag_filename)\n                  files << File.join( ticket_name, tag_filename )\n                end\n              end\n            end\n          end\n        end\n        files.each {|file|\n          base.git.add file\n        }\n        base.git.commit(\"added ticket #{ticket_name}\")\n      end\n      # ticket_id\n    end\n\n    def self.clean_string(string)\n      string.downcase.gsub(/[^a-z0-9]+/i, '-')\n    end\n\n    def add_comment(comment)\n      return false if !comment\n      base.in_branch do |wd|\n        t=nil\n        Dir.chdir(ticket_name) do\n          base.new_file(t=comment_name(email), comment)\n        end\n        base.git.add File.join(ticket_name, t)\n        base.git.commit(\"added comment to ticket #{ticket_name}\")\n      end\n      @comments << TicGitNG::Comment.new( comment, email )\n      self\n    end\n\n    def add_attach( base, filename, time=nil )\n        filename=File.expand_path(filename)\n        #FIXME Refactor -- Attachment.new should be called from Ticket.rb\n        #               -- Attachment filename creation should be handled\n        #                  by the Attachment.rb code\n        base.in_branch do |wd|\n            attachments << (a=TicGitNG::Attachment.create( filename, self, time))\n            base.git.add File.join( ticket_name, a.filename )\n            base.git.commit(\"added attachment #{File.basename(a.filename)} to ticket #{ticket_name}\")\n        end\n        if attachments.class!=NilClass and attachments.size > 1\n            @attachments=attachments.sort {|a1,a2| a1.added <=> a2.added }\n        end\n        self\n    end\n\n    #file_id can be one of:\n    #  - An index number of the attachment (1,2,3,...)\n    #  - A filename (fubar.jpg)\n    #  - nil (nil) means use the last attachment\n    #\n    #if new_filename is nil, use existing filename\n    def get_attach file_id=nil, new_filename=nil\n        attachment=nil\n        pwd=Dir.pwd\n        base.in_branch do |wd|\n            if file_id.to_i==0 and (file_id==\"0\" or file_id.class==Fixnum)\n                if !attachments[file_id.to_i].nil?\n                    attachment= attachments[0]\n                else\n                    puts \"No attachments match file id #{file_id}\"\n                    exit 1\n                end\n            elsif file_id.to_i  > 0\n                if !attachments[file_id.to_i].nil?\n                    attachment= attachments[file_id.to_i]\n                else\n                    puts \"No attachments match file id #{file_id}\"\n                    exit 1\n                end\n            else\n                #find attachment by filename\n                attachments.each {|a|\n                    attachment=a if a.attachment_name==file_id\n                }\n                if attachment.nil?\n                  puts \"No attachments match filename #{file_id}\"\n                  exit 1\n                end\n            end\n\n            if !new_filename\n                #if no filename is specified...\n                filename= attachment.attachment_name\n            else\n                #if there is a new_filename given\n                if File.exist?( new_filename ) and File.directory?( new_filename )\n                    #if it is a directory, not a filename\n                    filename= File.join(\n                        new_filename,\n                        File.basename(attachment.attachment_name)\n                    )\n                else\n                    #if it is a filename, not a dir\n                    filename= new_filename\n                end\n            end\n\n            unless File.exist?( File.dirname(filename) )\n                FileUtils.mkdir_p( File.dirname(filename) )\n            end\n            #save attachment [as new_filename]\n            t=File.join( ticket_name, attachment.filename )\n            unless filename[/^\\//]\n                filename=File.join( pwd, filename )\n            end\n            FileUtils.cp( t, filename )\n        end\n        self\n    end\n\n    def change_state(new_state)\n      return false if !new_state\n      return false if new_state == state\n      t=nil\n\n      base.in_branch do |wd|\n        Dir.chdir(ticket_name) do\n          base.new_file(t='STATE_' + new_state, new_state)\n        end\n        base.git.remove(File.join(ticket_name,'STATE_' + state))\n        base.git.add File.join(ticket_name, t)\n        base.git.commit(\"added state (#{new_state}) to ticket #{ticket_name}\")\n      end\n      @state=new_state\n      self\n    end\n\n    def change_assigned(new_assigned)\n      new_assigned ||= email\n      old_assigned= assigned || ''\n      return false if new_assigned == old_assigned\n\n      base.in_branch do |wd|\n        t=nil\n        Dir.chdir(ticket_name) do\n          base.new_file(t='ASSIGNED_' + new_assigned, new_assigned)\n        end\n        base.git.remove(File.join(ticket_name,'ASSIGNED_' + old_assigned))\n        base.git.add File.join(ticket_name,t)\n        base.git.commit(\"assigned #{new_assigned} to ticket #{ticket_name}\")\n      end\n      @assigned=new_assigned\n      self\n    end\n\n    def change_points(new_points)\n      return false if new_points == points\n\n      base.in_branch do |wd|\n        Dir.chdir(ticket_name) do\n          base.new_file('POINTS', new_points)\n        end\n        base.git.add File.join(ticket_name, 'POINTS')\n        base.git.commit(\"set points to #{new_points} for ticket #{ticket_name}\")\n      end\n      @points=new_points\n      self\n    end\n\n    def add_tag(tag)\n      return false if !tag\n      files=[]\n      added = false\n      tags = tag.split(',').map { |t| t.strip }\n      base.in_branch do |wd|\n        Dir.chdir(ticket_name) do\n          tags.each do |add_tag|\n            if add_tag.size > 0\n              tag_filename = 'TAG_' + Ticket.clean_string(add_tag)\n              if !File.exists?(tag_filename)\n                base.new_file(tag_filename, tag_filename)\n                files << File.join( ticket_name, tag_filename )\n                added = true\n              end\n            end\n          end\n        end\n        if added\n          files.each {|file|\n            base.git.add file\n          }\n          base.git.commit(\"added tags (#{tag}) to ticket #{ticket_name}\")\n        end\n      end\n      tags.each {|tag|\n        @tags << tag\n      }\n      self\n    end\n\n    def remove_tag(tag)\n      return false if !tag\n      removed = false\n      tags = tag.split(',').map { |t| t.strip }\n      base.in_branch do |wd|\n        tags.each do |add_tag|\n          tag_filename = File.join(ticket_name, 'TAG_' + Ticket.clean_string(add_tag))\n          if File.exists?(tag_filename)\n            base.git.remove(tag_filename)\n            removed = true\n          end\n        end\n        if removed\n          base.git.commit(\"removed tags (#{tag}) from ticket #{ticket_name}\")\n        end\n      end\n      @tags.delete_if {|t| t==tag }\n      self\n    end\n\n    def path\n      File.join(state, ticket_name)\n    end\n\n    def comment_name(email)\n      'COMMENT_' + Time.now.to_i.to_s + '_' + email\n    end\n\n    def email\n      opts[:user_email] || 'anon'\n    end\n\n    def assigned_name\n      assigned.split('@').first rescue ''\n    end\n\n    def self.create_ticket_name(title, time=nil)\n      [time.nil? ? Time.now.to_i.to_s : time, Ticket.clean_string(title), rand(999).to_i.to_s].join('_')\n    end\n\n    def create_attachment_name( attachment_name, time=nil )\n        raise ArgumentError, \"create_attachment_name( ) only takes a string\" unless attachment_name.class==String\n        if time\n            if time.to_i == 0\n                raise ArgumentError, \"argument 'time' is not valid\"  unless time.class==Fixnum\n            else\n                time=time.to_i\n            end\n        end\n        time or time=Time.now.to_i\n        time.to_s+'_'+email+'_'+File.basename( attachment_name )\n    end\n    def ==(ticket2)\n        self.instance_variables.each {|instance_var|\n            unless send( instance_var.gsub('@','').to_sym ) == ticket2.instance_eval {send(instance_var.gsub('@','').to_sym)}\n                return false\n            end\n        }\n        return true\n    end\n  end\nend\n"
  },
  {
    "path": "lib/ticgit-ng/version.rb",
    "content": "module TicGitNG\n  VERSION = '1.0.2.18'\nend\n"
  },
  {
    "path": "lib/ticgit-ng.rb",
    "content": "require 'fileutils'\nrequire 'logger'\nrequire 'optparse'\nrequire 'ostruct'\nrequire 'set'\nrequire 'yaml'\nrequire 'pp'\n\n# Add the directory containing this file to the start of the load path if it\n# isn't there already.\n$:.unshift(File.dirname(__FILE__)) unless\n  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))\n\nrequire 'rubygems'\n# requires git >= 1.0.5\nrequire 'git'\n\n#Only redefine if we are not using 1.9\nunless (defined?(RbConfig) ? RbConfig : Config)::CONFIG[\"ruby_version\"][/^\\d\\.9/]\n  # FIXME: Monkeypatch git until fixed upstream\n  module Git\n    class Lib\n      def config_get(name)\n        do_get = lambda do |x|\n          command('config', ['--get', name])\n        end\n        if @git_dir\n          Dir.chdir(@git_dir, &do_get)\n        else\n          build_list.call\n        end\n      end\n    end\n  end\nend\n\nrequire 'ticgit-ng/base'\nrequire 'ticgit-ng/cli'\nrequire 'ticgit-ng/attachment'\nmodule TicGitNG\n  autoload :VERSION, 'ticgit-ng/version'\n  autoload :Comment, 'ticgit-ng/comment'\n  autoload :Ticket, 'ticgit-ng/ticket'\n\n  # options\n  #   :logger            => Logger.new(STDOUT)\n  #   :tic_dir           => \"~/.#{ which_branch?() }\"\n  #   :working_directory => File.expand_path(File.join(@tic_dir, proj, 'working'))\n  #   :index_file        => File.expand_path(File.join(@tic_dir, proj, 'index'))\n  #   :init              => Boolean -- if true, allow initializing ticgit\n  def self.open(git_dir, options = {})\n    Base.new(git_dir, options)\n  end\n\n  class OpenStruct < ::OpenStruct\n    def to_hash\n      @table.dup\n    end\n  end\nend\n"
  },
  {
    "path": "note/IMPLEMENT",
    "content": "~/.ticgit/HEAD -> branch name\n~/.ticgit/CHECKOUT -> current ticket\n~/.ticgit/USER -> schacon / email\n\nticgit/master\n\n  open/\n    080315060503_my_first_ticket_8956\n\t      TICKET_ID - this is filled with ts + random, the sha is \n\t            used as the ticket handle\n        ASSIGNED_schacon\n\t      COMMENT_080315060503045__schacon_at_gmail\n\t      COMMENT_080315060503045__schacon\n\t      COMMENT_080315060503045__someoneelse\n\t      COMMENT_080315060503045__schacon\n\t      COMMENT_080315060503045__someoneelse\n\t      COMMENT_080315060503045__schacon\n\t      TAG_something\n\t      TAG_my_tag\n\t      TAG_again\n    080315140503_my_other_ticket_3982\n  resolved/\n    080215134503_easy_fix_9386\n  invalid/\n    080211134503_everything_is_broke_0183\n  closed/\n    080112153503_needs_fixing_3984\n    080314134501_needs_fixing_2934\n    080314040501_needs_fixing_9486\n\nticgit/devbranch\n"
  },
  {
    "path": "note/NOTES",
    "content": "\n* store the tickets (stories, cards, bugs) - in a subdir of the repo, or a branch?\n\n* merge strategy - if in branch, we can automate, if in subdir, must be human readable\n\n* branch work?\n  - if closed in a branch, how do we handle that when branch merged? (seperate command)\n  $ git merge branch_name; tic merge\n\n* Lighthouse integration\n  $ tic sync\n\nStates - open, resolved, invalid, hold\n\nAssignment - user/email\n\n\nUSAGE\n==========\n\ntic recent\n\ntic list (all open)\ntic list state:closed\ntic list tag:bug\ntic list git:treeish\n\ntic find assigned:me state:open date:\"this week\"\n\ntic milestone\ntic milestone migration1 (list tickets)\ntic milestone -n migration1 3/4/08 (new milestone)\ntic milestone -a {1} (add ticket to milestone)\ntic milestone -d migration1 (delete)\n\ntic status (tics grouped by milestone, stats)\n\ntic tag (show tags)\ntic tag {1} -n new_tag\ntic tag {1} -d tag_name\ntic tag -D tag_name\ntic tag -r old_tag new_tag (rename tag)\n\ntic show {1} \ntic show {1} -c (comments)\ntic show {1} -t (tasks)\ntic show {1} -a (attachments)\n\ntic sync (lighthouse)\n\ntic checkout {1} - checks out a bug for time tracking - says you're working on it\ntic assign {1} (person/partial - defaults to self) [-c] (and checkout)\ntic state {1} resolved [branch - defaults to current, only shows in this branch)\n\ntic attach {1} file.ext -m \"file description\"\ntic attach {1} \ntic attach {1} {attach-id} > file\n\ntic comment {1} -m \"I think this might be done\"\ntic comment --recent\n\ntic new [prompts for info] (title, comment, tags, [state, assigned])\ntic new -t bug \"the thingy doesnt work\" (treeish - defaults to current branch)\n\n??\n\ntic branch (shows tic branches - automatically created when using tic in a git branch)\ntic merge [git_branch]  (brings in all bug states from branch)\ntic merge --preview [git_branch]  (doesn't do the merge, but shows what it would do)\n\ntic git-commit \"message\" (commits git and attaches tic number)\n\n-- later? --\n\ntic task\ntic task new -m \"my new task\"\n"
  },
  {
    "path": "note/OUTPUT",
    "content": "OUTPUT\n==========\n\n> tic recent\n\n1 34j238\tthis one is important   03/05  comment added\n2 3kd898  anther bug              03/05  comment added\n3 3kd898  anther bug              03/04  new ticket created\n4 as8fk5  my first ticket\t        02/01  tag added\n\n\n> tic list\n# on branch 'master'\n1 34j238\tthis one is important \topen\t  schacon (bug, accepted)\n2 3kd898\tanther bug\t          \topen\t  schacon (bug)\n3 as8fk5\tmy first ticket\t\t      closed\tnickh68 (bug, dead)\n\n\n> tic list state:closed\n# on branch 'master'\n1 as8fk5\tmy first ticket\t\t      closed\tnickh68 (bug, dead)\n\n\n> tic milestone\ntix\tms\t\tdate\t\tleft\n-----------------------------------------------\n  3\t migration1\t  03/15/08\t 35 days\n 18\t mall_network\t04/15/08\t 65 days\n 87\t future       05/30/08\t135 days\n\n\n> tic milestone migration1 (list tickets)\n\n|###########################-----------|\n open:   3  closed:  10  progress:  80%\n\n* Open *\n34j238\tthis one is important \topen\tschacon (bug, accepted)\n3kd898\tanther bug\t\t          open\tschacon (bug)\nas8fk5\topen tick               open\tnickh68 (bug, dead)\n\n* Closed *\n34j238\tthis one is important \tclosed\tschacon (bug, accepted)\n3kd898\tanther bug\t\t          closed\tschacon (bug)\nas8fk5\topen tick\t\t            closed\tnickh68 (bug, dead)\n\n\n> tic tag \nbug\t\t    35\naccepted\t20\ndead\t\t   8\n\n> tic show {1} \n\nTicket : 34j238\nTitle  : The Sweetest Ticket Ever\n\nAssign : Scott Chacon <schacon@gmail.com>\nState  : OPEN\nTags   : bug, accepted, sweet, feature\nDate   : 03/01/08  (two weeks ago)\n\nAttachments : 2  \n329jd2 patch1.txt - some description\n7sjhe3 patch2.txt - some other description\n\nRecent Comments :\n03/18 schacon - why do you think this is still open\n03/14 schacon - why do you think this is still open -...(more)\n03/12 schacon - another comment on the ticket that is...(more)\n02/01 schacon - opening the ticket\n(12 more comments)\n\n# `tic show 34j238 -c` for more comments\n# `tic show 34j238 -a` for more attachment detail\n\n> tic checkout {1}\nyou are now working on tic 34j238, \"The Sweetest Ticket Ever\"\n"
  },
  {
    "path": "note/TODO",
    "content": "link to another ticket (child tickets)\n\nMerge\n\nlink to a git object\n\nWeb UI\n\nTicGit goes up directories until it finds .git dir\n\nTicket\n- remove ticket ( git.remove(ticket_dir, :recursive => true) )\n\nColor Output + Paging long results\n\nAttachments\n  - add\n  - download    \n\nMilestones\n\nTags\n  * show all tags\n  * rename tag\n  * delete tag\n  * tag multiple tics\n  "
  },
  {
    "path": "spec/attachments_spec.rb",
    "content": "require File.dirname(__FILE__) + \"/spec_helper\"\n\ndescribe TicGitNG::Attachment do\n  include TicGitNGSpecHelper\n\n  before(:all) do\n    @path = setup_new_git_repo\n    @orig_test_opts = test_opts\n    @ticgitng = TicGitNG.open(@path, @orig_test_opts)\n  end\n\n  after(:all) do\n    Dir.glob(File.expand_path(\"~/.ticgit-ng/-tmp*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n    Dir.glob(File.expand_path(\"~/.ticgit/-tmp*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n    Dir.glob(File.expand_path(\"/tmp/ticgit-ng-*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n  end\n  #To make sure attachments[] isn't loaded randomly and that we're aren't just getting \n  #lucky this time around, run the test 100 times in a loop.\n  it \"should sort attachments[] chronologically, not randomly\" do\n      #FIXME implementation failure\n      #Does not properly detect randomized loads\n      #Test with and without TicGitNG.open\n    Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do\n      5.times do\n          #setup git repo\n          git_dir= setup_new_git_repo\n          base= TicGitNG.open( git_dir, test_opts )\n          #add ticket\n          tic= base.ticket_new('new ticket')\n          #add 5 attachments\n          5.times do |i|\n              #FIXME attahcments must not be added at the exact same time\n              attachment_fname= File.join( Dir.mktmpdir('to_attach'), \"fubar.txt#{i}\" ) \n              new_file( attachment_fname, \"content#{i}\" )\n              tic= base.ticket_attach( attachment_fname, tic.ticket_id, time_skew() )\n          end\n          tic.attachments.size.should == 5\n          #re-read the ticket to read the attachments\n          #check the sort\n          last=nil\n          tic.attachments.each {|a|\n              unless last.nil?\n                  a.added.should >= last.added\n              end\n              last=a\n          }\n          base= TicGitNG.open( git_dir, test_opts )\n          #check attachments are in order\n          tic= base.ticket_show( tic.ticket_id )\n          #check the sort\n          last=nil\n          tic.attachments.each {|a|\n              unless last.nil?\n                  a.added.should >= last.added\n              end\n              last=a\n          }\n      end\n    end\n  end\n\n  it \"should be able to add an attachment to a ticket\" do\n    Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do\n        tic= @ticgitng.ticket_new('my_delicious_ticket')\n        #create a file to attach\n        to_attach= Dir.mktmpdir('to_attach')\n        new_file( attachment_fname=File.join( to_attach, 'fubar.txt' ), \"I am the contents of the attachment\" )\n        #attach the file\n        tic= @ticgitng.ticket_attach( attachment_fname, tic.ticket_id ) \n        #check that the file was attached\n        tic.attachments.map {|a|\n            a.filename.split('_').pop=='fubar.txt'\n        }.index( true ).should_not == nil\n    end\n  end\n\n  it \"should support multiple attachments per ticket\" do\n    Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do\n        tic= @ticgitng.ticket_new('my_delicious_ticket')\n        #create a file to attach\n        to_attach= Dir.mktmpdir('to_attach')\n        new_file( attachment_fname1=File.join( to_attach, 'fubar.txt' ), \"I am the contents of the attachment\" )\n        new_file( attachment_fname2=File.join( to_attach, 'fubar.jpg' ), \"More contents!\" )\n        #attach the file\n        tic= @ticgitng.ticket_attach( attachment_fname1, tic.ticket_id ) \n        tic= @ticgitng.ticket_attach( attachment_fname2, tic.ticket_id )\n        tic= @ticgitng.ticket_show( tic.ticket_id )\n        #check that the file was attached\n        cond_1=false\n        cond_2=false\n        tic.attachments.map {|a|\n            if a.filename.split('_').pop=='fubar.txt'\n                cond_1=true\n            elsif a.filename.split('_').pop=='fubar.jpg'\n                cond_2=true\n            end\n        }\n        [cond_1,cond_2].uniq.size.should == 1\n        cond_1.should == true\n    end\n  end\n  it \"should be able to see an attachment that has been added to a ticket\" do\n    Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do\n        tic= @ticgitng.ticket_new('my_delicious_ticket')\n        #create a file to attach\n        to_attach= Dir.mktmpdir('to_attach')\n        contents=\"I am the contents of the attachment\"\n        new_file( attachment_fname=File.join( to_attach, 'fubar.txt' ), contents )\n        #attach the file\n        tic= @ticgitng.ticket_attach( attachment_fname, tic.ticket_id ) \n        #check that the file was attached with details\n        tic.attachments.size.should == 1\n        tic.attachments[0].attachment_name.should == 'fubar.txt'\n        tic.email.should == tic.attachments[0].user\n        tic.base.in_branch do |wd|\n            read_line_of(File.join( tic.ticket_name, tic.attachments[0].filename)).strip.should == contents \n        end\n    end\n  end\n  it \"should be able to get the attachment based on 'AttachmentID'\" do     #AttachmentID is a number\n    Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do\n        tic= @ticgitng.ticket_new('my_delicious_ticket')\n        #create a file to attach\n        to_attach= Dir.mktmpdir('to_attach')\n        content0=\"I am the contents of the attachment\"\n        content1=\"More contents!\"\n        new_file( attachment_fname0=File.join( to_attach, 'fubar.txt' ), content0 )\n        new_file( attachment_fname1=File.join( to_attach, 'fubar.jpg' ), content1 )\n        #attach the file\n        #FIXME time_skew randomizes the ordering of the attachments\n        tic= @ticgitng.ticket_attach( attachment_fname0, tic.ticket_id, Time.now.to_i ) \n        tic= @ticgitng.ticket_attach( attachment_fname1, tic.ticket_id, Time.now.to_i+500)\n        #get attachment\n        new_filename0= File.join( \n            File.expand_path(Dir.mktmpdir('ticgit-ng-get_attachment-test')),\n            'new_filename.txt' )\n        new_filename1= File.join( \n            File.expand_path(Dir.mktmpdir('ticgit-ng-get_attachment-test')),\n            'new_filename.jpg' )\n        #check contents\n        @ticgitng.ticket_get_attachment( 0, new_filename0, tic.ticket_id )\n        File.exist?( new_filename0 ).should == true\n        read_line_of( new_filename0 ).strip.should == content0\n        @ticgitng.ticket_get_attachment( 1, new_filename1, tic.ticket_id )\n        File.exist?( new_filename1 ).should == true\n        read_line_of( new_filename1 ).strip.should == content1\n    end\n  end\n\n  it \"should be able to get the attachment based on filename\" do\n    Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do\n        tic= @ticgitng.ticket_new('my_delicious_ticket')\n        # a file to attach\n        to_attach= Dir.mktmpdir('to_attach')\n        content0=\"I am the contents of the attachment\"\n        content1=\"More contents!\"\n        new_file( attachment_fname0=File.join( to_attach, 'fubar.txt' ), content0 )\n        new_file( attachment_fname1=File.join( to_attach, 'fubar.jpg' ), content1 )\n        #attach the file\n        tic= @ticgitng.ticket_attach( attachment_fname0, tic.ticket_id ) \n        tic= @ticgitng.ticket_attach( attachment_fname1, tic.ticket_id )\n        #get attachment\n        new_filename0= File.join( \n            File.expand_path(Dir.mktmpdir('ticgit-ng-get_attachment-test')),\n            'new_filename.txt' )\n        new_filename1= File.join(\n            File.expand_path(Dir.mktmpdir('ticgit-ng-get_attachment-test')),\n            'new_filename.jpg' )\n        #check contents\n        @ticgitng.ticket_get_attachment( 'fubar.txt', new_filename0, tic.ticket_id )\n        #test getting a file to a directory by specifying new-filename as a directory\n        @ticgitng.ticket_get_attachment( 'fubar.txt', File.dirname(new_filename0), tic.ticket_id )\n        File.exist?( new_filename0 ).should == true\n        File.exist?( File.join(File.dirname(new_filename0), 'fubar.txt') ).should==true\n        read_line_of( new_filename0 ).strip.should == content0\n        read_line_of( File.join(File.dirname(new_filename0), 'fubar.txt') ).strip.should == content0\n        @ticgitng.ticket_get_attachment( 'fubar.jpg', new_filename1, tic.ticket_id )\n        #test getting a file to a directory by specifying new-filename as a directory\n        @ticgitng.ticket_get_attachment( 'fubar.jpg', File.dirname(new_filename1), tic.ticket_id )\n        File.exist?( new_filename1 ).should == true\n        File.exist?( File.join(File.dirname(new_filename1), 'fubar.jpg' ) ).should==true\n        read_line_of( new_filename1 ).strip.should == content1\n        read_line_of( File.join(File.dirname(new_filename1), 'fubar.jpg') ).strip.should==content1\n    end\n  end\n  it \"should only have valid filenames that begin with 'ATTACHMENTS/'\" do\n    Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do\n        tic= @ticgitng.ticket_new('my_delicious_ticket')\n        # a file to attach\n        to_attach= Dir.mktmpdir('to_attach')\n        content0=\"I am the contents of the attachment\"\n        content1=\"More contents!\"\n        new_file( attachment_fname0=File.join( to_attach, 'fubar.txt' ), content0 )\n        new_file( attachment_fname1=File.join( to_attach, 'fubar.jpg' ), content1 )\n        #attach the file\n        tic= @ticgitng.ticket_attach( attachment_fname0, tic.ticket_id, Time.now.to_i) \n        tic= @ticgitng.ticket_attach( attachment_fname1, tic.ticket_id, Time.now.to_i + 60)\n        tic.attachments.each {|a| a.filename[/^ATTACHMENTS\\//].nil?.should == false }\n    end\n  end\n  it \"should be able to list the attachments on the current ticket\" do  #`ti attach list`\n    Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do\n        tic= @ticgitng.ticket_new('my_delicious_ticket')\n        # a file to attach\n        to_attach= Dir.mktmpdir('to_attach')\n        content0=\"I am the contents of the attachment\"\n        content1=\"More contents!\"\n        new_file( attachment_fname0=File.join( to_attach, 'fubar.txt' ), content0 )\n        new_file( attachment_fname1=File.join( to_attach, 'fubar.jpg' ), content1 )\n        #attach the file\n        tic= @ticgitng.ticket_attach( attachment_fname0, tic.ticket_id, Time.now.to_i ) \n        tic= @ticgitng.ticket_attach( attachment_fname1, tic.ticket_id, Time.now.to_i+60 )\n        tic.attachments.size.should == 2\n        tic.attachments[0].attachment_name.should == 'fubar.txt'\n        tic.attachments[1].attachment_name.should == 'fubar.jpg'\n        tic.attachments[0].user.should_not == nil\n        tic.attachments[1].user.should_not == nil\n    end\n  end\n  it \"should not change the attachment that has been attached if the local file changes\" do\n    Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do\n        tic= @ticgitng.ticket_new('my_delicious_ticket')\n        # a file to attach\n        to_attach= Dir.mktmpdir('to_attach')\n        content0=\"I am the contents of the attachment\"\n        content1=\"More contents!\"\n        new_file( attachment_fname0=File.join( to_attach, 'fubar.txt' ), content0 )\n        new_file( attachment_fname1=File.join( to_attach, 'fubar.jpg' ), content1 )\n        #attach the file\n        tic= @ticgitng.ticket_attach( attachment_fname0, tic.ticket_id, Time.now.to_i ) \n        tic= @ticgitng.ticket_attach( attachment_fname1, tic.ticket_id, Time.now.to_i+60 )\n        File.open( attachment_fname0, 'a' ) {|f|\n            f.puts \"I am a second line in the first attachment!\"\n        }\n        File.open( attachment_fname1, 'a' ) {|f|\n            f.puts \"I am a second line in the second attachment!\"\n        }\n        tic.base.in_branch {|wd|\n            File.read( File.join( \n                                 tic.ticket_name,\n                                 tic.attachments[0].filename \n                                )\n                     ).strip.split(\"\\n\").size.should==1\n            File.read( File.join(\n                                 tic.ticket_name,\n                                 tic.attachments[1].filename \n                                )\n                     ).strip.split(\"\\n\").size.should==1\n        }\n        File.read( attachment_fname0 ).strip.split(\"\\n\").size.should==2\n        File.read( attachment_fname1 ).strip.split(\"\\n\").size.should==2\n        #FIXME checkout the attachments to see if they have changed\n    end\n  end\n  it \"should not explode violently when retrieving an attachment from no attachments\" do\n    Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do\n        tic= @ticgitng.ticket_new('my_delicious_ticket')\n        lambda {\n            tic.attachments[0]\n        }.should_not raise_error\n        lambda {\n            @ticgitng.ticket_get_attachment( 0, nil, tic.ticket_id )\n        }.should raise_error(SystemExit)\n    end\n  end\n  it \"should be able to handle filenames with '_' in them -- '_' is a special char\" do\n    Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do\n        #Split the attachment basename, delete the first two (time,user), remianing is filename\n        tic= @ticgitng.ticket_new('my_delicious_ticket')\n        # a file to attach\n        to_attach= Dir.mktmpdir('to_attach')\n        content0=\"I am the contents of the attachment\"\n        new_file( attachment_fname0=File.join( to_attach, 'fu_bar.txt' ), content0 )\n        #attach the file\n        tic= @ticgitng.ticket_attach( attachment_fname0, tic.ticket_id, Time.now.to_i ) \n        tic.attachments[0].attachment_name.should == 'fu_bar.txt'\n    end\n  end\n  it \"should allow the attaching of multiple filenames with the same name\" do\n    Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do\n        tic= @ticgitng.ticket_new('my_delicious_ticket')\n        # a file to attach\n        to_attach= Dir.mktmpdir('to_attach')\n        content0=\"I am the contents of the attachment\"\n        content1=\"More contents!\"\n        new_file( attachment_fname0=File.join( to_attach, 'fubar.jpg' ), content0 )\n        new_file( attachment_fname1=File.join( to_attach, 'fubar.jpg' ), content1 )\n        #attach the file\n        tic= @ticgitng.ticket_attach( attachment_fname0, tic.ticket_id, Time.now.to_i ) \n        tic= @ticgitng.ticket_attach( attachment_fname1, tic.ticket_id, Time.now.to_i+60 )\n        tic.attachments[0].attachment_name.should == 'fubar.jpg'\n        tic.attachments[1].attachment_name.should == 'fubar.jpg'\n    end\n  end\n  it \"should not explode violently when a duplicate file is attached\" do\n    Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do\n        tic= @ticgitng.ticket_new('my_delicious_ticket')\n        # a file to attach\n        to_attach= Dir.mktmpdir('to_attach')\n        content0=\"I am the contents of the attachment\"\n        new_file( attachment_fname0=File.join( to_attach, 'fubar.jpg' ), content0 )\n        new_file( attachment_fname1=File.join( to_attach, 'fubar.jpg' ), content0 )\n        #attach the file\n        tic= @ticgitng.ticket_attach( attachment_fname0, tic.ticket_id, Time.now.to_i ) \n        tic= @ticgitng.ticket_attach( attachment_fname1, tic.ticket_id, Time.now.to_i+60 )\n        tic.attachments[0].attachment_name.should == 'fubar.jpg'\n        tic.attachments[1].attachment_name.should == 'fubar.jpg'\n    end\n  end\n  it \"should be able to properly get attachments with '_' in the filename\" do\n    Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do\n        tic= @ticgitng.ticket_new('my_delicious_ticket')\n        # a file to attach\n        to_attach= Dir.mktmpdir('to_attach')\n        content0=\"I am the contents of the attachment\"\n        content1=\"More contents!\"\n        new_file( attachment_fname0=File.join( to_attach, 'fu_bar_baz_ted_zim.txt' ), content0 )\n        new_file( attachment_fname1=File.join( to_attach, 'fu_bar_baz_ted_zim*$@#.jpg' ), content1 )\n        #attach the file\n        tic= @ticgitng.ticket_attach( attachment_fname0, tic.ticket_id ) \n        tic= @ticgitng.ticket_attach( attachment_fname1, tic.ticket_id )\n        #get attachment\n        new_filename0= File.join( \n            File.expand_path(Dir.mktmpdir('ticgit-ng-get_attachment-test')),\n            'new_filename.txt' )\n        new_filename1= File.join(\n            File.expand_path(Dir.mktmpdir('ticgit-ng-get_attachment-test')),\n            'new_filename.jpg' )\n        #check contents\n        @ticgitng.ticket_get_attachment( 'fu_bar_baz_ted_zim.txt', new_filename0, tic.ticket_id )\n        @ticgitng.ticket_get_attachment( 'fu_bar_baz_ted_zim.txt', File.dirname(new_filename0), tic.ticket_id )\n        File.exist?( new_filename0 ).should == true\n        File.exist?( File.join(File.dirname(new_filename0), 'fu_bar_baz_ted_zim.txt') ).should==true\n        @ticgitng.ticket_get_attachment( 'fu_bar_baz_ted_zim*$@#.jpg', new_filename1, tic.ticket_id )\n        @ticgitng.ticket_get_attachment( 'fu_bar_baz_ted_zim*$@#.jpg', File.dirname(new_filename1), tic.ticket_id )\n        File.exist?( new_filename1 ).should == true\n        File.exist?( File.join(File.dirname(new_filename1), 'fu_bar_baz_ted_zim*$@#.jpg' ) ).should==true\n    end\n  end\n  it \"should fail gracefully when trying to get a filename that does not exist\" do\n    Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do\n      lambda {\n          tic= @ticgitng.ticket_new('my_delicious_ticket')\n          # a file to attach\n          to_attach= Dir.mktmpdir('to_attach')\n          content0=\"I am the contents of the attachment\"\n          content1=\"More contents!\"\n          new_file( attachment_fname0=File.join( to_attach, 'fubar.txt' ), content0 )\n          new_file( attachment_fname1=File.join( to_attach, 'fubar.jpg' ), content1 )\n          #attach the file\n          tic= @ticgitng.ticket_attach( attachment_fname0, tic.ticket_id )\n          tic= @ticgitng.ticket_attach( attachment_fname1, tic.ticket_id )\n          #get attachment\n          new_filename0= File.join(\n              File.expand_path(Dir.mktmpdir('ticgit-ng-get_attachment-test')),\n              'new_filename.txt' )\n          new_filename1= File.join(\n              File.expand_path(Dir.mktmpdir('ticgit-ng-get_attachment-test')),\n              'new_filename.jpg' )\n          #check contents\n          @ticgitng.ticket_get_attachment( 'fake_file.txt', new_filename0, tic.ticket_id )\n        }.should raise_error SystemExit\n    end\n  end\nend\n"
  },
  {
    "path": "spec/base_spec.rb",
    "content": "require File.dirname(__FILE__) + \"/spec_helper\"\n\ndescribe TicGitNG::Base do\n  include TicGitNGSpecHelper\n\n  before(:all) do\n    @path = setup_new_git_repo\n    @orig_test_opts = test_opts\n    @ticgitng = TicGitNG.open(@path, @orig_test_opts)\n  end\n\n  after(:all) do\n    Dir.glob(File.expand_path(\"~/.ticgit-ng/-tmp*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n    Dir.glob(File.expand_path(\"~/.ticgit/-tmp*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n    Dir.glob(File.expand_path(\"/tmp/ticgit-ng-*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n  end\n\n  it \"should fail gracefully when init-ing if git has no commits\" do\n    tempdir = Dir.mktmpdir\n    Dir.chdir(tempdir) do\n      git = Git.init\n    end\n    opts=test_opts\n    lambda {\n      TicGitNG.open( tempdir, opts )\n    }.should raise_error SystemExit\n  end\n\n  it \"should have 4 ticket states\" do\n    @ticgitng.tic_states.size.should eql(4)\n  end\n\n  it \"should be able to create new tickets\" do\n    @ticgitng.tickets.size.should eql(0)\n    @ticgitng.ticket_new('my new ticket').should be_an_instance_of(TicGitNG::Ticket)\n    @ticgitng.tickets.size.should eql(1)\n  end\n\n  it \"should be able to list existing tickets\" do\n    @ticgitng.ticket_new('my second ticket').should be_an_instance_of(TicGitNG::Ticket)\n    list = @ticgitng.ticket_list\n    list.first.should be_an_instance_of(TicGitNG::Ticket)\n    list.size.should eql(2)\n  end\n\n  it \"should be able to change the state of a ticket\" do\n    tic = @ticgitng.ticket_list.first\n    @ticgitng.ticket_change('resolved', tic.ticket_id)\n    tic = @ticgitng.ticket_show(tic.ticket_id)\n    tic.state.should eql('resolved')\n  end\n\n  it \"should not be able to change the state of a ticket to something invalid\" do\n    tic = @ticgitng.ticket_list.first\n    @ticgitng.ticket_change('resolve', tic.ticket_id)\n    tic = @ticgitng.ticket_show(tic.ticket_id)\n    tic.state.should_not eql('resolve')\n  end\n\n  it \"should be able to change to whom the ticket is assigned\" do\n    tic = @ticgitng.ticket_list.first\n    @ticgitng.ticket_assign('pope', tic.ticket_id)\n    tic = @ticgitng.ticket_show(tic.ticket_id)\n    tic.assigned.should eql('pope')\n  end\n\n  it \"should not be able to change to whom the ticket is assigned if it is already assigned to that user\" do\n    tic = @ticgitng.ticket_list.first\n    tic_id = tic.ticket_id\n    lambda {\n      @ticgitng.ticket_assign(tic.assigned, tic_id)\n      @ticgitng.ticket_show(tic_id)\n    }.should_not change(@ticgitng.ticket_recent(tic_id), :size)\n  end\n\n  it \"should default to the current user when changing to whom the ticket is assigned\" do\n    tic = @ticgitng.ticket_list.first\n    @ticgitng.ticket_checkout(tic.ticket_id)\n    @ticgitng.ticket_assign()\n    tic = @ticgitng.ticket_show(tic.ticket_id)\n    tic.assigned.should eql(tic.email)\n  end\n\n  it \"should only show open tickets by default\" do\n    @ticgitng.ticket_new('my third ticket')\n    tics = @ticgitng.ticket_list\n    states = tics.map { |t| t.state }.uniq\n    states.size.should eql(1)\n    states.first.should eql('open')\n  end\n\n  it \"should be able to filter tickets on state\" do\n    tics = @ticgitng.ticket_list(:state => 'resolved')\n    tics.size.should eql(1)\n    tics = @ticgitng.ticket_list(:state => 'open')\n    tics.size.should eql(2)\n  end\n\n  it \"should be able to save and recall filtered ticket lists\" do\n    tics = @ticgitng.ticket_list(:state => 'resolved', :save => 'resolve')\n    tics.size.should eql(1)\n    rtics = @ticgitng.ticket_list(:saved => 'resolve')\n    tics.size.should eql(1)\n  end\n\n  it \"should be able to comment on tickets\" do\n    t = @ticgitng.ticket_new('my fourth ticket')\n    t.comments.size.should eql(0)\n\n    @ticgitng.ticket_comment('my new comment', t.ticket_id)\n    t = @ticgitng.ticket_show(t.ticket_id)\n    t.comments.size.should eql(1)\n    t.comments.first.comment.should eql('my new comment')\n  end\n\n  it \"should retrieve specific tickets\" do\n    tid = @ticgitng.ticket_list.last.ticket_id\n    tic = @ticgitng.ticket_show(tid)\n    tic.ticket_id.should eql(tid)\n  end\n\n  it \"should be able to checkout a ticket\" do\n    tid = @ticgitng.ticket_list.last.ticket_id\n    @ticgitng.ticket_checkout(tid)\n    @ticgitng.ticket_show.ticket_id.should eql(tid)\n  end\n\n  it \"should resolve partial shas into ticket\" do\n    tid = @ticgitng.ticket_list.last.ticket_id\n    @ticgitng.ticket_checkout(tid[0, 5])\n    @ticgitng.ticket_show.ticket_id.should eql(tid)\n\n    @ticgitng.ticket_checkout(tid[0, 20])\n    @ticgitng.ticket_show.ticket_id.should eql(tid)\n  end\n\n  it \"should resolve order number from most recent list into ticket\" do\n    tics = @ticgitng.ticket_list(:state => 'open')\n    @ticgitng.ticket_show('1').ticket_id.should eql(tics[0].ticket_id)\n    @ticgitng.ticket_show('2').ticket_id.should eql(tics[1].ticket_id)\n  end\n\n  it \"should be able to tag a ticket\" do\n    t = @ticgitng.ticket_list.last\n    t.tags.size.should eql(0)\n    @ticgitng.ticket_tag('newtag', t.ticket_id)\n    t = @ticgitng.ticket_show(t.ticket_id)\n    t.tags.size.should eql(1)\n    t.tags.first.should eql('newtag')\n  end\n\n  it \"should not be able to tag a ticket with a blank tag\" do\n    t = @ticgitng.ticket_new('my fourth ticket', :tags => [' '])\n    t.tags.size.should eql(0)\n\n    @ticgitng.ticket_tag(' ', t.ticket_id)\n    t = @ticgitng.ticket_show(t.ticket_id)\n    t.tags.size.should eql(0)\n\n    @ticgitng.ticket_tag('', t.ticket_id)\n    t = @ticgitng.ticket_show(t.ticket_id)\n    t.tags.size.should eql(0)\n\n    @ticgitng.ticket_tag(',mytag', t.ticket_id)\n    t = @ticgitng.ticket_show(t.ticket_id)\n    t.tags.size.should eql(1)\n    t.tags.first.should eql('mytag')\n  end\n\n  it \"should be able to remove a tag from a ticket\" do\n    t = @ticgitng.ticket_new('my next ticket', :tags => ['scotty', 'chacony'])\n    t.tags.size.should eql(2)\n\n    o=OpenStruct.new\n    o.remove=true\n    @ticgitng.ticket_tag('scotty', t.ticket_id, o)\n    t.tags.size.should eql(2)\n    t.tags.first.should eql('chacony')\n  end\n\n  it \"should save state to disk after a new ticket\" do\n    time = File.lstat(@ticgitng.state).mtime.to_i\n    sleep 1\n    t = @ticgitng.ticket_new('my next ticket', :tags => ['scotty', 'chacony'])\n    File.lstat(@ticgitng.state).mtime.to_i.should_not eql(time)\n  end\n\n  it \"should be able to change the points of a ticket\" do\n    @ticgitng.ticket_new('my new ticket')\n    tic = @ticgitng.ticket_list.first\n    tic.state.should_not == 3\n    @ticgitng.ticket_points(3, tic.ticket_id)\n    tic = @ticgitng.ticket_show(tic.ticket_id)\n    tic.points.should == 3\n  end\n\n  it \"should detect the ticgit branch when the repository is moved\" do\n    #create git dir\n      #done in before(:all) block\n    #create some tickets\n    tic=@ticgitng.ticket_new('my new ticket')\n    #move the git dir\n    FileUtils.mv( @path, @path+'1' )\n    #test that the program does not raise SystemExit\n    opts=test_opts\n    opts[:init]=false\n    lambda {\n        @ticgitng=TicGitNG.open( @path+'1', opts )\n    }.should_not raise_error SystemExit\n  end\n\n  it \"should use the same email that git provides\" do\n    #This is necessary because the other specs depend\n    #on the side effects of one another, but those \n    #side effects are detrimental to this spec so\n    #we initialize things again for a clean slate.\n    @path = setup_new_git_repo\n    @orig_test_opts = test_opts\n    @ticgitng = TicGitNG.open(@path, @orig_test_opts)\n    tic=@ticgitng.ticket_new('my new ticket')\n    tic.email.should == @ticgitng.git.lib.config_get('user.email')\n  end\n\n  it \"should be able to use '_' in assigning\" do\n    #This is necessary because the other specs depend\n    #on the side effects of one another, but those\n    #side effects are detrimental to this spec so\n    #we initialize things again for a clean slate.\n    @path = setup_new_git_repo\n    @orig_test_opts = test_opts\n    @ticgitng = TicGitNG.open(@path, @orig_test_opts)\n    tic=@ticgitng.ticket_new('my new ticket')\n    tic=@ticgitng.ticket_assign( 'some_random_user', tic.ticket_id )\n    tic=@ticgitng.ticket_show( tic.ticket_id )\n    tic.assigned.should == 'some_random_user'\n  end\n\n  it \"should return an updated ticket for each of the ticket_* methods\" do\n    #This is necessary because the other specs depend\n    #on the side effects of one another, but those\n    #side effects are detrimental to this spec so\n    #we initialize things again for a clean slate.\n    @path = setup_new_git_repo\n    @orig_test_opts = test_opts\n    @ticgitng = TicGitNG.open(@path, @orig_test_opts)\n    num_of_methods= @ticgitng.methods.collect {|m|\n      m if m[/^ticket_/]\n    }.compact.size.-(1).should == 12\n    #ticket_new, ticket_points, ticket_tag\n    ticket=@ticgitng.ticket_new('my new ticket')\n    ticket.class.should == TicGitNG::Ticket\n    ticket.title.should == 'my new ticket'\n    ticket=@ticgitng.ticket_points( 1337, ticket.ticket_id )\n    ticket.class.should == TicGitNG::Ticket\n    ticket.points.should == 1337\n    ticket=@ticgitng.ticket_tag( 'fubar', ticket.ticket_id )\n    ticket.class.should == TicGitNG::Ticket\n    ticket.tags.size.should == 1\n    ticket.tags[0].should == 'fubar'\n    #ticket_attach, ticket_get_attachment,\n    Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do\n        #create a file to attach\n        to_attach= Dir.mktmpdir('to_attach')\n        new_file( attachment_fname=File.join( to_attach, 'fubar.txt' ), \"I am the contents of the attachment\" )\n        #attach the file\n        ticket= @ticgitng.ticket_attach( attachment_fname, ticket.ticket_id )\n        ticket.class.should == TicGitNG::Ticket\n        ticket.attachments.size.should == 1\n        ticket.attachments[0].attachment_name.should == 'fubar.txt'\n        ticket= @ticgitng.ticket_get_attachment( 'fubar.txt', nil, ticket.ticket_id )\n        ticket.class.should == TicGitNG::Ticket\n        ticket.attachments.size.should == 1\n        ticket.attachments[0].attachment_name.should == 'fubar.txt'\n    end\n    #ticket_assign, ticket_revparse,\n    ticket=@ticgitng.ticket_assign( 'some_random_guy', ticket.ticket_id )\n    ticket.class.should == TicGitNG::Ticket\n    ticket.assigned.should == 'some_random_guy'\n    ticket1=@ticgitng.ticket_revparse( ticket.ticket_id[/[0-9a-z]{5}/] )\n    ticket1.should == ticket.ticket_name\n    #ticket_change, ticket_show,\n    ticket=@ticgitng.ticket_change( 'resolved', ticket.ticket_id )\n    ticket.class.should == TicGitNG::Ticket\n    ticket.state.should == 'resolved'\n    @ticgitng.ticket_change( 'open', ticket.ticket_id )\n    ticket=@ticgitng.ticket_show( ticket.ticket_id )\n    ticket.class.should == TicGitNG::Ticket\n    #ticket_checkout, ticket_list,\n    ticket=@ticgitng.ticket_checkout( ticket.ticket_id )\n    ticket.class.should == TicGitNG::Ticket\n    @ticgitng.current_ticket.should == ticket.ticket_name\n    tickets=@ticgitng.ticket_list\n    tickets.size.should == 1\n    tickets[0].class.should == TicGitNG::Ticket\n    tickets[0].ticket_id.should == ticket.ticket_id\n    #ticket_comment\n    ticket=@ticgitng.ticket_comment( 'fubar fubar fubar', ticket.ticket_id )\n    ticket.comments[0].comment.should == 'fubar fubar fubar'\n  end\n\nend\n"
  },
  {
    "path": "spec/base_ticket_revparse_spec.rb",
    "content": "require File.dirname(__FILE__) + \"/spec_helper\"\n\ndescribe TicGitNG::Base do\n  include TicGitNGSpecHelper\n\n  before(:each) do\n    @path = setup_new_git_repo\n    @orig_test_opts = test_opts\n    @ticgitng = TicGitNG.open(@path, @orig_test_opts)\n  end\n\n  after(:each) do\n    Dir.glob(File.expand_path(\"~/.ticgit-ng/-tmp*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n    Dir.glob(File.expand_path(\"~/.ticgit/-tmp*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n    Dir.glob(File.expand_path(\"/tmp/ticgit-ng-*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n  end\n\n  it \"should return a ticket by index\" do\n    @ticgitng = TicGitNG.open(@path, @orig_test_opts)\n    test_titles = [\"0\", \"1\", \"2\"]\n    test_titles.each do |title|\n      @ticgitng.ticket_new(title)\n    end\n\n    # This forces the ticket list to cache as an indexable list\n    # Use the middle ticket as our test ticket\n    title_index = @ticgitng.ticket_list[1].title.to_i\n\n    # Ticket indexing is 1 based. Query for the middle ticket.\n    found_tic_name = @ticgitng.ticket_revparse(\"2\")\n    clean_name = test_titles[title_index].downcase.gsub(/[^a-z0-9]+/i, '-')\n    found_tic_name.should match /^\\d+_#{clean_name}_\\d+$/\n  end\n\n  it \"should return a ticket by full SHA\" do\n    test_title = \"My SHA test ticket\"\n    tic = @ticgitng.ticket_new(test_title)\n\n    found_tic_name = @ticgitng.ticket_revparse(tic.ticket_id)\n    clean_name = test_title.downcase.gsub(/[^a-z0-9]+/i, '-')\n    found_tic_name.should match /^\\d+_#{clean_name}_\\d+$/\n  end\n\n  it \"should return a ticket by partial SHA which is an integer\" do\n    test_title = \"My partial integer SHA test ticket\"\n    integer_partial_sha = '432513'\n\n    clean_name = test_title.downcase.gsub(/[^a-z0-9]+/i, '-')\n    @ticgitng.should_receive(:read_tickets).with().and_return(\n      {\n        \"1306092232_#{clean_name}_317\" =>\n          {\n            \"files\"=> [\n                [\"ASSIGNED_some_person@email.com\", \"2d4e94d6963e02f079bc5712ed90a8237a415ebf\"],\n                [\"STATE_open\", \"f510327578a4562e26a7c64bdf061e4a49f85ee6\"],\n                [\"TICKET_ID\", integer_partial_sha+'ajf34j2lk23bk3423'],\n                [\"TICKET_TITLE\", \"44c496d5543823f54e7920738b70b03e85955866\"],\n                [\"TITLE\", \"44c496d5543823f54e7920738b70b03e85955866\"]\n            ]\n          }\n      }\n    )\n\n    found_tic_name = @ticgitng.ticket_revparse(integer_partial_sha)\n    found_tic_name.should match /^\\d+_#{clean_name}_\\d+$/\n  end\n\n  it \"should return a ticket by partial SHA\" do\n    test_title = \"My partial SHA test ticket\"\n    tic = @ticgitng.ticket_new(test_title)\n\n    found_tic_name = @ticgitng.ticket_revparse(tic.ticket_id[0..5])\n    clean_name = test_title.downcase.gsub(/[^a-z0-9]+/i, '-')\n    found_tic_name.should match /^\\d+_#{clean_name}_\\d+$/\n  end\n\n  it \"should not return a ticket by short partial SHA\" do\n    tic = @ticgitng.ticket_new(\"My short partial SHA test ticket\")\n\n    found_tic_name = @ticgitng.ticket_revparse( tic.ticket_id[0..3] )\n    found_tic_name.should == nil\n  end\n\nend\n"
  },
  {
    "path": "spec/cache_spec.rb",
    "content": "require File.dirname(__FILE__) + \"/spec_helper\"\nrequire 'pp'\n\ndescribe TicGitNG do\n  include TicGitNGSpecHelper\n  include TicGitNG\n\n  before(:each) do\n    @path= setup_new_git_repo\n    @orig_test_opts= test_opts\n    @ticgitng= TicGitNG.open(@path, @orig_test_opts)\n  end\n\n  after(:each) do\n    Dir.glob(File.expand_path(\"~/.ticgit-ng/-tmp*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n    Dir.glob(File.expand_path(\"~/.ticgit/-tmp*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n    Dir.glob(File.expand_path(\"/tmp/ticgit-ng-*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n  end\n\n  it \"Should not contaminate ticgit/ticgit-ng branch just because working dir is contaminated\" do\n    Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do\n      @ticgitng.ticket_new('new ticket, clean state', :comment=>\"I am the content\")\n      workingdir_ticket=File.join( @ticgitng.tic_working, @ticgitng.tickets.sort[0][0] )\n      new_file( File.join(workingdir_ticket, 'fake_file'), 'I am a file that should not be commited' )\n      @ticgitng.ticket_new('another ticket', :comment=>\"This commit should not add the new_file()\" )\n      #@ticgitng.git.gtree(@ticgitng.which_branch?).trees.map {|dir_name| dir_name.include?('fake_file') }.size.should eq(2)\n      has_fake_file=false\n      @ticgitng.git.gtree(@ticgitng.which_branch?).trees.each {|tree| tree[1].blobs.map {|blob_name| has_fake_file=true if blob_name[0].include?('fake_file') }}\n      has_fake_file.should eq(false)\n    end\n\n  end\n\nend\n"
  },
  {
    "path": "spec/cli_spec.rb",
    "content": "require File.dirname(__FILE__) + \"/spec_helper\"\n\ndescribe TicGitNG::CLI do\n  include TicGitNGSpecHelper\n\n  before(:each) do\n    @path = setup_new_git_repo\n    @orig_test_opts = test_opts\n    @ticgitng = TicGitNG.open(@path, @orig_test_opts)\n  end\n\n  after(:each) do\n    Dir.glob(File.expand_path(\"~/.ticgit-ng/-tmp*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n    Dir.glob(File.expand_path(\"~/.ticgit/-tmp*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n    Dir.glob(File.expand_path(\"/tmp/ticgit-ng-*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n  end\n\n  it \"should list the tickets\" do\n    @ticgitng.tickets.size.should eql(0)\n    @ticgitng.ticket_new('my new ticket').should be_an_instance_of(TicGitNG::Ticket)\n    @ticgitng.ticket_new('my second ticket').should be_an_instance_of(TicGitNG::Ticket)\n    @ticgitng.tickets.size.should eql(2)\n    fields = %w[TicId Title State Date Assgn Tags]\n    output = []\n    # It's unclear why it's necessary to append each line like this, but\n    # cli('list') would otherwise return nil. The spec helper probably\n    # needs some refactoring.\n    cli(@path, 'init','list') do |line|\n      output << line\n    end\n    output.shift.should match \"\"\n    output.shift.should match /#{fields.join( '\\s+' )}/\n    output.shift.should match /^-+$/\n    #check that at least the SHA1 prefix exists\n    output.shift[/^[a-z0-9]{6}\\s/].should_not == nil\n    output.shift[/^[a-z0-9]{6}\\s/].should_not == nil\n    output.shift.should match \"\"\n  end\n\n  it \"should return the same ticket from ticket_show and ticket_new\" do\n      #FIXME the output of cli(@path,'list') produces a random order\n      #- This has to do with a lack of timeskew\n      20.times do\n        #setup git repo\n        git_dir= setup_new_git_repo\n        base= TicGitNG.open( git_dir, test_opts )\n        base.tickets.size.should eql(0)\n\n        tic1=base.ticket_new('my new ticket', Hash.new, t1=time_skew)\n        tic1.should be_an_instance_of(TicGitNG::Ticket)\n        tic1.should == base.ticket_show( tic1.ticket_id )\n\n        tic2=base.ticket_new('my second ticket', Hash.new, t2=time_skew)\n        tic2.should be_an_instance_of(TicGitNG::Ticket)\n        tic2.should == base.ticket_show( tic2.ticket_id )\n\n        tic1.should_not == tic2\n        tic1.should_not == base.ticket_show( tic2.ticket_id )\n\n        tic1.title.should == 'my new ticket'\n        tic2.title.should == 'my second ticket'\n        base.tickets.size.should eql(2)\n\n        if t1>t2\n            t=tic2\n            tic2=tic1\n            tic1=t\n        end\n\n        fields = %w[TicId Title State Date Assgn Tags]\n        output = []\n        # It's unclear why it's necessary to append each line like this, but\n        # cli('list') would otherwise return nil. The spec helper probably\n        # needs some refactoring.\n        cli(git_dir, 'init','list') do |line|\n          output << line\n        end\n        output.shift.should match \"\"\n        output.shift.should match /#{fields.join( '\\s+' )}/\n        output.shift.should match /^-+$/\n\n        #first ticket\n        line=output.shift.split(' ')\n        line[0].should match /^[a-z0-9]{6}/\n        #This doesn't hinge on t1<t2 because assigned will be\n        # the same for both tickets\n        a=tic1.assigned\n        if a.bytesize > 8\n            a=\"#{a[0, 7]}+\"\n        end\n        line.pop.should == a\n        #FIXME if t1<t2, t1, else, t2\n        line.pop.should == tic1.opened.strftime('%m/%d')\n        line.pop.should == 'open'\n        #delete the sha1\n        line.shift\n        line.join(' ').should == tic1.title\n\n        #second ticket\n        line=output.shift.split(' ')\n        line[0].should match /^[a-z0-9]{6}/\n        a=tic2.assigned\n        if a.bytesize > 8\n            a=\"#{a[0, 7]}+\"\n        end\n        line.pop.should == a\n        line.pop.should == tic2.opened.strftime('%m/%d')\n        line.pop.should == 'open'\n        #delete the sha1\n        line.shift\n        line.join(' ').should == tic2.title\n      end\n  end\n\n  it \"should show a ticket\" do\n    #FIXME needs time_sku to avoid random failures\n    @ticgitng.tickets.size.should eql(0)\n\n    tic1=@ticgitng.ticket_new('my new ticket', Hash.new, t1=time_skew)\n    tic1.should be_an_instance_of(TicGitNG::Ticket)\n    tic1=@ticgitng.ticket_show(tic1.ticket_id)\n\n    tic2=@ticgitng.ticket_new('my second ticket', Hash.new, t2=time_skew)\n    tic2.should be_an_instance_of(TicGitNG::Ticket)\n    tic2=@ticgitng.ticket_show(tic2.ticket_id)\n\n    @ticgitng.tickets.size.should eql(2)\n    if t1>t2\n        t=tic2\n        tic2=tic1\n        tic1=t\n    end\n\n    fields = %w[TicId Title State Date Assgn Tags]\n    output = []\n    # It's unclear why it's necessary to append each line like this, but\n    # cli('list') would otherwise return nil. The spec helper probably\n    # needs some refactoring.\n    cli(@path, 'init','list') do |line|\n      output << line\n    end\n    output.shift.should match \"\"\n    output.shift.should match /#{fields.join( '\\s+' )}/\n    output.shift.should match /^-+$/\n\n    #first ticket\n    line=output.shift.split(' ')\n    line[0].should match /^[a-z0-9]{6}/\n    a=tic1.assigned\n    if a.bytesize > 8\n        a=\"#{a[0, 7]}+\"\n    end\n    line.pop.should == a\n    line.pop.should == tic1.opened.strftime('%m/%d')\n    line.pop.should == 'open'\n    #delete the sha1\n    line.shift\n    line.join(' ').should == tic1.title\n\n    #second ticket\n    line=output.shift.split(' ')\n    line[0].should match /^[a-z0-9]{6}/\n    a=tic2.assigned\n    if a.bytesize > 8\n        a=\"#{a[0, 7]}+\"\n    end\n    line.pop.should == a\n    line.pop.should == tic2.opened.strftime('%m/%d')\n    line.pop.should == 'open'\n    #delete the sha1\n    line.shift\n    line.join(' ').should == tic2.title\n  end\n\n  it 'displays --help' do\n    expected = format_expected(<<-OUT)\nPlease specify at least one action to execute.\n\nUsage: ti COMMAND [FLAGS] [ARGS]\n\nThe available ticgit commands are:\n    assign                           Assings a ticket to someone\n    attach                           Attach file to ticket\n    checkout                         Checkout a ticket\n    comment                          Comment on a ticket\n    help                             Show help for a ticgit command\n    init                             Initialize Ticgit-ng\n    list                             List tickets\n    new                              Create a new ticket\n    points                           Assign points to a ticket\n    recent                           List recent activities\n    show                             Show a ticket\n    state                            Change state of a ticket\n    sync                             Sync tickets\n    tag                              Modify tags of a ticket\n\nCommon options:\n    -v, --version                    Show the version number\n    -h, --help                       Display this help\n    OUT\n\n    cli(@path) do |line|\n      line.should == expected.shift\n    end\n  end\n\n  it 'displays empty list' do\n    fields = %w[TicId Title State Date Assgn Tags]\n    output = []\n    # It's unclear why it's necessary to append each line like this, but\n    # cli('list') would otherwise return nil. The spec helper probably\n    # needs some refactoring.\n    cli(@path, 'init','list') do |line|\n      output << line\n    end\n    output.shift.should match \"\"\n    output.shift.should match /#{fields.join '\\s+'}/\n    output.shift.should match /^-+$/\n  end\nend\n"
  },
  {
    "path": "spec/merging_spec.rb",
    "content": "require File.dirname(__FILE__) + \"/spec_helper\"\nrequire 'pp'\n\ndescribe TicGitNG do\n  include TicGitNGSpecHelper\n\n  before(:each) do\n    @path= setup_new_git_repo\n    @orig_test_opts= test_opts\n    @ticgitng= TicGitNG.open(@path, @orig_test_opts)\n  end\n\n  after(:each) do\n    Dir.glob(File.expand_path(\"~/.ticgit-ng/-tmp*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n    Dir.glob(File.expand_path(\"~/.ticgit/-tmp*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n    Dir.glob(File.expand_path(\"/tmp/ticgit-ng-*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n  end\n\n  it \"Should merge in tickets from a remote source\" do\n    Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do\n      #prep, get temp dirs, init git2\n      @ticgitng.ticket_new('my new ticket')\n      git2=Git.clone(@path, 'remote_1')\n      git=Git.open(@path)\n      git_path_2= tmp_dir + '/remote_1/'\n\n      #Make ticgit-ng branch in remote_1\n      git2.checkout('origin/ticgit')\n      git2.branch('ticgit-ng').checkout\n      ticgit2=TicGitNG.open(git_path_2, @orig_test_opts)\n\n      ticgit2.ticket_new('my second ticket')\n      git2.checkout('master')\n\n      git.add_remote('upstream', git_path_2)\n      git.checkout('ticgit')\n      git.pull('upstream', 'upstream/ticgit-ng')\n      git.checkout('master')\n\n      ticgit2.tickets.length.should == @ticgitng.tickets.length\n    end\n  end\n\n  it \"should be able to sync with origin\" do\n    Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do\n      #prep, get temp dirs, init git2\n\n      #@ticgitng.ticket_new('my new ticket')\n      #git=Git.open(@path)\n\n      git_path_2= tmp_dir + '/remote_1/'\n      git_path_3= tmp_dir + '/remote_2/'\n\n      #Make ticgit-ng branch in remote_1\n      git2=Git.clone(@path, 'remote_1')\n      git2.checkout('origin/ticgit')\n      #this creates the ticgit-ng branch, tracking origin/ticgit-ng\n      git2.branch('ticgit-ng').checkout\n      git2.checkout('master')\n\n      git3=Git.clone(git_path_2, 'remote_2')\n      git3.checkout('origin/ticgit-ng')\n      git3.branch('ticgit-ng').checkout\n      git3.checkout('master')\n\n      ticgit2=TicGitNG.open(git_path_2, @orig_test_opts)\n      ticgit2.ticket_new('my first ticket')\n      ticgit3=TicGitNG.open(git_path_3, @orig_test_opts)\n      ticgit3.ticket_new('my second ticket')\n      ticgit2.ticket_new('my third ticket')\n\n      #git.add_remote('upstream', git_path_2)\n      #git.checkout('ticgit-ng')\n      #git.pull('upstream', 'upstream/ticgit-ng')\n      #git.checkout('master')\n      ticgit3.sync_tickets('origin', true, false)\n\n      ticgit3.tickets.length.should == ticgit2.tickets.length\n    end\n  end\n\n  it \"should be able to sync with other repos\" do\n    Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do\n      #prep, get temp dirs, init git2\n\n      git_path_2= tmp_dir + '/remote_1/'\n      git_path_3= tmp_dir + '/remote_2/'\n      git_path_4= tmp_dir + '/remote_3/'\n\n      #Make ticgit-ng branch in remote_1\n      git2=Git.clone(@path, 'remote_1')\n      git2.checkout('origin/ticgit')\n      #this creates the ticgit-ng branch, tracking from the \n      #branch we are already on, origin/ticgit-ng\n      git2.branch('ticgit-ng').checkout\n      git2.checkout('master')\n\n      #Make ticgit-ng branch in remote_2\n      git3=Git.clone(@path, 'remote_2')\n      git3.checkout('origin/ticgit')\n      git3.branch('ticgit-ng').checkout\n      git3.checkout('master')\n\n      #Make ticgit-ng branch in remote_2\n      git4=Git.clone(@path, 'remote_3')\n      git4.checkout('origin/ticgit')\n      git4.branch('ticgit-ng').checkout\n      git4.checkout('master')\n\n      ticgit2=TicGitNG.open(git_path_2, @orig_test_opts)\n      ticgit2.tickets.length.should==0\n      ticgit2.ticket_new('my first ticket')\n      ticgit3=TicGitNG.open(git_path_3, @orig_test_opts)\n      ticgit3.tickets.length.should==0\n      ticgit3.ticket_new('my second ticket')\n      ticgit4=TicGitNG.open(git_path_4, @orig_test_opts)\n      ticgit4.tickets.length.should==0\n      ticgit4.ticket_new('my third ticket')\n      ticgit2.ticket_new('my fourth ticket')\n\n      #git.add_remote('upstream', git_path_2)\n      #git.checkout('ticgit-ng')\n      #git.pull('upstream', 'upstream/ticgit-ng')\n      #git.checkout('master')\n      \n      git3.add_remote('ticgit2', git_path_2)\n      git4.add_remote('ticgit3', git_path_3)\n\n      ticgit3.sync_tickets('ticgit2', true, false) #ticgit3 should now have tickets 1, 2, and 4\n                                                   #and ticgit2 should now have the same\n      ticgit3.tickets.length.should==3\n      ticgit2.tickets.length.should==3\n\n      ticgit4.sync_tickets('ticgit3', false, false) #ticgit4 should now have tickets 1,2,3,4\n                                                    #but ticgit2 and 3 should only have 1,2,4\n      ticgit4.tickets.length.should==4\n      ticgit3.tickets.length.should==3\n      ticgit2.tickets.length.should==3\n\n      git4.add_remote('ticgit2', git_path_2)\n      ticgit4.sync_tickets('ticgit2', true, false) #ticgit2 and 4 should now have 4 tickets while\n                                                   #ticgit3 only has 3 tickets\n      ticgit4.tickets.length.should==4\n      ticgit3.tickets.length.should==3\n      ticgit2.tickets.length.should==4\n    end\n  end\n  it \"Use the 'ticgit' branch if 'ticgit-ng' isn't available (legacy support)\" do\n    Dir.chdir(File.expand_path( tmp_dir=Dir.mktmpdir('ticgit-ng-gitdir1-') )) do\n      #Because there is no 'ticgit' or 'ticgit-ng' branch\n      #this will create a new ticket in 'ticgit-ng'\n      @ticgitng.ticket_new('original shinanigins')\n      git1=Git.clone( @path, 'remote_0' )\n      #This checks out origin/ticgit-ng and creates a new \n      #branch following it callled ticgit, which should be\n      #used transparently instead of ticgit-ng\n      git1.checkout( 'origin/ticgit' )\n      git1.branch('ticgit').checkout\n      ticgitng1=TicGitNG.open( tmp_dir+'/remote_0/', @orig_test_opts )\n      ticgitng1.which_branch?.should == 'ticgit'\n\n      git2=Git.clone( @path, 'remote_1' )\n      git2.checkout( 'origin/ticgit' )\n      git2.branch('ticgit-ng').checkout\n      ticgitng2=TicGitNG.open( tmp_dir+'/remote_1/', @orig_test_opts )\n      ticgitng2.which_branch?.should == 'ticgit-ng'\n\n      git3=Git.clone( @path, 'remote_2' )\n      git3.checkout( 'origin/ticgit' )\n      git3.branch('ticgit').checkout\n      git3.checkout( 'origin/ticgit' )\n      git3.branch('ticgit-ng').checkout\n      ticgitng3=TicGitNG.open( tmp_dir+'/remote_2/', @orig_test_opts )\n      ticgitng3.which_branch?.should == 'ticgit-ng'\n\n      # if 'ticgit' and 'ticgit-ng'\n      #   should use 'ticgit-ng'\n      # elsif 'ticgit' and !'ticgit-ng'\n      #   should use 'ticgit'\n      # elsif !'ticgit' and 'ticgit-ng'\n      #   should use 'ticgit-ng'\n      # end\n    end\n  end\nend\n"
  },
  {
    "path": "spec/scalability_spec.rb",
    "content": "require File.dirname(__FILE__) + \"/spec_helper\"\n\ndescribe TicGitNG::Base do\n  include TicGitNGSpecHelper\n\n  before(:each) do\n    @path = setup_new_git_repo\n    @orig_test_opts = test_opts\n    @ticgitng = TicGitNG.open(@path, @orig_test_opts)\n  end\n\n  after(:each) do\n    Dir.glob(File.expand_path(\"~/.ticgit-ng/-tmp*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n    Dir.glob(File.expand_path(\"~/.ticgit/-tmp*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n    Dir.glob(File.expand_path(\"/tmp/ticgit-ng-*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n  end\n\n  it \"Should take the same amount of time to init on a large repo as a small one\" do\n    t1_before=0\n    t1_after=0\n    t2_before=0\n    t2_after=0\n    path1= setup_new_git_repo\n    Dir.chdir( path1 ) do\n      #test a small repo\n      #do this a couple times to make it a bit fairer re caching\n      10.times do\n        t1_before=Time.now.to_i\n        ticgit1=TicGitNG.open( path1, @orig_test_opts )\n        t1_after=Time.now.to_i\n      end\n    end\n\n    path2= setup_new_git_repo\n    Dir.chdir( path2 ) do\n      #test a large repo\n      git=Git.open '.'\n      500.times do |i|\n        new_file(\"file_#{i}\", \"#{rand(9999999)}_#{i}\")\n        git.add \"file_#{i}\"\n        git.commit \"Added file_#{i}\"\n      end\n      #do this a couple times to make it fairer re caching\n      10.times do\n        t2_before=Time.now.to_i\n        ticgit2=TicGitNG.open( path2, @orig_test_opts )\n        t2_after=Time.now.to_i\n      end\n    end\n    #Opening is a simple operation, it should take less than a second in most cases,\n    #But this test is intended to make sure that the size of the repo does not impact\n    #the initialization time of TicGit-ng\n    #FIXME Fix this dirty hack, find out what the proper way to do this is\n    true.should == ((t1_after-t1_before) < 5)\n    true.should == ((t2_after-t2_before) < 5)\n  end\n\nend\n"
  },
  {
    "path": "spec/spec_helper.rb",
    "content": "require File.expand_path(File.dirname(__FILE__) + \"/../lib/ticgit-ng\")\nrequire 'fileutils'\nrequire 'logger'\nrequire 'tempfile'\n\nTICGITNG_HISTORY = StringIO.new\n\nmodule TicGitNGSpecHelper\n\n=begin\ntempdir -\n  test => \"content\"\n  subdir -\n    testfile => \"content2\"\n=end\n  def setup_new_git_repo prefix='ticgit-ng-gitdir-'\n    tempdir = Dir.mktmpdir prefix\n    Dir.chdir(tempdir) do\n      git = Git.init\n      new_file('test', 'content')\n      Dir.mkdir('subdir')\n      new_file('subdir/testfile', 'content2')\n      git.add\n      git.commit('first commit')\n    end\n    tempdir\n  end\n\n  def test_opts\n    tempdir = Dir.mktmpdir 'ticgit-ng-ticdir-'\n    logger = Logger.new(Tempfile.new('ticgit-ng-log-'))\n    { :tic_dir => tempdir, :logger => logger, :init => true }\n  end\n\n\n  def new_file(name, contents)\n    File.open(name, 'w') do |f|\n      f.puts contents\n    end\n  end\n\n  def format_expected(string)\n    string.enum_for(:each_line).map{|line| line.strip }\n  end\n\n  def cli(path, *args, &block)\n    TICGITNG_HISTORY.truncate 0\n    TICGITNG_HISTORY.rewind\n\n    ticgitng = TicGitNG::CLI.new(args.flatten, path, TICGITNG_HISTORY)\n    ticgitng.parse_options!\n    ticgitng.execute!\n\n    replay_history(&block)\n  rescue SystemExit => error\n    replay_history(&block)\n  end\n\n  def replay_history\n    TICGITNG_HISTORY.rewind\n    return unless block_given?\n\n    while line = TICGITNG_HISTORY.gets\n      yield(line.strip)\n    end\n  end\n    \n    def read_line_of filename \n        File.open(filename, \"r\").each_line do |line|\n          return line\n        end\n    end\n\n      def time_skew\n          Time.now.to_i + rand(1000)\n      end\n\nend\n\n\n\n##\n# rSpec Hash additions.\n#\n# From\n#   * http://wincent.com/knowledge-base/Fixtures_considered_harmful%3F\n#   * Neil Rahilly\n\nclass Hash\n\n  ##\n  # Filter keys out of a Hash.\n  #\n  #   { :a => 1, :b => 2, :c => 3 }.except(:a)\n  #   => { :b => 2, :c => 3 }\n\n  def except(*keys)\n    self.reject { |k,v| keys.include?(k || k.to_sym) }\n  end\n\n  ##\n  # Override some keys.\n  #\n  #   { :a => 1, :b => 2, :c => 3 }.with(:a => 4)\n  #   => { :a => 4, :b => 2, :c => 3 }\n\n  def with(overrides = {})\n    self.merge overrides\n  end\n\n  ##\n  # Returns a Hash with only the pairs identified by +keys+.\n  #\n  #   { :a => 1, :b => 2, :c => 3 }.only(:a)\n  #   => { :a => 1 }\n\n  def only(*keys)\n    self.reject { |k,v| !keys.include?(k || k.to_sym) }\n  end\nend\n"
  },
  {
    "path": "spec/ticgit_spec.rb",
    "content": "require File.dirname(__FILE__) + \"/spec_helper\"\n\ndescribe TicGitNG do\n  include TicGitNGSpecHelper\n\n  before(:all) do\n    @path = setup_new_git_repo\n    @orig_test_opts = test_opts\n    @ticgitng = TicGitNG.open(@path, @orig_test_opts)\n  end\n\n  after(:all) do\n    Dir.glob(File.expand_path(\"~/.ticgit-ng/-tmp*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n    Dir.glob(File.expand_path(\"~/.ticgit/-tmp*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n    Dir.glob(File.expand_path(\"/tmp/ticgit-ng-*\")).each {|file_name| FileUtils.rm_r(file_name, {:force=>true,:secure=>true}) }\n  end\n\n  it \"Should only create a new branch when 'ti init' is called\" do\n    git_dir_2=        setup_new_git_repo\n    git_opts_2=       test_opts\n    git_opts_2[:init]=false\n\n    #With :init set to false, the default when calling ti\n    lambda { ticgitng_2=TicGitNG.open(git_dir_2, git_opts_2) }.should raise_error SystemExit\n\n    #with :init set to true, the default for TicGitNGSpecHelper.test_opts(), the branch should be created without error\n    lambda { ticgitng=TicGitNG.open( @path, @orig_test_opts )}.should_not raise_error SystemExit\n\n  end\n\n  it \"should create a new branch if it's not there\" do\n    br = @ticgitng.git.branches.map { |b| b.name }\n    br.should include('ticgit')\n  end\n\n  it \"should find an existing ticgit-ng branch if it's there\" do\n    tg = TicGitNG.open(@path, test_opts)\n    @ticgitng.git.branches.size.should eql(tg.git.branches.size)\n  end\n\n  it \"should find the .git directory if it's there\" do\n    @ticgitng.git.dir.path.should eql(@path)\n  end\n\n  it \"should look for the .git directory until it finds it\" do\n    tg = TicGitNG.open(File.join(@path, 'subdir'), @orig_test_opts)\n    tg.git.dir.path.should eql(@path)\n  end\n\n  it \"should add a .hold file to a new branch\" do\n    @ticgitng.in_branch{ File.file?('.hold').should == true }\n  end\n\nend\n"
  },
  {
    "path": "ticgit-ng.gemspec",
    "content": "lib= File.expand_path('../lib/', __FILE__)\n$:.unshift lib unless $:.include?(lib)\n\nrequire './lib/ticgit-ng'\n\nGem::Specification.new do |s|\n  s.name      = \"TicGit-ng\"\n  s.version   = TicGitNG::VERSION\n  s.platform  = Gem::Platform::RUBY\n  s.date      = Date.today.to_s\n  s.authors   = [\"Scott Chacon\", \"Jeff Welling\"]\n  s.email     = [\"Jeff.Welling@gmail.com\"]\n  s.homepage  = \"https://github.com/jeffWelling/ticgit\"\n  s.summary   = \"Git based distributed ticketing system\"\n  s.description=\"TicGit-ng is a simple ticketing system, roughly similar to the Lighthouse model, that is based in git.\"\n\n  s.rubyforge_project         = \"ticgit-ng\"\n\n  s.add_dependency \"git\"\n  s.add_development_dependency \"rspec\"\n  s.files       = Dir.glob(\"{bin,lib}/**/*\") + %w( LICENSE_MIT LICENSE_GPL README.mkd )\n  s.executables = ['ti', 'ticgitweb']\n  s.require_path= 'lib'\nend\n"
  }
]