New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rqrcode-with-patches

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rqrcode-with-patches

  • 0.6.0
  • Rubygems
  • Socket score

Version published
Maintainers
2
Created
Source

rQRCode, Encode QRCodes

Build Status

I have republished this gem as rqrcode-with-patches as Duncan seams to have abandoned the project. You can find the original project here: http://github.com/whomwah/rqrcode

Short changelog

0.6.0 (Jun 2, 2015)

  • Improved png rendering. Previous png rendering could result in hard to scan qrcodes. Big thanks to Bart Jedrocha

0.5.5 (Apr 25, 2015)

  • Fixed major bug. The rs block data was missing resulting in qr codes failing to be generated. Upgrade highly recomended!!

Overview

rQRCode is a library for encoding QR Codes in Ruby. It has a simple interface with all the standard qrcode options. It was adapted from the Javascript library by Kazuhiko Arase.

Let's clear up some rQRCode stuff.

  • rQRCode is a standalone library It requires no other libraries. Just Ruby!
  • It is an encoding library. You can't decode QR codes with it.
  • The interface is simple and assumes you just want to encode a string into a QR code
  • QR code is trademarked by Denso Wave inc

Resources

Installing

You may get the latest stable version from Rubygems.

gem install rqrcode-with-patches

You can also get the latest source from https://github.com/bjornblomqvist/rqrcode

git clone git://github.com/bjornblomqvist/rqrcode.git

Tests

To run the tests:

$ rake

Loading rQRCode Itself

You have installed the gem already, yeah?

require 'rubygems'
require 'rqrcode'

Simple QRCode generation to screen

qr = RQRCode::QRCode.new( 'my string to generate', :size => 4, :level => :h )
puts qr.to_s
#
# Prints:
# xxxxxxx x  x x   x x  xx  xxxxxxx
# x     x  xxx  xxxxxx xxx  x     x
# x xxx x  xxxxx x       xx x xxx x
# ... etc

Simple QRCode generation to template (RubyOnRails)

Controller

@qr = RQRCode::QRCode.new( 'my string to generate', :size => 4, :level => :h )

View: (minimal styling added)

<style type="text/css">
table {
  border-width: 0;
  border-style: none;
  border-color: #0000ff;
  border-collapse: collapse;
}
td {
  border-width: 0;
  border-style: none;
  border-color: #0000ff;
  border-collapse: collapse;
  padding: 0;
  margin: 0;
  width: 10px;
  height: 10px;
}
td.black { background-color: #000; }
td.white { background-color: #fff; }
</style>

<%= raw @qr.as_html %>

If you want to generate the HTML manually for customization, you can start with the following:

<table>
<% @qr.modules.each_index do |x| %>
  <tr>
  <% @qr.modules.each_index do |y| %>
   <% if @qr.dark?(x,y) %>
    <td class="black"/>
   <% else %>
    <td class="white"/>
   <% end %>
  <% end %>
  </tr>
<% end %>
</table>

Exporting

You can also require optional export features:

  • SVG -> no dependencies
  • PNG -> depends on 'chunky_png' gem
  • JPG -> depends on 'mini_magick' gem

Example to render png:

require 'rqrcode/export/png'
image = RQRCode::QRCode.new("nice qr").as_png

Notice the 'as_png'. Same goes for 'as_svg', 'as_xxx'.

Export Options

Exporters support these options:

  • size - Image size, in pixels.
  • fill - Background color, defaults to 'white'
  • color - Foreground color, defaults to 'black'

SVG Export supports the parameter module_size to generate smaller or larger QR Codes

require 'rqrcode/export/svg'
svg = RQRCode::QRCode.new("nice qr").as_svg(:module_size => 6)

Authors

Original author: Duncan Robertson

Special thanks to the following people for submitting patches:

Contributing

  • Fork the project
  • Send a pull request
  • Don't touch the .gemspec, I'll do that when I release a new version

MIT License (http://www.opensource.org/licenses/mit-license.html)

FAQs

Package last updated on 02 Jun 2015

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc