{"id":13879689,"url":"https://github.com/ConsultingMD/schlepper","last_synced_at":"2025-07-16T15:32:54.211Z","repository":{"id":56894442,"uuid":"67555788","full_name":"ConsultingMD/schlepper","owner":"ConsultingMD","description":"A utility gem for running and cataloging onetime tasks for Rails","archived":true,"fork":false,"pushed_at":"2019-03-13T18:35:25.000Z","size":65,"stargazers_count":10,"open_issues_count":3,"forks_count":2,"subscribers_count":96,"default_branch":"master","last_synced_at":"2024-11-19T15:56:46.742Z","etag":null,"topics":["library"],"latest_commit_sha":null,"homepage":"","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/ConsultingMD.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-07T00:00:27.000Z","updated_at":"2024-05-21T21:57:35.000Z","dependencies_parsed_at":"2022-08-21T01:20:21.695Z","dependency_job_id":null,"html_url":"https://github.com/ConsultingMD/schlepper","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ConsultingMD%2Fschlepper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ConsultingMD%2Fschlepper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ConsultingMD%2Fschlepper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ConsultingMD%2Fschlepper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ConsultingMD","download_url":"https://codeload.github.com/ConsultingMD/schlepper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226143895,"owners_count":17580245,"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":["library"],"created_at":"2024-08-06T08:02:29.070Z","updated_at":"2024-11-24T08:31:38.453Z","avatar_url":"https://github.com/ConsultingMD.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Schlepper\n[![Code Climate](https://codeclimate.com/repos/57cf60bd8ffd8f13f100096b/badges/31af7643bb2adb58ccb7/gpa.svg)](https://codeclimate.com/repos/57cf60bd8ffd8f13f100096b/feed)\n[![Test Coverage](https://codeclimate.com/repos/57cf60bd8ffd8f13f100096b/badges/31af7643bb2adb58ccb7/coverage.svg)](https://codeclimate.com/repos/57cf60bd8ffd8f13f100096b/coverage)\n[![Build Status](https://travis-ci.org/ConsultingMD/schlepper.svg?branch=master)](https://travis-ci.org/ConsultingMD/schlepper)\n\n_Schlepper: a person who carries, a task runner_\n\nA gem for running and keeping track of one time tasks in a Rails application. Tasks\nare versioned and tracked much like Rails migrations.\n\nThe purpose of Schlepper is to provide an alternative to onetime data tasks inside migrations, while\noffering the conventions, convenience and tracking like Rails migrations.\n\n## Requirements\n\nRails 3.2+\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'schlepper'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install schlepper\n\n## Usage\n\nSchlepper comes with a generator for creating a new task, and a Rake task that will\nrun any pending onetime tasks.\n\nTo create a new onetime task, run `rails generate schlepper:task name_of_task`; where name\\_of\\_task\nfollows the same pattern as the Rails' migration generator. Here, a new file is created in `script/schleppers`\nthat looks like `numerictimestamp_name_of_task.rb`. These also follow the same pattern as Rails' migrations.\n\nEdit the file that was generated and you see a class has been created with some methods for you to\noverride:\n\n```ruby\nclass NameOfTask \u003c Schlepper::Task\n  attr_reader :failure_message\n\n  # Signals to the task runner that this task will control its own transaction.\n  # When true the task runner will not open a transaction.\n  # Use with caution.\n  # @return [Boolean] \n  def controls_transaction?\n    false\n  end\n\n  # @return [String] A short note on what the purpose of this task is\n  def description\n    \u003c\u003c-DOC.strip_heredoc\n      Add your documentation here.\n    DOC\n    fail NotImplementedError, \"Documentation has not been added for #{self.class.name}\"\n  end\n\n  # @return [String] The individuals that are responsible for this task\n  def owner\n    \"John Bjön\"\n    fail NotImplementedError, \"Ownership has not been claimed for #{self.class.name}\"\n  end\n\n  # This is the entry point for your task. The full Rails stack is available.\n  # Return true if it was successful, false if not. If not successful,\n  # set @failure_message to something meaningful. Tasks that return false\n  # will not be marked as run and will be continue to be run in subsequent\n  # batch runs\n  # @return [Bool] Success or failure\n  def run\n\n  end\nend\n```\n\nThese methods are self-explanatory. The generator places a failure inside the required methods to ensure that\nthere is nothing overlooked. The `owner` and `description` methods are utilized in the task running\nprocess to insert that information into the database.\n\nThe entry point for the task is in the `run` method. Take special note of the meaning of the return value\nof the `run` method. You must return a literal `true` to signal to the task runner that this task\nhas completed successfully. Any return value other than `true` will signal to the task runner\nthat this task has not completed successfully, and will not be marked as successful.\n\nThe method `controls_transaction?` is optional. If it returns `true`, the task\nwon't run in a transaction, and returning `false` from `run` won't roll anything back.\n\nAlso take note of the instance variable `@failure_message`. Setting this to something\ndescriptive if your task fails provides meaningful output to the person running the task.\n\nUse `rake schlepper:run` to start the task running process. The task running procedure is as follows:\n\n- Load the Rails app, the `schlepper:run` task inherits from `environment`\n- Create the schlepper\\_tasks table if it does not exist\n- Select all of the version numbers from the schlepper\\_tasks table\n- Load all task files that have not yet been run\n- For each task file\n  - Begin a database transaction\n  - Create a new instance of the Task class defined in the file\n  - Execute the `run` method of that class\n  - If the return value of `run` is true\n    - Commit the transaction\n    - Insert into the schlepper\\_tasks table the owner, description, and\n      verison of the tasks\n  - Otherwise\n    - Roll back transaction\n    - Display the name of the owner, and @failure\\_message if provided\n\nThe transaction steps are skipped if `controls_transaction?` is defined and returns `true`.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/ConsultingMD/schlepper.\n\n## License\n\nSchlepper is released under the [MIT License](https://opensource.org/licenses/MIT).\n\n## TODO\n\nImplement saving the change registry by providing some back-ends.\n\nImplement rolling back a task\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FConsultingMD%2Fschlepper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FConsultingMD%2Fschlepper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FConsultingMD%2Fschlepper/lists"}