pax_global_header00006660000000000000000000000064134730723300014514gustar00rootroot0000000000000052 comment=71c8b2c40700d9014374efb14df10d3252b54d3d ruby-progressbar-releases-v1.10.1/000077500000000000000000000000001347307233000170735ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/.chamber.pub.pem000066400000000000000000000007031347307233000220420ustar00rootroot00000000000000-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvUvrgcqkZWuE0m6qRkDx tBtnUTIX7JzDfN1byCUrWUT2af635KxaA2TNTEW1nhhMFZIvZc+UCI+2nNWx2lZo jyyt4AQ83F0JX4sqJQxtdlXym5g/Vp5etv4OBHADhZvvrzJCOCO8p25OOvwTfyq6 65YshBNQRVoB0oXHPTz5SGvtrzKNX2EulZGESPAIhFtNMBjmtOnWAtWoseOGxNGy oDSElZzYi3DEfNpUMQr49K9JZTpz+kIAeXUSpkdtTQ9PYY/jcyka1XZ/RkKbGK1V VtKQ2WCcB5R3jnAThverEVv28rLwn4dZeySd1lYJ4+1oZMWbGskR03zFoyMYGMmi ZwIDAQAB -----END PUBLIC KEY----- ruby-progressbar-releases-v1.10.1/.codeclimate.yml000066400000000000000000000022351347307233000221470ustar00rootroot00000000000000engines: brakeman: enabled: false bundler-audit: enabled: true csslint: enabled: false duplication: enabled: true config: languages: - 'ruby' - 'javascript' eslint: enabled: true config: extensions: - '.es6' - '.js' fixme: enabled: true config: strings: - 'BUG' - 'FIXME' - 'HACK' - 'XXX' flog: enabled: false markdownlint: enabled: true rubocop: enabled: false scss-lint: enabled: true shellcheck: enabled: true stylelint: enabled: false tailor: enabled: false vint: enabled: true ratings: paths: - '**.md' - '**.rake' - '**.rb' - '**.scss' - '**.swift' - '**.vim' - '**.bash' - '**.sh' - '**.zsh' - '**.es6' - '**.js' exclude_paths: - '**/.github/**/*' - '**/bin/deploy' - '**/bin/setup' - '**/db/migrate/**/*' - '**/db/schema.rb' - '**/db/structure.sql' - '**/public/**/*' - '**/scripts/**/*' - '**/vendor/**/*' - '.overcommit.yml' - '.rubocop.yml' - '.rubocop_core.yml' - '.rubocop_rails.yml' - 'spec/**/*' ruby-progressbar-releases-v1.10.1/.github/000077500000000000000000000000001347307233000204335ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/.github/ISSUE_TEMPLATE/000077500000000000000000000000001347307233000226165ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/.github/ISSUE_TEMPLATE/bug.md000066400000000000000000000027061347307233000237220ustar00rootroot00000000000000--- name: Bug about: Create a report to help us improve --- ## Current Behavior ### Steps to Reproduce 1. Sign in as "marty@hillvalley.net" 2. Click "Current Orders" 3. Try to remove "Flux Capacitor" from the cart ### Screenshot ## Expected Behavior ## Environment - Device: - OS: - [ ] Windows - [ ] macOS - [ ] iOS - [ ] Android - [ ] Linux - [ ] Other - OS Version: - Browser: - [ ] Chrome - [ ] Safari - [ ] Firefox - [ ] Internet Explorer - [ ] Edge - [ ] Opera - Browser Version: ruby-progressbar-releases-v1.10.1/.github/ISSUE_TEMPLATE/feature_request.md000066400000000000000000000016661347307233000263540ustar00rootroot00000000000000--- name: Feature Request about: Suggest an idea for this project --- ## Current Problem ## Potential Solution or New Behavior ### Mockups ruby-progressbar-releases-v1.10.1/.github/contributing.md000066400000000000000000000027411347307233000234700ustar00rootroot00000000000000# Contributing We love pull requests from everyone. By participating in this project, you agree to abide by the code of conduct. Here are some ways *you* can contribute: * by using alpha, beta, and prerelease versions * by reporting bugs * by suggesting new features * by writing or editing documentation * by writing specifications * by writing code * by fixing styling inconsistencies * by refactoring code * by closing issues * by reviewing patches ## Submitting an Issue We use the GitHub issue tracker to track bugs and features. Before submitting a bug report or feature request, check to make sure it hasn't already been submitted. When submitting a bug report, please include a [Gist][] that includes a stack trace and any details that may be necessary to reproduce the bug. Ideally, a bug report should include a pull request with failing specs. [gist]: https://gist.github.com/ ## Submitting a Pull Request 1. [Fork][fork] the official repository. 2. [Create a topic branch.][branch] 3. Implement your feature or bug fix. 4. Add, commit, and push your changes. 5. [Submit a pull request.][pr] ## Notes * Please add tests if you changed code. Contributions without tests won't be accepted. [fork]: https://help.github.com/articles/fork-a-repo/ [branch]: https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/ [pr]: https://help.github.com/articles/using-pull-requests/ Inspired by https://github.com/thoughtbot/factory_bot/blob/master/CONTRIBUTING.md ruby-progressbar-releases-v1.10.1/.github/pull_request_template.md000066400000000000000000000043421347307233000253770ustar00rootroot00000000000000Why This Change Is Necessary -------------------------------------------------------------------------------- - [ ] Bug Fix - [ ] New Feature How These Changes Address the Issue -------------------------------------------------------------------------------- Side Effects Caused By This Change -------------------------------------------------------------------------------- - [ ] This Causes a Breaking Change - [ ] This Does Not Cause Any Known Side Effects Screenshots -------------------------------------------------------------------------------- Checklist: -------------------------------------------------------------------------------- - [ ] I have run `rubocop` against the codebase - [ ] I have added tests to cover my changes - [ ] All new and existing tests passed ruby-progressbar-releases-v1.10.1/.gitignore000066400000000000000000000063751347307233000210760ustar00rootroot00000000000000# Vendored Dependencies Pods bower_components node_modules web/app/mu-plugins web/app/plugins web/app/upgrade web/app/uploads web/wp vendor # OS Files .AppleDB .AppleDesktop .AppleDouble .DS_Store .LSOverride .apdisk Thumbs.db # Testing Files *.gemfile.lock capybara* pickle-email-*.html public/uploads rerun.txt site/web/app/uploads test/data # Cache Files *.stTheme.cache *.tfstate *.tmPreferences.cache *.tmlanguage.cache .TAGS .byebug_history .divshot-cache .dropbox .dropbox.attr .dropbox.cache .rake_tasks .repl_history .sass-cache .tags .yardoc /variables.tf.json TAGS _yardoc disk_image_for_*.json disk_image_settings.json lambdas/*.js lambdas/*.py lambdas/*.zip packer_cache public/packs* public/system site/web/app/upgrade spec/reports tags terraform.tfvars test/tmp test/version_tmp tmtags variables.sls !TAGS/ !tags/ # Local Compiled Files **/cordova/platforms/android/CordovaLib/ant-build **/cordova/platforms/android/CordovaLib/ant-gen **/cordova/platforms/android/CordovaLib/bin **/cordova/platforms/android/CordovaLib/gen **/cordova/platforms/android/ant-build **/cordova/platforms/android/ant-gen **/cordova/platforms/android/assets/www **/cordova/platforms/android/bin **/cordova/platforms/android/gen **/cordova/platforms/browser/build **/cordova/platforms/browser/www **/cordova/platforms/ios/build/ **/cordova/platforms/ios/www/ **/cordova/platforms/wp8/*.csproj.user **/cordova/platforms/wp8/*.suo **/cordova/platforms/wp8/.staging **/cordova/platforms/wp8/bin **/cordova/platforms/wp8/obj **/cordova/platforms/wp8/www **/public/stylesheets/*.css *.a *.css.map *.elc *.gem *.hmap *.ipa *.o *.rbc *.sass.map *.scss.map *.so *.xccheckout *.xcuserdatad DerivedData build build-iPhoneOS build-iPhoneSimulator coverage coverage.data dist files/scripts/**/*.js files/scripts/**/*.py files/scripts/**/*.zip out pillars/files pkg profile rdoc target # Local Configuration Files **/cordova/platforms/android/CordovaLib/local.properties **/cordova/platforms/android/local.properties **/settings-local.yml **/settings/*-local.yml *.bundle *.iml *.ipr *.iws *.mode1v3 *.mode2v3 *.pbxuser *.perspectivev3 *.project *.sublime-project *.sublime-settings *.sublime-workspace *.tmproj .Rhistory .build .bundle .chamber*.enc .chamber*.enc.pass .chamber*.pem .emacs.desktop .emacs.desktop.lock .env .env.* .env.*.local .env.local .env.yml .foreman .htaccess .idea .idea_modules .powenv .powrc .pryrc .railsrc .rspec .rvmrc .secrets .shellwreck.sh .tern-port .terraform Gemfile.local Procfile.local atlassian-ide-plugin.xml com_crashlytics_export_strings.xml config.yml config/application.yml config/database.yml config/initializers/secret_token.rb config/master.key config/secrets.yml crashlytics-build.properties crashlytics.properties nbproject xcuserdata !.circleci/config.yml !.env.example !default.mode1v3 !default.mode2v3 !default.pbxuser !default.perspectivev3 # Temporary files *.backup *.bak *.gho *.lck *.lock *.log* *.moved-aside *.old *.ori *.orig *.rs.bk *.sqlite3 *.sqlite3-journal *.swo *.swp *.tmp *~ .\#* .netrwhist \#* db-sync dump.rdb log solr/* spec/examples.txt sql-dump-*.sql tmp # Vagrant .vagrant # Always keep chamber public keys !.chamber*.pub.pem # Always keep lock files !yarn.lock !Gemfile.lock !Cargo.lock !composer.lock # Always Version .keep and .gitkeep files !.gitkeep !.keep ruby-progressbar-releases-v1.10.1/.overcommit.yml000066400000000000000000000244171347307233000220700ustar00rootroot00000000000000# This is an opinionated list of which hooks are valuable to run and what their # out-of-the-box settings should be. #------------------------------------------------------------------------------- # Loads Bundler context from a Gemfile. If false, does nothing (default). # # Specifying a Gemfile for Bundler to load allows you to control which gems are # available in the load path (i.e. loadable via `require`) within your hook # runs. Note that having a Gemfile requires you to include `overcommit` itself # in your Gemfile (otherwise Overcommit can't load itself!). # # This is useful if you want to: # # - Enforce a specific version of Overcommit to use for all hook runs # (or to use a version from the master branch that has not been released yet) # - Enforce a specific version or unreleased branch is used for a gem you want # to use in your git hooks # # WARNING: This makes your hook runs slower, but you can work around this! # # Loading a Bundler context necessarily adds a startup delay to your hook runs # as Bundler parses the Gemfile and checks that the dependencies are satisfied. # Thus for projects with many gems this can introduce a noticeable delay. # # The recommended workaround is to create a separate Gemfile in the root of your # repository (call it `.overcommit_gems.rb`), and include only the gems that # your Overcommit hooks need in order to run. This significantly reduces the # startup delay in your hook runs. Make sure to commit both # `.overcommit_gems.rb` and the resulting `.overcommit_gems.rb.lock` file to # your repository, and then set the `gemfile` option below to the name you gave # the file. # (Generate lock file by running `bundle install --gemfile=.overcommit_gems.rb`) gemfile: false # Where to store hook plugins specific to a repository. These are loaded in # addition to the default hooks Overcommit comes with. The location is relative # to the root of the repository. plugin_directory: '.git-hooks' # Whether to hide hook output by default. This results in completely silent hook # runs except in the case of warning or failure. quiet: false # Number of hooks that can be run concurrently. Typically this won't need to be # adjusted, but if you know that some of your hooks themselves use multiple # processors you can lower this value accordingly. You can define # single-operator mathematical expressions, e.g. '%{processors} * 2', or # '%{processors} / 2'. concurrency: '%{processors}' # Whether to check if a hook plugin has changed since Overcommit last ran it. # This is a defense mechanism when working with repositories which can contain # untrusted code (e.g. when you fetch a pull request from a third party). # See https://github.com/brigade/overcommit#security for more information. verify_signatures: true PreCommit: ALL: problem_on_unmodified_line: 'report' requires_files: true required: false exclude: - 'bower_components/**/*' - 'node_modules/**/*' - 'vendor/**/*' AuthorEmail: enabled: true AuthorName: enabled: true BerksfileCheck: enabled: true Brakeman: enabled: false BrokenSymlinks: enabled: true BundleAudit: enabled: true include: - 'Gemfile' - 'Gemfile.lock' - '*.gemspec' BundleCheck: enabled: true include: - 'Gemfile' - 'Gemfile.lock' - '*.gemspec' BundleOutdated: enabled: true include: - 'Gemfile' - 'Gemfile.lock' - '*.gemspec' CaseConflicts: enabled: true ChamberSecurity: enabled: true CoffeeLint: enabled: true Credo: enabled: true include: - '**/*.ex' - '**/*.exs' CssLint: enabled: true Dogma: enabled: true EsLint: enabled: true ExecutePermissions: enabled: true exclude: - 'Rakefile' - 'bin/**/*' - 'scripts/**/*' Fasterer: enabled: false include: - '**/*.rb' FixMe: enabled: true keywords: - 'BROKEN' - 'BUG' - 'ERROR' - 'FIXME' - 'HACK' - 'NOTE' - 'OPTIMIZE' - 'REVIEW' - 'TODO' - 'WTF' - 'XXX' Foodcritic: enabled: false ForbiddenBranches: enabled: false GoLint: enabled: true GoVet: enabled: true Hlint: enabled: true HamlLint: enabled: false HardTabs: enabled: true exclude: - '**/*.svg' - '**/Info.plist' - '**/project.pbxproj' - '**/structure.sql' - '**/xcschememanagement.plist' HtmlHint: enabled: true HtmlTidy: enabled: false ImageOptim: enabled: false JavaCheckstyle: enabled: true Jscs: enabled: false JsHint: enabled: false JsLint: enabled: false Jsl: enabled: false JsonSyntax: enabled: true LicenseHeader: enabled: false licence_file: 'LICENSE.txt' LineEndings: enabled: true LocalPathsInGemfile: enabled: true Mdl: enabled: true include: - '**/*.md' MergeConflicts: enabled: true MessageFormat: enabled: true pattern: '(Add|Fix|Change|Remove|Deprecate|Security|Docs|Style|Tests|Chore|WIP):\s' expected_pattern_message: ': ' sample_message: 'Chore: Refactor onboarding flow' NginxTest: enabled: true Pep257: enabled: false Pep8: enabled: false PuppetLint: enabled: true Pyflakes: enabled: false Pylint: enabled: false PythonFlake8: enabled: false RailsBestPractices: enabled: false RailsSchemaUpToDate: enabled: true include: - '**/db/migrate/*.rb' - '**/db/schema.rb' - '**/db/structure.sql' Reek: enabled: false RuboCop: enabled: true RubyLint: enabled: false Scalariform: enabled: false Scalastyle: enabled: false ScssLint: enabled: true SemiStandard: enabled: false ShellCheck: enabled: true flags: - '--format=gcc' - '-e SC1090' - '-e SC1117' - '-e SC2148' - '-e SC2155' - '-e SC2181' include: - '**/*.sh' - '**/*.bash' - '**/*.zsh' - '**/bash_profile' - '**/bashrc' - '**/zshrc' SlimLint: enabled: false Sqlint: enabled: true Standard: enabled: false TrailingWhitespace: enabled: true exclude: '**/structure.sql' TravisLint: enabled: true TsLint: enabled: true include: - '**/*.ts' Vint: enabled: true W3cCss: enabled: false W3cHtml: enabled: false XmlLint: enabled: true XmlSyntax: enabled: true YamlLint: enabled: false include: - '**/*.yaml' - '**/*.yml' YamlSyntax: enabled: true PrePush: ALL: requires_files: false required: false Minitest: enabled: false ProtectedBranches: enabled: false RSpec: enabled: false PreRebase: ALL: requires_files: false required: false MergedCommits: enabled: false CommitMsg: ALL: requires_files: false CapitalizedSubject: enabled: true Commitplease: enabled: false EmptyMessage: enabled: false GerritChangeId: enabled: false HardTabs: enabled: true RussianNovel: enabled: false SingleLineSubject: enabled: true SpellCheck: enabled: false TextWidth: enabled: true max_subject_width: 72 max_body_width: 80 TrailingPeriod: enabled: true PostCheckout: ALL: required: false skip_file_checkout: true BowerInstall: enabled: false BundleCheck: enabled: true IndexTags: enabled: false NpmInstall: enabled: false SubmoduleStatus: enabled: false PostCommit: ALL: requires_files: false required: false BowerInstall: enabled: false BundleInstall: enabled: false GitGuilt: enabled: false IndexTags: enabled: false NpmInstall: enabled: false SubmoduleStatus: enabled: false PostMerge: ALL: enabled: false requires_files: false BowerInstall: enabled: false BundleInstall: enabled: false IndexTags: enabled: false NpmInstall: enabled: false SubmoduleStatus: enabled: false PostRewrite: ALL: requires_files: false BowerInstall: enabled: false BundleInstall: enabled: false IndexTags: enabled: false NpmInstall: enabled: false SubmoduleStatus: enabled: false ruby-progressbar-releases-v1.10.1/.rubocop.yml000066400000000000000000000002411347307233000213420ustar00rootroot00000000000000inherit_from: - '.rubocop_core.yml' - '.rubocop_rspec.yml' - '.rubocop_local.yml' # Put your project-specific Rubocop configuration in .rubocop_local.yml ruby-progressbar-releases-v1.10.1/.rubocop_core.yml000066400000000000000000001474231347307233000223700ustar00rootroot00000000000000# Last updated to rubocop 0.67.2 AllCops: Include: - '**/*.arb' - '**/*.axlsx' - '**/*.builder' - '**/*.fcgi' - '**/*.gemfile' - '**/*.gemspec' - '**/*.god' - '**/*.jb' - '**/*.jbuilder' - '**/*.mspec' - '**/*.opal' - '**/*.pluginspec' - '**/*.podspec' - '**/*.rabl' - '**/*.rake' - '**/*.rb' - '**/*.rbuild' - '**/*.rbw' - '**/*.rbx' - '**/*.ru' - '**/*.ruby' - '**/*.spec' - '**/*.thor' - '**/*.watchr' - '**/*Fastfile' - '**/.irbrc' - '**/.pryrc' - '**/Appraisals' - '**/Berksfile' - '**/Brewfile' - '**/Buildfile' - '**/Capfile' - '**/Cheffile' - '**/Dangerfile' - '**/Deliverfile' - '**/Fastfile' - '**/Gemfile' - '**/Guardfile' - '**/Jarfile' - '**/Mavenfile' - '**/Podfile' - '**/Puppetfile' - '**/Rakefile' - '**/Snapfile' - '**/Thorfile' - '**/Vagabondfile' - '**/Vagrantfile' - '**/buildfile' - '**/config.ru' Exclude: - '**/*.gemspec' - '**/admin/**/*.rb' - '**/config/deploy.rb' - '**/config/unicorn.rb' - '**/db/migrate/**/*' - '**/db/schema.rb' - '**/node_modules/**/*' - '**/spec/dummy/**/*' - '**/vendor/**/*' - '.git/**/*' - 'bin/rails' - 'bin/rake' - 'bin/spring' - 'dist/**/*' - 'log/**/*' - 'tmp/**/*' DefaultFormatter: 'fuubar' DisplayCopNames: true ################################################################################ # BUNDLER ################################################################################ Bundler/GemComment: Enabled: false Whitelist: [] Bundler/DuplicatedGem: Enabled: true Bundler/InsecureProtocolSource: Enabled: true Bundler/OrderedGems: Enabled: true TreatCommentsAsGroupSeparators: true ################################################################################ # GEMSPEC ################################################################################ Gemspec/DuplicatedAssignment: Enabled: true Gemspec/OrderedDependencies: Enabled: true TreatCommentsAsGroupSeparators: true Gemspec/RequiredRubyVersion: Enabled: true ################################################################################ # LAYOUT ################################################################################ Layout/AccessModifierIndentation: Enabled: true EnforcedStyle: 'indent' IndentationWidth: ~ Layout/AlignArray: Enabled: true Layout/AlignHash: Enabled: true EnforcedHashRocketStyle: 'table' EnforcedColonStyle: 'table' EnforcedLastArgumentHashStyle: 'always_inspect' Layout/AlignParameters: Enabled: true EnforcedStyle: 'with_first_parameter' IndentationWidth: ~ Exclude: - '**/Gemfile' Layout/BlockAlignment: Enabled: true EnforcedStyleAlignWith: 'either' Exclude: - '**/spec/**/factories/**/*.rb' - '**/spec/factories.rb' - 'app/controllers/**/*.rb' Layout/BlockEndNewline: Enabled: true Layout/CaseIndentation: Enabled: true EnforcedStyle: 'end' IndentOneStep: false IndentationWidth: ~ Layout/ClassStructure: Enabled: true ExpectedOrder: - 'prepend' - 'include' - 'extend' - 'constants' - 'cattr_accessor' - 'cattr_reader' - 'cattr_writer' - 'attr_accessor' - 'attr_reader' - 'attr_writer' - 'delegate' - 'serialize' - 'belongs_to' - 'has_one' - 'has_many' - 'has_and_belongs_to_many' - 'default_scope' - 'scope' - 'validates' - 'validate' - 'before_action' - 'before_validation' - 'after_validation' - 'before_save' - 'before_create' - 'after_action' - 'after_create' - 'after_save' - 'after_commit' - 'accepts_nested_attributes_for' - 'protect_from_forgery' - 'layout' - 'friendly_id' - 'geocoded_by' - 'has_attached_file' - 'has_attached_files' - 'has_one_attached' - 'has_many_attached' - 'states' - 'state_transitions' - 'public_class_methods' - 'initializer' - 'public_methods' - 'protected_methods' - 'private_methods' Layout/ClosingHeredocIndentation: Enabled: true Layout/ClosingParenthesisIndentation: Enabled: true Exclude: - '**/spec/**/*_spec.rb' Layout/CommentIndentation: Enabled: true Exclude: - '**/config/initializers/middleware.rb' Layout/ConditionPosition: Enabled: true Layout/DefEndAlignment: Enabled: true EnforcedStyleAlignWith: 'start_of_line' AutoCorrect: true Layout/DotPosition: Enabled: true EnforcedStyle: 'leading' Layout/ElseAlignment: Enabled: true Layout/EmptyComment: Enabled: true AllowBorderComment: true AllowMarginComment: true Layout/EmptyLineAfterGuardClause: Enabled: true Layout/EmptyLineAfterMagicComment: Enabled: true Layout/EmptyLineBetweenDefs: Enabled: true AllowAdjacentOneLineDefs: true NumberOfEmptyLines: 1 Layout/EmptyLinesAroundAccessModifier: Enabled: true Layout/EmptyLinesAroundArguments: Enabled: true Layout/EmptyLinesAroundBeginBody: Enabled: true Layout/EmptyLinesAroundBlockBody: Enabled: true EnforcedStyle: 'no_empty_lines' Exclude: - '**/engine.rb' - '**/spec/**/*.rb' Layout/EmptyLinesAroundClassBody: Enabled: true EnforcedStyle: 'no_empty_lines' Layout/EmptyLinesAroundExceptionHandlingKeywords: Enabled: true Layout/EmptyLinesAroundMethodBody: Enabled: true Layout/EmptyLinesAroundModuleBody: Enabled: true EnforcedStyle: 'no_empty_lines' Layout/EmptyLines: Enabled: true Layout/EndAlignment: Enabled: true EnforcedStyleAlignWith: 'keyword' AutoCorrect: true Layout/EndOfLine: Enabled: true EnforcedStyle: 'lf' Layout/ExtraSpacing: Enabled: true AllowBeforeTrailingComments: true AllowForAlignment: true ForceEqualSignAlignment: true Exclude: - '**/Gemfile' - '**/spec/**/factories/**/*.rb' - '**/spec/factories.rb' Layout/FirstArrayElementLineBreak: Enabled: true Layout/FirstHashElementLineBreak: Enabled: true Layout/FirstMethodArgumentLineBreak: # Disallows: my_method(foo, # bar) Enabled: false Layout/FirstMethodParameterLineBreak: # Disallows: def my_method(foo, # bar) Enabled: false Layout/FirstParameterIndentation: Enabled: true EnforcedStyle: 'consistent_relative_to_receiver' IndentationWidth: ~ Exclude: - '**/spec/**/*_spec.rb' Layout/IndentationConsistency: Enabled: true EnforcedStyle: 'normal' Layout/IndentationWidth: Enabled: true Width: 2 IgnoredPatterns: - '^\s*(module|class)' Layout/IndentArray: Enabled: true EnforcedStyle: 'align_brackets' IndentationWidth: ~ Layout/IndentAssignment: Enabled: true IndentationWidth: ~ Layout/IndentHash: Enabled: true EnforcedStyle: 'special_inside_parentheses' IndentationWidth: ~ Layout/IndentHeredoc: Enabled: true EnforcedStyle: 'squiggly' Layout/InitialIndentation: Enabled: true Layout/LeadingBlankLines: Enabled: true Layout/LeadingCommentSpace: Enabled: true Layout/MultilineArrayBraceLayout: Enabled: true EnforcedStyle: 'symmetrical' Layout/MultilineArrayLineBreaks: Enabled: true Layout/MultilineAssignmentLayout: Enabled: true EnforcedStyle: 'same_line' Layout/MultilineBlockLayout: Enabled: true Layout/MultilineHashBraceLayout: Enabled: true EnforcedStyle: 'symmetrical' Layout/MultilineHashKeyLineBreaks: Enabled: true # https://github.com/rubocop-hq/rubocop/issues/6936 Layout/MultilineMethodArgumentLineBreaks: Enabled: false Exclude: - 'Gemfile' - 'config/routes.rb' Layout/MultilineMethodCallBraceLayout: Enabled: true EnforcedStyle: 'symmetrical' Layout/MultilineMethodCallIndentation: Enabled: true EnforcedStyle: 'indented_relative_to_receiver' IndentationWidth: ~ Layout/MultilineMethodDefinitionBraceLayout: Enabled: true EnforcedStyle: 'symmetrical' Layout/MultilineOperationIndentation: # Disallows: @expires_at ||= Time.now.utc + # 60 Enabled: false EnforcedStyle: 'aligned' IndentationWidth: ~ Layout/RescueEnsureAlignment: Enabled: true Layout/SpaceAfterColon: Enabled: true Layout/SpaceAfterComma: Enabled: true Layout/SpaceAfterMethodName: Enabled: true Layout/SpaceAfterNot: Enabled: true Layout/SpaceAfterSemicolon: Enabled: true Layout/SpaceAroundBlockParameters: Enabled: true EnforcedStyleInsidePipes: 'no_space' Layout/SpaceAroundEqualsInParameterDefault: Enabled: true EnforcedStyle: 'space' Layout/SpaceAroundKeyword: Enabled: true Layout/SpaceAroundOperators: Enabled: true AllowForAlignment: true Layout/SpaceBeforeBlockBraces: Enabled: true EnforcedStyle: 'space' Layout/SpaceBeforeComma: Enabled: true Layout/SpaceBeforeComment: Enabled: true Layout/SpaceBeforeFirstArg: Enabled: true AllowForAlignment: true Exclude: - '**/spec/**/factories/**/*.rb' - '**/spec/factories.rb' Layout/SpaceBeforeSemicolon: Enabled: true Layout/SpaceInLambdaLiteral: Enabled: true EnforcedStyle: 'require_no_space' Layout/SpaceInsideArrayLiteralBrackets: Enabled: true EnforcedStyle: 'no_space' EnforcedStyleForEmptyBrackets: 'no_space' Layout/SpaceInsideArrayPercentLiteral: Enabled: true Layout/SpaceInsideBlockBraces: Enabled: true EnforcedStyle: 'space' EnforcedStyleForEmptyBraces: 'no_space' SpaceBeforeBlockParameters: true Layout/SpaceInsideHashLiteralBraces: Enabled: true EnforcedStyle: 'space' EnforcedStyleForEmptyBraces: 'no_space' Layout/SpaceInsideParens: Enabled: true Layout/SpaceInsidePercentLiteralDelimiters: Enabled: true Layout/SpaceInsideRangeLiteral: Enabled: true Layout/SpaceInsideReferenceBrackets: Enabled: true EnforcedStyle: 'no_space' EnforcedStyleForEmptyBrackets: 'no_space' Layout/SpaceInsideStringInterpolation: Enabled: true EnforcedStyle: 'no_space' Layout/Tab: Enabled: true Layout/TrailingBlankLines: Enabled: true EnforcedStyle: 'final_newline' Layout/TrailingWhitespace: Enabled: true ################################################################################ # LINTS ################################################################################ Lint/AmbiguousBlockAssociation: Enabled: true Exclude: - '**/app/models/**/*.rb' - '**/spec/**/*_spec.rb' Lint/AmbiguousOperator: Enabled: true Lint/AmbiguousRegexpLiteral: Enabled: true Lint/AssignmentInCondition: Enabled: true AllowSafeAssignment: true Lint/BigDecimalNew: Enabled: true Lint/BooleanSymbol: Enabled: true Lint/CircularArgumentReference: Enabled: true Lint/Debugger: Enabled: true Lint/DeprecatedClassMethods: Enabled: true Lint/DisjunctiveAssignmentInConstructor: Enabled: true Lint/DuplicatedKey: Enabled: true Lint/DuplicateMethods: Enabled: true Lint/EachWithObjectArgument: Enabled: true Lint/ElseLayout: Enabled: true Lint/EmptyEnsure: Enabled: true Lint/EmptyInterpolation: Enabled: true Lint/EmptyWhen: Enabled: true Lint/EndInMethod: Enabled: true Lint/EnsureReturn: Enabled: true Lint/ErbNewArguments: Enabled: true Lint/FlipFlop: Enabled: true Lint/FloatOutOfRange: Enabled: true Lint/FormatParameterMismatch: Enabled: true Lint/HandleExceptions: Enabled: true Lint/ImplicitStringConcatenation: Enabled: true Lint/IneffectiveAccessModifier: Enabled: true Lint/InheritException: Enabled: true EnforcedStyle: 'standard_error' Lint/LiteralAsCondition: Enabled: true Lint/LiteralInInterpolation: Enabled: true Lint/Loop: Enabled: true Lint/MissingCopEnableDirective: Enabled: true Lint/MultipleCompare: Enabled: true Lint/NestedMethodDefinition: Enabled: true Lint/NonLocalExitFromIterator: Enabled: true Lint/OrderedMagicComments: Enabled: true Lint/ParenthesesAsGroupedExpression: Enabled: true Lint/PercentStringArray: Enabled: true Lint/PercentSymbolArray: Enabled: true Lint/RandOne: Enabled: true Lint/RedundantWithIndex: Enabled: true Lint/RedundantWithObject: Enabled: true Lint/RequireParentheses: Enabled: true Lint/RescueException: Enabled: true Lint/ReturnInVoidContext: Enabled: true Lint/SafeNavigationChain: Enabled: true Whitelist: - 'present?' - 'blank?' - 'presence' - 'try!' - 'try' Lint/SafeNavigationConsistency: Enabled: true Lint/SafeNavigationWithEmpty: Enabled: true Lint/ScriptPermission: Enabled: true Lint/ShadowedArgument: Enabled: true IgnoreImplicitReferences: false Lint/ShadowedException: Enabled: true Lint/ShadowingOuterLocalVariable: Enabled: true Lint/StringConversionInInterpolation: Enabled: true Lint/ToJSON: Enabled: true Lint/UnderscorePrefixedVariableName: Enabled: true Lint/UnifiedInteger: Enabled: true Lint/UnneededCopDisableDirective: Enabled: true Lint/UnneededCopEnableDirective: Enabled: true Lint/UnneededRequireStatement: Enabled: true Lint/UnneededSplatExpansion: Enabled: true Lint/UnreachableCode: Enabled: true Lint/UnusedBlockArgument: Enabled: true AllowUnusedKeywordArguments: true IgnoreEmptyBlocks: true Lint/UnusedMethodArgument: Enabled: true AllowUnusedKeywordArguments: true IgnoreEmptyMethods: true Lint/UriEscapeUnescape: Enabled: true Lint/UriRegexp: Enabled: true Lint/UselessAccessModifier: Enabled: true Lint/UselessAssignment: Enabled: true Lint/UselessComparison: Enabled: true Lint/UselessElseWithoutRescue: Enabled: true Lint/UselessSetterCall: Enabled: true Lint/Void: Enabled: true ################################################################################ # METRICS ################################################################################ Metrics/AbcSize: Enabled: true Max: 25.0 Exclude: - '**/db/sample.rb' Metrics/BlockNesting: Enabled: true CountBlocks: true Max: 3 Exclude: - '**/*.rake' - '**/config/routes.rb' - '**/db/sample.rb' - '**/refinements/*.rb' - '**/spec/**/*_spec.rb' - '**/spec/**/factories/**/*.rb' - '**/spec/factories.rb' - 'Rakefile' Metrics/BlockLength: CountComments: false Max: 25 Exclude: - '**/*.rake' - '**/config/routes.rb' - '**/db/sample.rb' - '**/db/scrub.rb' - '**/db/seed.rb' - '**/refinements/*.rb' - '**/spec/**/*_spec.rb' - '**/spec/**/factories/**/*.rb' - '**/spec/factories.rb' - '**/spec/shared/**/*.rb' - '**/spec/support/**/*.rb' - 'Rakefile' ExcludedMethods: - 'namespace' - 'draw' - 'context' - 'describe' - 'refine' - 'shared_examples' - 'shared_examples_for' Metrics/ClassLength: Enabled: true CountComments: false Max: 200 Exclude: - '**/spec/**/*_spec.rb' Metrics/ModuleLength: Enabled: true CountComments: false Max: 200 Exclude: - '**/spec/**/*_spec.rb' Metrics/CyclomaticComplexity: Enabled: true Max: 6 # yamllint disable rule:line-length Metrics/LineLength: Enabled: true Max: 90 AllowHeredoc: true AllowURI: true IgnoreCopDirectives: true IgnoredPatterns: - "\\s+raise_error\\([^)]+\\)$" # raise_error(LongClassName) - "^(\\s+|.*)'[^']+'\\s+=\\>\\s+'[^']+',$" # 'foo' => 'really_long_string', - "^(\\s+|.*)'[^']+'\\s+=\\>\\s+\\\"[^\\\"]+\\\",$" # 'foo' => "really_long_string", - "^(\\s+|.*)'[^']+'\\s+=\\>\\s+match\\(.*\\)," # 'foo' => match(/really_long_regex/), - "^(\\s+|.*):[\\w_]+\\s+=\\>\\s+'[^']+',$" # :foo => 'really_long_string', - "^(\\s+|.*):[\\w_]+\\s+=\\>\\s+\\\"[^\\\"]+\\\",$" # :foo => "really_long_string", - "^(\\s+|.*)[\\w_]+:\\s+'[^']+',$" # foo: 'really_long_string', - "^(\\s+|.*)[\\w_]+:\\s+\\\"[^\\\"]+\\\",$" # foo: "really_long_string", - "^\\s*(fail|raise)\\s+" # fail or raise an exception - "^\\s*class\\s+" # class definition with really long inherited class - "^\\s*require\\s+'[^']+'$" # require 'some_really_long_path_name' - "^\\s+expect\\([^\\)]+\\)+\\.(not_)?to\\s+[^\\s]+\\s+%[qQ]{[^}]+}$" # RSpec expectation line for a string with %q syntax - "^\\s+expect\\([^\\)]+\\)+\\.(not_)?to\\s+[^\\s]+\\s+'[^']+'$" # RSpec expectation line for a single-quoted string - "^\\s+expect\\([^\\)]+\\)+\\.(not_)?to\\s+[^\\s]+\\s+Time\\.(new|utc).*" # RSpec expectation line for a Time - "^\\s+expect\\([^\\)]+\\)+\\.(not_)?to\\s+[^\\s]+\\s+\\\"[^\\\"]+\\\"$" # RSpec expectation line for a double-quoted string - "^\\s+return\\s+.*(if|unless)" # Short circuiting returns - '^\s*((private|public|protected)\s+)?def\s+[\w\._]+\(?' # Method definitions - '^\s+belongs_to\s+.*' # Rails belongs_to relationships - '^\s+broadcast[\s\\(].*' # Wisper Broadcasts - '^\s+context\s+.*' # RSpec context lines - '^\s+describe\s+.*' # RSpec describe lines - '^\s+expose\(:[\w_]+\)\s+\{.*' # Controller exposures - '^\s+factory\s+.*' # FactoryBot factory definitions - '^\s+has_many\s+.*' # Rails has_many relationships - '^\s+has_one\s+.*' # Rails has_one relationships - '^\s+it\s+.*' # RSpec it lines - '^\s+let\(:[\w_]+\)\s+\{.*' # RSpec lets on single line - '^\s+scope\s+.*' # Rails scopes URISchemes: - 'http' - 'https' Exclude: - '**/Gemfile' - '**/config/environments/**/*' - '**/config/initializers/**/*' - '**/config/routes.rb' - '**/db/sample.rb' - '**/db/scrub.rb' - '**/db/seed.rb' - '**/spec/**/factories/**/*.rb' - '**/spec/factories.rb' # yamllint enable rule:line-length Metrics/MethodLength: Enabled: true CountComments: false Max: 30 ExcludedMethods: [] Exclude: - '**/db/sample.rb' - '**/db/scrub.rb' - '**/db/seed.rb' Metrics/ParameterLists: Enabled: true Max: 5 CountKeywordArgs: true Metrics/PerceivedComplexity: Enabled: true Max: 7 ################################################################################ # NAMING ################################################################################ Naming/AccessorMethodName: Enabled: true Naming/AsciiIdentifiers: Enabled: true Naming/BinaryOperatorParameterName: Enabled: true Naming/ClassAndModuleCamelCase: Enabled: true Naming/ConstantName: Enabled: true Naming/FileName: Enabled: true IgnoreExecutableScripts: true ExpectMatchingDefinition: false Exclude: - '**/Rakefile' - '**/Gemfile' - '**/Capfile' - '**/Vagrantfile' - '**/Podfile' - '**/Thorfile' Naming/HeredocDelimiterNaming: Enabled: true Blacklist: - 'END' - !ruby/regexp '/EO[A-Z]{1}/' Naming/HeredocDelimiterCase: Enabled: true EnforcedStyle: 'uppercase' Naming/MemoizedInstanceVariableName: Enabled: true EnforcedStyleForLeadingUnderscores: 'disallowed' Naming/MethodName: Enabled: true EnforcedStyle: 'snake_case' Naming/PredicateName: Enabled: true NamePrefix: - 'is_' - 'was_' - 'has_' - 'have_' NamePrefixBlacklist: - 'is_' - 'was_' - 'have_' NameWhitelist: - 'is_a?' MethodDefinitionMacros: - 'define_method' - 'define_singleton_method' Exclude: - '**/spec/**/*.rb' Naming/RescuedExceptionsVariableName: Enabled: true PreferredName: 'error' Naming/UncommunicativeBlockParamName: Enabled: true MinNameLength: 1 AllowNamesEndingInNumbers: true AllowedNames: [] ForbiddenNames: [] Naming/UncommunicativeMethodParamName: Enabled: true MinNameLength: 3 AllowNamesEndingInNumbers: true AllowedNames: - 'at' - 'by' - 'db' - 'id' - 'in' - 'io' - 'ip' - 'on' - 'to' ForbiddenNames: [] Naming/VariableName: Enabled: true EnforcedStyle: 'snake_case' Naming/VariableNumber: Enabled: true EnforcedStyle: 'snake_case' ################################################################################ # PERFORMANCE ################################################################################ Performance/Caller: Enabled: true Performance/Casecmp: Enabled: true Performance/CaseWhenSplat: Enabled: true Performance/ChainArrayAllocation: Enabled: true Performance/CompareWithBlock: Enabled: true Performance/Count: Enabled: true Performance/Detect: Enabled: true Performance/DoubleStartEndWith: Enabled: true IncludeActiveSupportAliases: true Performance/EndWith: Enabled: true Performance/FixedSize: Enabled: true Performance/FlatMap: Enabled: true Performance/InefficientHashSearch: Enabled: true Performance/OpenStruct: Enabled: true Exclude: - '**/spec/**/*.rb' Performance/RangeInclude: Enabled: true Performance/RedundantBlockCall: Enabled: true Performance/RedundantMatch: Enabled: true Performance/RedundantMerge: Enabled: true Performance/RegexpMatch: Enabled: true Performance/ReverseEach: Enabled: true Performance/Size: Enabled: true Performance/StartWith: Enabled: true Performance/StringReplacement: Enabled: true Performance/TimesMap: Enabled: true AutoCorrect: true Performance/UnfreezeString: Enabled: true Performance/UriDefaultParser: Enabled: true ################################################################################ # SECURITY ################################################################################ Security/Eval: Enabled: true Security/JSONLoad: Enabled: true Exclude: - '**/spec/**/*.rb' Security/Open: Enabled: true Security/YAMLLoad: Enabled: true Exclude: - '**/spec/**/*.rb' Security/MarshalLoad: Enabled: true Exclude: - '**/spec/**/*.rb' ################################################################################ # STYLE ################################################################################ Style/AccessModifierDeclarations: Enabled: true EnforcedStyle: 'group' Style/Alias: Enabled: true EnforcedStyle: 'prefer_alias' Style/AndOr: Enabled: true EnforcedStyle: 'always' Style/ArrayJoin: Enabled: true Style/AsciiComments: Enabled: true AllowedChars: [] Style/Attr: Enabled: true Style/AutoResourceCleanup: Enabled: true Style/BarePercentLiterals: Enabled: true EnforcedStyle: 'percent_q' Style/BeginBlock: Enabled: true Style/BlockComments: Enabled: true Style/BlockDelimiters: Enabled: true EnforcedStyle: 'braces_for_chaining' AllowBracesOnProceduralOneLiners: true Exclude: - '**/spec/**/factories/**/*.rb' - '**/spec/factories.rb' - 'app/controllers/**/*.rb' Style/BracesAroundHashParameters: Enabled: true EnforcedStyle: 'context_dependent' Style/CaseEquality: Enabled: true Style/CharacterLiteral: Enabled: true Style/ClassAndModuleChildren: Enabled: true EnforcedStyle: 'nested' Style/ClassCheck: Enabled: true EnforcedStyle: 'is_a?' Style/ClassMethods: Enabled: true Style/ClassVars: Enabled: true Style/CollectionMethods: Enabled: true PreferredMethods: collect: 'map' collect!: 'map!' reduce: 'inject' detect: 'find' find_all: 'select' Style/ColonMethodCall: Enabled: true Style/ColonMethodDefinition: Enabled: true Style/CommandLiteral: Enabled: true EnforcedStyle: 'backticks' AllowInnerBackticks: false Style/CommentAnnotation: Enabled: true Keywords: - 'TODO' - 'FIXME' - 'OPTIMIZE' - 'HACK' - 'REVIEW' Style/CommentedKeyword: Enabled: true Exclude: - '**/Gemfile' Style/ConditionalAssignment: Enabled: true EnforcedStyle: 'assign_to_condition' IncludeTernaryExpressions: true SingleLineConditionsOnly: false Style/ConstantVisibility: Enabled: true Style/Copyright: # Copyrights at the Top of Files are Noisy Enabled: false Style/DefWithParentheses: Enabled: true Style/Dir: Enabled: true Style/Documentation: # Use Some Other Tool Like `inch` to Enforce This Enabled: false Style/DocumentationMethod: RequireForNonPublicMethods: false Style/DoubleNegation: Enabled: true Style/EachForSimpleLoop: Enabled: true Style/EachWithObject: Enabled: true Style/EmptyBlockParameter: Enabled: true Style/EmptyCaseCondition: Enabled: true Style/EmptyElse: Enabled: true EnforcedStyle: 'both' Style/EmptyLiteral: Enabled: true Exclude: - '**/spec/**/factories/**/*.rb' - '**/spec/factories.rb' Style/EmptyMethod: Enabled: true EnforcedStyle: 'compact' Style/Encoding: Enabled: true Style/EndBlock: Enabled: true Style/ExpandPathArguments: Enabled: true Style/EvalWithLocation: Enabled: true Style/EvenOdd: Enabled: true Style/For: Enabled: true EnforcedStyle: 'each' Style/FormatString: Enabled: true EnforcedStyle: 'percent' Style/FormatStringToken: Enabled: true EnforcedStyle: 'annotated' Style/FrozenStringLiteralComment: Enabled: true Style/GlobalVars: Enabled: true AllowedVariables: [] Style/GuardClause: Enabled: true MinBodyLength: 1 Style/HashSyntax: Enabled: true EnforcedStyle: 'ruby19' UseHashRocketsWithSymbolValues: false PreferHashRocketsForNonAlnumEndingSymbols: true Style/IdenticalConditionalBranches: Enabled: true Style/IfInsideElse: Enabled: true Style/IfUnlessModifier: Enabled: true Exclude: - '**/config/initializers/*.rb' Style/IfUnlessModifierOfIfUnless: Enabled: true Style/IfWithSemicolon: Enabled: true Style/ImplicitRuntimeError: Enabled: true Style/InfiniteLoop: Enabled: true Style/InlineComment: Enabled: true Exclude: - '**/Gemfile' - '**/config/boot.rb' - '**/config/initializers/*.rb' Style/InverseMethods: Enabled: true InverseMethods: :any?: :none? :even?: :odd? :==: :!= :=~: :!~ :<: :>= :>: :<= :present?: :blank?, :include?: :exclude? InverseBlocks: :select: :reject :select!: :reject! Style/IpAddresses: Enabled: true Whitelist: - '::' Exclude: - '**/spec/**/*_spec.rb' - '**/spec/**/factories/**/*.rb' - '**/spec/factories.rb' Style/Lambda: Enabled: true Style/LambdaCall: Enabled: true EnforcedStyle: 'call' Style/LineEndConcatenation: Enabled: true Style/MethodCalledOnDoEndBlock: Enabled: true Style/MethodCallWithArgsParentheses: # Would Require a *lot* of Effort Adding Ignored Methods Enabled: false AllowParenthesesInMultilineCall: true AllowParenthesesInChaining: true AllowParenthesesInCamelCaseMethod: true IgnoreMacros: true IgnoredMethods: - 'puts' Style/MethodCallWithoutArgsParentheses: Enabled: true IgnoredMethods: [] Style/MethodDefParentheses: Enabled: true EnforcedStyle: 'require_parentheses' Style/MethodMissingSuper: Enabled: true Style/MinMax: Enabled: true Style/MissingElse: # Decent Idea But Too Many Use Cases for `if` Without `else` Enabled: false EnforcedStyle: 'both' SupportedStyles: - 'if' - 'case' - 'both' Style/MissingRespondToMissing: Enabled: true Style/MixinGrouping: Enabled: true EnforcedStyle: 'separated' Exclude: - '**/spec/**/*_spec.rb' Style/MixinUsage: Enabled: true Style/ModuleFunction: Enabled: true EnforcedStyle: 'module_function' Style/MultilineBlockChain: Enabled: true Exclude: - '**/spec/**/*_spec.rb' Style/MultilineIfModifier: Enabled: true Style/MultilineIfThen: Enabled: true Style/MultilineMemoization: Enabled: true EnforcedStyle: 'keyword' Style/MultilineMethodSignature: # Disallows: my_method(foo, # bar) Enabled: false Style/MultilineTernaryOperator: Enabled: true Style/MultipleComparison: Enabled: true Style/MutableConstant: Enabled: true Style/NegatedIf: Enabled: true EnforcedStyle: 'both' Style/NegatedWhile: Enabled: true Style/NestedModifier: Enabled: true Style/NestedParenthesizedCalls: Enabled: true Whitelist: - 'be' - 'be_a' - 'be_an' - 'be_between' - 'be_falsey' - 'be_kind_of' - 'be_instance_of' - 'be_truthy' - 'be_within' - 'eq' - 'eql' - 'end_with' - 'include' - 'match' - 'raise_error' - 'respond_to' - 'start_with' Style/NestedTernaryOperator: Enabled: true Style/Next: Enabled: true EnforcedStyle: 'skip_modifier_ifs' MinBodyLength: 3 Style/NilComparison: Enabled: true EnforcedStyle: 'predicate' Style/NonNilCheck: Enabled: true IncludeSemanticChanges: false Style/Not: Enabled: true Style/NumericLiteralPrefix: Enabled: true EnforcedOctalStyle: 'zero_with_o' Style/NumericLiterals: Enabled: true MinDigits: 5 Strict: false Style/NumericPredicate: Enabled: true EnforcedStyle: 'predicate' IgnoredMethods: [] Exclude: - '**/spec/**/*_spec.rb' Style/OneLineConditional: Enabled: true Style/OptionalArguments: Enabled: true Style/OptionHash: Enabled: true Exclude: - '**/workers/**/*.rb' - '**/jobs/**/*.rb' SuspiciousParamNames: - 'options' - 'opts' - 'args' - 'params' - 'parameters' Style/OrAssignment: Enabled: true Style/ParallelAssignment: Enabled: true Style/ParenthesesAroundCondition: Enabled: true AllowSafeAssignment: true AllowInMultilineConditions: false Style/PercentLiteralDelimiters: Enabled: true PreferredDelimiters: '%': '{}' '%i': '{}' '%I': '{}' '%q': '{}' '%Q': '{}' '%r': '{}' '%s': '{}' '%w': '{}' '%W': '{}' '%x': '{}' Style/PercentQLiterals: Enabled: true EnforcedStyle: 'upper_case_q' Style/PerlBackrefs: Enabled: true Style/PreferredHashMethods: Enabled: true EnforcedStyle: 'verbose' Style/Proc: Enabled: true Style/RaiseArgs: Enabled: true EnforcedStyle: 'exploded' Style/RandomWithOffset: Enabled: true Style/RedundantBegin: Enabled: true Style/RedundantConditional: Enabled: true Style/RedundantException: Enabled: true Style/RedundantFreeze: Enabled: true Style/RedundantParentheses: Enabled: true Style/RedundantReturn: Enabled: true AllowMultipleReturnValues: true Style/RedundantSelf: Enabled: true Style/RedundantSortBy: Enabled: true Style/RegexpLiteral: Enabled: true EnforcedStyle: 'slashes' AllowInnerSlashes: false Style/RescueModifier: Enabled: true Style/RescueStandardError: Enabled: true Style/ReturnNil: Enabled: true EnforcedStyle: 'return' Style/SafeNavigation: Enabled: true ConvertCodeThatCanStartToReturnNil: false Whitelist: - 'blank?' - 'presence' - 'present?' - 'try!' - 'try' Style/Sample: Enabled: true Style/SelfAssignment: Enabled: true Style/Semicolon: Enabled: true AllowAsExpressionSeparator: false Style/Send: Enabled: true Exclude: - '**/spec/**/*_spec.rb' Style/SignalException: Enabled: true EnforcedStyle: 'semantic' Style/SingleLineBlockParams: Enabled: true Methods: - reduce: - 'm' - 'v' - inject: - 'm' - 'v' Style/SingleLineMethods: Enabled: true AllowIfMethodIsEmpty: true Exclude: - 'app/models/**/*.rb' Style/SpecialGlobalVars: Enabled: true EnforcedStyle: 'use_english_names' Style/StabbyLambdaParentheses: Enabled: true EnforcedStyle: 'require_parentheses' Style/StderrPuts: Enabled: true Style/StringHashKeys: Enabled: false # Requires Symbolized Hash Keys Style/StringLiterals: Enabled: true EnforcedStyle: 'single_quotes' ConsistentQuotesInMultiline: true Style/StringLiteralsInInterpolation: Enabled: true Style/StringMethods: Enabled: true PreferredMethods: intern: 'to_sym' Style/Strip: Enabled: true Style/StructInheritance: Enabled: true Style/SymbolArray: Enabled: true EnforcedStyle: 'percent' MinSize: 0 Style/SymbolLiteral: Enabled: true Style/SymbolProc: Enabled: true IgnoredMethods: - 'respond_to' - 'define_method' Style/TernaryParentheses: Enabled: true AllowSafeAssignment: true EnforcedStyle: 'require_parentheses_when_complex' Style/TrailingBodyOnClass: Enabled: true Style/TrailingBodyOnMethodDefinition: Enabled: true Style/TrailingBodyOnModule: Enabled: true Style/TrailingCommaInArguments: Enabled: true EnforcedStyleForMultiline: 'comma' Style/TrailingCommaInArrayLiteral: Enabled: true EnforcedStyleForMultiline: 'comma' Style/TrailingCommaInHashLiteral: Enabled: true EnforcedStyleForMultiline: 'comma' Style/TrailingMethodEndStatement: Enabled: true Style/TrailingUnderscoreVariable: Enabled: true AllowNamedUnderscoreVariables: true Style/TrivialAccessors: Enabled: true AllowPredicates: false Style/UnlessElse: Enabled: true Style/UnneededCapitalW: Enabled: true Style/UnneededCondition: Enabled: true Style/UnneededInterpolation: Enabled: true Style/UnneededPercentQ: Enabled: true Style/UnpackFirst: Enabled: true Style/VariableInterpolation: Enabled: true Style/WhenThen: Enabled: true Style/WhileUntilDo: Enabled: true Style/WhileUntilModifier: Enabled: true Style/WordArray: Enabled: true EnforcedStyle: 'percent' MinSize: 0 Style/YodaCondition: Enabled: true EnforcedStyle: 'forbid_for_all_comparison_operators' Style/ZeroLengthPredicate: Enabled: true ruby-progressbar-releases-v1.10.1/.rubocop_local.yml000066400000000000000000000016051347307233000225210ustar00rootroot00000000000000Layout/ClassStructure: Enabled: false Layout/ClosingParenthesisIndentation: Enabled: false Layout/DotPosition: EnforcedStyle: 'trailing' Layout/ExtraSpacing: Enabled: false Layout/IndentationWidth: Enabled: false Layout/MultilineMethodCallIndentation: Enabled: false Naming/FileName: Exclude: - 'lib/ruby-progressbar.rb' Style/ConstantVisibility: Enabled: false Style/FrozenStringLiteralComment: Enabled: false Style/HashSyntax: EnforcedStyle: hash_rockets Style/Lambda: Enabled: false Style/NumericPredicate: Enabled: false Style/OptionHash: Enabled: false Style/SafeNavigation: Enabled: false Style/SymbolArray: Enabled: false Style/TrailingCommaInArguments: EnforcedStyleForMultiline: 'no_comma' Style/TrailingCommaInArrayLiteral: EnforcedStyleForMultiline: 'no_comma' Style/TrailingCommaInHashLiteral: EnforcedStyleForMultiline: 'no_comma' ruby-progressbar-releases-v1.10.1/.rubocop_rspec.yml000066400000000000000000000134671347307233000225540ustar00rootroot00000000000000# Last updated to 1.31.0 require: - 'rubocop-rspec' Capybara/FeatureMethods: Enabled: true Capybara/CurrentPathExpectation: Enabled: true FactoryBot/CreateList: Enabled: true FactoryBot/AttributeDefinedStatically: Enabled: true Rails/HttpStatus: Enabled: true EnforcedStyle: 'numeric' RSpec/AlignLeftLetBrace: Enabled: true RSpec/AlignRightLetBrace: Enabled: false RSpec/AnyInstance: Enabled: true RSpec/AroundBlock: Enabled: true RSpec/Be: Enabled: true RSpec/BeEql: Enabled: true RSpec/BeforeAfterAll: Enabled: true Exclude: - 'spec/spec_helper.rb' - 'spec/rails_helper.rb' - 'spec/support/**/*.rb' RSpec/ContextWording: Enabled: true Prefixes: - 'administrators' - 'anyone' - 'regular users' - 'when' - 'with' - 'without' RSpec/DescribeClass: Enabled: true RSpec/DescribeMethod: Enabled: true RSpec/DescribeSymbol: Enabled: true RSpec/DescribedClass: Enabled: true SkipBlocks: false EnforcedStyle: 'explicit' RSpec/EmptyExampleGroup: Enabled: false CustomIncludeMethods: [] RSpec/EmptyLineAfterExampleGroup: Enabled: true RSpec/EmptyLineAfterFinalLet: Enabled: true RSpec/EmptyLineAfterHook: Enabled: true RSpec/EmptyLineAfterSubject: Enabled: true Exclude: - '**/factories/*.rb' RSpec/ExampleLength: Enabled: false Max: 50 RSpec/ExampleWithoutDescription: Enabled: true EnforcedStyle: 'single_line_only' RSpec/ExampleWording: Enabled: true IgnoredWords: [] RSpec/ExpectActual: Enabled: true Exclude: - 'spec/routing/**/*' RSpec/ExpectChange: Enabled: true EnforcedStyle: 'method_call' RSpec/ExpectInHook: Enabled: true RSpec/ExpectOutput: Enabled: true RSpec/FilePath: Enabled: false IgnoreMethods: false CustomTransform: RuboCop: 'rubocop' RSpec: 'rspec' RSpec/Focus: Enabled: true RSpec/HookArgument: Enabled: true EnforcedStyle: 'each' RSpec/HooksBeforeExamples: Enabled: true RSpec/ImplicitExpect: Enabled: true EnforcedStyle: 'is_expected' RSpec/ImplicitSubject: Enabled: true EnforcedStyle: 'single_statement_only' RSpec/InstanceSpy: Enabled: true RSpec/InstanceVariable: Enabled: true RSpec/InvalidPredicateMatcher: Enabled: true RSpec/ItBehavesLike: Enabled: true EnforcedStyle: 'it_behaves_like' RSpec/IteratedExpectation: Enabled: true RSpec/LeadingSubject: Enabled: true RSpec/LetBeforeExamples: Enabled: true RSpec/LetSetup: Enabled: true RSpec/MessageChain: Enabled: true RSpec/MessageExpectation: Enabled: true EnforcedStyle: 'allow' RSpec/MessageSpies: Enabled: true EnforcedStyle: 'have_received' RSpec/MissingExampleGroupArgument: Enabled: true RSpec/MultipleDescribes: Enabled: true RSpec/MultipleExpectations: Enabled: false AggregateFailuresByDefault: true Max: 5 RSpec/MultipleSubjects: Enabled: true RSpec/NamedSubject: Enabled: true IgnoreSharedExamples: true RSpec/NestedGroups: Enabled: true Max: 1 RSpec/NotToNot: Enabled: true EnforcedStyle: 'not_to' RSpec/OverwritingSetup: Enabled: true RSpec/Pending: Enabled: false RSpec/PredicateMatcher: Enabled: true Strict: true EnforcedStyle: 'inflected' RSpec/ReceiveCounts: Enabled: true RSpec/ReceiveNever: Enabled: true RSpec/RepeatedDescription: Enabled: true RSpec/RepeatedExample: Enabled: true RSpec/ReturnFromStub: Enabled: true EnforcedStyle: 'and_return' RSpec/ScatteredLet: Enabled: true RSpec/ScatteredSetup: Enabled: true RSpec/SharedContext: Enabled: true RSpec/SharedExamples: Enabled: true RSpec/SingleArgumentMessageChain: Enabled: true RSpec/SubjectStub: Enabled: true RSpec/UnspecifiedException: Enabled: true RSpec/VerifiedDoubles: Enabled: true IgnoreSymbolicNames: false IgnoreNameless: false RSpec/VoidExpect: Enabled: true RSpec/Yield: Enabled: true ruby-progressbar-releases-v1.10.1/.ruby-version000066400000000000000000000000061347307233000215340ustar00rootroot000000000000002.6.2 ruby-progressbar-releases-v1.10.1/.travis.yml000066400000000000000000000004311347307233000212020ustar00rootroot00000000000000language: ruby rvm: - 1.8.7 - 1.9.2 - 1.9.3 - 2.0 - 2.1 - 2.2 - 2.3.0 - 2.3.1 - 2.4.0 - 2.5.1 - 2.6.2 before_install: - gem update bundler script: bundle exec rspec notifications: slack: rooms: - thekompanee:p46x27zMG89XW66DgGuutoaW#open-source ruby-progressbar-releases-v1.10.1/.yamllint000066400000000000000000000035741347307233000207360ustar00rootroot00000000000000rules: braces: min-spaces-inside: 1 max-spaces-inside: 1 min-spaces-inside-empty: 0 max-spaces-inside-empty: 0 brackets: min-spaces-inside: 0 max-spaces-inside: 0 min-spaces-inside-empty: 0 max-spaces-inside-empty: 0 colons: max-spaces-before: 0 max-spaces-after: -1 commas: max-spaces-before: 0 min-spaces-after: 1 max-spaces-after: 1 comments: require-starting-space: true min-spaces-from-content: 1 comments-indentation: "enable" document-end: present: false document-start: present: false empty-lines: max: 1 max-start: 0 max-end: 0 empty-values: forbid-in-block-mappings: true forbid-in-flow-mappings: true hyphens: max-spaces-after: 1 indentation: spaces: 2 indent-sequences: true check-multi-line-strings: false key-duplicates: "enable" key-ordering: "disable" line-length: max: 90 allow-non-breakable-words: true allow-non-breakable-inline-mappings: true new-line-at-end-of-file: "enable" new-lines: type: "unix" octal-values: forbid-implicit-octal: true forbid-explicit-octal: true trailing-spaces: "enable" truthy: "enable" ruby-progressbar-releases-v1.10.1/CHANGELOG.md000066400000000000000000000722201347307233000207070ustar00rootroot00000000000000Version v1.10.0 - August 3, 2018 ================================================================================ Add -------------------------------------------------------------------------------- * %W flag for complete_bar_with_percentage * %W Flag for complete_bar_with_percentage Change -------------------------------------------------------------------------------- * Don't rely on default when building complete bar Fix -------------------------------------------------------------------------------- * NoMethodError on decrement when output is non-TTY Uncategorized -------------------------------------------------------------------------------- * Fix no method error on decrement when output is not TTY enabled Version v1.9.0 - September 27, 2017 ================================================================================ Performance -------------------------------------------------------------------------------- * don't shell out when it's avoidable. Change -------------------------------------------------------------------------------- * Don't allow user to override total or starting_at in Enumerator * print_and_flush to be explicitly a private method Uncategorized -------------------------------------------------------------------------------- * Enumerator#to_progressbar as a refinement Remove -------------------------------------------------------------------------------- * Explicit clear on start Fix -------------------------------------------------------------------------------- * Components::Time to allow #estimated_seconds_remaining to be called Add -------------------------------------------------------------------------------- * Base#to_h to expose all of the data about the current bar state * Outputs::Null for users who don't want the bar sent anywhere * Ability to specify a completely custom output stream * %u format flag to show ?? if total is unknown Version v1.8.3 - September 13, 2017 ================================================================================ * Update warning_filter to fix `require_relative` Version v1.8.2 - December 10, 2016 ================================================================================ Fix -------------------------------------------------------------------------------- * Predicates not available on 1.8.7 Add -------------------------------------------------------------------------------- * progressbar as a gem build target Removed -------------------------------------------------------------------------------- * reek Version v1.8.1 - May 13, 2016 ================================================================================ Fixed -------------------------------------------------------------------------------- * no dynamic length when working with spring Version v1.8.0 - April 24, 2016 ================================================================================ Added -------------------------------------------------------------------------------- * Gem signing via certificate * ActiveSupport Time-Traveling Compatibility Changed -------------------------------------------------------------------------------- * ProgressBar::Time to an instantiated class Fixed -------------------------------------------------------------------------------- * Progress#finish causing an exception when total was unknown Version v1.7.5 - March 25, 2015 ================================================================================ * Prevent `method redefined` warnings being generated by replacing uses of `attr_accessor` with: `attr_reader` where a setter function is already defined, `attr_writer` where a getter function is already defined Version v1.7.4 - March 23, 2015 ================================================================================ Version v1.7.3 - March 23, 2015 ================================================================================ Version v1.7.2 - March 23, 2015 ================================================================================ Added -------------------------------------------------------------------------------- * rubygems config Version v1.7.1 - December 21, 2014 ================================================================================ Bugfix -------------------------------------------------------------------------------- * ETA works again, when ProgressBar is initialized with a non zero starting_at. Uncategorized -------------------------------------------------------------------------------- * Describe the wiki link * Inline the cage image in the README * THE CAGE * Remove superfluous subtitle * Remove sections from the README that were moved to the Wiki * Add link to wiki * Update logo Version v1.7.0 - November 4, 2014 ================================================================================ Feature -------------------------------------------------------------------------------- * Massive internal refactoring. Now 236% faster! * Add Timer#restart Version v1.6.1 - October 30, 2014 ================================================================================ Uncategorized -------------------------------------------------------------------------------- * Update readme about output option * Display warnings when testing Bugfix -------------------------------------------------------------------------------- * Remove warnings from uninitialized instance variable * Instance variable @started_at not initialized * Instance variable @out_of_bounds_time_format not initialized * Change private attributes to protected * `*' interpreted as argument prefix * Prefix assigned but unused variables with underscores * Ambiguous first argument Version v1.6.0 - September 20, 2014 ================================================================================ Feature -------------------------------------------------------------------------------- * Add ability to disable auto-finish * Add SCSS lint configuration * Update JSHint config with our custom version * Add right-justified percentages - Closes #77 Bugfix -------------------------------------------------------------------------------- * Don't allow title to change for non-TTY output * Percentage formatter failed when total was 0 or unknown Version v1.5.1 - May 14, 2014 ================================================================================ Uncategorized -------------------------------------------------------------------------------- * Make grammar and spelling corrections in the README * Add the ability to scale the rate component * Add notes to the README about the new format components * Add the %R flag to the formatting to show the rate with 2 decimal places of precision * Remove unused molecule cruft * Add specs to make sure that rate works even if the bar is started in the middle * Add base functionality for the rate component * Add Slack notification to Travis builds * Upgrade rspectacular to v0.21.6 * Upgrade rspectacular to v0.21.5 * Upgrade rspectacular to v0.21.4 * Upgrade rspectacular to v0.21.3 * Upgrade rspectacular to v0.21.2 * Add badges to the README * Upgrade rspectacular to v0.21.1 * Lower Timecop version for Ruby 1.8 compatibility * Lower rake version to 0.9.6 so that it will be compatible with Ruby 1.8 * Update rspectacular to 0.21 * Add CODECLIMATE_REPO_TOKEN as a secure Travis ENV variable * Upgrade rspectacular to v0.20 * Add the Code Climate test reporter gem * Add Ruby 2.1 to Travis * Convert to RSpec 3 Feature -------------------------------------------------------------------------------- * The running average is always set back to 0 when the bar is reset Version v1.4.2 - March 1, 2014 ================================================================================ * Improve estimated timer for short durations * Remove useless protection * README Update * Slight formatting changes on the PACMAN example to make it consistent with the others * Pacman-style progressbar Version v1.4.1 - January 26, 2014 ================================================================================ * Change from 'STDOUT.puts' to the more appropriate 'Kernel.warn' * Add another spec which tests this in a different way * Add an acceptance spec to mimic running fuubar with no specs * Makes Timer#stop a no-op unless it has first been started. Version v1.4.0 - December 28, 2013 ================================================================================ * Displaying the call stack was probably too much * Upgrade fuubar * Add an error specifically for invalid progress so that, in parent libraries, it can be caught properly * Use the splat operator just to be clear * Fix an issue with the estimated timers blowing up if the total was nil - Closes #62 * Changed my mind. Rather than checking if the bar is stopped/started just blow up when the attempt is made to increment/decrement the bar to an invalid value * Remove the CannotUpdateStoppedBarError * Changes to the total should also be considered a change in progress and should therefore not be allowed for a stopped bar * Add a warning that any changes to progress while the bar is stopped, will eventually be an exception * Use the helper to divide the seconds. Don't know why I didn't do this before * When finishing the bar, we also should stop the timers * When checking 'finished?' make sure we check all progressables * Always thought it was weird that the 'finished?' check was in the update method * Move the 'finished' logic into the progressable * Rather than specifying @elapsed_time explicitly, use the with_timers helper * Add a method to check to see whether the bar has been started * Extract logic for updating progress into a 'update_progress' method * Add placeholder for an Error which will be used in v2.0.0 * Update the copyright in the README to 2014 (we're almost there :) * Add 'Zero dependencies' to the README as a beneifit of using ruby-progressbar Version v1.3.2 - December 15, 2013 ================================================================================ * Try to fix issues with testing on 1.8 and 1.9 when 'console/io' is not available * Remove rspectacular so we can get the specs to pass on 1.8 and 1.9.2 Version v1.3.1 - December 15, 2013 ================================================================================ * Even if the throttle rate is passed in as nil, use the default regardless Version v1.3.0 - December 15, 2013 ================================================================================ * Remove the 'Road Map' section in the README * Add notes to the README about non-TTY output * Add notes to the CHANGELOG * Give the bar the option of whether or not to automatically start or if `#start` has to be explicitly called * Default to a non-TTY-safe format if there is no TTY support when outputting the bar * Do not output the bar multiple times if `#resume` is called when the bar is already started * Do not output the bar multiple times if `#stop` is called when the bar is already stopped * Do not output multiple bars if `#finish` is called multiple times * Change progressbar variables in specs to be `let`'s instead * Change output variables in specs to be `let`'s instead * Update Gemfile.lock to use HTTPS for Rubygems * Add Ruby 2.0.0 to the README as a supported Ruby version * Test with Ruby 2.0.0 on Travis CI * Use HTTPS RubyGems source * Added an option to set the :remainder_mark (along the lines of :progress_mark) that allows the user to set the character used to represent the remaining progress to be made along the bar. * Add specs for the ANSI color code length calculation * Name the regex for the ANSI SGR codes so that it's more clear what we're doing * Remove comment * allows to inclue ANSI SGR codes into molecules, preserving the printable length * Switch from using 'git ls-files' to Ruby Dir globbing - Closes #54 Version v1.2.0 - August 12, 2013 ================================================================================ * Add note to CHANGELOG about TTY updates * Update benchmark script * Update logic to describe the bar as being 'stopped' also when it is 'finished' * Only print the bar output if we're printing to a TTY device, or any device as long as the bar is finished * Switch to instead of STDOUT so that it can be properly reassigned for redirections * Move carriage return to the clear method * Add better inspection now that we can have a nil total * Add note about unknown progress to the changelog * Add notes to the README about displaying unknown progress * Fix missing throttle rate in README * Allow the progress bar to have an 'unknown' amount of progress * Add item to the changelog * Update the benchmark script * Add #log to progressbar for properly handling bar output when printing to the output IO * Add CHANGELOG * Rename all of the requires lines to be consistent with the new lib file * Remove depreciation code Version v1.1.2 - August 11, 2013 ================================================================================ * Fix the 'negative argument' problem - Closes #47 * Update a spec that was passing when it shouldn't have been and pend it until we can implement the fix * Upgrade rspec and fuubar * When dividing up the remainder of the length and determining how much space a completed bar should take up, round down so that the bar doesn't complete until 100% * Add tags file to gitignore Version v1.1.1 - June 8, 2013 ================================================================================ * Fix file modes to be world readable * Filter out specs themselves from coverage report * Add tags file to gitignore * Simplify #with_progressables and #with_timers Version v1.1.0 - May 29, 2013 ================================================================================ * Upgrade simplecov so it is resilient to mathn being loaded * fix progress format when core lib mathn is loaded * Rename throttle_period to throttle_rate * Set a default throttle_period of 100 times per second * Use the new precise #elapsed_seconds in the throttle component * Add #elapsed_seconds that gets a more precise value for the elapsed time * Rename #elapsed_seconds to #elapsed_whole_seconds * Add throttle_period documentation * Made throttle API resemble other components * Add throttle_period option to #create * Add throttle component * Use StringIO in the new spec so we don't get output to STDOUT * fix for the ruby_debug error, where debug defines a start method on kernel that is used erroneously by progressbar * spec that recreates the problem we're seeing with ruby-debug under jruby * fix terminal width crashing progressbar * Add failing test for terminal width crashing progress bar * Make sure we're using an up-to-date version of the JSON gem * Fix gemspec since Date.today is no longer supported * Update ruby-prof * Upgrade timecop * Upgrade simplecov * Upgrade rake * Make changes related to rspectacular * Install rspectacular * Remove guard * Rework gem manifest so that it only calls ls-files once * Replace .rvmrc with .ruby-version * Rework #length specs now that we have a more complex set of specifications * Fix overriding the progress bar length with an environment variable. * Fix the `rdoc_options` specification in the gemspec * Add Ruby Markdown code fencing to the README Version v1.0.2 - October 7, 2012 ================================================================================ * Remove superfluous comment * The amount returned if the total is 0 should always be 100 (as in 100%) and not the DEFAULT_TOTAL. Even though they currently happen to be the same number. * return DEFAULT_TOTAL for percentage_completed of total is zero, fixing ZeroDivisionError * Use io/console where available. * Add tmux notifications to Guardfile * Bundler is not a development dependency * Hashes are not ordered and therefore when looking for the time mocking method, we weren't selecting the proper one. Switched to an Array instead. * Update development gems * Move ruby-prof into the Gemfile so it is only loaded when it's MRI Ruby * Add a script for benchmarking * Now that we're memoizing Format::Base#bar_molecules, just use it to calculate how many bar molecules are left * Limit the API of the Format.Base class by making #non_bar_molecules and #bar_molecules private * Move Formatter#process into Format::Base because it is much more concerned with the format * Remove the Kernel#tap in Formatter#process and just use an instance variable instead * Now that we're not reparsing the format string each time, we can save some cycles by memoizing the Format::Base#non_bar_molecules and #bar_molecules * When setting the format string, if it hasn't changed, we don't need to reparse it * Extract the logic of setting the format string out into its own private method ProgressBar::Formatter#format_string= * Add 'ruby-prof' to the project as a development gem Version v1.0.1 - August 28, 2012 ================================================================================ * Add Ruby 1.8.7 back into Travis CI build * Fixing string slice bug * Add a Rakefile * Update .gitignore * Add Rake to the Gemfile Version v1.0.0 - August 18, 2012 ================================================================================ * Remove 1.8 from the Ruby Travis builds * Add a spec for the %% molecule * Fix bug where a progress bar with an integrated percentage miscalculated the space it was taking up * fix @terminal_width and bar_width calculation * Fix more README typos * Set the default bar mark to '=' * Make sure to blow up if a molecule is not value * It's not sufficient to say that a molecule is 'a percent sign followed by something that isn't a percent sign', we need to force it to be followed by a letter * Fix   problems in the README * Update the formatting to make sure the %b and %i formatting molecules can coexist with each other * Now that we can use the %b and %i flags, we can create a mirrored bar simply by using a format string of '%i%b' and therefore this extra code is no longer necessary * Make sure that when the timer is started, then stopped, then started again, it should not register as `stopped?` * Allow %i to be used display the incomplete space of the bar * Update `ProgressBar::Formatter#format` to reset the bar style to default if it is called without passing in a format string * Allow the %b molecule to be used to display the bar only without incomplete space * Update the %B format test to be more reasonable * Make the %w molecule only return the bar with the percentage instead of including empty space * Remove the `length` argument when calling `ProgressBar::Components::Bar#to_s` and instead set the attribute * Rename `ProgressBar::Formatter#bar` to `#complete_bar` * Change the %b (bar with percentage) format molecule to %w * Swap the meaning of the %b and %B molecules * There was a typo in the example formats in the README. The literal percent sign needs to be included in the format string * Make sure the '%%' molecule is formatted properly * Little refactoring on the `ProgressBar::Formatter#process` method * README update * Remove all of the `ProgressBar::Base#update` calls and convert to method calls that take a block `#with_update` * Add an "In The Weeds" section to the README * Add 'It's better than some other library' section to the README * Add contributors to the README * Add supported Rubies to the README * Tons of README formatting updates * Add time-mocking information to the README * If Time is being mocked via Delorean, make sure that the progress bar always uses the unmocked time * If Time is being mocked via Timecop, make sure that the progress bar always uses the unmocked time * When testing, make sure that we're able to always get the proper version of `now` that we need for our particular spec * When calling `ProgressBar::Time.now` allow a Time-like object to be passed in * Add a `ruby-progressbar`-specific implementation of Time to encapsulate the business logic * Extract the notion of `now` into a method on the `Timer` module * Remove extra `private` * Use inheritance to put `title=` in the Formatter module where it belongs * I didn't notice that #total and #progress were available in the Formatter module * Move logic specific to the modules into those modules and use the inheritance chain to get at them * Evidently Travis is having issues with Rubinius so we'll remove them from our .travis.yml file to get a passing build * Try and get better 1.8.7 compatibility when checking the end character in the progressbar string * Add the Travis-CI build status to the README * Add the Travis-CI configuration file * Update the other deprecation warnings outside of `ProgressBar::Base` * Add the remaining method deprecation/warning messages * Use a little metaprogramming to further dry up the deprecation messages * fixup! c3e6991988107ab45ac3dac380750b287db3bc2e * When displaying deprecation warnings for methods, only show them one time; not every time the method is invoked * Dry up the warning messages in `ProgressBar::Depreciable` * Move `ProgressBar::Base#backwards_compatible_args_to_options_conversion` to the `ProgressBar::Depreciable` module * Add a new `ProgressBar::Depreciable` module to encapsulate all of the deprecation logic * Forgot to return the `options` hash from `ProgressBar::Base#backwards_compatible_args_to_options_conversion` * Add the old `bar_mark=` method back so it's more backwards compatible * Update deprecation warnings to expire June 30th, 2013 instead of October 30th, 2013 * Update the README to reflect the new syntax for creating a ProgressBar * Override `ProgressBar.new` and remain backward compatible with the pre-1.0 versions of the gem * Convert the `ProgressBar` module to a class so that we can... * Add `ProgressBar::Base#progress` and `#total` * Update the gemspec * Update the `EstimatedTimer` specs when smoothing is turned off such that the `#decrement` spec is sufficiently different from the smoothing on `#decrement` spec * Update `EstimatedTimer` specs when smoothing is turned off to be more consistent with the new smoothing specs * Add `EstimatedTimer` specs to test when smoothing is turned on * Update the spec text for the `EstimatedTimer` class so that it doesn't contain the actual expected value but rather the general expectation * Extract `smoothing` into its own `let` variable * Add notes to the README about smoothing * Invert the smoothing value such that 0.0 is no smoothing and 1.0 is maximum smoothing * Set the default smoothing value to 0.9 * Convert the `EstimatedTime#estimated_seconds_remaining` over to using the running average * Tell the `Progressable` module to update the running average any time the `progress` is set * Add the notion of a `smoothing` variable to the `Progressable` module for use when calculating the running average * Introduce `Progressable#running_average` and reset it any time `Progressable#start` is called * Add a RunningAverageCalculator so we can offload the logic for calculating running averages in our Progressables * Always refer to `total` using the accessor rather than the instance variable * Fix place where we were using a literal string for our time format rather than the TIME_FORMAT constant * Make the `Progressable` initializer optional * Fix README mistake regarding out of bounds ETAs * In Progressable, rather than accessing the starting_position instance variable, use an accessor * Rather than having the logic in multiple places, use `Progressable#start` where possible * Update the Progressable module to always reference the `progress` accessor rather than the instance variable * Add the ability to customize the bar's title in real time * Add a note to the README about customizing the bar in real time * Add notes to the README about overriding the bar's length * Update the deprecation date of * Upgrade the README to describe the new 'integrated percentage' formatting option * Update Ruby version in .rvmrc * Replace @out.print with @out.write to work better in dumb terminal like Emacs' M-x shell. * Document the smoothing attribute a little better. * Rewrote smoothing stuff to something better. * Offload handling of weird time values to format_time (isn't that its job?) ;-) * Added "smoothing" attribute (default 0.9). It can be set to nil to use the old ETA code. * Make time estimate a smoothed moving average * Use the inherited #initialize * Add a format where the bar has an integrated percentage * Just always run all specs * Alias stopped? to paused? * If the bar is completed, show the elapsed time, otherwise show the estimated time * estimated_time to estimated_time_with_no_oob * Add a Guardfile * Add the ability to set the progress mark at any point * Upgrade RSpec in the Gemfile * Allow :focused w/o the '=> true' * More gem updates. Include guard * Quotes * Unindent private methods * And again * Consistency is key * And again * Change to new date and repo * Upgraded RSpec uses RSpec not Rspec * Not sure why I did this here * Upgrade RSpec and SimpleCov * Bump Ruby version to 1.9.3 * allow to customize the #title_width * Detect whether the output device is a terminal, and use a simplified output strategy when it is not. * Use 1.9 compatible require in test. * Add tests for Timecop and Delorean time mocking * Make Progressbar resistant to time mocking * Automatically tag gem builds as Date.today * Replace the Bar's instance variable references * Remove Options Parser * The starting value should be passed on #start * Remove Title class for now * Change 'reversed bar' to 'mirrored bar' * Rename `out` to `output` and access w/o variable * Change default output to STDOUT * Rename `output_stream` to `output` * Rename `current` to `progress` * Update README * Add #decrement to the progress bar * Backwards compatibility for instantiation * Create `with_timers` helper * Update spec_helper with new root gem file * Update gemspec with new license file * Update gemspec to auto-update Date * Add deprecation and backwards compatibility helprs * Add SimpleCov to the project * Rename 'beginning_position' option to 'started_at' * Fix require files * Update README * Update README * Update README * Remove Test::Unit test cases which are covered * Replace licenses with the MIT license * Begin updating README * Add .gitignore * Fix 'ArgumentError: negative argument' when using with Spork * Bar can be forcibly stopped * Autostart for now * Add ability to pause/resume progress bar * Bar resets the elapsed time when reset. * Bar resets the estimated time when reset. * Timers can now be reset * #start determines #reset position * On #reset, bar goes back to its starting position * Bar can be reset back to 0 * Fix test typo * Fix tests * Reminder for autostart * Move #title * Delete unneeded code * Stop Elapsed Timer on finish * Progressable components finish properly * Refactor out common 'Progressable' functionality * Prepare for more 'finish' functionality * Refactor common Timer functionality into a module * Bar outputs a \n when it's finished * Bar can now be "finished" * Remove unnecessary (for now) code * Resizing algorithm is much smarter * Fix length_changed? check * Move formatting methods and make them private * Create #inspect method * Remove implemented methods * We have a LICENSE file. No need for this. * Fix output problem * Always show 2 decimal places with precise percentage * Elapsed Time works properly with progress bar * Estimated Timer works properly with progress bar * %r format string works properly * Estimated Timer can now be incremented * Bar graphic can now be reversed * Remove method arguments from molecule * %e, %E and %f format the estimated time correctly * Formatting * Include Molecule specs * Estimated Timer works with out of bounds times * Estimated Timer displays estimated time correctly * Estimated Timer displays unknown time remaining * Estimated Time can now be displayed * Make Timer work properly * Move bar_spec to the proper locale * Elapsed Time can now be displayed * Percentage information can now be displayed * Capacity information can now be displayed * Move Bar and Title into Components submodule * Base refactoring work laid out * Add RSpec support files * Create a Gemfile and other infrastructure files * Update gemspec * Fix to failing test: Adjusting the path to progressbar.rb file * accessor for alternate bar mark * Updated gem name to match project (so it would build) * Add a gemspec. * Move progressbar.rb into lib/. * Add LICENSE files. * Get rid of the ChangeLog. That's what revision logs are for. * Make the readme use Markdown. * Initial commit (based on Ruby/ProgressBar 0.9). ruby-progressbar-releases-v1.10.1/CODE-OF-CONDUCT.md000066400000000000000000000036771347307233000215430ustar00rootroot00000000000000# Contributor Code of Conduct As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality. Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery * Personal attacks * Trolling or insulting/derogatory comments * Public or private harassment * Publishing other's private information, such as physical or electronic addresses, without explicit permission * Other unethical or unprofessional conduct. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team. This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/) ruby-progressbar-releases-v1.10.1/Gemfile000066400000000000000000000004101347307233000203610ustar00rootroot00000000000000# frozen_string_literal: true source 'https://rubygems.org' group :console do gem 'awesome_print', '~> 1.6' end gem 'ruby-prof', '~> 0.15.8', :platforms => :mri_20, :group => :development gemspec :name => 'ruby-progressbar' ruby-progressbar-releases-v1.10.1/Gemfile.lock000066400000000000000000000017141347307233000213200ustar00rootroot00000000000000PATH remote: . specs: ruby-progressbar (1.10.1) GEM remote: https://rubygems.org/ specs: awesome_print (1.8.0) diff-lcs (1.3) fuubar (2.3.2) rspec-core (~> 3.0) ruby-progressbar (~> 1.4) rspec (3.8.0) rspec-core (~> 3.8.0) rspec-expectations (~> 3.8.0) rspec-mocks (~> 3.8.0) rspec-core (3.8.0) rspec-support (~> 3.8.0) rspec-expectations (3.8.3) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.8.0) rspec-mocks (3.8.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.8.0) rspec-support (3.8.0) rspectacular (0.70.7) fuubar (~> 2.0) rspec (~> 3.1) ruby-prof (0.15.9) timecop (0.6.0) warning_filter (0.0.6) PLATFORMS ruby DEPENDENCIES awesome_print (~> 1.6) fuubar (~> 2.3) rspec (~> 3.7) rspectacular (~> 0.70.6) ruby-prof (~> 0.15.8) ruby-progressbar! timecop (= 0.6.0) warning_filter (~> 0.0.6) BUNDLED WITH 1.17.2 ruby-progressbar-releases-v1.10.1/LICENSE.txt000066400000000000000000000020521347307233000207150ustar00rootroot00000000000000Copyright (c) 2010-2016 The Kompanee, Ltd Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ruby-progressbar-releases-v1.10.1/README.md000066400000000000000000000044201347307233000203520ustar00rootroot00000000000000Ruby/ProgressBar ================================ [![Gem Version](https://img.shields.io/gem/v/ruby-progressbar.svg)](https://rubygems.org/gems/ruby-progressbar) ![Rubygems Rank Overall](https://img.shields.io/gem/rt/ruby-progressbar.svg) ![Rubygems Rank Daily](https://img.shields.io/gem/rd/ruby-progressbar.svg) ![Rubygems Downloads](https://img.shields.io/gem/dv/ruby-progressbar/stable.svg) [![Build Status](https://img.shields.io/travis/jfelchner/ruby-progressbar/master.svg)](http://travis-ci.org/jfelchner/ruby-progressbar) [![Code Climate](https://codeclimate.com/github/jfelchner/ruby-progressbar.svg)](https://codeclimate.com/github/jfelchner/ruby-progressbar) [![Code Climate](https://codeclimate.com/github/jfelchner/ruby-progressbar/coverage.svg)](https://codeclimate.com/github/jfelchner/ruby-progressbar) The **ultimate** text progress bar library for Ruby! It'll **SMASH YOU OVER THE HEAD** with a **PURE RUSH** of progress bar excitement! Don't miss out on what all the kids are talking about! If you want everyone to know that your gem or app can survive _in the cage_ then YOU WANT **RUBY-PROGRESSBAR**!


Full Reference -------------------------------- There's gotten to be too much awesome to pack into one page. Visit the [wiki](https://github.com/jfelchner/ruby-progressbar/wiki) for the full documentation. Here's a [quick link](https://github.com/jfelchner/ruby-progressbar/wiki/Basic-Usage) to the 'Basic Usage' section. Issues -------------------------------- If you have problems, please create a [Github issue](https://github.com/jfelchner/ruby-progressbar/issues). Credits -------------------------------- ![The Kompanee](https://kompanee-public-assets.s3.amazonaws.com/readmes/kompanee-horizontal-black.png) ruby-progressbar is maintained by [The Kompanee, Ltd.](http://www.thekompanee.com) The names and logos for The Kompanee are trademarks of The Kompanee, Ltd. License -------------------------------- ruby-progressbar 1.0 is Copyright © 2011-2018 The Kompanee. It is free software, and may be redistributed under the terms specified in the LICENSE file. ruby-progressbar 0.9.0 is Copyright © 2008 [Satoru Takabayashi](http://0xcc.net) ruby-progressbar-releases-v1.10.1/Rakefile000077500000000000000000000000601347307233000205370ustar00rootroot00000000000000#!/usr/bin/env rake require 'bundler/gem_tasks' ruby-progressbar-releases-v1.10.1/bin/000077500000000000000000000000001347307233000176435ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/bin/console000077500000000000000000000002111347307233000212250ustar00rootroot00000000000000#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/setup' Bundler.require(:default, :console) require 'irb' IRB.start ruby-progressbar-releases-v1.10.1/bin/setup000077500000000000000000000034551347307233000207400ustar00rootroot00000000000000#!/usr/bin/env bash # shellcheck disable=SC2037 ### # Install Bundler Source Credentials # declare private_url="$(command chamber show --as-env --files="config/settings/**/*.yml" | grep 'GEMFURY_URL' | perl -p -e 's/GEMFURY_URL="(.*)"/\1/')" declare private_token="$(command chamber show --as-env --files="config/settings/**/*.yml" | grep 'GEMFURY_TOKEN' | perl -p -e 's/GEMFURY_TOKEN="(.*)"/\1/')" if [ -n "${private_url}" ] && [ -n "${private_token}" ]; then bundle config --local "${private_url}" "${private_token}" else bundle config --delete "${private_url}" fi ### # Install Dependencies # echo 'Installing Ruby Packages...' gem install bundler --conservative bundle check || bundle install gem install rubocop --conservative echo 'Installing NPM Packages...' command npm install -g "jsonlint" 2> /dev/null command npm update -g "jsonlint" 2> /dev/null nodenv rehash 2> /dev/null ### # Install Project bin Executables # echo 'Installing project binaries...' if ! [ -d ".git/shellwreck-verification-dir" ]; then mkdir .git/shellwreck-verification-dir fi ### # Add Project Information to the Git Repository # echo 'Installing project configuration into git repo...' command git config --replace-all --local project.application-name 'ruby-progressbar' command git config --replace-all --local deployment.pipeline 'rubygems' command git config --replace-all --local deployment.profile 'jfelchner' command git config --replace-all --local workflow.issue-tracker 'github' ### # Setup Git Hook Templates # gem install overcommit --conservative if [ -d "${HOME}/.shellwreck/plugins/git/symlinks/hooks" ]; then rm --recursive --force .git/hooks ln -s "${HOME}/.shellwreck/plugins/git/symlinks/hooks" .git/hooks fi ruby-progressbar-releases-v1.10.1/certs/000077500000000000000000000000001347307233000202135ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/certs/jfelchner.pem000066400000000000000000000031061347307233000226560ustar00rootroot00000000000000-----BEGIN CERTIFICATE----- MIIEdjCCAt6gAwIBAgIBATANBgkqhkiG9w0BAQsFADAyMTAwLgYDVQQDDCdhY2Nv dW50c19ydWJ5Z2Vtcy9EQz10aGVrb21wYW5lZS9EQz1jb20wHhcNMTgwODAzMjEz NDA1WhcNMTkwODAzMjEzNDA1WjAyMTAwLgYDVQQDDCdhY2NvdW50c19ydWJ5Z2Vt cy9EQz10aGVrb21wYW5lZS9EQz1jb20wggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAw ggGKAoIBgQCqhYn5ODEoLvuBIF2M1GzoaZU28+ntP5QApvDE0Te04n0JbBC1cNYH mr71neeSx7tlZ9w9kJ/8GNcY5bm7pNJqhyhfc+uG9M7FttcxM8AYXogjcdUDP234 +TdmZIz20JxtWBgAZK2I3ktlgLFLC3Pxq63yzhJ75Xok07Wh+ypwjGzDNofPhz+y XR+UeUTp2UGe7kDVoqu/AwwPVhk1qUIRFLfC8SLDTD0CuNW3/AnkwQrKSm8vkiIn q9GCnOq0+jQly0b6a1Gi3ZDYEEswnTzziw2gotUZnQkF5bcOcxK1CB/Okk2jtG7i ztMEU785tERbOSszZrz9rBS/+GnMxlD0pxy50zFfHX3jY1hwnwGjE8Gg+0iYr/tm eysjhcbZfKrMynoqAioCSwstIwtYYYYpYzCPZzwaIBaBqQmUTkuMeiGbAdOdFOrR lOgl5jxCYbNOOTaXbm0nGBFaTucB88+JLbsNAuoNGUf/ybDcZ1zKRkMr2vtb+OtL GoP81fN6l88CAwEAAaOBljCBkzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV HQ4EFgQUL4eV4OM9h7fkM27qf9p4ragHi6AwLAYDVR0RBCUwI4EhYWNjb3VudHMr cnVieWdlbXNAdGhla29tcGFuZWUuY29tMCwGA1UdEgQlMCOBIWFjY291bnRzK3J1 YnlnZW1zQHRoZWtvbXBhbmVlLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEANh9Y8ccw o3/+ZNjNhewsxip/oj8NZHRBLfrSXNT8nIxlB/CrHXHJ5UvJmsH45MYnU8Blsm04 T6PNtZIh8sPWF0ByU/gJhs23C2CGgeDrijZWL/VcOK8ErhLd92lrtXiCei4mexo5 flFW1vLZVTJRiXzVSmuBLkrhQE7BqSHvUTz2vkyf4f/G9jnqp+8Tf0IRZiPGFi82 2qI/IOGmCb8Oqybt4lcHymLZBYPmj1hb/HVxEWTmQ9Y6ePHSonoK+QZf6Vi+wKga JxeLxFp0fQc+Mfjx+bFdJgOhcXMjLnDtAaQoDkQfRvQmCTKkXUhNRoTiWtxojkjX 8mN+AQ66SKTSztEZRZWizqWmTUtkSG+IKlL5E9fUkLYsKV3xgiuwgh+3vSdz398u KuaMSG4L1U+uHNl3upTjh6wZjzKptsxE0eHSeTlt74ei2EZ4XpDQgMAdxnG19eUY Ew38fD/eb7KjFt6HWjaE88pp12uYoAUV0xTysHhml+rk1/rn/h3T1Exa -----END CERTIFICATE----- ruby-progressbar-releases-v1.10.1/checksum/000077500000000000000000000000001347307233000206755ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/checksum/progressbar-1.10.0.gem.md5000066400000000000000000000000411347307233000251120ustar00rootroot0000000000000042fa7971f60a90e1876dfb9cca884b3d ruby-progressbar-releases-v1.10.1/checksum/progressbar-1.10.0.gem.sha256000066400000000000000000000001011347307233000254320ustar00rootroot000000000000002de99e75d62346a6061a049d04df5e6d00ac456f504926bdae5fe2406a666799 ruby-progressbar-releases-v1.10.1/checksum/progressbar-1.10.0.gem.sha512000066400000000000000000000002011347307233000254260ustar00rootroot00000000000000cc91568aa0c7d40612fac118c00ba2b5b76f56e6fffcbcc1324639dff4281916530010366c4beab3a64d5e16f272e236a18cb3350c5caa23a6c5f3fde65a667d ruby-progressbar-releases-v1.10.1/checksum/progressbar-1.8.1.gem.md5000066400000000000000000000000411347307233000250420ustar00rootroot00000000000000f70f124c2d85b7923760de5b27220966 ruby-progressbar-releases-v1.10.1/checksum/progressbar-1.8.1.gem.sha256000066400000000000000000000001011347307233000253620ustar00rootroot000000000000002dbac4b02919b215acb2d2251d75dbcf3c4320803c384d854b691a65f4aa074b ruby-progressbar-releases-v1.10.1/checksum/progressbar-1.8.1.gem.sha512000066400000000000000000000002011347307233000253560ustar00rootroot00000000000000c4a223ac27aa72c0b546baf31a9a8b2338fdfaf36deb3b273de191818ba3921230448b82ca438900e239ef36567e6ae5c98cff2a9a67fb03ce1f6fbad73f9afb ruby-progressbar-releases-v1.10.1/checksum/progressbar-1.8.2.gem.md5000066400000000000000000000000411347307233000250430ustar00rootroot000000000000005daea819b84c3b702d09d4abd9a6f57c ruby-progressbar-releases-v1.10.1/checksum/progressbar-1.8.2.gem.sha256000066400000000000000000000001011347307233000253630ustar00rootroot0000000000000051394d27a4f84bc8d81666128e0d72f3b286da9234ffbe8c47e2978d8212fa97 ruby-progressbar-releases-v1.10.1/checksum/progressbar-1.8.2.gem.sha512000066400000000000000000000002011347307233000253570ustar00rootroot000000000000009bc8a304420d0faa0c8fde669ff9d06ea60d937b6c68d5c198b195d38cb4a5c39e9b3c1068305800ecff2cada52328093d814aec039dd83700d74544ed86fd04 ruby-progressbar-releases-v1.10.1/checksum/progressbar-1.9.0.gem.md5000066400000000000000000000000411347307233000250420ustar00rootroot000000000000000cbd6df79d4fa4955da1ea738951e4df ruby-progressbar-releases-v1.10.1/checksum/progressbar-1.9.0.gem.sha256000066400000000000000000000001011347307233000253620ustar00rootroot00000000000000dbb8497223e4bef55cf763acd435dfa723238c9e4fdf25c375fbad72b5065c1b ruby-progressbar-releases-v1.10.1/checksum/progressbar-1.9.0.gem.sha512000066400000000000000000000002011347307233000253560ustar00rootroot000000000000008b860e7e6d00ceb4c235073482797cc41c0a724fcd2e6cb6c24592d78feccc007524e761bb8bf24d8b5f8d24ed153089ebfec8dcbdc06188ff607294ca828084 ruby-progressbar-releases-v1.10.1/checksum/ruby-progressbar-1.10.0.gem.md5000066400000000000000000000000411347307233000260710ustar00rootroot0000000000000010511dedc1b37b3ae1060f4e4d4edd7c ruby-progressbar-releases-v1.10.1/checksum/ruby-progressbar-1.10.0.gem.sha256000066400000000000000000000001011347307233000264110ustar00rootroot00000000000000933e58652a6e7eac5426310d5dc96a629dadd631de029210df3a019a47f562b3 ruby-progressbar-releases-v1.10.1/checksum/ruby-progressbar-1.10.0.gem.sha512000066400000000000000000000002011347307233000264050ustar00rootroot000000000000007214a228cd153e817e7f89bfb763db4bc67c06c41162c91422e0f4e2d7bd02a19b2bf56281552029e87d3cffbd60d1dc8eb36c67aeea39be9fe6819c90c85130 ruby-progressbar-releases-v1.10.1/checksum/ruby-progressbar-1.8.0.gem.md5000066400000000000000000000000411347307233000260200ustar00rootroot00000000000000c2fb5a016efd590284cb06858621ad0e ruby-progressbar-releases-v1.10.1/checksum/ruby-progressbar-1.8.0.gem.sha256000066400000000000000000000001011347307233000263400ustar00rootroot0000000000000078020988fc8603843747e316edb8fc50481c6842583eab5749e29fbbc9660f54 ruby-progressbar-releases-v1.10.1/checksum/ruby-progressbar-1.8.0.gem.sha512000066400000000000000000000002011347307233000263340ustar00rootroot00000000000000ecb44206390ad277908cb89fc247ea249c1c81b6aa18e941679dcfaea14e27160cafb2e06abc9ef42512d6a88f9d33096bc58c6d70f93ccb03801f80c4c4f79c ruby-progressbar-releases-v1.10.1/checksum/ruby-progressbar-1.8.1.gem.md5000066400000000000000000000000411347307233000260210ustar00rootroot0000000000000007f7eddceb272e9b0c8ea123c489f0e8 ruby-progressbar-releases-v1.10.1/checksum/ruby-progressbar-1.8.1.gem.sha256000066400000000000000000000001011347307233000263410ustar00rootroot0000000000000095ded755295440de814704970d7ccaf3cb259854534f03a03a6d05918f3eece3 ruby-progressbar-releases-v1.10.1/checksum/ruby-progressbar-1.8.1.gem.sha512000066400000000000000000000002011347307233000263350ustar00rootroot00000000000000bded41f29ed3386b83b0c4fe208813de330cb6be527c4b91cbf436f44d0efe58cb717a783d104f32b697fe1d9b71eeec500c8a72a9a5b34fc416c86e7565bc01 ruby-progressbar-releases-v1.10.1/checksum/ruby-progressbar-1.8.3.gem.md5000066400000000000000000000000411347307233000260230ustar00rootroot0000000000000074a2da533496f8e0c018f25caec7fcc0 ruby-progressbar-releases-v1.10.1/checksum/ruby-progressbar-1.8.3.gem.sha256000066400000000000000000000001011347307233000263430ustar00rootroot000000000000000e47b5ce47c71e74ca25bb3aea20f9889a148ebd9e4ce5651e05bb3930d83309 ruby-progressbar-releases-v1.10.1/checksum/ruby-progressbar-1.8.3.gem.sha512000066400000000000000000000002011347307233000263370ustar00rootroot00000000000000b6959c91e612e1cf2c806a8c81372e22a251431973abe133068be60cfa4f7fd0cc03dcc88e3b9fbd7b6559e5eb447e24013bf6cdd79cf393b2d6a5a16801443f ruby-progressbar-releases-v1.10.1/checksum/ruby-progressbar-1.9.0.gem.md5000066400000000000000000000000411347307233000260210ustar00rootroot00000000000000fd9767c49846e37c4a8e81ed7b951d51 ruby-progressbar-releases-v1.10.1/checksum/ruby-progressbar-1.9.0.gem.sha256000066400000000000000000000001011347307233000263410ustar00rootroot00000000000000d32d1b046400e58007e7043e3b07c9e2c32a248964a55afc780516b7630ff0c5 ruby-progressbar-releases-v1.10.1/checksum/ruby-progressbar-1.9.0.gem.sha512000066400000000000000000000002011347307233000263350ustar00rootroot00000000000000c95bc065c96a2f11cd4d77a351dad0d3bd9928a1c8463107984bb3b100b7916bd744a33d856e91039cecee6a216dbcf7e122a3709dc332cb41cbc70e96dfd097 ruby-progressbar-releases-v1.10.1/lib/000077500000000000000000000000001347307233000176415ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/lib/progressbar.rb000066400000000000000000000013171347307233000225210ustar00rootroot00000000000000# frozen_string_literal: true require 'ruby-progressbar/output' require 'ruby-progressbar/outputs/tty' require 'ruby-progressbar/outputs/non_tty' require 'ruby-progressbar/timer' require 'ruby-progressbar/progress' require 'ruby-progressbar/throttle' require 'ruby-progressbar/calculators/length' require 'ruby-progressbar/calculators/running_average' require 'ruby-progressbar/components' require 'ruby-progressbar/format' require 'ruby-progressbar/base' require 'ruby-progressbar/refinements' if Module. private_instance_methods. include?(:using) class ProgressBar def self.create(*args) ProgressBar::Base.new(*args) end end ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar.rb000066400000000000000000000013171347307233000235000ustar00rootroot00000000000000# frozen_string_literal: true require 'ruby-progressbar/output' require 'ruby-progressbar/outputs/tty' require 'ruby-progressbar/outputs/non_tty' require 'ruby-progressbar/timer' require 'ruby-progressbar/progress' require 'ruby-progressbar/throttle' require 'ruby-progressbar/calculators/length' require 'ruby-progressbar/calculators/running_average' require 'ruby-progressbar/components' require 'ruby-progressbar/format' require 'ruby-progressbar/base' require 'ruby-progressbar/refinements' if Module. private_instance_methods. include?(:using) class ProgressBar def self.create(*args) ProgressBar::Base.new(*args) end end ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/000077500000000000000000000000001347307233000231515ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/base.rb000066400000000000000000000111441347307233000244110ustar00rootroot00000000000000require 'forwardable' class ProgressBar class Base extend Forwardable def_delegators :output, :clear, :log, :refresh def_delegators :progressable, :progress, :total def initialize(options = {}) self.autostart = options.fetch(:autostart, true) self.autofinish = options.fetch(:autofinish, true) self.finished = false self.timer = Timer.new(options) self.progressable = Progress.new(options) options = options.merge(:timer => timer, :progress => progressable) self.title_comp = Components::Title.new(options) self.bar = Components::Bar.new(options) self.percentage = Components::Percentage.new(options) self.rate = Components::Rate.new(options) self.time = Components::Time.new(options) self.output = Output.detect(options.merge(:bar => self)) @format = Format::String.new(output.resolve_format(options[:format])) start :at => options[:starting_at] if autostart end def start(options = {}) timer.start update_progress(:start, options) end def finish return if finished? output.with_refresh do self.finished = true progressable.finish timer.stop end end def pause output.with_refresh { timer.pause } unless paused? end def stop output.with_refresh { timer.stop } unless stopped? end def resume output.with_refresh { timer.resume } if stopped? end def reset output.with_refresh do self.finished = false progressable.reset timer.reset end end def stopped? timer.stopped? || finished? end alias paused? stopped? def finished? finished || (autofinish && progressable.finished?) end def started? timer.started? end def decrement update_progress(:decrement) end def increment update_progress(:increment) end def progress=(new_progress) update_progress(:progress=, new_progress) end def total=(new_total) update_progress(:total=, new_total) end def progress_mark=(mark) output.refresh_with_format_change { bar.progress_mark = mark } end def remainder_mark=(mark) output.refresh_with_format_change { bar.remainder_mark = mark } end def title title_comp.title end def title=(title) output.refresh_with_format_change { title_comp.title = title } end def to_s(new_format = nil) self.format = new_format if new_format Format::Formatter.process(@format, output.length, self) end # rubocop:disable Metrics/AbcSize, Metrics/LineLength def to_h { 'output_stream' => output.__send__(:stream), 'length' => output.length, 'title' => title_comp.title, 'progress_mark' => bar.progress_mark, 'remainder_mark' => bar.remainder_mark, 'progress' => progressable.progress, 'total' => progressable.total, 'percentage' => progressable.percentage_completed_with_precision.to_f, 'elapsed_time_in_seconds' => time.__send__(:timer).elapsed_seconds, 'estimated_time_remaining_in_seconds' => time.__send__(:estimated_seconds_remaining), 'base_rate_of_change' => rate.__send__(:base_rate), 'scaled_rate_of_change' => rate.__send__(:scaled_rate), 'unknown_progress_animation_steps' => bar.upa_steps, 'throttle_rate' => output.__send__(:throttle).rate, 'started?' => started?, 'stopped?' => stopped?, 'finished?' => finished? } end # rubocop:enable Metrics/AbcSize, Metrics/LineLength def inspect "#" end def format=(other) output.refresh_with_format_change do @format = Format::String.new(other || output.default_format) end end alias format format= protected attr_accessor :output, :timer, :progressable, :title_comp, :bar, :percentage, :rate, :time, :autostart, :autofinish, :finished def update_progress(*args) output.with_refresh do progressable.__send__(*args) timer.stop if finished? end end end end ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/calculators/000077500000000000000000000000001347307233000254655ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/calculators/length.rb000066400000000000000000000042141347307233000272740ustar00rootroot00000000000000class ProgressBar module Calculators class Length attr_reader :length_override attr_accessor :current_length, :output def initialize(options = {}) self.length_override = options[:length] self.output = options[:output] self.current_length = nil end def length current_length || reset_length end def length_changed? previous_length = current_length self.current_length = calculate_length previous_length != current_length end def calculate_length length_override || terminal_width || 80 end def reset_length self.current_length = calculate_length end def length_override=(other) @length_override ||= ENV['RUBY_PROGRESS_BAR_LENGTH'] || other @length_override = @length_override.to_i if @length_override end private # This code was copied and modified from Rake, available under MIT-LICENSE # Copyright (c) 2003, 2004 Jim Weirich # rubocop:disable Style/RescueStandardError def terminal_width return 80 unless unix? result = dynamic_width (result < 20) ? 80 : result rescue 80 end # rubocop:enable Style/RescueStandardError # rubocop:disable Lint/DuplicateMethods begin require 'io/console' def dynamic_width if output && output.tty? && output.respond_to?(:winsize) dynamic_width_via_output_stream_object elsif IO.console dynamic_width_via_io_object else dynamic_width_via_system_calls end end rescue LoadError def dynamic_width dynamic_width_via_system_calls end end # rubocop:enable Lint/DuplicateMethods def dynamic_width_via_output_stream_object _rows, columns = output.winsize columns end def dynamic_width_via_io_object _rows, columns = IO.console.winsize columns end def dynamic_width_via_system_calls dynamic_width_stty.nonzero? || dynamic_width_tput end def dynamic_width_stty `stty size 2>/dev/null`.split[1].to_i end def dynamic_width_tput `tput cols 2>/dev/null`.to_i end def unix? RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i end end end end ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/calculators/running_average.rb000066400000000000000000000003701347307233000311640ustar00rootroot00000000000000class ProgressBar module Calculators class RunningAverage def self.calculate(current_average, new_value_to_average, smoothing_factor) new_value_to_average * (1.0 - smoothing_factor) + current_average * smoothing_factor end end end end ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/components.rb000066400000000000000000000003351347307233000256640ustar00rootroot00000000000000require 'ruby-progressbar/components/bar' require 'ruby-progressbar/components/percentage' require 'ruby-progressbar/components/rate' require 'ruby-progressbar/components/time' require 'ruby-progressbar/components/title' ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/components/000077500000000000000000000000001347307233000253365ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/components/bar.rb000066400000000000000000000045111347307233000264300ustar00rootroot00000000000000### # UPA = Unknown Progress Animation # class ProgressBar module Components class Bar DEFAULT_PROGRESS_MARK = '='.freeze DEFAULT_REMAINDER_MARK = ' '.freeze DEFAULT_UPA_STEPS = ['=---', '-=--', '--=-', '---='].freeze attr_accessor :progress_mark, :remainder_mark, :length, :progress, :upa_steps def initialize(options = {}) self.upa_steps = options[:unknown_progress_animation_steps] || DEFAULT_UPA_STEPS self.progress_mark = options[:progress_mark] || DEFAULT_PROGRESS_MARK self.remainder_mark = options[:remainder_mark] || DEFAULT_REMAINDER_MARK self.progress = options[:progress] self.length = options[:length] end def to_s(options = { :format => :standard }) if progress.unknown? unknown_string elsif options[:format] == :standard "#{standard_complete_string}#{incomplete_string}" elsif options[:format] == :integrated_percentage "#{integrated_percentage_complete_string}#{incomplete_string}" end end private def integrated_percentage_complete_string return standard_complete_string if completed_length < 5 " #{progress.percentage_completed} ".to_s.center(completed_length, progress_mark) end def standard_complete_string progress_mark * completed_length end def incomplete_string remainder_mark * (length - completed_length) end def bar(length) self.length = length standard_complete_string end def complete_bar(length) self.length = length to_s(:format => :standard) end def complete_bar_with_percentage(length) self.length = length to_s(:format => :integrated_percentage) end def unknown_string unknown_frame_string = unknown_progress_frame * ((length / upa_steps.size) + 2) unknown_frame_string[0, length] end def incomplete_space(length) self.length = length if progress.unknown? unknown_string else incomplete_string end end def bar_with_percentage(length) self.length = length integrated_percentage_complete_string end def completed_length (length * progress.percentage_completed / 100).floor end def unknown_progress_frame current_animation_step = progress.progress % upa_steps.size upa_steps[current_animation_step] end end end end ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/components/percentage.rb000066400000000000000000000010141347307233000277740ustar00rootroot00000000000000class ProgressBar module Components class Percentage attr_accessor :progress def initialize(options = {}) self.progress = options[:progress] end private def percentage progress.percentage_completed end def justified_percentage progress.percentage_completed.to_s.rjust(3) end def percentage_with_precision progress.percentage_completed_with_precision end def justified_percentage_with_precision progress.percentage_completed_with_precision.to_s.rjust(6) end end end end ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/components/rate.rb000066400000000000000000000014661347307233000266250ustar00rootroot00000000000000class ProgressBar module Components class Rate attr_accessor :rate_scale, :started_at, :stopped_at, :timer, :progress def initialize(options = {}) self.rate_scale = options[:rate_scale] || lambda { |x| x } self.started_at = nil self.stopped_at = nil self.timer = options[:timer] self.progress = options[:progress] end private def rate_of_change(format_string = '%i') return 0 unless elapsed_seconds > 0 format_string % scaled_rate end def rate_of_change_with_precision rate_of_change('%.2f') end def scaled_rate rate_scale.call(base_rate) end def base_rate progress.absolute / elapsed_seconds end def elapsed_seconds timer.elapsed_whole_seconds.to_f end end end end ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/components/time.rb000066400000000000000000000050661347307233000266300ustar00rootroot00000000000000### # OOB = 'Out of Bounds' # class ProgressBar module Components class Time TIME_FORMAT = '%02d:%02d:%02d'.freeze OOB_TIME_FORMATS = [:unknown, :friendly, nil].freeze OOB_LIMIT_IN_HOURS = 99 OOB_UNKNOWN_TIME_TEXT = '??:??:??'.freeze OOB_FRIENDLY_TIME_TEXT = '> 4 Days'.freeze NO_TIME_ELAPSED_TEXT = '--:--:--'.freeze ESTIMATED_LABEL = ' ETA'.freeze ELAPSED_LABEL = 'Time'.freeze def initialize(options = {}) self.out_of_bounds_time_format = options[:out_of_bounds_time_format] self.timer = options[:timer] self.progress = options[:progress] end def estimated_with_label "#{ESTIMATED_LABEL}: #{estimated}" end def elapsed_with_label "#{ELAPSED_LABEL}: #{elapsed}" end protected def estimated_with_no_oob self.out_of_bounds_time_format = nil estimated_with_elapsed_fallback end def estimated_with_unknown_oob self.out_of_bounds_time_format = :unknown estimated_with_elapsed_fallback end def estimated_with_friendly_oob self.out_of_bounds_time_format = :friendly estimated_with_elapsed_fallback end attr_reader :out_of_bounds_time_format attr_accessor :timer, :progress def out_of_bounds_time_format=(format) unless OOB_TIME_FORMATS.include? format fail 'Invalid Out Of Bounds time format. Valid formats are ' + OOB_TIME_FORMATS.inspect end @out_of_bounds_time_format = format end private def estimated memo_estimated_seconds_remaining = estimated_seconds_remaining return OOB_UNKNOWN_TIME_TEXT unless memo_estimated_seconds_remaining hours, minutes, seconds = timer.divide_seconds(memo_estimated_seconds_remaining) if hours > OOB_LIMIT_IN_HOURS && out_of_bounds_time_format out_of_bounds_time else TIME_FORMAT % [hours, minutes, seconds] end end def elapsed return NO_TIME_ELAPSED_TEXT unless timer.started? hours, minutes, seconds = timer.divide_seconds(timer.elapsed_whole_seconds) TIME_FORMAT % [hours, minutes, seconds] end def estimated_with_elapsed_fallback progress.finished? ? elapsed_with_label : estimated_with_label end def estimated_seconds_remaining return if progress.unknown? || progress.none? || timer.stopped? (timer.elapsed_seconds * (progress.total / progress.running_average - 1)).round end def out_of_bounds_time case out_of_bounds_time_format when :unknown OOB_UNKNOWN_TIME_TEXT when :friendly OOB_FRIENDLY_TIME_TEXT end end end end end ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/components/title.rb000066400000000000000000000003251347307233000270040ustar00rootroot00000000000000class ProgressBar module Components class Title DEFAULT_TITLE = 'Progress'.freeze attr_accessor :title def initialize(options = {}) self.title = options[:title] || DEFAULT_TITLE end end end end ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/errors/000077500000000000000000000000001347307233000244655ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/errors/invalid_progress_error.rb000066400000000000000000000001101347307233000315650ustar00rootroot00000000000000class ProgressBar class InvalidProgressError < RuntimeError end end ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/format.rb000066400000000000000000000002001347307233000247560ustar00rootroot00000000000000require 'ruby-progressbar/format/molecule' require 'ruby-progressbar/format/formatter' require 'ruby-progressbar/format/string' ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/format/000077500000000000000000000000001347307233000244415ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/format/formatter.rb000066400000000000000000000014121347307233000267670ustar00rootroot00000000000000class ProgressBar module Format class Formatter def self.process(format_string, max_length, bar) processed_string = format_string.dup format_string.non_bar_molecules.each do |molecule| processed_string.gsub!(molecule.full_key, molecule.lookup_value(bar, nil)) end processed_string.gsub!(/%%/, '%') bar_length = max_length - processed_string.displayable_length + format_string.bar_molecule_placeholder_length bar_length = (bar_length < 0) ? 0 : bar_length format_string.bar_molecules.each do |molecule| processed_string.gsub!(molecule.full_key, molecule.lookup_value(bar, bar_length)) end processed_string end end end end ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/format/molecule.rb000066400000000000000000000031441347307233000265750ustar00rootroot00000000000000class ProgressBar module Format class Molecule MOLECULES = { :t => [:title_comp, :title], :T => [:title_comp, :title], :c => [:progressable, :progress], :C => [:progressable, :total], :u => [:progressable, :total_with_unknown_indicator], :p => [:percentage, :percentage], :P => [:percentage, :percentage_with_precision], :j => [:percentage, :justified_percentage], :J => [:percentage, :justified_percentage_with_precision], :a => [:time, :elapsed_with_label], :e => [:time, :estimated_with_unknown_oob], :E => [:time, :estimated_with_friendly_oob], :f => [:time, :estimated_with_no_oob], :B => [:bar, :complete_bar], :b => [:bar, :bar], :W => [:bar, :complete_bar_with_percentage], :w => [:bar, :bar_with_percentage], :i => [:bar, :incomplete_space], :r => [:rate, :rate_of_change], :R => [:rate, :rate_of_change_with_precision] }.freeze BAR_MOLECULES = %w{W w B b i}.freeze attr_accessor :key, :method_name def initialize(letter) self.key = letter self.method_name = MOLECULES.fetch(key.to_sym) end def bar_molecule? BAR_MOLECULES.include? key end def non_bar_molecule? !bar_molecule? end def full_key "%#{key}" end def lookup_value(environment, length = 0) component = environment.__send__(method_name[0]) if bar_molecule? component.__send__(method_name[1], length).to_s else component.__send__(method_name[1]).to_s end end end end end ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/format/string.rb000066400000000000000000000014421347307233000262750ustar00rootroot00000000000000class ProgressBar module Format class String < ::String MOLECULE_PATTERN = /%[a-zA-Z]/.freeze ANSI_SGR_PATTERN = /\e\[[\d;]+m/.freeze def displayable_length gsub(ANSI_SGR_PATTERN, '').length end def bar_molecule_placeholder_length @bar_molecule_placeholder_length ||= bar_molecules.size * 2 end def non_bar_molecules @non_bar_molecules ||= molecules.select(&:non_bar_molecule?) end def bar_molecules @bar_molecules ||= molecules.select(&:bar_molecule?) end def molecules @molecules ||= begin molecules = [] scan(MOLECULE_PATTERN) do |match| molecules << Molecule.new(match[1, 1]) end molecules end end end end end ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/output.rb000066400000000000000000000026521347307233000250430ustar00rootroot00000000000000class ProgressBar class Output DEFAULT_OUTPUT_STREAM = $stdout attr_accessor :stream def initialize(options = {}) self.bar = options[:bar] self.stream = options[:output] || DEFAULT_OUTPUT_STREAM self.throttle = Throttle.new(options) self.length_calculator = Calculators::Length.new( :length => options[:length], :output => stream ) end def self.detect(options = {}) if options[:output].is_a?(Class) && options[:output] <= ProgressBar::Output options[:output].new(options) elsif (options[:output] || DEFAULT_OUTPUT_STREAM).tty? Outputs::Tty.new(options) else Outputs::NonTty.new(options) end end def log(string) clear stream.puts string refresh(:force => true) unless bar.stopped? end def clear_string ' ' * length_calculator.length end def length length_calculator.length end def with_refresh yield refresh end def refresh(options = {}) throttle.choke(:force_update_if => (bar.stopped? || options[:force])) do clear if length_calculator.length_changed? print_and_flush end end protected attr_accessor :length_calculator, :throttle, :bar private def print_and_flush stream.print bar_update_string + eol stream.flush end end end ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/outputs/000077500000000000000000000000001347307233000246745ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/outputs/non_tty.rb000066400000000000000000000014671347307233000267230ustar00rootroot00000000000000require 'ruby-progressbar/output' class ProgressBar module Outputs class NonTty < Output DEFAULT_FORMAT_STRING = '%t: |%b|'.freeze def clear self.last_update_length = 0 stream.print "\n" end def last_update_length @last_update_length ||= 0 end def bar_update_string formatted_string = bar.to_s formatted_string = formatted_string[0...-1] unless bar.finished? output_string = formatted_string[last_update_length..-1] self.last_update_length = formatted_string.length output_string.to_s end def default_format DEFAULT_FORMAT_STRING end def resolve_format(*) default_format end def refresh_with_format_change(*); end def eol bar.stopped? ? "\n" : '' end protected attr_writer :last_update_length end end end ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/outputs/null.rb000066400000000000000000000006201347307233000261710ustar00rootroot00000000000000require 'ruby-progressbar/output' class ProgressBar module Outputs class Null < Output alias refresh_with_format_change with_refresh def clear; end def log(_string); end def refresh(*); end def clear_string '' end def bar_update_string '' end def default_format '' end def resolve_format(_format) '' end def eol '' end end end end ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/outputs/tty.rb000066400000000000000000000007531347307233000260460ustar00rootroot00000000000000require 'ruby-progressbar/output' class ProgressBar module Outputs class Tty < Output DEFAULT_FORMAT_STRING = '%t: |%B|'.freeze alias refresh_with_format_change with_refresh def clear stream.print clear_string stream.print "\r" end def bar_update_string bar.to_s end def default_format DEFAULT_FORMAT_STRING end def resolve_format(other_format) other_format || default_format end def eol bar.stopped? ? "\n" : "\r" end end end end ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/progress.rb000066400000000000000000000056321347307233000253500ustar00rootroot00000000000000require 'ruby-progressbar/errors/invalid_progress_error' class ProgressBar class Progress DEFAULT_TOTAL = 100 DEFAULT_BEGINNING_POSITION = 0 DEFAULT_SMOOTHING = 0.1 attr_reader :total, :progress attr_accessor :starting_position, :running_average, :smoothing def initialize(options = {}) self.total = options.fetch(:total, DEFAULT_TOTAL) self.smoothing = options[:smoothing] || DEFAULT_SMOOTHING start :at => DEFAULT_BEGINNING_POSITION end def start(options = {}) self.running_average = 0 self.progress = \ self.starting_position = options[:at] || progress end def finish self.progress = total unless unknown? end def finished? @progress == @total end def increment if progress == total warn "WARNING: Your progress bar is currently at #{progress} out of #{total} " \ "and cannot be incremented. In v2.0.0 this will become a " \ "ProgressBar::InvalidProgressError." end self.progress += 1 unless progress == total end def decrement if progress == 0 warn "WARNING: Your progress bar is currently at #{progress} out of #{total} " \ "and cannot be decremented. In v2.0.0 this will become a " \ "ProgressBar::InvalidProgressError." end self.progress -= 1 unless progress == 0 end def reset start :at => starting_position end def progress=(new_progress) if total && new_progress > total fail ProgressBar::InvalidProgressError, "You can't set the item's current value to be greater than the total." end @progress = new_progress self.running_average = Calculators::RunningAverage.calculate(running_average, absolute, smoothing) end def total=(new_total) unless progress.nil? || new_total.nil? || new_total >= progress fail ProgressBar::InvalidProgressError, "You can't set the item's total value to less than the current progress." end @total = new_total end def percentage_completed return 0 if total.nil? return 100 if total == 0 # progress / total * 100 # # Doing this way so we can avoid converting each # number to a float and then back to an integer. # (progress * 100 / total).to_i end def none? running_average.zero? || progress.zero? end def unknown? progress.nil? || total.nil? end def total_with_unknown_indicator total || '??' end def percentage_completed_with_precision return 100.0 if total == 0 return 0.0 if total.nil? '%5.2f' % [(progress * 100 / total.to_f * 100).floor / 100.0] end def absolute progress - starting_position end end end ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/refinements.rb000066400000000000000000000000621347307233000260130ustar00rootroot00000000000000require 'ruby-progressbar/refinements/enumerator' ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/refinements/000077500000000000000000000000001347307233000254705ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/refinements/enumerator.rb000066400000000000000000000007161347307233000302020ustar00rootroot00000000000000class ProgressBar module Refinements module Enumerator refine ::Enumerator do def with_progressbar(options = {}, &block) chain = ::Enumerator.new do |yielder| progress_bar = ProgressBar.create(options.merge(:starting_at => 0, :total => size)) each do |*args| yielder.yield(*args).tap do progress_bar.increment end end end return chain unless block_given? chain.each(&block) end end end end end ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/throttle.rb000066400000000000000000000011141347307233000253400ustar00rootroot00000000000000class ProgressBar class Throttle attr_accessor :rate, :started_at, :stopped_at, :timer def initialize(options = {}) self.rate = options[:throttle_rate] || 0.01 self.started_at = nil self.stopped_at = nil self.timer = options.fetch(:throttle_timer, Timer.new) end def choke(options = {}) return unless !timer.started? || options.fetch(:force_update_if, false) || timer.elapsed_seconds >= rate timer.restart yield end end end ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/time.rb000066400000000000000000000016161347307233000244400ustar00rootroot00000000000000# rubocop:disable Style/InlineComment class ProgressBar class Time TIME_MOCKING_LIBRARY_METHODS = [ :__simple_stub__now, # ActiveSupport :now_without_mock_time, # Timecop :now_without_delorean, # Delorean :now # Unmocked ].freeze def initialize(time = ::Time) self.time = time end def now time.__send__(unmocked_time_method) end def unmocked_time_method @unmocked_time_method ||= begin TIME_MOCKING_LIBRARY_METHODS.find do |method| time.respond_to? method end end end protected attr_accessor :time end end # rubocop:enable Style/InlineComment ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/timer.rb000066400000000000000000000020131347307233000246120ustar00rootroot00000000000000require 'ruby-progressbar/time' class ProgressBar class Timer attr_accessor :started_at, :stopped_at def initialize(options = {}) self.time = options[:time] || ::ProgressBar::Time.new end def start self.started_at = stopped? ? time.now - (stopped_at - started_at) : time.now self.stopped_at = nil end def stop return unless started? self.stopped_at = time.now end def pause stop end def resume start end def started? started_at end def stopped? stopped_at end def reset self.started_at = nil self.stopped_at = nil end def reset? !started_at end def restart reset start end def elapsed_seconds ((stopped_at || time.now) - started_at) end def elapsed_whole_seconds elapsed_seconds.floor end def divide_seconds(seconds) hours, seconds = seconds.divmod(3600) minutes, seconds = seconds.divmod(60) [hours, minutes, seconds] end protected attr_accessor :time end end ruby-progressbar-releases-v1.10.1/lib/ruby-progressbar/version.rb000066400000000000000000000000621347307233000251610ustar00rootroot00000000000000class ProgressBar VERSION = '1.10.1'.freeze end ruby-progressbar-releases-v1.10.1/progressbar.gemspec000066400000000000000000000037371347307233000230030ustar00rootroot00000000000000# encoding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'ruby-progressbar/version' Gem::Specification.new do |spec| spec.name = 'progressbar' spec.version = ProgressBar::VERSION spec.authors = ['thekompanee', 'jfelchner'] spec.email = ['support@thekompanee.com'] spec.summary = %q{Ruby/ProgressBar is a flexible text progress bar library for Ruby.} spec.description = %q{Ruby/ProgressBar is an extremely flexible text progress bar library for Ruby. The output can be customized with a flexible formatting system including: percentage, bars of various formats, elapsed time and estimated time remaining.} spec.homepage = 'https://github.com/jfelchner/ruby-progressbar' spec.licenses = ['MIT'] spec.cert_chain = ['certs/jfelchner.pem'] spec.signing_key = File.expand_path('~/.gem/certs/jfelchner-private_key.pem') if $0 =~ /gem\z/ spec.executables = [] spec.files = Dir['{app,config,db,lib/ruby-progressbar}/**/*'] + %w{lib/progressbar.rb Rakefile README.md LICENSE.txt} spec.metadata = { 'bug_tracker_uri' => 'https://github.com/jfelchner/ruby-progressbar/issues', 'changelog_uri' => 'https://github.com/jfelchner/ruby-progressbar/blob/master/CHANGELOG.md', 'documentation_uri' => "https://github.com/jfelchner/ruby-progressbar/tree/releases/v#{ProgressBar::VERSION}", 'homepage_uri' => 'https://github.com/jfelchner/ruby-progressbar', 'source_code_uri' => 'https://github.com/jfelchner/ruby-progressbar', 'wiki_uri' => 'https://github.com/jfelchner/ruby-progressbar/wiki', } spec.add_development_dependency 'rspec', ["~> 3.7"] spec.add_development_dependency 'rspectacular', ["~> 0.70.6"] spec.add_development_dependency 'fuubar', ["~> 2.3"] spec.add_development_dependency 'warning_filter', ["~> 0.0.6"] spec.add_development_dependency 'timecop', ["= 0.6.0"] end ruby-progressbar-releases-v1.10.1/ruby-progressbar.gemspec000066400000000000000000000037511347307233000237560ustar00rootroot00000000000000# encoding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'ruby-progressbar/version' Gem::Specification.new do |spec| spec.name = 'ruby-progressbar' spec.version = ProgressBar::VERSION spec.authors = ['thekompanee', 'jfelchner'] spec.email = ['support@thekompanee.com'] spec.summary = %q{Ruby/ProgressBar is a flexible text progress bar library for Ruby.} spec.description = %q{Ruby/ProgressBar is an extremely flexible text progress bar library for Ruby. The output can be customized with a flexible formatting system including: percentage, bars of various formats, elapsed time and estimated time remaining.} spec.homepage = 'https://github.com/jfelchner/ruby-progressbar' spec.licenses = ['MIT'] spec.cert_chain = ['certs/jfelchner.pem'] spec.signing_key = File.expand_path('~/.gem/certs/jfelchner-private_key.pem') if $0 =~ /gem\z/ spec.executables = [] spec.files = Dir['{app,config,db,lib/ruby-progressbar}/**/*'] + %w{lib/ruby-progressbar.rb Rakefile README.md LICENSE.txt} spec.metadata = { 'bug_tracker_uri' => 'https://github.com/jfelchner/ruby-progressbar/issues', 'changelog_uri' => 'https://github.com/jfelchner/ruby-progressbar/blob/master/CHANGELOG.md', 'documentation_uri' => "https://github.com/jfelchner/ruby-progressbar/tree/releases/v#{ProgressBar::VERSION}", 'homepage_uri' => 'https://github.com/jfelchner/ruby-progressbar', 'source_code_uri' => 'https://github.com/jfelchner/ruby-progressbar', 'wiki_uri' => 'https://github.com/jfelchner/ruby-progressbar/wiki', } spec.add_development_dependency 'rspec', ["~> 3.7"] spec.add_development_dependency 'rspectacular', ["~> 0.70.6"] spec.add_development_dependency 'fuubar', ["~> 2.3"] spec.add_development_dependency 'warning_filter', ["~> 0.0.6"] spec.add_development_dependency 'timecop', ["= 0.6.0"] end ruby-progressbar-releases-v1.10.1/settings/000077500000000000000000000000001347307233000207335ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/settings/rubygems.yml000066400000000000000000000005661347307233000233220ustar00rootroot00000000000000rubygems: _secure_api_key: ebkL9zPPh6WsxKbUTq9769eqjSdVYEeFwCMkDGSZ7kd+F/P+uj5XX0iCAyoOOG9KmB5JIfsnGlUDrlYqkYxRic37IhHYJyAr8PWntPuNasljAnYQFdRK93KzH2Ce0MFPVlhsKuGTx3dTd9a2TWgksglghWLk0zSXt+LpgsyVaWChbGUuC/Tga6SLK6CKL8qbh0lF78laMsGvGQ5apOgXVhg3i8UGEVzTS3fE2NSy85CQdhBQDyJd595T26tlUd57J4tUNkIcgYBaCsFYSjVIqz5ZMF5NKc7PtfkAe3Wlg9fRPLWBCWxS9P6BTmpV4gYm+iusRsJbcdIKWfqV356iZg== ruby-progressbar-releases-v1.10.1/spec/000077500000000000000000000000001347307233000200255ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/spec/fixtures/000077500000000000000000000000001347307233000216765ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/spec/fixtures/benchmark.rb000066400000000000000000000012441347307233000241560ustar00rootroot00000000000000# bundle exec ruby-prof --printer=graph_html # --file=../results.html # --require 'ruby-progressbar' # --sort=total ./spec/fixtures/benchmark.rb total = 100_000 # output = File.open('/Users/jfelchner/Downloads/benchmark.txt', 'w+') output = $stdout # Progressbar gem # bar = ProgressBar.new('Progress', total) # # total.times do |i| # bar.inc # end # # bar.finish # Ruby/ProgressBar bar = ProgressBar.create(:output => output, :length => 80, :start => 0, :total => total) total.times do |_i| # bar.log i bar.increment end ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/000077500000000000000000000000001347307233000233355ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/base_spec.rb000066400000000000000000000526761347307233000256260ustar00rootroot00000000000000require 'spec_helper' require 'support/time' require 'stringio' class ProgressBar describe Base do let(:output) do StringIO.new('', 'w+').tap do |io| allow(io).to receive(:tty?).and_return true end end let(:output_string) do output.rewind output.read end let(:non_tty_output) do StringIO.new('', 'w+').tap do |io| allow(io).to receive(:tty?).and_return false end end let(:non_tty_output_string) do non_tty_output.rewind non_tty_output.read end context 'with the title' do it 'has a default' do progressbar = ProgressBar::Base.new expect(progressbar.send(:title)).to eql \ ProgressBar::Components::Title::DEFAULT_TITLE end it 'is able to be overridden on creation' do progressbar = ProgressBar::Base.new(:title => 'We All Float') expect(progressbar.send(:title).to_s).to eql 'We All Float' end it 'allows title updates even after the bar is started' do progressbar = ProgressBar::Base.new(:output => output, :length => 20, :throttle_rate => 0.0) progressbar.progress = 50 progressbar.title = 'Items' expect(output_string).to eql " \r" \ "Progress: | |\r" \ "Progress: |==== |\r" \ "Items: |===== |\r" \ end it 'ignores title changes for a non-TTY enabled devices' do progressbar = ProgressBar::Base.new(:output => non_tty_output, :length => 80, :starting_at => 10, :throttle_rate => 0.0) progressbar.title = 'Testing' expect(non_tty_output_string).to eql "\n" \ "Progress: |======" end it 'allows for custom title for a non-TTY enabled devices on creation' do _progressbar = ProgressBar::Base.new(:output => non_tty_output, :title => 'Custom', :length => 80, :starting_at => 10) expect(non_tty_output_string).to eql "\n" \ "Custom: |=======" end end context 'with the progress_mark' do it 'can be changed even after the bar is started' do progressbar = ProgressBar::Base.new(:output => output, :length => 20, :throttle_rate => 0.0) progressbar.progress = 30 progressbar.progress_mark = 'x' expect(output_string).to eql " \r" \ "Progress: | |\r" \ "Progress: |== |\r" \ "Progress: |xx |\r" end end context 'with the remainder_mark' do it 'can be changed even after the bar is started' do progressbar = ProgressBar::Base.new(:output => output, :length => 20, :throttle_rate => 0.0) progressbar.progress = 30 progressbar.remainder_mark = 'x' expect(output_string).to eql " \r" \ "Progress: | |\r" \ "Progress: |== |\r" \ "Progress: |==xxxxxx|\r" end end context 'with the output stream' do it 'has a default' do progressbar = ProgressBar::Base.new default_stream = progressbar.send(:output).send(:stream) expect(default_stream).to eql ProgressBar::Output::DEFAULT_OUTPUT_STREAM end it 'is able to be overridden on creation' do progressbar = ProgressBar::Base.new(:output => STDERR) output_stream = progressbar.send(:output).send(:stream) expect(output_stream).to eql STDERR end end context 'with the bar length' do it 'is able to be overridden on creation' do progressbar = ProgressBar::Base.new(:length => 88) length_calculator = progressbar.send(:output).send(:length_calculator) expect(length_calculator.send(:length)).to be 88 end it 'can handle the terminal width changing on the fly' do progressbar = ProgressBar::Base.new(:output => output, :title => 'a' * 25, :format => '%t|%B|', :throttle_rate => 0.0) length_calculator = progressbar.send(:output).send(:length_calculator) allow(length_calculator).to receive(:terminal_width).and_return 30 progressbar.start allow(length_calculator).to receive(:terminal_width).and_return 20 progressbar.increment expect(output_string).to end_with " \r" \ "aaaaaaaaaaaaaaaaaaaaaaaaa| |\r" \ " \r" \ "aaaaaaaaaaaaaaaaaaaaaaaaa||\r" end end context 'when starting the bar' do it 'clears the current terminal line' do progressbar = ProgressBar::Base.new(:output => output, :length => 20, :throttle_rate => 0.0) progressbar.start expect(output_string).to start_with(" \r") end it 'prints the bar for the first time' do progressbar = ProgressBar::Base.new(:output => output, :length => 40, :throttle_rate => 0.0) progressbar.start expect(output_string).to end_with("Progress: | |\r") end it 'prints correctly when a position to start at is specified' do progressbar = ProgressBar::Base.new(:output => output, :length => 40, :throttle_rate => 0.0) progressbar.start(:at => 20) expect(output_string).to end_with("Progress: |===== |\r") end it 'does not blow up if there is a total of zero' do progressbar = ProgressBar::Base.new(:output => output, :autostart => false) progressbar.total = 0 expect { progressbar.start }.not_to raise_error end end context 'when stopping the bar' do it 'forcibly halts the bar wherever it is and cancels further progress' do progressbar = ProgressBar::Base.new(:output => output, :length => 20) progressbar.progress = 33 progressbar.stop expect(output_string).to end_with("\rProgress: |== |\n") end it 'forcibly halts the bar wherever it is for a non-TTY enabled devices' do progressbar = ProgressBar::Base.new(:output => non_tty_output, :length => 20, :throttle_rate => 0.0) progressbar.progress = 33 progressbar.stop expect(non_tty_output_string).to eql "\n" \ "Progress: |==\n" end it 'does not output multiple bars if stopped multiple times in a row' do progressbar = ProgressBar::Base.new(:output => output, :length => 20) progressbar.progress = 10 progressbar.stop progressbar.stop expect(output_string).to start_with(" \r") end it 'does not error if there is nothing to do and it has not been started' do progressbar = ProgressBar::Base.new(:started_at => 0, :total => 0, :autostart => false, :format => ' %c/%C |%w>%i| %e ', :output => output) expect { progressbar.stop }.not_to raise_error end it 'appends proper ending to string for non-TTY devices' do progressbar = ProgressBar::Base.new(:output => non_tty_output) progressbar.stop expect(non_tty_output_string).to end_with("\n") end end context 'when finishing the bar' do it 'does not spam the screen for a non-TTY enabled devices' do progressbar = ProgressBar::Base.new(:output => non_tty_output, :length => 20, :starting_at => 0, :total => 6, :throttle_rate => 0.0) 6.times { progressbar.increment } expect(non_tty_output_string).to eql "\n" \ "Progress: |========|\n" end it 'can finish a bar in the middle of progress for a non-TTY enabled devices' do progressbar = ProgressBar::Base.new(:output => non_tty_output, :length => 20, :starting_at => 0, :total => 6, :throttle_rate => 0.0) progressbar.progress = 3 progressbar.finish expect(non_tty_output_string).to eql "\n" \ "Progress: |========|\n" end it 'properly prints a newline when incremented to its total' do progressbar = ProgressBar::Base.new(:output => output, :starting_at => 5, :total => 6, :length => 20) progressbar.increment expect(progressbar).to be_finished expect(output_string).to end_with("\n") end it 'does not spam the screen if the bar is autofinished and finish is called' do progressbar = ProgressBar::Base.new(:output => output, :starting_at => 5, :total => 6, :length => 20) progressbar.increment progressbar.finish expect(progressbar).to be_finished expect(output_string).to end_with " \r" \ "Progress: |====== |\r" \ "Progress: |========|\n" end it 'does not autofinish if autofinish is disabled' do progressbar = ProgressBar::Base.new(:output => output, :starting_at => 5, :total => 6, :length => 20, :autofinish => false) progressbar.increment expect(progressbar).not_to be_finished end it 'does not print a newline if incremented to total and autofinish is disabled' do progressbar = ProgressBar::Base.new(:output => output, :starting_at => 5, :total => 6, :length => 20, :autofinish => false) progressbar.increment expect(output_string).not_to end_with("\n") end it 'still allows the bar to be reset if autofinish is disabled' do progressbar = ProgressBar::Base.new(:output => output, :starting_at => 5, :total => 6, :length => 20, :autofinish => false) progressbar.increment progressbar.finish expect(progressbar).to be_finished progressbar.reset expect(progressbar).not_to be_finished end it 'still able to be manually finished even if autofinish is disabled' do progressbar = ProgressBar::Base.new(:output => output, :starting_at => 5, :total => 6, :length => 20, :autofinish => false) progressbar.increment progressbar.finish expect(progressbar).to be_finished expect(output_string).to end_with("\n") end it 'does not spam the screen on multiple manual calls when autofinish is disabled' do progressbar = ProgressBar::Base.new(:output => output, :starting_at => 5, :total => 6, :length => 20, :autofinish => false) progressbar.increment progressbar.finish expect(progressbar).to be_finished expect(output_string).to end_with " \r" \ "Progress: |====== |\r" \ "Progress: |========|\n" end end context 'when resetting the bar' do it 'sets the bar back to the starting value' do progressbar = ProgressBar::Base.new(:output => output, :length => 20, :throttle_rate => 0.0) progressbar.progress = 33 progressbar.reset expect(output_string).to eql " \r" \ "Progress: | |\r" \ "Progress: |== |\r" \ "Progress: | |\r" end it 'sets the bar back to its starting value set during creation' do progressbar = ProgressBar::Base.new(:output => output, :starting_at => 33, :total => 100, :length => 20, :throttle_rate => 0.0) progressbar.progress += 10 progressbar.reset expect(output_string).to eql " \r" \ "Progress: |== |\r" \ "Progress: |=== |\r" \ "Progress: |== |\r" end end context 'when logging messages' do it 'can log messages for a TTY enabled device' do progressbar = ProgressBar::Base.new(:output => output, :length => 20, :starting_at => 3, :total => 6, :throttle_rate => 0.0) progressbar.increment progressbar.log 'We All Float' progressbar.increment expect(output_string).to eql " \r" \ "Progress: |==== |\r" \ "Progress: |===== |\r" \ " \r" \ "We All Float\n" \ "Progress: |===== |\r" \ "Progress: |====== |\r" end it 'can log messages for a non-TTY enabled device' do progressbar = ProgressBar::Base.new(:output => non_tty_output, :length => 20, :starting_at => 4, :total => 6, :throttle_rate => 0.0) progressbar.increment progressbar.log 'We All Float' progressbar.increment progressbar.finish expect(non_tty_output_string).to eql "\n" \ "Progress: |======\n" \ "We All Float\n" \ "Progress: |========|\n" end end context 'when formatting the bar' do it 'allows the bar format to be updated dynamically after it is started' do progressbar = ProgressBar::Base.new(:output => output, :format => '%B %p%%', :length => 20) expect(progressbar.to_s).to eql "#{' ' * 18}0%" progressbar.format = '%t' expect(progressbar.to_s).to eql 'Progress' end it 'allows the bar to be reset back to the default format' do progressbar = ProgressBar::Base.new(:output => output, :format => '%B %p%%', :length => 100) expect(progressbar.to_s).to eql "#{' ' * 98}0%" progressbar.format = nil expect(progressbar.to_s).to eql "Progress: |#{' ' * 88}|" end end context 'when clearing the bar' do it 'clears the current terminal line and/or bar text' do progressbar = ProgressBar::Base.new(:output => output, :starting_at => 40, :length => 20, :throttle_rate => 0.0) progressbar.clear expect(output_string).to eql " \r" \ "Progress: |=== |\r" \ " \r" end end context 'when incrementing the bar' do it 'displays the bar with the correct progress' do progressbar = ProgressBar::Base.new(:output => output, :length => 20, :starting_at => 0, :total => 6, :throttle_rate => 0.0) progressbar.increment expect(output_string).to eql " \r" \ "Progress: | |\r" \ "Progress: |= |\r" end end context 'when decrementing the bar' do it 'displays the bar with the correct progress' do progressbar = ProgressBar::Base.new(:output => output, :length => 20, :starting_at => 1, :total => 6, :throttle_rate => 0.0) progressbar.decrement expect(output_string).to eql " \r" \ "Progress: |= |\r" \ "Progress: | |\r" end context 'with non-TTY enabled devices' do it 'does nothing' do progressbar = ProgressBar::Base.new(:output => non_tty_output, :length => 20, :starting_at => 2, :total => 6, :throttle_rate => 0.0) progressbar.decrement expect(non_tty_output_string).to eql "\n" \ "Progress: |==" end end end it 'can be converted into a hash' do Timecop.freeze(::Time.utc(2012, 7, 26, 18, 0, 0)) progressbar = ProgressBar::Base.new(:output => output, :total => 33, :title => 'My Title', :format => '%t|%B|', :progress_mark => 'x', :remainder_mark => '-', :length => 92, :rate_scale => lambda { |rate| rate * 200 }, :throttle_rate => 12.3) Timecop.travel(-600) do progressbar.start progressbar.progress += 22 end expect(progressbar.to_h).to include( 'output_stream' => be_a(StringIO), 'length' => 92, 'elapsed_time_in_seconds' => be_within(0.001).of(600), 'estimated_time_remaining_in_seconds' => 400, 'percentage' => 66.66, 'progress' => 22, 'progress_mark' => 'x', 'base_rate_of_change' => 0.03672787979966611, 'scaled_rate_of_change' => 7.345575959933222, 'remainder_mark' => '-', 'throttle_rate' => 12.3, 'title' => 'My Title', 'total' => 33, 'unknown_progress_animation_steps' => ['=---', '-=--', '--=-', '---='], 'started?' => be_within(1).of(::Time.now.utc - 600), 'stopped?' => false, 'finished?' => false ) end end end ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/calculators/000077500000000000000000000000001347307233000256515ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/calculators/length_spec.rb000066400000000000000000000067321347307233000305010ustar00rootroot00000000000000require 'spec_helper' require 'ruby-progressbar/calculators/length' class ProgressBar module Calculators describe Length do let(:tty_output) do IO.new(IO.sysopen('/dev/tty', 'w')).tap do |io| allow(io).to receive(:tty?).and_return true end end let(:non_tty_output) do IO.new(IO.sysopen('/dev/null', 'w')).tap do |io| allow(io).to receive(:tty?).and_return false end end context 'when the RUBY_PROGRESS_BAR_LENGTH environment variable exists' do before(:each) { ENV['RUBY_PROGRESS_BAR_LENGTH'] = '44' } after(:each) { ENV['RUBY_PROGRESS_BAR_LENGTH'] = nil } it 'calculates the length as the value of the environment variable as an integer' do length_calculator = Calculators::Length.new expect(length_calculator.length).to be 44 end end if RUBY_PLATFORM != 'java' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('1.9.3') it 'can properly calculate the length even if IO.console is nil' do calculator = Length.new allow(IO).to receive(:console).and_return nil allow(calculator).to receive(:dynamic_width_via_system_calls).and_return 123_456 expect(calculator.calculate_length).to be 123_456 end end it 'allows the length to be overridden on creation' do length_calculator = Calculators::Length.new(:length => 88) expect(length_calculator.length).to be 88 end it 'can calculate the width of the terminal in Unix environments' do length_calculator = Calculators::Length.new allow(length_calculator).to receive(:unix?).and_return(true) allow(length_calculator).to receive(:dynamic_width).and_return(99) expect(length_calculator.length).to be 99 end unless RUBY_VERSION.start_with?('1.') it 'asks stream for length if it is a TTY' do allow(tty_output).to receive(:winsize).and_return [123, 456] allow(IO).to receive(:console).and_call_original length_calculator = Calculators::Length.new(:output => tty_output) expect(IO).not_to have_received :console expect(length_calculator.length).to be 456 end it 'asks IO.console to calculate length if the output is null' do allow(tty_output).to receive(:winsize).and_return [123, 456] allow(IO).to receive(:console).and_return(tty_output) length_calculator = Calculators::Length.new expect(length_calculator.length).to be 456 expect(IO).to have_received(:console). at_least(:once) end it 'asks IO.console to calculate length if the output is not a TTY' do allow(non_tty_output).to receive(:winsize).and_return [654, 321] allow(tty_output).to receive(:winsize).and_return [123, 456] allow(IO).to receive(:console).and_return(tty_output) length_calculator = Calculators::Length.new(:output => non_tty_output) expect(length_calculator.length).to be 456 end end it 'defaults to 80 if it is not a Unix environment' do length_calculator = Calculators::Length.new allow(length_calculator).to receive(:unix?).and_return(false) expect(length_calculator.length).to be 80 end it 'defaults to 80 if the width is less than 20' do length_calculator = Calculators::Length.new allow(length_calculator).to receive(:unix?).and_return(true) allow(length_calculator).to receive(:dynamic_width).and_return(19) expect(length_calculator.length).to be 80 end end end end ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/calculators/running_average_spec.rb000066400000000000000000000010721347307233000323620ustar00rootroot00000000000000require 'spec_helper' require 'ruby-progressbar/calculators/running_average' class ProgressBar module Calculators describe RunningAverage do it 'can properly calculate a running average' do first_average = RunningAverage.calculate(4.5, 12, 0.1) expect(first_average).to be_within(0.001).of 11.25 second_average = RunningAverage.calculate(8.2, 51, 0.7) expect(second_average).to be_within(0.001).of 21.04 third_average = RunningAverage.calculate(41.8, 100, 0.59) expect(third_average).to be_within(0.001).of 65.662 end end end end ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/components/000077500000000000000000000000001347307233000255225ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/components/bar_spec.rb000066400000000000000000000156141347307233000276340ustar00rootroot00000000000000require 'spec_helper' require 'ruby-progressbar/components/bar' class ProgressBar module Components describe Bar do it 'has a default mark when a new bar is created and no parameters are passed' do expect(Bar.new.progress_mark).to eql Bar::DEFAULT_PROGRESS_MARK end it 'has a default remainder mark when a new bar is created and no parameters ' \ 'are passed' do expect(Bar.new.remainder_mark).to eql Bar::DEFAULT_REMAINDER_MARK end it 'returns the overridden mark when a new bar is created and options are passed' do progressbar = Bar.new(:progress_mark => 'x') expect(progressbar.progress_mark).to eql 'x' end it 'returns the overridden remainder mark when a new bar is created and options ' \ 'are passed' do progressbar = Bar.new(:remainder_mark => 'o') expect(progressbar.remainder_mark).to eql 'o' end it 'displays the bar with no indication of progress when just begun' do progress = Progress.new(:total => 50) progressbar = Bar.new(:progress => progress, :length => 100) expect(progressbar.to_s).to eql ' ' * 100 end it 'displays the bar with an indication of progress when nothing has been ' \ 'completed and the bar is incremented' do progress = Progress.new :total => 50 progressbar = Bar.new :progress => progress, :length => 100 progress.increment expect(progressbar.to_s).to eql '==' + (' ' * 98) end it 'displays the bar with no indication of progress when a fraction of a percentage ' \ 'has been completed' do progress = Progress.new :total => 200 progressbar = Bar.new :progress => progress, :length => 100 progress.start :at => 1 expect(progressbar.to_s).to eql(' ' * 100) end it 'displays the bar as 100% complete when completed' do progress = Progress.new :total => 50 progressbar = Bar.new :progress => progress, :length => 100 progress.start :at => 50 progress.increment expect(progressbar.to_s).to eql '=' * 100 end it 'displays the bar as 98% complete when completed and the bar is decremented' do progress = Progress.new :total => 50 progressbar = Bar.new :progress => progress, :length => 100 progress.start :at => 50 progress.decrement expect(progressbar.to_s).to eql(('=' * 98) + (' ' * 2)) end it 'is represented correctly when a bar has an unknown amount to completion' do progress = Progress.new :total => nil progressbar = Bar.new :progress => progress, :length => 80 expect(progressbar.to_s).to eql('=---' * 20) end it 'is represented after being incremented once when a bar has an unknown amount ' \ 'to completion' do progress = Progress.new :total => nil progressbar = Bar.new :progress => progress, :length => 80 progress.increment expect(progressbar.to_s).to eql('-=--' * 20) end it 'is represented after being incremented twice when a bar has an unknown amount ' \ 'to completion' do progress = Progress.new :total => nil progressbar = Bar.new :progress => progress, :length => 80 2.times { progress.increment } expect(progressbar.to_s).to eql('--=-' * 20) end it 'is represented correctly when a bar has a customized unknown animation' do progress = Progress.new :total => nil progressbar = Bar.new :progress => progress, :unknown_progress_animation_steps => ['*--', '-*-', '--*'], :length => 80 expect(progressbar.to_s).to eql(('*--' * 26) + '*-') end it 'displays the bar with an integrated percentage properly when empty' do progress = Progress.new :total => 100 progressbar = Bar.new :progress => progress, :length => 100 bar_text = progressbar.to_s(:format => :integrated_percentage) expect(bar_text).to eql ' ' * 100 end it 'displays the bar with an integrated percentage properly just before' \ 'the percentage is displayed' do progress = Progress.new :total => 100 progressbar = Bar.new :progress => progress, :length => 100 4.times { progress.increment } bar_text = progressbar.to_s(:format => :integrated_percentage) expect(bar_text).to eql '====' + (' ' * 96) end it 'displays the bar with an integrated percentage properly immediately after' \ 'the percentage is displayed' do progress = Progress.new :total => 100 progressbar = Bar.new :progress => progress, :length => 100 5.times { progress.increment } bar_text = progressbar.to_s(:format => :integrated_percentage) expect(bar_text).to eql '= 5 =' + (' ' * 95) end it 'displays the bar with an integrated percentage properly on double digit' \ 'percentage' do progress = Progress.new :total => 100 progressbar = Bar.new :progress => progress, :length => 100 10.times { progress.increment } bar_text = progressbar.to_s(:format => :integrated_percentage) expect(bar_text).to eql '=== 10 ===' + (' ' * 90) end it 'displays the bar with an integrated percentage properly when finished' do progress = Progress.new :total => 100 progressbar = Bar.new :progress => progress, :length => 100 progress.finish bar_text = progressbar.to_s(:format => :integrated_percentage) expect(bar_text).to eql(('=' * 47) + ' 100 ' + ('=' * 48)) end it 'calculates the remaining negative space properly with an integrated percentage ' \ 'bar of 0 percent' do progress = Progress.new :total => 200 progressbar = Bar.new :progress => progress, :length => 100 bar_text = progressbar.to_s(:format => :integrated_percentage) expect(bar_text).to eql ' ' * 100 9.times { progress.increment } bar_text = progressbar.to_s(:format => :integrated_percentage) expect(bar_text).to eql '====' + (' ' * 96) progress.increment bar_text = progressbar.to_s(:format => :integrated_percentage) expect(bar_text).to eql '= 5 =' + (' ' * 95) end it 'raises an error when attempting to set the current value of the bar to be ' \ 'greater than the total' do progress = Progress.new :total => 10 _progressbar = Bar.new :progress => progress expect { progress.start :at => 11 }.to \ raise_error(InvalidProgressError, "You can't set the item's current value to be greater than the total.") end end end end ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/components/percentage_spec.rb000066400000000000000000000002241347307233000311740ustar00rootroot00000000000000require 'spec_helper' require 'ruby-progressbar/components/percentage' class ProgressBar module Components describe Percentage do end end end ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/components/rate_spec.rb000066400000000000000000000002101347307233000300050ustar00rootroot00000000000000require 'spec_helper' require 'ruby-progressbar/components/rate' class ProgressBar module Components describe Rate do end end end ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/components/throttle_spec.rb000066400000000000000000000060741347307233000307350ustar00rootroot00000000000000require 'spec_helper' require 'ruby-progressbar/progress' class ProgressBar describe Throttle do let(:timer) { ProgressBar::Timer.new(:time => ::Time) } it 'yields the first time if the throttle rate is given and the timer is not started' do throttle = ProgressBar::Throttle.new(:throttle_rate => 10, :throttle_timer => timer) yielded = false throttle.choke do yielded = true end expect(yielded).to be_a TrueClass end it 'does not yield after the initial yield if the period has not passed yet' do throttle = ProgressBar::Throttle.new(:throttle_rate => 10, :throttle_timer => timer) timer.start throttle.choke {} yielded = false 9.times do Timecop.freeze(1) throttle.choke do yielded = true end end Timecop.return expect(yielded).to be_a FalseClass end it 'always yields if forced to, even after the initial yield or if the period ' \ 'has not passed' do throttle = ProgressBar::Throttle.new(:throttle_rate => 10, :throttle_timer => timer) timer.start throttle.choke {} yielded = 0 25.times do Timecop.freeze(1) throttle.choke(:force_update_if => true) do yielded += 1 end end Timecop.return expect(yielded).to be 25 end it 'yields if the period has passed, even after the initial yield' do throttle = ProgressBar::Throttle.new(:throttle_rate => 10, :throttle_timer => timer) timer.start throttle.choke {} yielded = false Timecop.freeze(11) throttle.choke do yielded = true end Timecop.return expect(yielded).to be true end it 'does not yield after a previous yield if the period has not passed yet' do throttle = ProgressBar::Throttle.new(:throttle_rate => 10, :throttle_timer => timer) Timecop.freeze(0) timer.start Timecop.freeze(15) throttle.choke {} yielded = false 9.times do Timecop.freeze(1) throttle.choke do yielded = true end expect(yielded).to be false end Timecop.return end it 'yields after the period has passed, even after a previous yield' do throttle = ProgressBar::Throttle.new(:throttle_rate => 10, :throttle_timer => timer) Timecop.freeze(0) timer.start Timecop.freeze(15) throttle.choke {} yielded = false Timecop.freeze(10) throttle.choke do yielded = true end Timecop.return expect(yielded).to be true end it 'does not throttle if no throttle rate is given' do throttle = Throttle.new(:throttle_timer => timer, :throttle_rate => nil) yield_count = 0 25.times do Timecop.freeze(1) throttle.choke do yield_count += 1 end end Timecop.return expect(yield_count).to be 25 end end end ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/components/time_spec.rb000066400000000000000000000174131347307233000300250ustar00rootroot00000000000000require 'spec_helper' require 'ruby-progressbar/components/time' class ProgressBar module Components describe Time do let(:timer) { Timer.new(:time => ::Time) } it 'displays an unknown estimated time remaining when the timer has been started ' \ 'but no progress has been made' do progress = Progress.new(:total => 100) time = Time.new(:timer => timer, :progress => progress) timer.start expect(time.estimated_with_label).to eql ' ETA: ??:??:??' end it 'does not display unknown time remaining when the timer has been started and ' \ 'it is incremented' do progress = Progress.new(:total => 100) time = Time.new(:timer => timer, :progress => progress) timer.start progress.increment expect(time.estimated_with_label).to eql ' ETA: 00:00:00' end it 'displays unsmoothed time remaining when progress has been made' do progress = Progress.new(:total => 100, :smoothing => 0.0) time = Time.new(:timer => timer, :progress => progress) Timecop.freeze(-13_332) timer.start 50.times { progress.increment } Timecop.return expect(time.estimated_with_label).to eql ' ETA: 03:42:12' end it 'displays unknown time remaining when progress has been made and then progress ' \ 'is reset' do progress = Progress.new(:total => 100) time = Time.new(:timer => timer, :progress => progress) Timecop.freeze(-13_332) timer.start 50.times { progress.increment } Timecop.return progress.reset expect(time.estimated_with_label).to eql ' ETA: ??:??:??' end it 'displays unsmoothed time remaining when progress has been made even after the ' \ 'bar is decremented' do progress = Progress.new(:total => 100, :smoothing => 0.0) time = Time.new(:timer => timer, :progress => progress) Timecop.freeze(-13_332) timer.start 50.times { progress.increment } Timecop.return 20.times { progress.decrement } expect(time.estimated_with_label).to eql ' ETA: 08:38:28' end it 'displays estimated time of "> 4 Days" when estimated time is out of bounds ' \ 'and the out of bounds format is set to "friendly"' do progress = Progress.new(:total => 100, :smoothing => 0.0) time = Time.new(:out_of_bounds_time_format => :friendly, :timer => timer, :progress => progress) Timecop.freeze(-120_000) timer.start 25.times { progress.increment } Timecop.return expect(time.estimated_with_label).to eql ' ETA: > 4 Days' end it 'displays estimated time of "??:??:??" when estimated time is out of bounds ' \ 'and the out of bounds format is set to "unknown"' do progress = Progress.new(:total => 100, :smoothing => 0.0) time = Time.new(:out_of_bounds_time_format => :unknown, :timer => timer, :progress => progress) Timecop.freeze(-120_000) timer.start 25.times { progress.increment } Timecop.return expect(time.estimated_with_label).to eql ' ETA: ??:??:??' end it 'displays actual estimated time when estimated time is out of bounds and the ' \ 'out of bounds format is unset' do progress = Progress.new(:total => 100, :smoothing => 0.0) time = Time.new(:out_of_bounds_time_format => nil, :timer => timer, :progress => progress) Timecop.freeze(-120_000) timer.start 25.times { progress.increment } Timecop.return expect(time.estimated_with_label).to eql ' ETA: 100:00:00' end it 'displays smoothed estimated time properly even when taking decrements into ' \ 'account' do progress = Progress.new(:total => 100, :smoothing => 0.5) time = Time.new(:timer => timer, :progress => progress) Timecop.freeze(-13_332) timer.start 50.times { progress.increment } Timecop.return 20.times { progress.decrement } expect(time.estimated_with_label).to eql ' ETA: 08:14:34' end it 'displays smoothed unknown estimated time when reset is called after progress ' \ 'is made' do progress = Progress.new(:total => 100, :smoothing => 0.5) time = Time.new(:timer => timer, :progress => progress) Timecop.freeze(-13_332) timer.start 50.times { progress.increment } Timecop.return progress.reset expect(time.estimated_with_label).to eql ' ETA: ??:??:??' end it 'displays smoothed estimated time after progress has been made' do progress = Progress.new(:total => 100, :smoothing => 0.5) time = Time.new(:timer => timer, :progress => progress) Timecop.freeze(-13_332) timer.start 50.times { progress.increment } Timecop.return expect(time.estimated_with_label).to eql ' ETA: 03:51:16' end it 'displays the estimated time remaining properly even for progress increments ' \ 'very short intervals' do progress = Progress.new(:total => 10, :smoothing => 0.1) time = Time.new(:timer => timer, :progress => progress) estimated_time_results = [] now = ::Time.now Timecop.freeze(now) timer.start 10.times do Timecop.freeze(now += 0.5) progress.increment estimated_time_results << time.estimated_with_label end Timecop.return expect(estimated_time_results).to eql( [ ' ETA: 00:00:05', ' ETA: 00:00:04', ' ETA: 00:00:04', ' ETA: 00:00:03', ' ETA: 00:00:03', ' ETA: 00:00:02', ' ETA: 00:00:02', ' ETA: 00:00:01', ' ETA: 00:00:01', ' ETA: 00:00:00' ] ) end it 'displays unknown elapsed time when the timer has not been started' do progress = Progress.new time = Time.new(:timer => timer, :progress => progress) expect(time.elapsed_with_label).to eql 'Time: --:--:--' end it 'displays elapsed time when the timer has just been started' do progress = Progress.new time = Time.new(:timer => timer, :progress => progress) timer.start expect(time.elapsed_with_label).to eql 'Time: 00:00:00' end it 'displays elapsed time if it was previously started' do progress = Progress.new time = Time.new(:timer => timer, :progress => progress) Timecop.freeze(-16_093) timer.start Timecop.return expect(time.elapsed_with_label).to eql 'Time: 04:28:13' end it 'displays elapsed time frozen to a specific time if it was previously stopped' do progress = Progress.new time = Time.new(:timer => timer, :progress => progress) Timecop.freeze(-16_093) timer.start Timecop.return Timecop.freeze(-32) timer.stop Timecop.return expect(time.elapsed_with_label).to eql 'Time: 04:27:41' end it 'displays unknown elapsed time after reset has been called' do progress = Progress.new time = Time.new(:timer => timer, :progress => progress) Timecop.freeze(-16_093) timer.start Timecop.return timer.reset expect(time.elapsed_with_label).to eql 'Time: --:--:--' end it 'raises an exception when an invalid out of bounds time format is specified' do expect { Time.new(:out_of_bounds_time_format => :foo) }.to( raise_error 'Invalid Out Of Bounds time format. Valid formats are ' \ '[:unknown, :friendly, nil]' ) end end end end ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/components/title_spec.rb000066400000000000000000000004011347307233000301750ustar00rootroot00000000000000require 'spec_helper' require 'ruby-progressbar/components/title' class ProgressBar module Components describe Title do it 'can use the default title if none is specified' do expect(Title.new.title).to eql Title::DEFAULT_TITLE end end end end ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/format/000077500000000000000000000000001347307233000246255ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/format/formatter_spec.rb000066400000000000000000000621221347307233000301720ustar00rootroot00000000000000require 'spec_helper' require 'support/time' require 'ruby-progressbar/format/formatter' class ProgressBar module Format describe Formatter do let(:to_the_past) { -3_723 } let(:one_hundred_hours_ago) { -360_000 } let(:four_minutes_ago) { -240 } let(:one_minute_ago) { -60 } context 'with the %% flag' do let(:format) { Format::String.new('%%') } it 'displays a literal percent sign' do progressbar = ProgressBar::Base.new(:starting_at => 66, :total => 99) expect(Formatter.process(format, 100, progressbar)).to eql '%' end end context 'with the %a flag' do let(:format) { Format::String.new('%a') } it 'is "--:--:--" when displayed after starting the bar and then resetting the bar' do progressbar = ProgressBar::Base.new Timecop.freeze(to_the_past) do progressbar.start end progressbar.reset expect(Formatter.process(format, 100, progressbar)).to eql 'Time: --:--:--' end it 'is the time elapsed when displayed after starting the bar' do progressbar = ProgressBar::Base.new(:throttle_rate => 0.0) Timecop.freeze(to_the_past) do progressbar.start end expect(Formatter.process(format, 100, progressbar)).to eql 'Time: 01:02:03' end it 'is the total amount of time elapsed once the bar finishes' do progressbar = ProgressBar::Base.new(:throttle_rate => 0.0) Timecop.freeze(four_minutes_ago) do progressbar.start end Timecop.freeze(one_minute_ago) do progressbar.finish end expect(Formatter.process(format, 100, progressbar)).to eql 'Time: 00:03:00' end end context 'with the %b flag' do let(:format) { Format::String.new('%b') } it 'is the bar (excluding incomplete space)' do progressbar = ProgressBar::Base.new(:starting_at => 20) expect(Formatter.process(format, 100, progressbar)).to eql('=' * 20) end end context 'with the %B flag' do let(:format) { Format::String.new('%B') } it 'is the bar (including incomplete space)' do progressbar = ProgressBar::Base.new(:starting_at => 20) expect(Formatter.process(format, 100, progressbar)).to eql "#{'=' * 20}#{' ' * 80}" end end context 'with the %c flag' do let(:format) { Format::String.new('%c') } it 'is the current capacity/progress' do progressbar = ProgressBar::Base.new expect(Formatter.process(format, 100, progressbar)).to eql '0' progressbar.increment expect(Formatter.process(format, 100, progressbar)).to eql '1' progressbar.decrement expect(Formatter.process(format, 100, progressbar)).to eql '0' end end context 'with the %C flag' do let(:format) { Format::String.new('%C') } it 'is the total capacity/progress' do progressbar = ProgressBar::Base.new(:total => 100) expect(Formatter.process(format, 100, progressbar)).to eql '100' end it 'is nothing when the total is unknown' do progressbar = ProgressBar::Base.new(:total => nil) expect(Formatter.process(format, 100, progressbar)).to eql '' end end context 'with the %e flag' do let(:format) { Format::String.new('%e') } it 'is unknown estimated time when called before the bar is started' do progressbar = ProgressBar::Base.new expect(Formatter.process(format, 100, progressbar)).to eql ' ETA: ??:??:??' end it 'is unknown estimated time when the bar is started with any progress' do progressbar = ProgressBar::Base.new(:starting_at => 1) expect(Formatter.process(format, 100, progressbar)).to eql ' ETA: ??:??:??' end it 'is "??:??:??" when called after the bar is started makes progress and reset' do progressbar = ProgressBar::Base.new Timecop.freeze(to_the_past) do progressbar.start progressbar.progress = 50 end progressbar.reset expect(Formatter.process(format, 100, progressbar)).to eql ' ETA: ??:??:??' end it 'is the estimated time remaining when called after the bar is started' do progressbar = ProgressBar::Base.new(:smoothing => 0.0) Timecop.freeze(to_the_past) do progressbar.start progressbar.progress = 50 end expect(Formatter.process(format, 100, progressbar)).to eql ' ETA: 01:02:03' end it 'is "??:??:??" when it could take 100 hours or longer to finish' do progressbar = ProgressBar::Base.new(:total => 100, :smoothing => 0.0) Timecop.freeze(one_hundred_hours_ago) do progressbar.start progressbar.progress = 50 end expect(Formatter.process(format, 100, progressbar)).to eql ' ETA: ??:??:??' end it 'is the total amount of time elapsed once the bar finishes' do progressbar = ProgressBar::Base.new(:throttle_rate => 0.0) Timecop.freeze(four_minutes_ago) do progressbar.start end Timecop.freeze(one_minute_ago) do progressbar.finish end expect(Formatter.process(format, 100, progressbar)).to eql 'Time: 00:03:00' end end context 'with the %E flag' do let(:format) { Format::String.new('%E') } it 'is unknown estimated time when called before the bar is started' do progressbar = ProgressBar::Base.new expect(Formatter.process(format, 100, progressbar)).to eql ' ETA: ??:??:??' end it 'is unknown estimated time when the bar is started with any progress' do progressbar = ProgressBar::Base.new(:starting_at => 1) expect(Formatter.process(format, 100, progressbar)).to eql ' ETA: ??:??:??' end it 'is "??:??:??" when called after the bar is started makes progress and reset' do progressbar = ProgressBar::Base.new Timecop.freeze(to_the_past) do progressbar.start progressbar.progress = 50 end progressbar.reset expect(Formatter.process(format, 100, progressbar)).to eql ' ETA: ??:??:??' end it 'is the estimated time remaining when called after the bar is started' do progressbar = ProgressBar::Base.new(:smoothing => 0.0) Timecop.freeze(to_the_past) do progressbar.start progressbar.progress = 50 end expect(Formatter.process(format, 100, progressbar)).to eql ' ETA: 01:02:03' end it 'is the total amount of time elapsed once the bar finishes' do progressbar = ProgressBar::Base.new(:throttle_rate => 0.0) Timecop.freeze(four_minutes_ago) do progressbar.start end Timecop.freeze(one_minute_ago) do progressbar.finish end expect(Formatter.process(format, 100, progressbar)).to eql 'Time: 00:03:00' end it 'is "> 4 Days" when it could take 100 hours or longer to finish' do progressbar = ProgressBar::Base.new(:total => 100, :smoothing => 0.0) Timecop.freeze(one_hundred_hours_ago) do progressbar.start progressbar.progress = 50 end expect(Formatter.process(format, 100, progressbar)).to eql ' ETA: > 4 Days' end end context 'with the %f flag' do let(:format) { Format::String.new('%f') } it 'is unknown estimated time when called before the bar is started' do progressbar = ProgressBar::Base.new expect(Formatter.process(format, 100, progressbar)).to eql ' ETA: ??:??:??' end it 'is unknown estimated time when the bar is started with any progress' do progressbar = ProgressBar::Base.new(:starting_at => 1) expect(Formatter.process(format, 100, progressbar)).to eql ' ETA: ??:??:??' end it 'is "??:??:??" when called after the bar is started makes progress and reset' do progressbar = ProgressBar::Base.new Timecop.freeze(to_the_past) do progressbar.start progressbar.progress = 50 end progressbar.reset expect(Formatter.process(format, 100, progressbar)).to eql ' ETA: ??:??:??' end it 'is the estimated time remaining when called after the bar is started' do progressbar = ProgressBar::Base.new(:smoothing => 0.0) Timecop.freeze(to_the_past) do progressbar.start progressbar.progress = 50 end expect(Formatter.process(format, 100, progressbar)).to eql ' ETA: 01:02:03' end it 'is the exact estimated time when it could take 100 hours or longer to finish' do progressbar = ProgressBar::Base.new(:total => 100, :smoothing => 0.0) Timecop.freeze(one_hundred_hours_ago) do progressbar.start progressbar.progress = 50 end expect(Formatter.process(format, 100, progressbar)).to eql ' ETA: 100:00:00' end end context 'with the %i flag' do let(:format) { Format::String.new('%i') } it 'is the incomplete space' do progressbar = ProgressBar::Base.new(:starting_at => 20) expect(Formatter.process(format, 100, progressbar)).to eql(' ' * 80) end it 'is unknown progress when the bar total is unknown' do progressbar = ProgressBar::Base.new(:total => nil) expect(Formatter.process(format, 100, progressbar)).to eql '=---' * 25 end it 'is unknown progress when the bar total is unknown and has been incremented' do progressbar = ProgressBar::Base.new(:total => nil) progressbar.increment expect(Formatter.process(format, 100, progressbar)).to eql '-=--' * 25 progressbar.increment expect(Formatter.process(format, 100, progressbar)).to eql '--=-' * 25 end it 'is the custom unknown progress steps if those are specified' do progressbar = ProgressBar::Base.new( :total => nil, :unknown_progress_animation_steps => %w{ *-- -*- --* } ) progressbar.progress = 2 expect(Formatter.process(format, 100, progressbar)).to eql "--*-#{'-*-' * 32}" end end context 'with the %j flag' do let(:format) { Format::String.new('%j') } it 'is the justified percentage complete floored to the nearest whole number' do progressbar = ProgressBar::Base.new(:starting_at => 33, :total => 200) expect(Formatter.process(format, 100, progressbar)).to eql ' 16' end it 'is zero when the total is unknown' do progressbar = ProgressBar::Base.new(:total => nil) expect(Formatter.process(format, 100, progressbar)).to eql ' 0' end it 'is 100% when the total is zero' do progressbar = ProgressBar::Base.new(:total => 0) expect(Formatter.process(format, 100, progressbar)).to eql '100' end end context 'with the %J flag' do let(:format) { Format::String.new('%J') } it 'is the justified percentage complete floored to two decimal places' do progressbar = ProgressBar::Base.new(:starting_at => 33, :total => 200) expect(Formatter.process(format, 100, progressbar)).to eql ' 16.50' end it 'is zero when the total is unknown' do progressbar = ProgressBar::Base.new(:total => nil) expect(Formatter.process(format, 100, progressbar)).to eql ' 0.0' end it 'is 100% when the total is zero' do progressbar = ProgressBar::Base.new(:total => 0) expect(Formatter.process(format, 100, progressbar)).to eql ' 100.0' end end context 'with the %p flag' do let(:format) { Format::String.new('%p') } it 'is the percentage complete floored to the nearest whole number' do progressbar = ProgressBar::Base.new(:starting_at => 33, :total => 200) expect(Formatter.process(format, 100, progressbar)).to eql '16' end it 'is zero when the total is unknown' do progressbar = ProgressBar::Base.new(:total => nil) expect(Formatter.process(format, 100, progressbar)).to eql '0' end it 'is 100% when the total is zero' do progressbar = ProgressBar::Base.new(:total => 0) expect(Formatter.process(format, 100, progressbar)).to eql '100' end end context 'with the %P flag' do let(:format) { Format::String.new('%P') } it 'is the percentage complete floored to two decimal places' do progressbar = ProgressBar::Base.new(:starting_at => 33, :total => 200) expect(Formatter.process(format, 100, progressbar)).to eql '16.50' end it 'is the percentage complete only up to two decimal places' do progressbar = ProgressBar::Base.new(:starting_at => 66, :total => 99) expect(Formatter.process(format, 100, progressbar)).to eql '66.66' end it 'is zero when the total is unknown' do progressbar = ProgressBar::Base.new(:total => nil) expect(Formatter.process(format, 100, progressbar)).to eql '0.0' end it 'is 100% when the total is zero' do progressbar = ProgressBar::Base.new(:total => 0) expect(Formatter.process(format, 100, progressbar)).to eql '100.0' end end context 'with the %r flag' do let(:format) { Format::String.new('%r') } it 'is the rate' do progressbar = ProgressBar::Base.new Timecop.freeze do progressbar.start progressbar.progress += 20 Timecop.freeze(2) do expect(Formatter.process(format, 100, progressbar)).to eql '10' end end end it 'is zero when no time has elapsed' do Timecop.freeze do progressbar = ProgressBar::Base.new expect(Formatter.process(format, 100, progressbar)).to eql '0' end end it 'is zero when no progress has been made' do progressbar = ProgressBar::Base.new(:starting_at => 20) Timecop.freeze(2) do expect(Formatter.process(format, 100, progressbar)).to eql '0' end end it 'takes the starting position into account' do progressbar = ProgressBar::Base.new(:starting_at => 20) Timecop.freeze do progressbar.start progressbar.progress += 20 Timecop.freeze(2) do expect(Formatter.process(format, 100, progressbar)).to eql '10' end end end it 'is the rate when a custom rate is used' do progressbar = ProgressBar::Base.new(:rate_scale => lambda { |rate| rate / 2 }) Timecop.freeze do progressbar.start progressbar.progress += 20 Timecop.freeze(2) do expect(Formatter.process(format, 100, progressbar)).to eql '5' end end end it 'is zero when no progress has been made when a custom rate is used' do progressbar = ProgressBar::Base.new(:starting_at => 20, :rate_scale => lambda { |rate| rate / 2 }) Timecop.freeze(2) do expect(Formatter.process(format, 100, progressbar)).to eql '0' end end it 'takes the starting position into account when a custom rate is used' do progressbar = ProgressBar::Base.new(:starting_at => 20, :rate_scale => lambda { |rate| rate / 2 }) Timecop.freeze do progressbar.start progressbar.progress += 20 Timecop.freeze(2) do expect(Formatter.process(format, 100, progressbar)).to eql '5' end end end end context 'with the %R flag' do let(:format) { Format::String.new('%R') } it 'is the rate' do progressbar = ProgressBar::Base.new Timecop.freeze do progressbar.start progressbar.progress += 10 Timecop.freeze(6) do expect(Formatter.process(format, 100, progressbar)).to eql '1.67' end end end it 'is zero when no time has elapsed' do Timecop.freeze do progressbar = ProgressBar::Base.new expect(Formatter.process(format, 100, progressbar)).to eql '0' end end it 'is zero when no progress has been made' do progressbar = ProgressBar::Base.new(:starting_at => 20) Timecop.freeze(2) do expect(Formatter.process(format, 100, progressbar)).to eql '0.00' end end it 'takes the starting position into account' do progressbar = ProgressBar::Base.new(:starting_at => 20) Timecop.freeze do progressbar.start progressbar.progress += 13 Timecop.freeze(2) do expect(Formatter.process(format, 100, progressbar)).to eql '6.50' end end end it 'is the rate when a custom rate is used' do progressbar = ProgressBar::Base.new(:rate_scale => lambda { |rate| rate / 2 }) Timecop.freeze do progressbar.start progressbar.progress += 10 Timecop.freeze(6) do expect(Formatter.process(format, 100, progressbar)).to eql '0.83' end end end it 'is zero when no progress has been made when a custom rate is used' do progressbar = ProgressBar::Base.new(:starting_at => 20, :rate_scale => lambda { |rate| rate / 2 }) Timecop.freeze(2) do expect(Formatter.process(format, 100, progressbar)).to eql '0.00' end end it 'takes the starting position into account when a custom rate is used' do progressbar = ProgressBar::Base.new(:starting_at => 20, :rate_scale => lambda { |rate| rate / 2 }) Timecop.freeze do progressbar.start progressbar.progress += 13 Timecop.freeze(2) do expect(Formatter.process(format, 100, progressbar)).to eql '3.25' end end end end context 'with the %t flag' do let(:format) { Format::String.new('%t') } it 'is the title' do progressbar = ProgressBar::Base.new expect(Formatter.process(format, 100, progressbar)).to eql 'Progress' end end context 'with the %T flag' do let(:format) { Format::String.new('%T') } it 'is the title' do progressbar = ProgressBar::Base.new expect(Formatter.process(format, 100, progressbar)).to eql 'Progress' end end context 'with the %u flag' do let(:format) { Format::String.new('%u') } it 'is "??" when the total is unknown' do progressbar = ProgressBar::Base.new(:total => nil) expect(Formatter.process(format, 100, progressbar)).to eql '??' end end context 'with the %W flag' do let(:format) { Format::String.new('%W') } it 'is the bar with percentage (including incomplete space)' do progressbar = ProgressBar::Base.new(:length => 100) expect(Formatter.process(format, 100, progressbar)).to eql ' ' * 100 4.times { progressbar.increment } expect(Formatter.process(format, 100, progressbar)).to eql "====#{' ' * 96}" progressbar.increment expect(Formatter.process(format, 100, progressbar)).to eql "= 5 =#{' ' * 95}" 5.times { progressbar.increment } expect(Formatter.process(format, 100, progressbar)).to eql "=== 10 ===#{' ' * 90}" progressbar.decrement expect(Formatter.process(format, 100, progressbar)).to eql "=== 9 ===#{' ' * 91}" 91.times { progressbar.increment } expect(Formatter.process(format, 100, progressbar)).to eql \ "#{'=' * 47} 100 #{'=' * 48}" end end context 'with the %w flag' do let(:format) { Format::String.new('%w') } it 'is the bar with the percentage' do progressbar = ProgressBar::Base.new(:length => 100) expect(Formatter.process(format, 100, progressbar)).to eql '' 4.times { progressbar.increment } expect(Formatter.process(format, 100, progressbar)).to eql '====' progressbar.increment expect(Formatter.process(format, 100, progressbar)).to eql '= 5 =' 5.times { progressbar.increment } expect(Formatter.process(format, 100, progressbar)).to eql '=== 10 ===' progressbar.decrement expect(Formatter.process(format, 100, progressbar)).to eql '=== 9 ===' 91.times { progressbar.increment } expect(Formatter.process(format, 100, progressbar)).to eql \ "#{'=' * 47} 100 #{'=' * 48}" end end context 'with combined flags' do it 'is the whole bar when combining both the bar and incomplete space flags' do format = Format::String.new('%b%i') progressbar = ProgressBar::Base.new(:length => 100) expect(Formatter.process(format, 100, progressbar)).to eql(' ' * 100) 4.times { progressbar.increment } expect(Formatter.process(format, 100, progressbar)).to eql("====#{' ' * 96}") progressbar.increment expect(Formatter.process(format, 100, progressbar)).to eql("=====#{' ' * 95}") 5.times { progressbar.increment } expect(Formatter.process(format, 100, progressbar)).to eql("==========#{' ' * 90}") progressbar.decrement expect(Formatter.process(format, 100, progressbar)).to eql("=========#{' ' * 91}") 91.times { progressbar.increment } expect(Formatter.process(format, 100, progressbar)).to eql('=' * 100) end it 'is the proper ETA when the bar has an unknown total' do unknown_oob_format = Format::String.new('%i%e') friendly_oob_format = Format::String.new('%i%E') progressbar = ProgressBar::Base.new(:total => nil) progressbar.increment unknown_format_string = Formatter.process(unknown_oob_format, 100, progressbar) friendly_format_string = Formatter.process(friendly_oob_format, 100, progressbar) expect(unknown_format_string).to eql "#{'-=--' * 21}-= ETA: ??:??:??" expect(friendly_format_string).to eql "#{'-=--' * 21}-= ETA: ??:??:??" end it 'is the truncated string when the terminal width is shorter than the string ' \ 'being output and the bar length is calculated' do format = Format::String.new('%t%w') progressbar = ProgressBar::Base.new(:title => ('*' * 21), :autostart => false) expect(Formatter.process(format, 20, progressbar)).to eql '*********************' end it 'is the truncated string when the terminal width is shorter than the string ' \ 'being output and the incomplete bar length is calculated' do format = Format::String.new('%t%i') progressbar = ProgressBar::Base.new(:title => ('*' * 21), :autostart => false) expect(Formatter.process(format, 20, progressbar)).to eql '*********************' end it 'is an empty bar when the terminal width is shorter than the string ' \ 'being output and the full bar length is calculated (but lacks the ' \ 'space to output the entire bar)' do format = Format::String.new('%t%B') progressbar = ProgressBar::Base.new(:title => ('*' * 19), :autostart => false) expect(Formatter.process(format, 20, progressbar)).to eql '******************* ' end it 'is an empty bar when the terminal width is shorter than the string ' \ 'being output and the combination of bar and incomplete length is ' \ 'calculated (but lacks the space to output the entire bar)' do format = Format::String.new('%t%w%i') progressbar = ProgressBar::Base.new(:title => ('*' * 19), :autostart => false) expect(Formatter.process(format, 20, progressbar)).to eql '******************* ' end it 'has the proper negative space when a bar with integrated percentage is used' do format = Format::String.new('%w%i') progressbar = ProgressBar::Base.new(:length => 100, :total => 200) expect(Formatter.process(format, 100, progressbar)).to eql(' ' * 100) progressbar.progress = 9 expect(Formatter.process(format, 100, progressbar)).to eql "====#{' ' * 96}" progressbar.increment expect(Formatter.process(format, 100, progressbar)).to eql "= 5 =#{' ' * 95}" end end context 'when format contains ANSI SGR codes' do it 'ignores their long versions when calculating bar length' do color_code = "\e[0m\e[32m\e[7m\e[1m" reset_code = "\e[0m" progress_mark = "#{color_code} #{reset_code}" format = Format::String.new("#{color_code}Processing... %b%i#{reset_code}" \ "#{color_code} %p%%#{reset_code}") progressbar = ProgressBar::Base.new(:progress_mark => progress_mark) progressbar.progress = 75 expect(Formatter.process(format, 24, progressbar)).to eql \ "#{color_code}Processing... " \ "#{progress_mark * 4}#{' ' * 2}#{reset_code}" \ "#{color_code} 75%#{reset_code}" end it 'ignores their short versions when calculating bar length' do color_code = "\e[0;32;7;1m" reset_code = "\e[0m" progress_mark = "#{color_code} #{reset_code}" format = Format::String.new("#{color_code}Processing... %b%i#{reset_code}" \ "#{color_code} %p%%#{reset_code}") progressbar = ProgressBar::Base.new(:progress_mark => progress_mark) progressbar.progress = 75 expect(Formatter.process(format, 24, progressbar)).to eql \ "#{color_code}Processing... " \ "#{progress_mark * 4}#{' ' * 2}#{reset_code}" \ "#{color_code} 75%#{reset_code}" end end end end end ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/format/molecule_spec.rb000066400000000000000000000011751347307233000277750ustar00rootroot00000000000000require 'spec_helper' require 'ruby-progressbar/format/molecule' class ProgressBar module Format describe Molecule do it 'sets the key when initialized' do molecule = Molecule.new('t') expect(molecule.key).to eql 't' end it 'sets the method name when initialized' do molecule = Molecule.new('t') expect(molecule.method_name).to eql [:title_comp, :title] end it 'can retrieve the full key for itself' do molecule = Molecule.new('t') expect(molecule.full_key).to eql '%t' end it 'can determine if it is a bar molecule' do expect(Molecule.new('B')).to be_bar_molecule end end end end ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/format/string_spec.rb000066400000000000000000000002041347307233000274660ustar00rootroot00000000000000require 'spec_helper' require 'ruby-progressbar/format/string' class ProgressBar module Format describe String do end end end ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/output_spec.rb000066400000000000000000000032351347307233000262370ustar00rootroot00000000000000require 'spec_helper' require 'ruby-progressbar/output' class MyTestOutput < ProgressBar::Output def clear; end def bar_update_string bar.to_s end def log(_string) stream.puts 'We All Float' end def resolve_format(*) '%t |%B|' end def eol bar.stopped? ? "\n" : "\r" end end class ProgressBar describe Output do let(:output_io) { StringIO.new } it 'uses the passed in output class if it is a ProgressBar::Output' do allow_any_instance_of(MyTestOutput).to receive(:stream).and_return(output_io) # rubocop:disable RSpec/AnyInstance progressbar = ProgressBar::Base.new(:length => 20, :output => MyTestOutput) progressbar.log('hello') output_io.rewind expect(output_io.read).to eql "Progress | |\r" \ "We All Float\n" end it 'passes the output stream to the length calculator' do allow(Calculators::Length).to receive(:new).and_call_original ProgressBar::Output.new(:output => output_io) expect(Calculators::Length).to have_received(:new). with( :length => nil, :output => output_io ) end it 'passes stdout to the length calculator if output is not specified' do allow(Calculators::Length).to receive(:new).and_call_original ProgressBar::Output.new expect(Calculators::Length).to have_received(:new). with( :length => nil, :output => $stdout ) end end end ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/outputs/000077500000000000000000000000001347307233000250605ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/outputs/non_tty_spec.rb000066400000000000000000000002071347307233000301100ustar00rootroot00000000000000require 'spec_helper' require 'ruby-progressbar/outputs/non_tty' class ProgressBar module Outputs describe NonTty do end end end ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/outputs/null_spec.rb000066400000000000000000000011151347307233000273670ustar00rootroot00000000000000require 'spec_helper' require 'ruby-progressbar/outputs/null' class ProgressBar module Outputs describe Null do let(:output_io) { StringIO.new } it 'does not output anything ever' do allow_any_instance_of(Null).to receive(:stream).and_return(output_io) # rubocop:disable RSpec/AnyInstance progressbar = ProgressBar::Base.new(:length => 20, :output => Null) progressbar.increment progressbar.log('hello') progressbar.progress += 20 progressbar.reset progressbar.finish output_io.rewind expect(output_io.read).to be_empty end end end end ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/outputs/tty_spec.rb000066400000000000000000000002001347307233000272270ustar00rootroot00000000000000require 'spec_helper' require 'ruby-progressbar/outputs/tty' class ProgressBar module Outputs describe Tty do end end end ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/progress_spec.rb000066400000000000000000000076271347307233000265540ustar00rootroot00000000000000require 'spec_helper' require 'ruby-progressbar/progress' class ProgressBar describe Progress do it 'knows the default total when no parameters are passed' do progress = Progress.new expect(progress.total).to eql Progress::DEFAULT_TOTAL end it 'knows the default beginning progress when no parameters are passed and ' \ 'the progress has not been started' do progress = Progress.new expect(progress.progress).to be_zero end it 'knows the default starting value when no parameters are passed and the ' \ 'progress has been started' do progress = Progress.new progress.start expect(progress.progress).to eql Progress::DEFAULT_BEGINNING_POSITION end it 'knows the given starting value when no parameters are passed and the ' \ 'progress is started with a starting value' do progress = Progress.new progress.start :at => 10 expect(progress.progress).to be 10 end it 'knows how to finish itself even if the total is unknown' do progress = Progress.new :total => nil expect(progress.finish).to be_nil end it 'knows the overridden total when the total is passed in' do progress = Progress.new(:total => 12, :progress_mark => 'x', :remainder_mark => '.') expect(progress.total).to be 12 end it 'knows the percentage completed when begun with no progress' do progress = Progress.new progress.start expect(progress.percentage_completed).to be 0 end it 'knows the progress after it has been incremented' do progress = Progress.new progress.start progress.increment expect(progress.progress).to be 1 end it 'knows the percentage completed after it has been incremented' do progress = Progress.new(:total => 50) progress.start progress.increment expect(progress.percentage_completed).to be 2 end it 'knows to always round down the percentage completed' do progress = Progress.new(:total => 200) progress.start :at => 1 expect(progress.percentage_completed).to be 0 end it 'cannot increment past the total' do progress = Progress.new(:total => 50) progress.start :at => 50 progress.increment expect(progress.progress).to be 50 expect(progress.percentage_completed).to be 100 end it 'allow progress to be decremented once it is finished' do progress = Progress.new(:total => 50) progress.start :at => 50 progress.decrement expect(progress.progress).to be 49 expect(progress.percentage_completed).to be 98 end # rubocop:disable RSpec/BeEql it 'knows the running average even when progress has been made' do progress = Progress.new(:total => 50) progress.running_average = 10 progress.start :at => 0 expect(progress.running_average).to be_zero progress.progress += 40 expect(progress.running_average).to eql 36.0 end it 'knows the running average is reset even after progress is started' do progress = Progress.new(:total => 50) progress.running_average = 10 progress.start :at => 0 expect(progress.running_average).to be_zero progress.start :at => 40 expect(progress.running_average).to eql 0.0 end it 'allows the default smoothing to be overridden' do expect(Progress.new(:smoothing => 0.3).smoothing).to eql 0.3 end it 'has a default smoothing value' do expect(Progress.new.smoothing).to eql 0.1 end # rubocop:enable RSpec/BeEql it 'knows the percentage completed is 100% if the total is zero' do progress = Progress.new(:total => 0) expect(progress.percentage_completed).to be 100 end it 'raises an error when passed a number larger than the total' do progress = Progress.new(:total => 100) expect { progress.progress = 101 }.to \ raise_error(InvalidProgressError, "You can't set the item's current value to be greater than the total.") end end end ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/refinements/000077500000000000000000000000001347307233000256545ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/refinements/enumerator_spec.rb000066400000000000000000000046151347307233000314020ustar00rootroot00000000000000if Module.private_instance_methods.include?(:using) require 'spec_helper' require 'ruby-progressbar/refinements/enumerator' class ProgressBar module Refinements describe Enumerator do using ProgressBar::Refinements::Enumerator it 'creates a progress bar with the Enumerable size' do allow(ProgressBar).to receive(:create). with(hash_including(:total => 10)). and_call_original (0...10).each.with_progressbar { |_| } end it 'does not allow the user to override the progress bar total' do allow(ProgressBar).to receive(:create). with(hash_including(:total => 10)). and_call_original (0...10).each.with_progressbar(:total => 20) { |_| } end it 'does not allow the user to override the progress bar starting position' do allow(ProgressBar).to receive(:create). with(hash_including(:starting_at => 0)). and_call_original (0...10).each.with_progressbar(:starting_at => 20) { |_| } end it 'passes arguments to create' do allow(ProgressBar).to receive(:create). with(hash_including(:title => 'We All Float')). and_call_original (0...10).each.with_progressbar(:title => 'We All Float') { |_| } end it 'calls progressbar.increment the right number of times' do mock = instance_double(ProgressBar::Progress) allow(ProgressBar).to receive(:create).and_return(mock) allow(mock).to receive(:increment).exactly(10).times (0...10).each.with_progressbar { |_| } end it 'chains return values properly' do transform = lambda { |i| 10 * i } chained_progress_transform = (0...10).map.with_progressbar(&transform) direct_transform = (0...10).map(&transform) expect(chained_progress_transform).to eql direct_transform end it 'chains properly in the middle ' do transform = lambda { |i| 10 * i } chained_progress_transform = (0...10).each.with_progressbar.map(&transform) direct_transform = (0...10).each.map(&transform) expect(chained_progress_transform).to eql direct_transform end it 'returns an enumerator' do transform = lambda { |i| 10 * i } enumerator = (0...10).each.with_progressbar expect(enumerator.map(&transform)).to eql((0...10).map(&transform)) end end end end end ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/time_spec.rb000066400000000000000000000025471347307233000256420ustar00rootroot00000000000000require 'spec_helper' class TimeMockedWithTimecop def self.now_without_mock_time; end end class TimeMockedWithDelorean def self.now_without_delorean; end end class TimeMockedWithActiveSupport def self.__simple_stub__now; end end class UnmockedTime def self.now; end end class ProgressBar describe Time do it 'when Time is being mocked by Timecop retrieves the unmocked Timecop time' do allow(TimeMockedWithTimecop).to receive(:now_without_mock_time) Time.new(TimeMockedWithTimecop).now expect(TimeMockedWithTimecop).to have_received(:now_without_mock_time).once end it 'when Time is being mocked by Delorean retrieves the unmocked Delorean time' do allow(TimeMockedWithDelorean).to receive(:now_without_delorean) Time.new(TimeMockedWithDelorean).now expect(TimeMockedWithDelorean).to have_received(:now_without_delorean).once end it 'when Time is being mocked by ActiveSupport retrieves the unmocked time' do allow(TimeMockedWithActiveSupport).to receive(:__simple_stub__now) Time.new(TimeMockedWithActiveSupport).now expect(TimeMockedWithActiveSupport).to have_received(:__simple_stub__now).once end it 'when Time is not being mocked will return the actual time' do allow(UnmockedTime).to receive(:now) Time.new(UnmockedTime).now expect(UnmockedTime).to have_received(:now).once end end end ruby-progressbar-releases-v1.10.1/spec/ruby-progressbar/timer_spec.rb000066400000000000000000000001471347307233000260160ustar00rootroot00000000000000require 'spec_helper' require 'ruby-progressbar/timer' class ProgressBar describe Timer do end end ruby-progressbar-releases-v1.10.1/spec/spec_helper.rb000066400000000000000000000001521347307233000226410ustar00rootroot00000000000000require 'rspectacular' require 'warning_filter' RSpec.configure do |config| config.warnings = true end ruby-progressbar-releases-v1.10.1/spec/support/000077500000000000000000000000001347307233000215415ustar00rootroot00000000000000ruby-progressbar-releases-v1.10.1/spec/support/time.rb000066400000000000000000000004271347307233000230270ustar00rootroot00000000000000### # In our specs, I want to make sure time gets mocked so I can accurately test # times displayed to the user. # class PBTimeTester def self.now ::Time.now end end class ProgressBar class Time def initialize(time = ::PBTimeTester) self.time = time end end end