label_factory 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 699985a71a8f3c2ab179dbdb4e67b0d26dc44547
4
- data.tar.gz: 379e9a218744d0abfb884556f132465ad494db7c
3
+ metadata.gz: 0e434fb2a46de090cb1f8f99a5320af7070f33b5
4
+ data.tar.gz: bb83215195c08c5e4a720052ebf69bbd24adb46d
5
5
  SHA512:
6
- metadata.gz: b495e132ab0c909b8873f086981d9123f9b785e8cecab5b007b7ade7a8ec4a7f7fa5e70544737dba84cbe39c7046f84622cbcd4f2271ef527084ec1775ed46aa
7
- data.tar.gz: 0921a5676cc434edf0bccd920f6b3f2611524a928730149c6a9f336d0004d36a5b6b8c7e82379eb2c723903157d00a45d38793ea4f6a2228b53a7030ba4329fe
6
+ metadata.gz: 6f73cf6eee1798263a7fa4b8d88a16a8cc11339629e52559f76f4c1baa49bd90fa559acc41fdc98a79518a7d759114c248ab51dcea75b60e2820fe5e0df78e89
7
+ data.tar.gz: 9152d70308213c483091a100515c770b220d595b742ad391f36cf40330193486fe154b2fb80913f0c70431d55944d7cc8c8995ed0ece79ab636abb1c2161db46
data/Rakefile CHANGED
@@ -1 +1,9 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ end
7
+
8
+ desc "Run tests"
9
+ task default: :test
@@ -1,6 +1,8 @@
1
1
  module LabelFactory
2
2
  module Batch
3
3
  class Base
4
+ extend Forwardable
5
+ def_delegator :@layout, :labels_per_page
4
6
 
5
7
  DEFAULTS = { justification: :left, font_size: 12, font_type: 'Helvetica' }
6
8
  CONVERTER = Iconv.new( 'ISO-8859-1//IGNORE//TRANSLIT', 'utf-8')
@@ -1,3 +1,3 @@
1
1
  module LabelFactory
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
  end
data/lib/label_factory.rb CHANGED
@@ -2,6 +2,7 @@ require 'pdf/writer'
2
2
  require 'xml/mapping'
3
3
  require 'xml/mapping/base'
4
4
  require 'iconv'
5
+ require 'forwardable'
5
6
 
6
7
  module LabelFactory
7
8
 
@@ -0,0 +1,32 @@
1
+ <?xml version="1.0"?>
2
+ <Glabels-templates>
3
+ <!-- =================================================================== -->
4
+ <!-- Pimaco 6080 family: Address Labels, 1'' x 2_5/8'', 30 per sheet x -->
5
+ <!-- =================================================================== -->
6
+ <Template name="Pimaco 6080" size="US-Letter" _description="Address Labels">
7
+ <Label-rectangle id="0" width="2.68in" height="1.026in" round="0.0625in">
8
+ <Markup-margin size="0.00in"/>
9
+ <Layout nx="3" ny="10" x0="0.045in" y0="0.390in" dx="2.83in" dy="1.026in"/>
10
+ </Label-rectangle>
11
+ </Template>
12
+
13
+ <!-- =================================================================== -->
14
+ <!-- Pimaco 6081 family: Address Labels, 1'' x 4'', 20 per sheet x -->
15
+ <!-- =================================================================== -->
16
+ <Template name="Pimaco 6081" size="US-Letter" _description="Address Labels">
17
+ <Label-rectangle id="0" width="4.100in" height="1.026in" round="0.0625in">
18
+ <Markup-margin size="0.00in"/>
19
+ <Layout nx="2" ny="10" x0="0.02in" y0="0.38in" dx="4.3in" dy="1.026in"/>
20
+ </Label-rectangle>
21
+ </Template>
22
+
23
+ <!-- =================================================================== -->
24
+ <!-- Pimaco 6082 family: Address Labels, 1'' x 4'', 14 per sheet x -->
25
+ <!-- =================================================================== -->
26
+ <Template name="Pimaco 6082" size="US-Letter" _description="Address Labels">
27
+ <Label-rectangle id="0" width="4.100in" height="1.37in" round="0.0625in">
28
+ <Markup-margin size="0.00in"/>
29
+ <Layout nx="2" ny="7" x0="0.02in" y0="0.70in" dx="4.3in" dy="1.37in"/>
30
+ </Label-rectangle>
31
+ </Template>
32
+ </Glabels-templates>
@@ -1,10 +1,12 @@
1
- # encoding: utf-8
1
+ # encoding: UTF-8
2
2
  require 'test/unit'
3
3
  require 'label_factory'
4
4
 
5
5
  class TestPdfLabelBatch < Test::Unit::TestCase
6
6
  ROOT = File.expand_path(File.dirname(__FILE__) + "/../")
7
7
  def setup
8
+ LabelFactory::Batch::Base.load_template_set
9
+ @staff_names = ["Dan Stark", "Pierce Morar II", "Casimer Runolfsson", "Bella Jacobi"]
8
10
  end
9
11
 
10
12
  def test_new_with_tempalte_name
@@ -36,22 +38,22 @@ class TestPdfLabelBatch < Test::Unit::TestCase
36
38
 
37
39
  def test_PdfLabelBatch_load_tempalte_set
38
40
  LabelFactory::Batch::Base.load_template_set("#{ROOT}/templates/avery-iso-templates.xml")
39
- #Avery 7160 is found in avery-iso-templates
40
- p = LabelFactory::Batch::Base.new("Avery 7160")
41
- assert p
42
- assert_equal p.pdf.page_width, 595.28
43
- assert_equal p.pdf.page_height, 841.89
44
- LabelFactory::Batch::Base.load_template_set("#{ROOT}/templates/avery-us-templates.xml")
45
- end
46
-
47
- def test_PdfLabelBatch_all_template_names
48
- #what happens if we havn't loaded a template yet?
49
- t = LabelFactory::Batch::Base.all_template_names
50
- assert t
51
- assert_equal t.class, Array
52
- assert_equal t.count, 292
53
- assert_equal t.first, "Avery 5160"
54
- end
41
+ #Avery 7160 is found in avery-iso-templates
42
+ p = LabelFactory::Batch::Base.new("Avery 7160")
43
+ assert p
44
+ assert_equal p.pdf.page_width, 595.28
45
+ assert_equal p.pdf.page_height, 841.89
46
+ LabelFactory::Batch::Base.load_template_set("#{ROOT}/templates/avery-us-templates.xml")
47
+ end
48
+
49
+ def test_PdfLabelBatch_all_template_names
50
+ #what happens if we havn't loaded a template yet?
51
+ t = LabelFactory::Batch::Base.all_template_names
52
+ assert t
53
+ assert_equal t.class, Array
54
+ assert_equal t.count, 292
55
+ assert_equal t.first, "Avery 5160"
56
+ end
55
57
 
56
58
  def test_add_label_3_by_10
57
59
  p = LabelFactory::Batch::Base.new("Avery 8160") # label is 2 x 10
@@ -131,4 +133,38 @@ class TestPdfLabelBatch < Test::Unit::TestCase
131
133
  t.find_description
132
134
  end
133
135
  end
136
+
137
+ def test_staff_pimaco_labels_6080
138
+ LabelFactory::Batch::Base.load_template_set('templates/pimaco-templates.xml')
139
+ p = LabelFactory::Batch::Base.new("Pimaco 6080")
140
+ p.draw_boxes(false, true)
141
+ @staff_names.each_with_index { |name, i| p.add_label(name, position: i, justification: :center) }
142
+
143
+ p.save_as("#{ROOT}/test_staff_pimaco_labels_6080.pdf")
144
+ end
145
+
146
+ def test_staff_pimaco_labels_6081
147
+ LabelFactory::Batch::Base.load_template_set('templates/pimaco-templates.xml')
148
+ p = LabelFactory::Batch::Base.new("Pimaco 6081")
149
+ p.draw_boxes(false, true)
150
+ @staff_names.each_with_index { |name, i| p.add_label(name, position: i, justification: :center) }
151
+
152
+ p.save_as("#{ROOT}/test_staff_pimaco_labels_6081.pdf")
153
+ end
154
+
155
+ def test_staff_pimaco_labels_6082
156
+ LabelFactory::Batch::Base.load_template_set('templates/pimaco-templates.xml')
157
+ p = LabelFactory::Batch::Base.new("Pimaco 6082")
158
+ p.draw_boxes(false, true)
159
+ @staff_names.each_with_index { |name, i| p.add_label(name, position: i, justification: :center) }
160
+
161
+ p.save_as("#{ROOT}/test_staff_pimaco_labels_6082.pdf")
162
+ end
163
+
164
+ def test_get_labels_per_page
165
+ LabelFactory::Batch::Base.load_template_set('templates/pimaco-templates.xml')
166
+ p = LabelFactory::Batch::Base.new("Pimaco 6082")
167
+ assert p.labels_per_page
168
+ assert_equal 14, p.labels_per_page
169
+ end
134
170
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: label_factory
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - gagoar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-18 00:00:00.000000000 Z
11
+ date: 2013-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventioz-pdf-writer
@@ -117,6 +117,7 @@ files:
117
117
  - templates/misc-other-templates.xml
118
118
  - templates/misc-us-templates.xml
119
119
  - templates/paper-sizes.xml
120
+ - templates/pimaco-templates.xml
120
121
  - templates/zweckform-iso-templates.xml
121
122
  - test/test_pdf_label_page.rb
122
123
  homepage: http://github.com/eventioz/label_factory
@@ -139,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
140
  version: '0'
140
141
  requirements: []
141
142
  rubyforge_project:
142
- rubygems_version: 2.0.3
143
+ rubygems_version: 2.1.11
143
144
  signing_key:
144
145
  specification_version: 4
145
146
  summary: http://github.com/eventioz/label_factory