barkeep_rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in barkeep_rails.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Robert Sanders
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # BarkeepRails
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'barkeep_rails'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install barkeep_rails
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'barkeep_rails/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "barkeep_rails"
8
+ gem.version = BarkeepRails::VERSION
9
+ gem.authors = ["Robert Sanders"]
10
+ gem.email = ["robert@zeevex.com"]
11
+ gem.description = %q{Simple Rails helper to embed dynamically generated barcodes as images.
12
+ Currently Depends on the barcodes4me.com service.}
13
+ gem.summary = %q{Simple Rails helper to embed dynamically generated barcodes as images.}
14
+ gem.homepage = "http://github.com/zeevex/barkeep_rails"
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.add_development_dependency 'rspec', '~> 2.9.0'
22
+ gem.add_development_dependency 'rake'
23
+ gem.add_development_dependency 'pry'
24
+ gem.add_development_dependency 'activesupport'
25
+
26
+ end
@@ -0,0 +1,56 @@
1
+ require "barkeep_rails/version"
2
+ require 'active_support/core_ext'
3
+
4
+ module BarkeepRails
5
+ mattr_accessor :default_provider
6
+ #
7
+ # See http://www.barcodes4.me/apidocumentation
8
+ #
9
+ # There is one additional parameter not documented there:
10
+ # :secure => <Boolean> - If true, generate a HTTPS URL
11
+ #
12
+ def self.barcode_image_url(options)
13
+ type = options.delete(:type)
14
+ value = options.delete(:value)
15
+ imagetype = options.delete(:imagetype) || "png"
16
+ secure = options.delete(:secure) || false
17
+
18
+ unless %w{c39 c128 c128a c128b c128c i2of5 qr ean8 ean13 upca upce}.include?(type.to_s)
19
+ raise ArgumentError, "Cannot generate barcodes for type #{type}"
20
+ end
21
+
22
+ unless %w{gif png jpg}.include?(imagetype.to_s)
23
+ raise ArgumentError, "Cannot generate barcodes for image type #{imagetype}"
24
+ end
25
+
26
+ raise ArgumentError, "Must provide value" unless value && !value.to_s.empty?
27
+
28
+ provider = options.delete(:provider) || self.default_provider
29
+
30
+ case provider.to_sym
31
+ when :barcodes4me
32
+ url = (secure ? "https" : "http") +
33
+ "://barcodes4.me/barcode/#{type}/#{value}.#{imagetype}"
34
+ when :barkeep
35
+ url = (secure ? "https" : "http") +
36
+ "://barkeep.zeevex.net/barcode/#{value}.#{imagetype}"
37
+ # barkeep expects type as a query arg so put it back in the hash
38
+ options[:type] = type
39
+ else
40
+ raise ArgumentError, "Unknown provider #{provider}"
41
+ end
42
+
43
+ unless options.empty?
44
+ url = url + "?" + options.to_query
45
+ end
46
+
47
+ url
48
+ end
49
+ end
50
+
51
+ BarkeepRails.default_provider = :barkeep
52
+
53
+ if defined?(Rails)
54
+ require File.join(File.dirname(__FILE__), *%w[barkeep_rails barcode_helper])
55
+ ActionView::Base.send :include, BarkeepRails::BarcodeHelper
56
+ end
@@ -0,0 +1,17 @@
1
+ # coding: utf-8
2
+ require 'barkeep_rails'
3
+
4
+ module BarkeepRails
5
+ module BarcodeHelper
6
+ #
7
+ # See http://www.barcodes4.me/apidocumentation
8
+ #
9
+ def barcode_image_url(options)
10
+ BarkeepRails.barcode_image_url options
11
+ end
12
+
13
+ def barcode_image_tag(barcode_options, tag_options = {})
14
+ image_tag barcode_image_url(barcode_options), tag_options
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module BarkeepRails
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.join(File.dirname(__FILE__), "../lib")
3
+
4
+ require 'pry'
5
+ require 'barkeep_rails'
6
+
7
+ binding.pry
8
+
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: barkeep_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Robert Sanders
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 2.9.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 2.9.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: pry
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: activesupport
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: ! "Simple Rails helper to embed dynamically generated barcodes as images.\n
79
+ \ Currently Depends on the barcodes4me.com service."
80
+ email:
81
+ - robert@zeevex.com
82
+ executables: []
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - .gitignore
87
+ - Gemfile
88
+ - LICENSE.txt
89
+ - README.md
90
+ - Rakefile
91
+ - barkeep_rails.gemspec
92
+ - lib/barkeep_rails.rb
93
+ - lib/barkeep_rails/barcode_helper.rb
94
+ - lib/barkeep_rails/version.rb
95
+ - script/console
96
+ homepage: http://github.com/zeevex/barkeep_rails
97
+ licenses: []
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 1.8.23
117
+ signing_key:
118
+ specification_version: 3
119
+ summary: Simple Rails helper to embed dynamically generated barcodes as images.
120
+ test_files: []