{"id":21940743,"url":"https://github.com/garno/stairway","last_synced_at":"2025-04-22T15:44:12.610Z","repository":{"id":10892741,"uuid":"13184903","full_name":"garno/stairway","owner":"garno","description":"Easy step by step processing of your business logic.","archived":false,"fork":false,"pushed_at":"2013-10-16T15:04:58.000Z","size":146,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-18T03:24:30.850Z","etag":null,"topics":[],"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/garno.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-29T02:40:57.000Z","updated_at":"2017-09-17T01:59:40.000Z","dependencies_parsed_at":"2022-07-09T23:16:17.871Z","dependency_job_id":null,"html_url":"https://github.com/garno/stairway","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garno%2Fstairway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garno%2Fstairway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garno%2Fstairway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garno%2Fstairway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/garno","download_url":"https://codeload.github.com/garno/stairway/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250270682,"owners_count":21403068,"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-29T02:36:16.162Z","updated_at":"2025-04-22T15:44:12.579Z","avatar_url":"https://github.com/garno.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stairway\nEasy step by step processing of your business logic.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'stairway'\n```\n\n## Usage\n\nFirst, create a new *initializer* to define the different steps of your Stairway:\n\n```ruby\n# config/initializers/stairways.rb\n\nimport = Stairway::Stairs.new(:import)\nimport.steps = {\n  download:    ImportSchedule::Download.new,\n  unzip:       ImportSchedule::Unzip.new,\n  convert_sql: ImportSchedule::ConvertToSQL.new,\n  import:      ImportSchedule::Import.new\n  clean:       ImportSchedule::Cleanup.new\n}\n\nStairway.register(import)\n```\n\nNow, you can run the logic from anywhere in your application using:\n\n```ruby\nStairway.mount(:import).run\n```\n\n## Define your steps\n\nIn the above section, you can see a `ImportSchedule::Download` class being intanciated. All your step should at least, respond to the `run` method. This method will be automatically called.\n\n```ruby\nmodule ImportSchedule\n  class Download \u003c Stairway::Step\n    def run\n      # do stuff here…\n\n      context[:file_path] = '/tmp/boom.zip'\n\n      # `context` is available in all the steps\n      # and can be modified.\n    end\n  emd\nend\n```\n\n## Break the flow\n\nAt any time, if you want to stop the processing for whatever reason, you can do this:\n\n```ruby\nmodule ImportSchedule\n  class Download \u003c Stairway::Step\n    def run\n      begin\n        # download your content…\n      rescue DownloadError\n        Stairway.stop\n      end\n    end\n  end\nend\n```\n\n## Run a single step\n\nSometime, I guess, you'll want to run a single step.\n\n```ruby\nStairway.mount(:import).run_step(:download, context, options)\n```\n\n## License\n\nStairway is © 2013-2014 [Samuel Garneau](http://twitter.com/garno) and may be freely distributed under the [MIT license](https://github.com/garno/stairway/blob/master/LICENSE). See the `LICENSE` file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgarno%2Fstairway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgarno%2Fstairway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgarno%2Fstairway/lists"}