qrcli 0.0.1
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/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/bin/qrcli +37 -0
- data/lib/qrcli.rb +5 -0
- data/lib/qrcli/version.rb +3 -0
- data/qrcli.gemspec +22 -0
- metadata +66 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/bin/qrcli
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rqrcode'
|
4
|
+
|
5
|
+
BLACK = "\e[40m"
|
6
|
+
WHITE = "\e[107m"
|
7
|
+
DEFAULT = "\e[0m"
|
8
|
+
SPACER = " "
|
9
|
+
|
10
|
+
text = ARGV[0] || STDIN.read
|
11
|
+
|
12
|
+
# make a qr code of the smallest possible size
|
13
|
+
def minimal_qrcode text, opts={}
|
14
|
+
opts[:size] = 1
|
15
|
+
begin
|
16
|
+
return RQRCode::QRCode.new(text, opts)
|
17
|
+
rescue RQRCode::QRCodeRunTimeError => e
|
18
|
+
opts[:size] += 1
|
19
|
+
raise e if opts[:size] > 10
|
20
|
+
retry
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def format_qrcode qr
|
25
|
+
width = qr.module_count
|
26
|
+
pad = WHITE + SPACER * (width + 2) + BLACK
|
27
|
+
|
28
|
+
lines = qr.to_s(:true => BLACK + SPACER, :false => WHITE + SPACER).split("\n")
|
29
|
+
lines.map! { |line| WHITE + SPACER + line + WHITE + SPACER + DEFAULT }
|
30
|
+
|
31
|
+
([pad] + lines + [pad]).join("\n")
|
32
|
+
end
|
33
|
+
|
34
|
+
level = 'l'
|
35
|
+
qr = minimal_qrcode text, :level => level
|
36
|
+
puts format_qrcode(qr)
|
37
|
+
|
data/lib/qrcli.rb
ADDED
data/qrcli.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "qrcli/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "qrcli"
|
7
|
+
s.version = Qrcli::VERSION
|
8
|
+
s.authors = ["John Hawthorn"]
|
9
|
+
s.email = ["[email protected]"]
|
10
|
+
s.homepage = "https://github.com/jhawthorn/qrcli"
|
11
|
+
s.summary = %q{Generates QR codes on the command line using ANSI terminal colors}
|
12
|
+
s.description = %q{Generates QR codes on the command line using ANSI terminal colors}
|
13
|
+
|
14
|
+
s.rubyforge_project = "qrcli"
|
15
|
+
|
16
|
+
s.add_dependency 'rqrcode'
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: qrcli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- John Hawthorn
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-09-09 00:00:00.000000000 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rqrcode
|
17
|
+
requirement: &69910882196080 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *69910882196080
|
26
|
+
description: Generates QR codes on the command line using ANSI terminal colors
|
27
|
+
email:
|
28
|
|
29
|
+
executables:
|
30
|
+
- qrcli
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- Gemfile
|
36
|
+
- Rakefile
|
37
|
+
- bin/qrcli
|
38
|
+
- lib/qrcli.rb
|
39
|
+
- lib/qrcli/version.rb
|
40
|
+
- qrcli.gemspec
|
41
|
+
has_rdoc: true
|
42
|
+
homepage: https://github.com/jhawthorn/qrcli
|
43
|
+
licenses: []
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubyforge_project: qrcli
|
62
|
+
rubygems_version: 1.6.2
|
63
|
+
signing_key:
|
64
|
+
specification_version: 3
|
65
|
+
summary: Generates QR codes on the command line using ANSI terminal colors
|
66
|
+
test_files: []
|