progress 0.1.0.1 → 0.1.0.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.
- data/VERSION.yml +1 -1
 - data/lib/progress.rb +13 -7
 - data/progress.gemspec +1 -1
 - data/spec/progress_spec.rb +14 -0
 - metadata +1 -1
 
    
        data/VERSION.yml
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            [0, 1, 0,  
     | 
| 
      
 1 
     | 
    
         
            +
            [0, 1, 0, 2]
         
     | 
    
        data/lib/progress.rb
    CHANGED
    
    | 
         @@ -63,19 +63,25 @@ class Progress 
     | 
|
| 
       63 
63 
     | 
    
         
             
                end
         
     | 
| 
       64 
64 
     | 
    
         | 
| 
       65 
65 
     | 
    
         
             
                def step(steps = 1)
         
     | 
| 
       66 
     | 
    
         
            -
                  levels.last 
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
      
 66 
     | 
    
         
            +
                  if levels.last
         
     | 
| 
      
 67 
     | 
    
         
            +
                    levels.last.current += Float(steps)
         
     | 
| 
      
 68 
     | 
    
         
            +
                    print_message
         
     | 
| 
      
 69 
     | 
    
         
            +
                  end
         
     | 
| 
       68 
70 
     | 
    
         
             
                end
         
     | 
| 
       69 
71 
     | 
    
         | 
| 
       70 
72 
     | 
    
         
             
                def set(value)
         
     | 
| 
       71 
     | 
    
         
            -
                  levels.last 
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
      
 73 
     | 
    
         
            +
                  if levels.last
         
     | 
| 
      
 74 
     | 
    
         
            +
                    levels.last.current = Float(value)
         
     | 
| 
      
 75 
     | 
    
         
            +
                    print_message
         
     | 
| 
      
 76 
     | 
    
         
            +
                  end
         
     | 
| 
       73 
77 
     | 
    
         
             
                end
         
     | 
| 
       74 
78 
     | 
    
         | 
| 
       75 
79 
     | 
    
         
             
                def stop
         
     | 
| 
       76 
     | 
    
         
            -
                   
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
      
 80 
     | 
    
         
            +
                  if levels.last
         
     | 
| 
      
 81 
     | 
    
         
            +
                    print_message if levels.last.step_if_blank
         
     | 
| 
      
 82 
     | 
    
         
            +
                    levels.pop
         
     | 
| 
      
 83 
     | 
    
         
            +
                    io.puts if levels.empty?
         
     | 
| 
      
 84 
     | 
    
         
            +
                  end
         
     | 
| 
       79 
85 
     | 
    
         
             
                end
         
     | 
| 
       80 
86 
     | 
    
         | 
| 
       81 
87 
     | 
    
         
             
                attr_writer :io, :lines, :highlight # :nodoc:
         
     | 
    
        data/progress.gemspec
    CHANGED
    
    
    
        data/spec/progress_spec.rb
    CHANGED
    
    | 
         @@ -171,6 +171,20 @@ describe Progress do 
     | 
|
| 
       171 
171 
     | 
    
         
             
                end.should == 'qwerty'
         
     | 
| 
       172 
172 
     | 
    
         
             
              end
         
     | 
| 
       173 
173 
     | 
    
         | 
| 
      
 174 
     | 
    
         
            +
              it "should not raise errors on extra Progress.stop" do
         
     | 
| 
      
 175 
     | 
    
         
            +
                proc{
         
     | 
| 
      
 176 
     | 
    
         
            +
                  10.times_with_progress('10') do
         
     | 
| 
      
 177 
     | 
    
         
            +
                    Progress.start 'simple' do
         
     | 
| 
      
 178 
     | 
    
         
            +
                      Progress.start 'procedural'
         
     | 
| 
      
 179 
     | 
    
         
            +
                      Progress.stop
         
     | 
| 
      
 180 
     | 
    
         
            +
                      Progress.stop
         
     | 
| 
      
 181 
     | 
    
         
            +
                    end
         
     | 
| 
      
 182 
     | 
    
         
            +
                    Progress.stop
         
     | 
| 
      
 183 
     | 
    
         
            +
                  end
         
     | 
| 
      
 184 
     | 
    
         
            +
                  Progress.stop
         
     | 
| 
      
 185 
     | 
    
         
            +
                }.should_not raise_error
         
     | 
| 
      
 186 
     | 
    
         
            +
              end
         
     | 
| 
      
 187 
     | 
    
         
            +
             
     | 
| 
       174 
188 
     | 
    
         
             
              it "should pipe result from nested block" do
         
     | 
| 
       175 
189 
     | 
    
         
             
                [1, 2, 3].with_progress('a').map do |a|
         
     | 
| 
       176 
190 
     | 
    
         
             
                  [1, 2, 3].with_progress('b').map do |b|
         
     |