{"id":13747531,"url":"https://github.com/toy/progress","last_synced_at":"2025-05-16T04:03:39.583Z","repository":{"id":421645,"uuid":"41523","full_name":"toy/progress","owner":"toy","description":"Class to show progress during script run","archived":false,"fork":false,"pushed_at":"2025-04-24T12:44:58.000Z","size":250,"stargazers_count":68,"open_issues_count":0,"forks_count":6,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-24T13:40:56.639Z","etag":null,"topics":["progress","ruby"],"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/toy.png","metadata":{"files":{"readme":"README.markdown","changelog":"CHANGELOG.markdown","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2008-08-10T19:09:11.000Z","updated_at":"2025-04-24T12:45:02.000Z","dependencies_parsed_at":"2024-01-13T03:01:13.991Z","dependency_job_id":"fed6fadd-a957-415e-8d67-6082c4f9c470","html_url":"https://github.com/toy/progress","commit_stats":{"total_commits":393,"total_committers":4,"mean_commits":98.25,"dds":"0.025445292620865145","last_synced_commit":"01c5d40cb6d135f15a1096b1f2f32e16aca86f45"},"previous_names":[],"tags_count":59,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toy%2Fprogress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toy%2Fprogress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toy%2Fprogress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toy%2Fprogress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toy","download_url":"https://codeload.github.com/toy/progress/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254464891,"owners_count":22075570,"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":["progress","ruby"],"created_at":"2024-08-03T06:01:32.760Z","updated_at":"2025-05-16T04:03:39.563Z","avatar_url":"https://github.com/toy.png","language":"Ruby","readme":"[![Gem Version](https://img.shields.io/gem/v/progress?logo=rubygems)](https://rubygems.org/gems/progress)\n[![Check](https://img.shields.io/github/actions/workflow/status/toy/progress/check.yml?label=check\u0026logo=github)](https://github.com/toy/progress/actions/workflows/check.yml)\n[![Rubocop](https://img.shields.io/github/actions/workflow/status/toy/progress/rubocop.yml?label=rubocop\u0026logo=rubocop)](https://github.com/toy/progress/actions/workflows/rubocop.yml)\n[![Code Climate](https://img.shields.io/codeclimate/maintainability/toy/progress?logo=codeclimate)](https://codeclimate.com/github/toy/progress)\n[![Depfu](https://img.shields.io/depfu/toy/progress)](https://depfu.com/github/toy/progress)\n[![Inch CI](https://inch-ci.org/github/toy/progress.svg?branch=master)](https://inch-ci.org/github/toy/progress)\n\n# progress\n\nShow progress during console script run.\n\n## Installation\n\n    gem install progress\n\n## Usage\n\n```ruby\n1000.times_with_progress('Counting to 1000') do |i|\n  # do something with i\nend\n```\n\nor without title:\n\n```ruby\n1000.times_with_progress do |i|\n  # do something with i\nend\n```\n\nWith array:\n\n```ruby\n[1, 2, 3].with_progress('1…2…3').each do |i|\n  # still counting\nend\n```\n\n`.each` is optional:\n\n```ruby\n[1, 2, 3].with_progress('1…2…3') do |i|\n  # =||=\nend\n```\n\nNested progress\n\n```ruby\n(1..10).with_progress('Outer').map do |a|\n  (1..10).with_progress('Middle').map do |b|\n    (1..10).with_progress('Inner').map do |c|\n      # do something with a, b and c\n    end\n  end\nend\n```\n\nYou can also show note:\n\n```ruby\n[1, 2, 3].with_progress do |i|\n  Progress.note = i\n  sleep 5\nend\n```\n\nYou can use any enumerable method:\n\n```ruby\n[1, 2, 3].with_progress.map{ |i| 'do stuff' }\n[1, 2, 3].with_progress.each_cons(3){ |i| 'do stuff' }\n[1, 2, 3].with_progress.each_slice(2){ |i| 'do stuff' }\n# …\n```\n\nAny enumerable will work:\n\n```ruby\n(1..100).with_progress('Wait') do |i|\n  # ranges are good\nend\n\nDir.new('.').with_progress do |path|\n  # check path\nend\n```\n\nNOTE: progress gets number of objects using `length`, `size`, `to_a.length` or just `inject` and if used on objects which needs rewind (like opened File), cycle itself will not work.\n\nUse simple blocks:\n\n```ruby\nsymbols = []\nProgress.start('Input 100 symbols', 100) do\n  while symbols.length \u003c 100\n    input = gets.scan(/\\S/)\n    symbols += input\n    Progress.step input.length\n  end\nend\n```\n\nor just\n\n```ruby\nsymbols = []\nProgress('Input 100 symbols', 100) do\n  while symbols.length \u003c 100\n    input = gets.scan(/\\S/)\n    symbols += input\n    Progress.step input.length\n  end\nend\n```\n\nNOTE: you will get WRONG progress if you use something like this:\n\n```ruby\n10.times_with_progress('A') do |time|\n  10.times_with_progress('B') do\n    # code\n  end\n  10.times_with_progress('C') do\n    # code\n  end\nend\n```\n\nBut you can use this:\n\n```ruby\n10.times_with_progress('A') do |time|\n  Progress.step 5 do\n    10.times_with_progress('B') do\n      # code\n    end\n  end\n  Progress.step 5 do\n    10.times_with_progress('C') do\n      # code\n    end\n  end\nend\n```\n\nOr if you know that B runs 9 times faster than C:\n\n```ruby\n10.times_with_progress('A') do |time|\n  Progress.step 1 do\n    10.times_with_progress('B') do\n      # code\n    end\n  end\n  Progress.step 9 do\n    10.times_with_progress('C') do\n      # code\n    end\n  end\nend\n```\n\n## Copyright\n\nCopyright (c) 2008-2021 Ivan Kuchin. See LICENSE.txt for details.\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoy%2Fprogress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoy%2Fprogress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoy%2Fprogress/lists"}