tty-progressbar 0.15.1 → 0.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +63 -0
 - data/LICENSE.txt +1 -1
 - data/README.md +495 -125
 - data/lib/tty-progressbar.rb +2 -2
 - data/lib/tty/progressbar.rb +169 -68
 - data/lib/tty/progressbar/configuration.rb +121 -27
 - data/lib/tty/progressbar/converter.rb +16 -19
 - data/lib/tty/progressbar/formats.rb +120 -0
 - data/lib/tty/progressbar/formatter.rb +33 -38
 - data/lib/tty/progressbar/formatter/bar.rb +74 -27
 - data/lib/tty/progressbar/formatter/byte_rate.rb +6 -20
 - data/lib/tty/progressbar/formatter/current.rb +4 -19
 - data/lib/tty/progressbar/formatter/current_byte.rb +9 -17
 - data/lib/tty/progressbar/formatter/elapsed.rb +9 -18
 - data/lib/tty/progressbar/formatter/estimated.rb +18 -20
 - data/lib/tty/progressbar/formatter/estimated_time.rb +39 -0
 - data/lib/tty/progressbar/formatter/mean_byte.rb +6 -20
 - data/lib/tty/progressbar/formatter/mean_rate.rb +6 -20
 - data/lib/tty/progressbar/formatter/percent.rb +10 -16
 - data/lib/tty/progressbar/formatter/rate.rb +5 -19
 - data/lib/tty/progressbar/formatter/total.rb +10 -16
 - data/lib/tty/progressbar/formatter/total_byte.rb +14 -18
 - data/lib/tty/progressbar/formatters.rb +53 -0
 - data/lib/tty/progressbar/meter.rb +2 -2
 - data/lib/tty/progressbar/multi.rb +61 -21
 - data/lib/tty/progressbar/pipeline.rb +13 -6
 - data/lib/tty/progressbar/timer.rb +89 -0
 - data/lib/tty/progressbar/version.rb +3 -1
 - metadata +56 -164
 - data/.codeclimate.yml +0 -11
 - data/.gitignore +0 -14
 - data/.rspec +0 -3
 - data/.travis.yml +0 -26
 - data/CODE_OF_CONDUCT.md +0 -74
 - data/Gemfile +0 -14
 - data/Rakefile +0 -8
 - data/appveyor.yml +0 -23
 - data/examples/color.rb +0 -18
 - data/examples/failure.rb +0 -12
 - data/examples/iterator.rb +0 -5
 - data/examples/lazy.rb +0 -6
 - data/examples/multi/main_bar.rb +0 -13
 - data/examples/multi/simple.rb +0 -13
 - data/examples/multi/width.rb +0 -13
 - data/examples/simple.rb +0 -7
 - data/examples/slow_process.rb +0 -29
 - data/examples/speed.rb +0 -11
 - data/examples/threaded.rb +0 -14
 - data/examples/tokens.rb +0 -12
 - data/examples/unicode.rb +0 -7
 - data/spec/spec_helper.rb +0 -51
 - data/spec/unit/advance_spec.rb +0 -25
 - data/spec/unit/clear_spec.rb +0 -17
 - data/spec/unit/complete_spec.rb +0 -16
 - data/spec/unit/converter/to_bytes_spec.rb +0 -47
 - data/spec/unit/converter/to_seconds_spec.rb +0 -15
 - data/spec/unit/converter/to_time_spec.rb +0 -19
 - data/spec/unit/custom_formatter_spec.rb +0 -26
 - data/spec/unit/custom_token_spec.rb +0 -14
 - data/spec/unit/events_spec.rb +0 -33
 - data/spec/unit/finish_spec.rb +0 -15
 - data/spec/unit/formatter/bar_spec.rb +0 -16
 - data/spec/unit/formatter/byte_rate_spec.rb +0 -32
 - data/spec/unit/formatter/current_byte_spec.rb +0 -16
 - data/spec/unit/formatter/current_spec.rb +0 -14
 - data/spec/unit/formatter/elapsed_spec.rb +0 -58
 - data/spec/unit/formatter/estimated_spec.rb +0 -27
 - data/spec/unit/formatter/mean_byte_spec.rb +0 -32
 - data/spec/unit/formatter/mean_rate_spec.rb +0 -31
 - data/spec/unit/formatter/percent_spec.rb +0 -16
 - data/spec/unit/formatter/rate_spec.rb +0 -31
 - data/spec/unit/formatter/total_byte_spec.rb +0 -16
 - data/spec/unit/formatter/total_spec.rb +0 -16
 - data/spec/unit/frequency_spec.rb +0 -27
 - data/spec/unit/head_spec.rb +0 -32
 - data/spec/unit/hide_cursor_spec.rb +0 -27
 - data/spec/unit/inspect_spec.rb +0 -11
 - data/spec/unit/iterate_spec.rb +0 -79
 - data/spec/unit/log_spec.rb +0 -29
 - data/spec/unit/meter_spec.rb +0 -70
 - data/spec/unit/multi/advance_spec.rb +0 -123
 - data/spec/unit/multi/events_spec.rb +0 -115
 - data/spec/unit/multi/finish_spec.rb +0 -41
 - data/spec/unit/multi/line_inset_spec.rb +0 -65
 - data/spec/unit/multi/register_spec.rb +0 -35
 - data/spec/unit/multi/reset_spec.rb +0 -28
 - data/spec/unit/multi/stop_spec.rb +0 -15
 - data/spec/unit/multi/width_spec.rb +0 -118
 - data/spec/unit/new_spec.rb +0 -76
 - data/spec/unit/pipeline_spec.rb +0 -19
 - data/spec/unit/ratio_spec.rb +0 -31
 - data/spec/unit/render_spec.rb +0 -25
 - data/spec/unit/reset_spec.rb +0 -31
 - data/spec/unit/resize_spec.rb +0 -35
 - data/spec/unit/set_current_spec.rb +0 -43
 - data/spec/unit/start_spec.rb +0 -14
 - data/spec/unit/stop_spec.rb +0 -19
 - data/spec/unit/update_spec.rb +0 -22
 - data/spec/unit/width_spec.rb +0 -86
 - data/tasks/console.rake +0 -9
 - data/tasks/coverage.rake +0 -9
 - data/tasks/spec.rake +0 -27
 - data/tty-progressbar.gemspec +0 -30
 
    
        data/.gitignore
    DELETED
    
    
    
        data/.rspec
    DELETED
    
    
    
        data/.travis.yml
    DELETED
    
    | 
         @@ -1,26 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            ---
         
     | 
| 
       2 
     | 
    
         
            -
            language: ruby
         
     | 
| 
       3 
     | 
    
         
            -
            sudo: false
         
     | 
| 
       4 
     | 
    
         
            -
            cache: bundler
         
     | 
| 
       5 
     | 
    
         
            -
            before_install: "gem update bundler"
         
     | 
| 
       6 
     | 
    
         
            -
            script: "bundle exec rake ci"
         
     | 
| 
       7 
     | 
    
         
            -
            rvm:
         
     | 
| 
       8 
     | 
    
         
            -
              - 2.0.0
         
     | 
| 
       9 
     | 
    
         
            -
              - 2.1.10
         
     | 
| 
       10 
     | 
    
         
            -
              - 2.2.9
         
     | 
| 
       11 
     | 
    
         
            -
              - 2.3.6
         
     | 
| 
       12 
     | 
    
         
            -
              - 2.4.4
         
     | 
| 
       13 
     | 
    
         
            -
              - 2.5.1
         
     | 
| 
       14 
     | 
    
         
            -
              - ruby-head
         
     | 
| 
       15 
     | 
    
         
            -
              - jruby-9.1.5.0
         
     | 
| 
       16 
     | 
    
         
            -
              - jruby-head
         
     | 
| 
       17 
     | 
    
         
            -
            matrix:
         
     | 
| 
       18 
     | 
    
         
            -
              allow_failures:
         
     | 
| 
       19 
     | 
    
         
            -
                - rvm: ruby-head
         
     | 
| 
       20 
     | 
    
         
            -
                - rvm: jruby-9.1.5.0
         
     | 
| 
       21 
     | 
    
         
            -
                - rvm: jruby-head
         
     | 
| 
       22 
     | 
    
         
            -
              fast_finish: true
         
     | 
| 
       23 
     | 
    
         
            -
            branches:
         
     | 
| 
       24 
     | 
    
         
            -
              only: master
         
     | 
| 
       25 
     | 
    
         
            -
            notifications:
         
     | 
| 
       26 
     | 
    
         
            -
              email: false
         
     | 
    
        data/CODE_OF_CONDUCT.md
    DELETED
    
    | 
         @@ -1,74 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # Contributor Covenant Code of Conduct
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            ## Our Pledge
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            In the interest of fostering an open and welcoming environment, we as
         
     | 
| 
       6 
     | 
    
         
            -
            contributors and maintainers pledge to making participation in our project and
         
     | 
| 
       7 
     | 
    
         
            -
            our community a harassment-free experience for everyone, regardless of age, body
         
     | 
| 
       8 
     | 
    
         
            -
            size, disability, ethnicity, gender identity and expression, level of experience,
         
     | 
| 
       9 
     | 
    
         
            -
            nationality, personal appearance, race, religion, or sexual identity and
         
     | 
| 
       10 
     | 
    
         
            -
            orientation.
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
            ## Our Standards
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
            Examples of behavior that contributes to creating a positive environment
         
     | 
| 
       15 
     | 
    
         
            -
            include:
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
            * Using welcoming and inclusive language
         
     | 
| 
       18 
     | 
    
         
            -
            * Being respectful of differing viewpoints and experiences
         
     | 
| 
       19 
     | 
    
         
            -
            * Gracefully accepting constructive criticism
         
     | 
| 
       20 
     | 
    
         
            -
            * Focusing on what is best for the community
         
     | 
| 
       21 
     | 
    
         
            -
            * Showing empathy towards other community members
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
            Examples of unacceptable behavior by participants include:
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
            * The use of sexualized language or imagery and unwelcome sexual attention or
         
     | 
| 
       26 
     | 
    
         
            -
            advances
         
     | 
| 
       27 
     | 
    
         
            -
            * Trolling, insulting/derogatory comments, and personal or political attacks
         
     | 
| 
       28 
     | 
    
         
            -
            * Public or private harassment
         
     | 
| 
       29 
     | 
    
         
            -
            * Publishing others' private information, such as a physical or electronic
         
     | 
| 
       30 
     | 
    
         
            -
              address, without explicit permission
         
     | 
| 
       31 
     | 
    
         
            -
            * Other conduct which could reasonably be considered inappropriate in a
         
     | 
| 
       32 
     | 
    
         
            -
              professional setting
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
            ## Our Responsibilities
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
            Project maintainers are responsible for clarifying the standards of acceptable
         
     | 
| 
       37 
     | 
    
         
            -
            behavior and are expected to take appropriate and fair corrective action in
         
     | 
| 
       38 
     | 
    
         
            -
            response to any instances of unacceptable behavior.
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
            Project maintainers have the right and responsibility to remove, edit, or
         
     | 
| 
       41 
     | 
    
         
            -
            reject comments, commits, code, wiki edits, issues, and other contributions
         
     | 
| 
       42 
     | 
    
         
            -
            that are not aligned to this Code of Conduct, or to ban temporarily or
         
     | 
| 
       43 
     | 
    
         
            -
            permanently any contributor for other behaviors that they deem inappropriate,
         
     | 
| 
       44 
     | 
    
         
            -
            threatening, offensive, or harmful.
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
            ## Scope
         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
            This Code of Conduct applies both within project spaces and in public spaces
         
     | 
| 
       49 
     | 
    
         
            -
            when an individual is representing the project or its community. Examples of
         
     | 
| 
       50 
     | 
    
         
            -
            representing a project or community include using an official project e-mail
         
     | 
| 
       51 
     | 
    
         
            -
            address, posting via an official social media account, or acting as an appointed
         
     | 
| 
       52 
     | 
    
         
            -
            representative at an online or offline event. Representation of a project may be
         
     | 
| 
       53 
     | 
    
         
            -
            further defined and clarified by project maintainers.
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
            ## Enforcement
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
            Instances of abusive, harassing, or otherwise unacceptable behavior may be
         
     | 
| 
       58 
     | 
    
         
            -
            reported by contacting the project team at [email]. All
         
     | 
| 
       59 
     | 
    
         
            -
            complaints will be reviewed and investigated and will result in a response that
         
     | 
| 
       60 
     | 
    
         
            -
            is deemed necessary and appropriate to the circumstances. The project team is
         
     | 
| 
       61 
     | 
    
         
            -
            obligated to maintain confidentiality with regard to the reporter of an incident.
         
     | 
| 
       62 
     | 
    
         
            -
            Further details of specific enforcement policies may be posted separately.
         
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
            Project maintainers who do not follow or enforce the Code of Conduct in good
         
     | 
| 
       65 
     | 
    
         
            -
            faith may face temporary or permanent repercussions as determined by other
         
     | 
| 
       66 
     | 
    
         
            -
            members of the project's leadership.
         
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
            ## Attribution
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
            This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
         
     | 
| 
       71 
     | 
    
         
            -
            available at [http://contributor-covenant.org/version/1/4][version]
         
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
            [homepage]: http://contributor-covenant.org
         
     | 
| 
       74 
     | 
    
         
            -
            [version]: http://contributor-covenant.org/version/1/4/
         
     | 
    
        data/Gemfile
    DELETED
    
    
    
        data/Rakefile
    DELETED
    
    
    
        data/appveyor.yml
    DELETED
    
    | 
         @@ -1,23 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            ---
         
     | 
| 
       2 
     | 
    
         
            -
            install:
         
     | 
| 
       3 
     | 
    
         
            -
              - SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
         
     | 
| 
       4 
     | 
    
         
            -
              - ruby --version
         
     | 
| 
       5 
     | 
    
         
            -
              - gem --version
         
     | 
| 
       6 
     | 
    
         
            -
              - bundle install
         
     | 
| 
       7 
     | 
    
         
            -
            build: off
         
     | 
| 
       8 
     | 
    
         
            -
            test_script:
         
     | 
| 
       9 
     | 
    
         
            -
              - bundle exec rake ci
         
     | 
| 
       10 
     | 
    
         
            -
            environment:
         
     | 
| 
       11 
     | 
    
         
            -
              matrix:
         
     | 
| 
       12 
     | 
    
         
            -
                - ruby_version: "200"
         
     | 
| 
       13 
     | 
    
         
            -
                - ruby_version: "200-x64"
         
     | 
| 
       14 
     | 
    
         
            -
                - ruby_version: "21"
         
     | 
| 
       15 
     | 
    
         
            -
                - ruby_version: "21-x64"
         
     | 
| 
       16 
     | 
    
         
            -
                - ruby_version: "22"
         
     | 
| 
       17 
     | 
    
         
            -
                - ruby_version: "22-x64"
         
     | 
| 
       18 
     | 
    
         
            -
                - ruby_version: "23"
         
     | 
| 
       19 
     | 
    
         
            -
                - ruby_version: "23-x64"
         
     | 
| 
       20 
     | 
    
         
            -
                - ruby_version: "24"
         
     | 
| 
       21 
     | 
    
         
            -
                - ruby_version: "24-x64"
         
     | 
| 
       22 
     | 
    
         
            -
                - ruby_version: "25"
         
     | 
| 
       23 
     | 
    
         
            -
                - ruby_version: "25-x64"
         
     | 
    
        data/examples/color.rb
    DELETED
    
    | 
         @@ -1,18 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'pastel'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require_relative '../lib/tty-progressbar'
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            pastel = Pastel.new
         
     | 
| 
       6 
     | 
    
         
            -
            green = pastel.on_green(" ")
         
     | 
| 
       7 
     | 
    
         
            -
            red = pastel.on_red(" ")
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
            bar = TTY::ProgressBar.new("|:bar|",
         
     | 
| 
       10 
     | 
    
         
            -
              total: 30,
         
     | 
| 
       11 
     | 
    
         
            -
              complete: green,
         
     | 
| 
       12 
     | 
    
         
            -
              incomplete: red
         
     | 
| 
       13 
     | 
    
         
            -
            )
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
            30.times do
         
     | 
| 
       16 
     | 
    
         
            -
              sleep(0.1)
         
     | 
| 
       17 
     | 
    
         
            -
              bar.advance
         
     | 
| 
       18 
     | 
    
         
            -
            end
         
     | 
    
        data/examples/failure.rb
    DELETED
    
    
    
        data/examples/iterator.rb
    DELETED
    
    
    
        data/examples/lazy.rb
    DELETED
    
    
    
        data/examples/multi/main_bar.rb
    DELETED
    
    | 
         @@ -1,13 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative '../../lib/tty-progressbar'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            bars = TTY::ProgressBar::Multi.new("main [:bar] :percent")
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            bar1 = bars.register "foo [:bar] :percent", total: 15
         
     | 
| 
       6 
     | 
    
         
            -
            bar2 = bars.register "bar [:bar] :percent", total: 15
         
     | 
| 
       7 
     | 
    
         
            -
            bar3 = bars.register "baz [:bar] :percent", total: 45
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
            th1 = Thread.new { 15.times { sleep(0.1); bar1.advance } }
         
     | 
| 
       10 
     | 
    
         
            -
            th2 = Thread.new { 15.times { sleep(0.1); bar2.advance } }
         
     | 
| 
       11 
     | 
    
         
            -
            th3 = Thread.new { 45.times { sleep(0.1); bar3.advance } }
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            [th1, th2, th3].each(&:join)
         
     | 
    
        data/examples/multi/simple.rb
    DELETED
    
    | 
         @@ -1,13 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative '../../lib/tty-progressbar'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            bars = TTY::ProgressBar::Multi.new
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            bar1 = bars.register "foo [:bar] :percent", total: 20
         
     | 
| 
       6 
     | 
    
         
            -
            bar2 = bars.register "bar [:bar] :percent", total: 30
         
     | 
| 
       7 
     | 
    
         
            -
            bar3 = bars.register "baz [:bar] :percent", total: 10
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
            th1 = Thread.new { 20.times { sleep(0.2); bar1.advance } }
         
     | 
| 
       10 
     | 
    
         
            -
            th2 = Thread.new { 30.times { sleep(0.1); bar2.advance } }
         
     | 
| 
       11 
     | 
    
         
            -
            th3 = Thread.new { 10.times { sleep(0.3); bar3.advance } }
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            [th1, th2, th3].each(&:join)
         
     | 
    
        data/examples/multi/width.rb
    DELETED
    
    | 
         @@ -1,13 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative '../../lib/tty-progressbar'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            bars = TTY::ProgressBar::Multi.new("main [:bar] :percent")
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            bar1 = bars.register "foo [:bar] :percent", total: 150
         
     | 
| 
       6 
     | 
    
         
            -
            bar2 = bars.register "bar [:bar] :percent", total: 250
         
     | 
| 
       7 
     | 
    
         
            -
            bar3 = bars.register "baz [:bar] :percent", total: 100
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
            th1 = Thread.new { 15.times { sleep(0.1); bar1.advance(10) } }
         
     | 
| 
       10 
     | 
    
         
            -
            th2 = Thread.new { 50.times { sleep(0.1); bar2.advance(5)} }
         
     | 
| 
       11 
     | 
    
         
            -
            th3 = Thread.new { 50.times { sleep(0.1); bar3.advance(5) } }
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            [th1, th2, th3].each(&:join)
         
     | 
    
        data/examples/simple.rb
    DELETED
    
    
    
        data/examples/slow_process.rb
    DELETED
    
    | 
         @@ -1,29 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative '../lib/tty-progressbar'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            CONTENT_SIZE = 2048
         
     | 
| 
       4 
     | 
    
         
            -
            CHUNK_SIZE = 255
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            # Dummy "long responding server"
         
     | 
| 
       7 
     | 
    
         
            -
            def download_from_server(offset, limit)
         
     | 
| 
       8 
     | 
    
         
            -
              sleep(0.1)
         
     | 
| 
       9 
     | 
    
         
            -
              "<chunk #{offset}..#{offset + limit}>"
         
     | 
| 
       10 
     | 
    
         
            -
            end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
            def download_finished?(position)
         
     | 
| 
       13 
     | 
    
         
            -
              position >= CONTENT_SIZE
         
     | 
| 
       14 
     | 
    
         
            -
            end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
            downloader = Enumerator.new do |y|
         
     | 
| 
       17 
     | 
    
         
            -
              start = 0
         
     | 
| 
       18 
     | 
    
         
            -
              loop do
         
     | 
| 
       19 
     | 
    
         
            -
                y.yield(download_from_server(start, CHUNK_SIZE))
         
     | 
| 
       20 
     | 
    
         
            -
                start += CHUNK_SIZE
         
     | 
| 
       21 
     | 
    
         
            -
                raise StopIteration if download_finished?(start)
         
     | 
| 
       22 
     | 
    
         
            -
              end
         
     | 
| 
       23 
     | 
    
         
            -
            end
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
            bar = TTY::ProgressBar.new("[:bar] :current_byte/:total_byte", total: CONTENT_SIZE)
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
            response = bar.iterate(downloader, CHUNK_SIZE).to_a.join
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
            puts response
         
     | 
    
        data/examples/speed.rb
    DELETED
    
    
    
        data/examples/threaded.rb
    DELETED
    
    | 
         @@ -1,14 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative '../lib/tty-progressbar'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            threads = []
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            bar = TTY::ProgressBar.new("[:bar] :percent", total: 30)
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            threads << Thread.new {
         
     | 
| 
       8 
     | 
    
         
            -
              15.times { sleep(0.1); bar.update(complete: '-', head: '-'); bar.advance(); }
         
     | 
| 
       9 
     | 
    
         
            -
            }
         
     | 
| 
       10 
     | 
    
         
            -
            threads << Thread.new {
         
     | 
| 
       11 
     | 
    
         
            -
              15.times { sleep(0.1); bar.update(complete: '+', head: '+'); bar.advance(); }
         
     | 
| 
       12 
     | 
    
         
            -
            }
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
            threads.map(&:join)
         
     | 
    
        data/examples/tokens.rb
    DELETED
    
    | 
         @@ -1,12 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative '../lib/tty-progressbar'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            files = [
         
     | 
| 
       4 
     | 
    
         
            -
              'file1.txt', 'file2.txt', 'file3.txt', 'file4.txt', 'file5.txt',
         
     | 
| 
       5 
     | 
    
         
            -
              'file6.txt', 'file7.txt', 'file8.txt', 'file9.txt', 'file10.txt'
         
     | 
| 
       6 
     | 
    
         
            -
            ]
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            bar = TTY::ProgressBar.new("downloading :file :percent", total: files.size)
         
     | 
| 
       9 
     | 
    
         
            -
            10.times do |num|
         
     | 
| 
       10 
     | 
    
         
            -
              sleep(0.1)
         
     | 
| 
       11 
     | 
    
         
            -
              bar.advance(file: files[num])
         
     | 
| 
       12 
     | 
    
         
            -
            end
         
     | 
    
        data/examples/unicode.rb
    DELETED
    
    
    
        data/spec/spec_helper.rb
    DELETED
    
    | 
         @@ -1,51 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            if ENV['COVERAGE'] || ENV['TRAVIS']
         
     | 
| 
       2 
     | 
    
         
            -
              require 'simplecov'
         
     | 
| 
       3 
     | 
    
         
            -
              require 'coveralls'
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
              SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
         
     | 
| 
       6 
     | 
    
         
            -
                SimpleCov::Formatter::HTMLFormatter,
         
     | 
| 
       7 
     | 
    
         
            -
                Coveralls::SimpleCov::Formatter
         
     | 
| 
       8 
     | 
    
         
            -
              ]
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
              SimpleCov.start do
         
     | 
| 
       11 
     | 
    
         
            -
                command_name 'spec'
         
     | 
| 
       12 
     | 
    
         
            -
                add_filter 'spec'
         
     | 
| 
       13 
     | 
    
         
            -
              end
         
     | 
| 
       14 
     | 
    
         
            -
            end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
            require 'timecop'
         
     | 
| 
       17 
     | 
    
         
            -
            require 'tty-progressbar'
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
            class StringIO
         
     | 
| 
       20 
     | 
    
         
            -
              undef_method :tty?
         
     | 
| 
       21 
     | 
    
         
            -
              def tty?
         
     | 
| 
       22 
     | 
    
         
            -
                true
         
     | 
| 
       23 
     | 
    
         
            -
              end
         
     | 
| 
       24 
     | 
    
         
            -
            end
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
            RSpec.configure do |config|
         
     | 
| 
       27 
     | 
    
         
            -
              config.expect_with :rspec do |expectations|
         
     | 
| 
       28 
     | 
    
         
            -
                expectations.include_chain_clauses_in_custom_matcher_descriptions = true
         
     | 
| 
       29 
     | 
    
         
            -
              end
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
              config.mock_with :rspec do |mocks|
         
     | 
| 
       32 
     | 
    
         
            -
                mocks.verify_partial_doubles = true
         
     | 
| 
       33 
     | 
    
         
            -
              end
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
              # Limits the available syntax to the non-monkey patched syntax that is recommended.
         
     | 
| 
       36 
     | 
    
         
            -
              config.disable_monkey_patching!
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
              # This setting enables warnings. It's recommended, but in some cases may
         
     | 
| 
       39 
     | 
    
         
            -
              # be too noisy due to issues in dependencies.
         
     | 
| 
       40 
     | 
    
         
            -
              config.warnings = true
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
              if config.files_to_run.one?
         
     | 
| 
       43 
     | 
    
         
            -
                config.default_formatter = 'doc'
         
     | 
| 
       44 
     | 
    
         
            -
              end
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
              config.profile_examples = 2
         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
              config.order = :random
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
              Kernel.srand config.seed
         
     | 
| 
       51 
     | 
    
         
            -
            end
         
     | 
    
        data/spec/unit/advance_spec.rb
    DELETED
    
    | 
         @@ -1,25 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            RSpec.describe TTY::ProgressBar, '#advance' do
         
     | 
| 
       2 
     | 
    
         
            -
              let(:output) { StringIO.new('', 'w+') }
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
              it "advances by custom value" do
         
     | 
| 
       5 
     | 
    
         
            -
                progress = TTY::ProgressBar.new("[:bar]", output: output, total: 10)
         
     | 
| 
       6 
     | 
    
         
            -
                progress.advance(8)
         
     | 
| 
       7 
     | 
    
         
            -
                expect(progress.current).to eq(8)
         
     | 
| 
       8 
     | 
    
         
            -
              end
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
              it "allows to go back" do
         
     | 
| 
       11 
     | 
    
         
            -
                progress = TTY::ProgressBar.new("[:bar]", output: output, total: 10)
         
     | 
| 
       12 
     | 
    
         
            -
                5.times { progress.advance(1) }
         
     | 
| 
       13 
     | 
    
         
            -
                expect(progress.current).to eq(5)
         
     | 
| 
       14 
     | 
    
         
            -
                5.times { progress.advance(-1) }
         
     | 
| 
       15 
     | 
    
         
            -
                expect(progress.current).to eq(0)
         
     | 
| 
       16 
     | 
    
         
            -
              end
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
              it "cannot backtrack on finished" do
         
     | 
| 
       19 
     | 
    
         
            -
                progress = TTY::ProgressBar.new("[:bar]", output: output, total: 10)
         
     | 
| 
       20 
     | 
    
         
            -
                10.times { progress.advance(1) }
         
     | 
| 
       21 
     | 
    
         
            -
                expect(progress.current).to eq(10)
         
     | 
| 
       22 
     | 
    
         
            -
                5.times { progress.advance(-1) }
         
     | 
| 
       23 
     | 
    
         
            -
                expect(progress.current).to eq(10)
         
     | 
| 
       24 
     | 
    
         
            -
              end
         
     | 
| 
       25 
     | 
    
         
            -
            end
         
     | 
    
        data/spec/unit/clear_spec.rb
    DELETED
    
    | 
         @@ -1,17 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            RSpec.describe TTY::ProgressBar, 'clear' do
         
     | 
| 
       2 
     | 
    
         
            -
              let(:output) { StringIO.new('', 'w+') }
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
              it "clears progress bar when finished" do
         
     | 
| 
       5 
     | 
    
         
            -
                progress = TTY::ProgressBar.new("[:bar]", output: output, total: 5,
         
     | 
| 
       6 
     | 
    
         
            -
                 clear: true)
         
     | 
| 
       7 
     | 
    
         
            -
                5.times { progress.advance }
         
     | 
| 
       8 
     | 
    
         
            -
                output.rewind
         
     | 
| 
       9 
     | 
    
         
            -
                expect(output.read).to eq([
         
     | 
| 
       10 
     | 
    
         
            -
                  "\e[1G[=    ]",
         
     | 
| 
       11 
     | 
    
         
            -
                  "\e[1G[==   ]",
         
     | 
| 
       12 
     | 
    
         
            -
                  "\e[1G[===  ]",
         
     | 
| 
       13 
     | 
    
         
            -
                  "\e[1G[==== ]",
         
     | 
| 
       14 
     | 
    
         
            -
                  "\e[1G[=====]\e[0m\e[2K\e[1G"
         
     | 
| 
       15 
     | 
    
         
            -
                ].join)
         
     | 
| 
       16 
     | 
    
         
            -
              end
         
     | 
| 
       17 
     | 
    
         
            -
            end
         
     |