{"id":18370201,"url":"https://github.com/docwhat/mergit","last_synced_at":"2025-09-10T15:36:22.247Z","repository":{"id":8108179,"uuid":"9523687","full_name":"docwhat/mergit","owner":"docwhat","description":null,"archived":false,"fork":false,"pushed_at":"2021-02-13T02:10:50.000Z","size":32,"stargazers_count":13,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-24T22:42:52.485Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/docwhat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-04-18T14:32:39.000Z","updated_at":"2019-11-21T16:48:41.000Z","dependencies_parsed_at":"2022-08-20T13:10:43.212Z","dependency_job_id":null,"html_url":"https://github.com/docwhat/mergit","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docwhat%2Fmergit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docwhat%2Fmergit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docwhat%2Fmergit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docwhat%2Fmergit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/docwhat","download_url":"https://codeload.github.com/docwhat/mergit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247531431,"owners_count":20953963,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T23:37:13.520Z","updated_at":"2025-04-06T18:32:47.619Z","avatar_url":"https://github.com/docwhat.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mergit\n\n* [![Build Status](https://secure.travis-ci.org/docwhat/mergit.png)](http://travis-ci.org/docwhat/mergit)\n* [![Dependencies](https://gemnasium.com/docwhat/mergit.png)](https://gemnasium.com/docwhat/mergit)\n* [![Coverage Status](https://coveralls.io/repos/docwhat/mergit/badge.png?branch=master)](https://coveralls.io/r/docwhat/mergit)\n\nMergit is a way to merge a bunch of `require`d files into one file.\n\nThis allows you develop, design, and test your ruby script using normal ruby best practices (rspec, etc.) and then\ndistribute them as a single-file ruby script.\n\nSome use cases include:\n\n* Administration scripts\n* Simple tools\n* Programs that need to work on any ruby without installing gems\n\n## My original use case\n\nWhen I wrote the original mergit, my goal was to distribute development/build\nscripts to a variety of systems.\n\nThese scripts had the following requirements:\n\n1. The scripts needed to be easy to install.\n    * Our developers hadn't had experience with Ruby yet.  This is before ruby\n      1.9.2 was released!\n    * We didn't have an in-house RPM server (which wouldn't help our Windows\n      systems anyway).\n2. The scripts needed minimal or no requirements.\n    * Bundler and RVM were new and a pain to automatically install.\n    * Not all systems had the (easy) root access needed to install required\n      gems or build tools.\n    * All the CentOS systems had Ruby (\u003e= 1.8.7 by default)\n    * All the Windows systems could easily get a version of Ruby (a quirk of\n      our development/build environment).\n    * We had a mechanism to get a reasonably current ruby for Solaris.\n3. The scripts needed to work on Windows, Solaris, and CentOS.\n4. I wanted to write the scripts with the best practices; unit tests,\none-class-per-file, SOLID design.\n    * I needed the scripts to work reliably, so I needed good tests.\n    * It was easier to work on if we followed SOLID design principles.\n\nThe scripts I wrote in the end could be installed on any development or build\nsystem via a simple `curl` and only required *any* working ruby of version\n1.8.7 or greater.\n\nThis was possible because all the `.rb` files were merged into single files, including the one gem I needed (the pure ruby `minitar`).\n\n## Limitations\n\nMergit uses simple text processing, therefore it can be tripped up.  Some known problems include:\n\n* `require` statements nested in code instead of at outermost scope of a file will expand in-place. This probably isn't what you want.\n* The order `require`d files are pulled in may be different than ruby.\n* The replacement feature is very brute force.  Be careful using it.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'mergit', '~\u003e 1.1'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install mergit\n\nNote: Mergit uses [Semantic Versioning](http://semver.org/).\n\n## Usage\n\n### Command Line Tool\n\nThe command line tool, `mergit`, is pretty self-explanatory.\n\nYou specify the ruby file you want `require`s merged into on the command line (via standard in, if you specify `-`) and any library directories\nyou want `require`d from.\n\nYou can specify the `--lib` flag multiple times.\n\nThere is also a `--replace` flag that lets you specify a string or regular expression (a string surrounded by `/`) that should be replaced.\n\nExample:\n\n    bin/mergit --replace mouse=cat filename\n\nThis will replace all occurances of \"mouse\" with \"cat\".\n\nYou can specify the `--replace` flag multiple times.\n\nUse the `--output` flag to send the resulting output to someplace other than stdout.\n\n#### MERGIT directives\n\nYou can also cause any line to be skipped by adding a Mergit directive in a comment at the end of the line.\n\nExample:\n\n    raise \"This won't be in the merged output.\" # MERGIT: skip\n\n### Library API\n\nSimple usage:\n\n    search_path = [ '/path/to/lib', '/path/to/other/lib' ]\n    mergit = Mergit.new(:search_path =\u003e search_path)\n\n    string_of_merged_file = mergit.process_file('/path/to/file')\n    # or\n    string_of_merged_string = mergit.process(some_string)\n\nFor more detailed information, see the [documentation](http://rubydoc.info/gems/mergit/frames).\n\n## Additional Notes\n\nTo use up less space, you can compress the resulting script with `gzexe`.\n\n## Contributing\n\n### Level 1 -- Apprentice\n\nFile an [issue](https://github.com/docwhat/mergit/issues).\n\nMake sure it includes the steps needed to reproduce it as well as what you expected to happen.\n\n### Level 2 -- Journeyman\n\n1. [Fork it](https://help.github.com/articles/fork-a-repo)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n### Level 3 -- Master\n\nRepeat Level 2 until I give you write access on github. :-)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdocwhat%2Fmergit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdocwhat%2Fmergit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdocwhat%2Fmergit/lists"}