rqrcode_png_bin 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6f7a93c7e88af7ad00650a260fdf82666f2e5c00
4
+ data.tar.gz: 0d43808a613a8e202a26dcc39f8b2f881b457ccf
5
+ SHA512:
6
+ metadata.gz: 7304ea95eafea1003b5a9b89e1a443cc428e1196598541682e51e92e5260dc311e6597a5a668db827a5211bb5cd3d9c6dd4587e926db9d15d32754ee3fbf78da
7
+ data.tar.gz: 8007c59f8f2b9800e729bf37ef53d5ec631fffe110a6f53a42c57bd454d984ea974e46fc8e100c04f2411b7499ddab775a84d778834611c507a567f2f0857e10
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ /vendor
19
+ *~
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
4
+ - 2.0.0
5
+ - 1.9.3
6
+ - ree
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rqrcode_png_bin.gemspec
4
+ gemspec
@@ -0,0 +1,12 @@
1
+ Two-Clause BSD
2
+
3
+ Copyright (c) 2013, wtnabe
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9
+
10
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,19 @@
1
+ # RqrcodePngBin
2
+
3
+ command line interface for rqrcode_png
4
+
5
+ ## Installation
6
+
7
+ $ gem install rqrcode_png_bin
8
+
9
+ ## Usage
10
+
11
+ rqrcode_png STRING > qrcode.png
12
+
13
+ ## Contributing
14
+
15
+ 1. Fork it
16
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
17
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
18
+ 4. Push to the branch (`git push origin my-new-feature`)
19
+ 5. Create new Pull Request
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rqrcode_png_bin'
4
+
5
+ RqrcodePngBin::App.new(ARGV).run
@@ -0,0 +1,6 @@
1
+ require "rqrcode_png"
2
+ require "rqrcode_png_bin/version"
3
+ require "rqrcode_png_bin/app"
4
+
5
+ module RqrcodePngBin
6
+ end
@@ -0,0 +1,81 @@
1
+ require "optparse"
2
+ require "nkf"
3
+
4
+ module RqrcodePngBin
5
+ class App
6
+ def initialize(argv = [])
7
+ @argv = argv
8
+ @size = 4
9
+ @level = :m
10
+ @canvas = nil
11
+
12
+ parser.parse!(@argv)
13
+ end
14
+ attr_reader :size, :level, :canvas
15
+
16
+ def run
17
+ if str
18
+ png = RQRCode::QRCode.new(str, opts).to_img
19
+ png = png.resize(*canvas) if canvas
20
+
21
+ STDOUT.puts png
22
+ else
23
+ STDERR.puts "rqrcode_png #{VERSION}", nil, parser.help
24
+ end
25
+ end
26
+
27
+ #
28
+ # [return] String
29
+ #
30
+ def str
31
+ str = @argv.first
32
+ end
33
+
34
+ #
35
+ # [return] Hash
36
+ #
37
+ def opts
38
+ h = {
39
+ :size => @size,
40
+ :level => @level
41
+ }
42
+ end
43
+
44
+ #
45
+ # [return] OptionParser
46
+ #
47
+ def parser
48
+ OptionParser.new do |opt|
49
+ opt.version = VERSION
50
+ opt.banner = "Usage: rqrcode_png [option] string"
51
+ opt.on('-s', '--size SIZE (default 4)') {|v|
52
+ re = %r{\A[0-9]+\z}
53
+
54
+ if v =~ re
55
+ @size = v.to_i
56
+ else
57
+ raise ArgumentError, "option size should match #{re}"
58
+ end
59
+ }
60
+ opt.on('-l', '--level LEVEL (default m)') {|v|
61
+ options = %w(l m q h)
62
+
63
+ if options.include?(v)
64
+ @level = v.to_sym
65
+ else
66
+ raise ArgumentError, "option level should be included #{options}"
67
+ end
68
+ }
69
+ opt.on('-c', '--canvas CANVAS (ex 200x200)') {|v|
70
+ re = %r{\A([0-9]+)x([0-9]+)\z}
71
+
72
+ if v =~ re
73
+ @canvas = [$1.to_i, $2.to_i]
74
+ else
75
+ raise ArgumentError, "option canvas should match #{re}"
76
+ end
77
+ }
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,3 @@
1
+ module RqrcodePngBin
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,26 @@
1
+ # -*- mode: ruby; coding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rqrcode_png_bin/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rqrcode_png_bin"
8
+ spec.version = RqrcodePngBin::VERSION
9
+ spec.authors = ["wtnabe"]
10
+ spec.email = ["wtnabe@gmail.com"]
11
+ spec.description = %q{command line interface for rqrcode_png}
12
+ spec.summary = %q{command line interface for rqrcode_png}
13
+ spec.homepage = "https://github.com/wtnabe/rqrcode_png_bin"
14
+ spec.license = "BSD"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "rqrcode_png"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec"
26
+ end
@@ -0,0 +1,62 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe RqrcodePngBin do
5
+ def app(argv = [])
6
+ RqrcodePngBin::App.new(argv)
7
+ end
8
+
9
+ describe '#parser' do
10
+ context 'size' do
11
+ context 'nil' do
12
+ it {
13
+ expect(app.size).to be == 4
14
+ }
15
+ end
16
+ context '5' do
17
+ it {
18
+ expect(app(%w(-s 5)).size).to be == 5
19
+ }
20
+ end
21
+ context 'a' do
22
+ it {
23
+ expect {app(%w(-s a))}.to raise_error(ArgumentError)
24
+ }
25
+ end
26
+ end
27
+ context 'level' do
28
+ context 'nil' do
29
+ it {
30
+ expect(app.level).to be == :m
31
+ }
32
+ end
33
+ context 'h' do
34
+ it {
35
+ expect(app(%w(-l h)).level).to be == :h
36
+ }
37
+ end
38
+ context 'z' do
39
+ it {
40
+ expect {app(%w(-l z))}.to raise_error(ArgumentError)
41
+ }
42
+ end
43
+ end
44
+ context 'canvas' do
45
+ context 'nil' do
46
+ it {
47
+ expect(app.canvas).to be_nil
48
+ }
49
+ end
50
+ context '200x200' do
51
+ it {
52
+ expect(app(%w(-c 200x200)).canvas).to be == [200, 200]
53
+ }
54
+ end
55
+ context 'abc' do
56
+ it {
57
+ expect {app(%w(-c abc))}.to raise_error(ArgumentError)
58
+ }
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'rqrcode_png_bin'
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rqrcode_png_bin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - wtnabe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rqrcode_png
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: command line interface for rqrcode_png
70
+ email:
71
+ - wtnabe@gmail.com
72
+ executables:
73
+ - rqrcode_png
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - .rspec
79
+ - .travis.yml
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/rqrcode_png
85
+ - lib/rqrcode_png_bin.rb
86
+ - lib/rqrcode_png_bin/app.rb
87
+ - lib/rqrcode_png_bin/version.rb
88
+ - rqrcode_png_bin.gemspec
89
+ - spec/rqrcode_png_bin_spec.rb
90
+ - spec/spec_helper.rb
91
+ homepage: https://github.com/wtnabe/rqrcode_png_bin
92
+ licenses:
93
+ - BSD
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.0.3
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: command line interface for rqrcode_png
115
+ test_files:
116
+ - spec/rqrcode_png_bin_spec.rb
117
+ - spec/spec_helper.rb