-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RQRCode is a library for creating and rendering QR codes into various formats. It has a simple interface with all the standard QR code options. refs: https://github.com/whomwah/rqrcode
- Loading branch information
Showing
6 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Exit command with non-zero status code, Output logs of every command executed, Treat unset variables as an error when substituting. | ||
set -eou pipefail | ||
# Internal Field Separator - Linux shell variable | ||
IFS=$'\n\t' | ||
# Print shell input lines | ||
set -v | ||
|
||
# Set RBS_DIR variable to change directory to execute type checks using `steep check` | ||
RBS_DIR=$(cd $(dirname $0)/..; pwd) | ||
# Set REPO_DIR variable to validate RBS files added to the corresponding folder | ||
REPO_DIR=$(cd $(dirname $0)/../../..; pwd) | ||
# Validate RBS files, using the bundler environment present | ||
bundle exec rbs --repo $REPO_DIR -r rqrcode:2.2 -r chunky_png validate --silent | ||
|
||
cd ${RBS_DIR}/_test | ||
# Run type checks | ||
bundle exec steep check | ||
|
||
$(git rev-parse --show-toplevel)/bin/check-untyped-call.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
D = Steep::Diagnostic | ||
|
||
target :test do | ||
check "." | ||
signature "." | ||
|
||
repo_path "../../../" | ||
library "rqrcode" | ||
|
||
library "chunky_png" | ||
|
||
configure_code_diagnostics(D::Ruby.all_error) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Write Ruby code to test the RBS. | ||
# It is type checked by `steep check` command. | ||
|
||
require "rqrcode" | ||
|
||
qr = RQRCode::QRCode.new("https://kyan.com") | ||
|
||
puts qr.to_s | ||
|
||
qrcode = RQRCode::QRCode.new("http://github.com/") | ||
|
||
# NOTE: showing with default options specified explicitly | ||
svg = qrcode.as_svg( | ||
color: "000", | ||
shape_rendering: "crispEdges", | ||
module_size: 11, | ||
standalone: true, | ||
use_path: true | ||
) | ||
|
||
qrcode = RQRCode::QRCode.new("http://github.com/") | ||
|
||
# NOTE: showing with default options specified explicitly | ||
png = qrcode.as_png( | ||
bit_depth: 1, | ||
border_modules: 4, | ||
color_mode: ChunkyPNG::COLOR_GRAYSCALE, | ||
color: "black", | ||
file: nil, | ||
fill: "white", | ||
module_px_size: 6, | ||
resize_exactly_to: false, | ||
resize_gte_to: false, | ||
size: 120 | ||
) | ||
|
||
IO.binwrite("/tmp/github-qrcode.png", png.to_s) | ||
|
||
|
||
qrcode = RQRCode::QRCode.new("http://github.com/") | ||
|
||
# NOTE: showing with default options specified explicitly | ||
ansi = qrcode.as_ansi( | ||
light: "\033[47m", dark: "\033[40m", | ||
fill_character: " ", | ||
quiet_zone_size: 4 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module RQRCode | ||
class QRCode | ||
type level = :l | :m | :q | :h | ||
type mode = :number | :alphanumeric | :byte_8bit | :kanji | ||
type segment = { data: String, mode: mode } | ||
|
||
def initialize: (String) -> void | ||
def as_svg: (?offset: Integer, ?fill: String | :white | :currentColor, ?color: String | :black | :currentColor, ?module_size: Integer, ?shape_rendering: "auto" | "optimizeSpeed" | "crispEdges" | "geometricPrecision", ?standalone: bool, ?use_path: bool, ?viewbox: bool, ?svg_attributes: Hash[untyped, untyped]) -> String | ||
def as_png: (?fill: untyped, ?color: untyped, ?size: Integer, ?border_modules: Integer, ?module_px_size: Integer, ?border: Integer, ?resize_exactly_to: bool, ?resize_gte_to: bool) -> ChunkyPNG::Image | ||
| (file: untyped, ?fill: untyped, ?color: untyped, ?color_mode: Integer, ?bit_depth: Integer, ?interlace: bool, ?compression: untyped, ?size: Integer, ?border_modules: Integer, ?module_px_size: Integer, ?border: Integer, ?resize_exactly_to: bool, ?resize_gte_to: bool) -> ChunkyPNG::Image | ||
def as_ansi: (?light: String, ?dark: String, ?fill_character: String, ?quiet_zone_size: Integer) -> String | ||
def to_s: () -> String | ||
end | ||
end |