barcodes 0.0.3 → 0.0.4

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/lib/barcodes/exec.rb CHANGED
@@ -42,9 +42,9 @@ module Barcodes
42
42
  def run
43
43
  unless self.symbology.nil?
44
44
  unless self.options[:ascii]
45
- Barcodes::Renderer::Pdf.new(Barcodes.create(self.symbology, self.options)).render
45
+ Barcodes::Renderer::Pdf.new(Barcodes.create(self.symbology, self.options)).render(self.target)
46
46
  else
47
- Barcodes::Renderer::Ascii.new(Barcodes.create(self.symbology, self.options)).render
47
+ Barcodes::Renderer::Ascii.new(Barcodes.create(self.symbology, self.options)).render(self.target)
48
48
  end
49
49
  end
50
50
  end
@@ -21,10 +21,25 @@ module Barcodes
21
21
 
22
22
  # Render the barcode as PDF with optional filename
23
23
  def render(filename=nil)
24
+ pdf = self.pdf
25
+
26
+ self.draw(pdf)
27
+
24
28
  unless filename.nil?
25
- self.pdf.render_file filename
29
+ pdf.render_file filename
30
+ else
31
+ pdf.render
32
+ end
33
+ end
34
+
35
+ # Draws the barcode to the provided Prawn::Document
36
+ def draw(pdf)
37
+ if self.barcode.class == Barcodes::Symbology::Ean8 || self.barcode.class == Barcodes::Symbology::Ean13 || self.barcode.class == Barcodes::Symbology::UpcA
38
+ self._draw_ean_upc(self.barcode, pdf)
39
+ elsif self.barcode.class == Barcodes::Symbology::Planet || self.barcode.class == Barcodes::Symbology::Postnet
40
+ self._draw_planet_postnet(self.barcode, pdf)
26
41
  else
27
- self.pdf.render
42
+ self._draw_standard(self.barcode, pdf)
28
43
  end
29
44
  end
30
45
 
@@ -41,15 +56,7 @@ module Barcodes
41
56
  :bottom_margin => 0
42
57
  }
43
58
 
44
- Prawn::Document.new document_options do |pdf|
45
- if @barcode.class == Barcodes::Symbology::Ean8 || @barcode.class == Barcodes::Symbology::Ean13 || @barcode.class == Barcodes::Symbology::UpcA
46
- self._draw_ean_upc(@barcode, pdf)
47
- elsif @barcode.class == Barcodes::Symbology::Planet || @barcode.class == Barcodes::Symbology::Postnet
48
- self._draw_planet_postnet(@barcode, pdf)
49
- else
50
- self._draw_standard(@barcode, pdf)
51
- end
52
- end
59
+ Prawn::Document.new document_options
53
60
  end
54
61
 
55
62
  protected
@@ -7,5 +7,5 @@
7
7
  #
8
8
  module Barcodes
9
9
  # Returns the current version
10
- VERSION = "0.0.3"
10
+ VERSION = "0.0.4"
11
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barcodes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -148,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
148
148
  version: '0'
149
149
  segments:
150
150
  - 0
151
- hash: 559850387649710345
151
+ hash: -3760866316115547301
152
152
  required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  none: false
154
154
  requirements:
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
157
  version: '0'
158
158
  segments:
159
159
  - 0
160
- hash: 559850387649710345
160
+ hash: -3760866316115547301
161
161
  requirements: []
162
162
  rubyforge_project: barcodes
163
163
  rubygems_version: 1.8.24