qrcoder 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/History +2 -0
- data/Rakefile +1 -1
- data/lib/{rqrcoder.rb → qrcoder.rb} +0 -0
- data/qrcoder.gemspec +30 -0
- data/test/rqrcode_svg_test.rb +79 -0
- metadata +41 -12
data/.gitignore
ADDED
data/History
ADDED
data/Rakefile
CHANGED
@@ -22,7 +22,7 @@ task :default => [:test]
|
|
22
22
|
|
23
23
|
Rake::RDocTask.new(:rdoc) do |rdoc|
|
24
24
|
rdoc.rdoc_dir = 'rdoc'
|
25
|
-
rdoc.title = '
|
25
|
+
rdoc.title = 'qrcoder'
|
26
26
|
rdoc.options << '--line-numbers' << '--inline-source'
|
27
27
|
rdoc.rdoc_files.include('README.rdoc')
|
28
28
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
File without changes
|
data/qrcoder.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
# Provide a simple gemspec so you can easily use your enginex
|
5
|
+
# project in your rails apps through git.
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "qrcoder"
|
8
|
+
s.summary = "Creates QR code files "
|
9
|
+
s.description = "Creates QR code files in png, bmp, png, jpg, tif and svg file format. This is fork of sam vincent rqrcode-rails3"
|
10
|
+
|
11
|
+
s.files = Dir["{lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "Gemfile", "README.md"]
|
12
|
+
|
13
|
+
s.author = "Bojan Milosavljevic"
|
14
|
+
s.email = "milboj@gmail.com"
|
15
|
+
s.homepage = "http://github.com/milboj/qrcoder"
|
16
|
+
s.version = "0.1.2"
|
17
|
+
|
18
|
+
s.add_development_dependency "rake"
|
19
|
+
s.add_development_dependency("bundler", ">= 1.0.0")
|
20
|
+
|
21
|
+
s.has_rdoc = true
|
22
|
+
s.extra_rdoc_files = ["README.md", "MIT-LICENSE"]
|
23
|
+
s.files = `git ls-files`.split("\n")
|
24
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
25
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
26
|
+
s.add_dependency 'rqrcode', '>= 0.4.2'
|
27
|
+
s.add_dependency 'mini_magick', '>= 3.0'
|
28
|
+
s.require_paths = ["lib"]
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require_relative "../lib/qrcoder.rb"
|
3
|
+
|
4
|
+
class QRCoder::QRCodeTest <Test::Unit::TestCase
|
5
|
+
include QRCoder
|
6
|
+
CURRENT_DIR = File.dirname(File.expand_path(__FILE__))
|
7
|
+
|
8
|
+
def test_creating_png
|
9
|
+
output_file = CURRENT_DIR + "/new_test.png"
|
10
|
+
QRCode.image("test", CURRENT_DIR, { :format => :png , :filename => "new_test" })
|
11
|
+
assert(File.exist?(output_file))
|
12
|
+
File.delete(output_file)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_creating_png_with_larger
|
16
|
+
output_file = [{:size => "small", :unit => 11}, {:size => "medium" ,:unit => 20}, {:size => "large",:unit => 41}]
|
17
|
+
output_file.each do |file|
|
18
|
+
QRCode.image("test", CURRENT_DIR, :format => :png , :filename => file[:size], :unit => file[:unit] )
|
19
|
+
path = CURRENT_DIR + "/" + file[:size] + ".png"
|
20
|
+
assert(File.exist?(path))
|
21
|
+
image = MiniMagick::Image.open(path)
|
22
|
+
assert_equal(image[:width], file[:unit] * 21)
|
23
|
+
File.delete(path)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_creating_jpg
|
28
|
+
output_file = CURRENT_DIR + "/new_test.jpg"
|
29
|
+
QRCode.image("test", CURRENT_DIR, { :format => :jpg , :filename => "new_test", :unit => 40 })
|
30
|
+
assert(File.exist?(output_file))
|
31
|
+
File.delete(output_file)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_creating_svg
|
35
|
+
output_file = CURRENT_DIR + "/new_test.svg"
|
36
|
+
QRCode.image("tesfadsghjklghjklfghjklfghrgthjkmlfghjktghjkfghjkffghjkl", CURRENT_DIR, { :format => :svg , :filename => "new_test" })
|
37
|
+
assert(File.exist?(output_file))
|
38
|
+
File.delete(output_file)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_creating_multiple
|
42
|
+
formats = [:svg, :png, :jpg, :gif, :tif, :bmp]
|
43
|
+
QRCode.image("tesfadsghjjklfghrgthjkmlfghjktghjkfghjkffghjkl", CURRENT_DIR, { :format => formats , :filename => "mulitple_test" })
|
44
|
+
formats.each do |format|
|
45
|
+
output_file = CURRENT_DIR + "/mulitple_test.#{format}"
|
46
|
+
assert(File.exist?(output_file))
|
47
|
+
File.delete(output_file)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_invalid_file_format
|
52
|
+
assert_raise QRCoder::QRCodeError do
|
53
|
+
QRCode.image("ghjk", CURRENT_DIR, {:format => :rtyui})
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_invalid_file_path
|
58
|
+
assert_raise QRCoder::QRCodeError do
|
59
|
+
QRCode.image("ghjk", "rtyufhadisuyiuds hfioh isufh", {:format => :png})
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_other_methods
|
64
|
+
formats = [:png, :jpg, :gif, :tif, :bmp]
|
65
|
+
QRCode.bmp("tesfajkfghjkffghjkl", CURRENT_DIR, {:filename => "meta_test" })
|
66
|
+
QRCode.png("tesfajkfghjkffghjkl", CURRENT_DIR, {:filename => "meta_test" })
|
67
|
+
QRCode.jpg("tesfajkfghjkffghjkl", CURRENT_DIR, {:filename => "meta_test" })
|
68
|
+
QRCode.gif("tesfajkfghjkffghjkl", CURRENT_DIR, {:filename => "meta_test" })
|
69
|
+
QRCode.tif("tesfajkfghjkffghjkl", CURRENT_DIR, {:filename => "meta_test" })
|
70
|
+
|
71
|
+
formats.each do |format|
|
72
|
+
output_file = CURRENT_DIR + "/meta_test.#{format}"
|
73
|
+
assert(File.exist?(output_file))
|
74
|
+
File.delete(output_file)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qrcoder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,9 +11,31 @@ bindir: bin
|
|
11
11
|
cert_chain: []
|
12
12
|
date: 2012-05-08 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: &2156492120 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2156492120
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: bundler
|
27
|
+
requirement: &2156490640 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.0
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2156490640
|
14
36
|
- !ruby/object:Gem::Dependency
|
15
37
|
name: rqrcode
|
16
|
-
requirement: &
|
38
|
+
requirement: &2156478740 !ruby/object:Gem::Requirement
|
17
39
|
none: false
|
18
40
|
requirements:
|
19
41
|
- - ! '>='
|
@@ -21,10 +43,10 @@ dependencies:
|
|
21
43
|
version: 0.4.2
|
22
44
|
type: :runtime
|
23
45
|
prerelease: false
|
24
|
-
version_requirements: *
|
46
|
+
version_requirements: *2156478740
|
25
47
|
- !ruby/object:Gem::Dependency
|
26
48
|
name: mini_magick
|
27
|
-
requirement: &
|
49
|
+
requirement: &2156477640 !ruby/object:Gem::Requirement
|
28
50
|
none: false
|
29
51
|
requirements:
|
30
52
|
- - ! '>='
|
@@ -32,21 +54,27 @@ dependencies:
|
|
32
54
|
version: '3.0'
|
33
55
|
type: :runtime
|
34
56
|
prerelease: false
|
35
|
-
version_requirements: *
|
57
|
+
version_requirements: *2156477640
|
36
58
|
description: Creates QR code files in png, bmp, png, jpg, tif and svg file format.
|
37
59
|
This is fork of sam vincent rqrcode-rails3
|
38
60
|
email: milboj@gmail.com
|
39
61
|
executables: []
|
40
62
|
extensions: []
|
41
|
-
extra_rdoc_files:
|
42
|
-
|
43
|
-
- lib/rqrcoder/renderers/svg.rb
|
44
|
-
- lib/rqrcoder/size_calculator.rb
|
45
|
-
- lib/rqrcoder.rb
|
63
|
+
extra_rdoc_files:
|
64
|
+
- README.md
|
46
65
|
- MIT-LICENSE
|
47
|
-
|
66
|
+
files:
|
67
|
+
- .gitignore
|
48
68
|
- Gemfile
|
69
|
+
- History
|
70
|
+
- MIT-LICENSE
|
49
71
|
- README.md
|
72
|
+
- Rakefile
|
73
|
+
- lib/qrcoder.rb
|
74
|
+
- lib/rqrcoder/renderers/svg.rb
|
75
|
+
- lib/rqrcoder/size_calculator.rb
|
76
|
+
- qrcoder.gemspec
|
77
|
+
- test/rqrcode_svg_test.rb
|
50
78
|
homepage: http://github.com/milboj/qrcoder
|
51
79
|
licenses: []
|
52
80
|
post_install_message:
|
@@ -71,4 +99,5 @@ rubygems_version: 1.8.15
|
|
71
99
|
signing_key:
|
72
100
|
specification_version: 3
|
73
101
|
summary: Creates QR code files
|
74
|
-
test_files:
|
102
|
+
test_files:
|
103
|
+
- test/rqrcode_svg_test.rb
|