tianji_qrcode_png 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +66 -0
- data/lib/tianji_qrcode_png/version.rb +1 -1
- data/tianji_qrcode_png.gemspec +3 -3
- metadata +5 -4
data/README.markdown
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# rqrcode_png
|
2
|
+
**Problem:** You need to generate your own QR code images
|
3
|
+
**Solution:** rqrcode_png
|
4
|
+
|
5
|
+
## Overview
|
6
|
+
rqrcode_png extends [rqrcode](https://github.com/whomwah/rqrcode), adding one simple method to instances of QRCode, **\#to_img**. [ChunkyPNG](https://github.com/wvanbergen/chunky_png) is used to generate the image itself in pure Ruby. As few assumptions are made as possible regarding the image itself.
|
7
|
+
|
8
|
+
### Rewrite
|
9
|
+
fork and rewrite part of the function
|
10
|
+
**1.** add size border size param
|
11
|
+
**2.** add qrcode color param
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
require 'rqrcode_png'
|
17
|
+
|
18
|
+
qr = RQRCode::QRCode.new( 'my string to generate', :size => 4, :level => :h )
|
19
|
+
png = qr.to_img # returns an instance of ChunkyPNG
|
20
|
+
png.resize(90, 90).save("really_cool_qr_image.png")
|
21
|
+
```
|
22
|
+
|
23
|
+
*NOTE:* For now, the :size of the QR code has to be 14 or less. Working on this.
|
24
|
+
|
25
|
+
### Bundler
|
26
|
+
```ruby
|
27
|
+
gem 'rqrcode_png'
|
28
|
+
```
|
29
|
+
|
30
|
+
### Rails
|
31
|
+
|
32
|
+
#### With [DragonFly](https://github.com/markevans/dragonfly)
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
# app/models/product.rb
|
36
|
+
class Product < ActiveRecord::Base
|
37
|
+
image_accessor :qr_code
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
# somewhere
|
43
|
+
qr_code_img = RQRCode::QRCode.new('http://www.google.com/', :size => 4, :level => :h ).to_img
|
44
|
+
@product.update_attribute :qr_code, qr_code_img.to_string
|
45
|
+
```
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
# app/controllers/products.rb
|
49
|
+
def show
|
50
|
+
@product = Product.find(params[:id])
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
# app/views/products/show.html.erb
|
56
|
+
<%= image_tag @product.qr_code.url %>
|
57
|
+
```
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
* Fork the project
|
61
|
+
* Send a pull request
|
62
|
+
* Don't touch the .gemspec, I'll do that when I release a new version
|
63
|
+
|
64
|
+
## Copyright
|
65
|
+
MIT Licence (http://www.opensource.org/licenses/mit-license.html)
|
66
|
+
|
data/tianji_qrcode_png.gemspec
CHANGED
@@ -5,8 +5,8 @@ require "tianji_qrcode_png/version"
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "tianji_qrcode_png"
|
7
7
|
s.version = TianjiQRCodePNG::VERSION
|
8
|
-
s.authors = ["
|
9
|
-
s.email = ["
|
8
|
+
s.authors = ["Backkom"]
|
9
|
+
s.email = ["99866770@qq.com"]
|
10
10
|
s.homepage = ""
|
11
11
|
s.summary = %q{Produces a .png from a given QR Code}
|
12
12
|
s.description = %q{Glues rQRCode together with chunky_png}
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
-
s.require_paths = ["
|
19
|
+
s.require_paths = ["lib"]
|
20
20
|
|
21
21
|
s.add_dependency "chunky_png"
|
22
22
|
s.add_dependency "rqrcode"
|
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tianji_qrcode_png
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
-
-
|
8
|
+
- Backkom
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
@@ -45,7 +45,7 @@ dependencies:
|
|
45
45
|
version: '0'
|
46
46
|
description: Glues rQRCode together with chunky_png
|
47
47
|
email:
|
48
|
-
-
|
48
|
+
- 99866770@qq.com
|
49
49
|
executables: []
|
50
50
|
extensions: []
|
51
51
|
extra_rdoc_files: []
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- .gitignore
|
54
54
|
- Gemfile
|
55
55
|
- LICENSE
|
56
|
+
- README.markdown
|
56
57
|
- Rakefile
|
57
58
|
- lib/tianji_qrcode_png.rb
|
58
59
|
- lib/tianji_qrcode_png/image.rb
|
@@ -65,7 +66,7 @@ licenses: []
|
|
65
66
|
post_install_message:
|
66
67
|
rdoc_options: []
|
67
68
|
require_paths:
|
68
|
-
-
|
69
|
+
- lib
|
69
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
71
|
none: false
|
71
72
|
requirements:
|