
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
progress_bar_snapshot
Advanced tools
= ProgressbarSnapshot
A simple widget that generates progress bars in png format. There are other ways to generate a progress bar with css, html and javascript. However, if you have to stick a progress bar in a pdf you probably need to stick it in as an image.
Rmagick gem required.
== Example usage:
In a stand alone script: require 'rubygems' require 'progress_bar_snapshot'
pb = ProgressBarSnapshot.new(200, 50, [15.0, 25, 4.1, 2.9]) pb.to_file("47percent.png")
This will generate a png file 200x50 called 47percent.png. Since the sum of 15.0, 25, 4.1, 2.9 is 47 the progress bar would be 47% full.
In your rails app:
In your controller: require 'progress_bar_snapshot' ... class MySomethingController < ApplicationController helper :progress_bar_snapshot ... # define an action to render and send the png def progress_bar
percentages = params[:percentages].split(",").collect { |p| p.to_f }
bar = ProgressBarSnapshot.new(
params[:width].to_i, params[:height].to_i,
percentages)
send_data bar.to_blob, :type => 'image/png', :disposition => 'inline',
:filename => "progress.png"
end
In your view: <%= progress_bar_png_tag( [12.4, 24,1, 25.6], ['#0398B3', '#E9C74B' ], { :width => 178, :height => 18, :controller => 'my_something', :action => 'progress_bar' } ) %>
Customizable colors:
These following parameters can be passed in to the progress bar snapshot constructor
:border_color # outer border color, defaults to "#666666", :progress_colors # progress bar colors, defaults to alternating between 'skyblue', 'grey' ,'salmon', :background # color of unfilled portion of the progress bar, defaults to "white", :font_family # default font to "arial", :font_color # default color of the font "black",
All the colors are passed straight to Rmagick, so they can be any color Rmagick supports.
For example:
pb = ProgressBarSnapshot.new(200, 50, [35.0, 25, 14.1, 12.9], :progress_colors => ['blue', 'SteelBlue', 'skyblue', 'grey'], :background => 'grey90')
Multiple Segments:
This release of progress bar can be instructed to generate "sausage links" segments of progress bars. You can pass it any number of percentages and their corresponding colors. Each of these percentages would be drawn and their sum would be displayed on the progress bar.
== Authors, credits, blame, contact!
FAQs
Unknown package
We found that progress_bar_snapshot demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.