mirror of
				https://github.com/red-data-tools/YouPlot.git
				synced 2025-11-04 19:58:12 +08:00 
			
		
		
		
	Pass standard input to standard output first
This commit is contained in:
		@@ -40,14 +40,28 @@ module YouPlot
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      # Sometimes the input file does not end with a newline code.
 | 
					      # Sometimes the input file does not end with a newline code.
 | 
				
			||||||
      while (input = Kernel.gets(nil))
 | 
					      while (input = Kernel.gets(nil))
 | 
				
			||||||
        input.freeze
 | 
					
 | 
				
			||||||
 | 
					        # Pass the input to subsequent pipelines
 | 
				
			||||||
 | 
					        case pass
 | 
				
			||||||
 | 
					        when IO
 | 
				
			||||||
 | 
					          pass.print(input)
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					          if pass
 | 
				
			||||||
 | 
					            File.open(pass, 'w') do |f|
 | 
				
			||||||
 | 
					              f.print(input)
 | 
				
			||||||
 | 
					            end
 | 
				
			||||||
 | 
					          end
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        @data = if @encoding
 | 
					        @data = if @encoding
 | 
				
			||||||
                  input2 = input.dup.force_encoding(@encoding).encode('utf-8')
 | 
					                  input2 = input.dup.force_encoding(@encoding).encode('utf-8')
 | 
				
			||||||
                  Preprocessing.input(input2, delimiter, headers, transpose)
 | 
					                  Preprocessing.input(input2, delimiter, headers, transpose)
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
                  Preprocessing.input(input, delimiter, headers, transpose)
 | 
					                  Preprocessing.input(input, delimiter, headers, transpose)
 | 
				
			||||||
                end
 | 
					                end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pp @data if @debug
 | 
					        pp @data if @debug
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        plot = case command
 | 
					        plot = case command
 | 
				
			||||||
               when :bar, :barplot
 | 
					               when :bar, :barplot
 | 
				
			||||||
                 @backend.barplot(data, params)
 | 
					                 @backend.barplot(data, params)
 | 
				
			||||||
@@ -78,16 +92,6 @@ module YouPlot
 | 
				
			|||||||
          end
 | 
					          end
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        case pass
 | 
					 | 
				
			||||||
        when IO
 | 
					 | 
				
			||||||
          pass.print(input)
 | 
					 | 
				
			||||||
        else
 | 
					 | 
				
			||||||
          if pass
 | 
					 | 
				
			||||||
            File.open(pass, 'w') do |f|
 | 
					 | 
				
			||||||
              f.print(input)
 | 
					 | 
				
			||||||
            end
 | 
					 | 
				
			||||||
          end
 | 
					 | 
				
			||||||
        end
 | 
					 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user