barcodes 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/lib/barcodes/exec.rb CHANGED
@@ -15,6 +15,9 @@ module Barcodes
15
15
  # It takes command line arguments and options and renders a barcode
16
16
  # using those options.
17
17
  class Exec
18
+ # Array of command line arguments
19
+ attr_reader :argv
20
+
18
21
  # The parser instance
19
22
  attr_reader :parser
20
23
 
@@ -27,12 +30,9 @@ module Barcodes
27
30
  # The output target
28
31
  attr_reader :target
29
32
 
30
- # Array of command line arguments
31
- attr_reader :arguments
32
-
33
33
  # Creates a new instance with given command line arguments and options
34
34
  def initialize(argv)
35
- @arguments = arguments
35
+ @argv = argv
36
36
  @options = {}
37
37
  self._init_parser
38
38
  self._parse!
@@ -40,12 +40,16 @@ module Barcodes
40
40
 
41
41
  # Runs the command and renders barcode
42
42
  def run
43
- unless self.symbology.nil?
44
- unless self.options[:ascii]
45
- Barcodes::Renderer::Pdf.new(Barcodes.create(self.symbology, self.options)).render(self.target)
46
- else
47
- Barcodes::Renderer::Ascii.new(Barcodes.create(self.symbology, self.options)).render(self.target)
43
+ begin
44
+ unless self.symbology.nil?
45
+ unless self.options[:ascii]
46
+ Barcodes::Renderer::Pdf.new(Barcodes.create(self.symbology, self.options)).render(self.target)
47
+ else
48
+ Barcodes::Renderer::Ascii.new(Barcodes.create(self.symbology, self.options)).render(self.target)
49
+ end
48
50
  end
51
+ rescue Exception => e
52
+ puts e.message
49
53
  end
50
54
  end
51
55
 
@@ -77,14 +81,14 @@ module Barcodes
77
81
  def _parse!
78
82
 
79
83
  begin
80
- self.parser.parse!(self.arguments)
84
+ self.parser.parse!(self.argv)
81
85
  rescue
82
86
  puts self.parser.help
83
87
  exit 1
84
88
  end
85
89
 
86
- @symbology = self.arguments.shift
87
- @target = self.arguments.shift
90
+ @symbology = self.argv.shift
91
+ @target = self.argv.shift
88
92
  end
89
93
 
90
94
  # Returns the current version
@@ -29,25 +29,25 @@ require 'barcodes/symbology/upca'
29
29
  module Barcodes
30
30
  module Symbology
31
31
  CODABAR = ['Codabar', 'codabar']
32
- CODE_11 = ['Code11', 'Code 11', 'code11']
33
- CODE_39 = ['Code39', 'Code 39', 'code39']
34
- CODE_39_MOD_43 = ['Code39Mod43', 'Code 39 Mod 43', 'code39mod43']
35
- CODE_39_EXTENDED = ['Code39Extended', 'Code 39 Extended', 'code39extended']
36
- CODE_39_EXTENDED_MOD_43 = ['Code39ExtendedMod43', 'Code 39 Extended Mod 43', 'code39extendedmod43']
37
- CODE_93 = ['Code93', 'Code 93', 'code93']
38
- CODE_93_EXTENDED = ['Code93Extended', 'Code 93 Extended', 'code93extended']
39
- CODE_128 = ['Code128', 'Code 128', 'code128']
40
- EAN_8 = ['EAN8', 'EAN 8', 'EAN-8', 'ean8']
41
- EAN_13 = ['EAN13', 'EAN 13', 'EAN-13', 'ean13']
32
+ CODE_11 = ['Code11', 'Code 11', 'code11', 'code_11']
33
+ CODE_39 = ['Code39', 'Code 39', 'code39', 'code_39']
34
+ CODE_39_MOD_43 = ['Code39Mod43', 'Code 39 Mod 43', 'code39mod43', 'code_39_mod_43']
35
+ CODE_39_EXTENDED = ['Code39Extended', 'Code 39 Extended', 'code39extended', 'code_39_extended']
36
+ CODE_39_EXTENDED_MOD_43 = ['Code39ExtendedMod43', 'Code 39 Extended Mod 43', 'code39extendedmod43', 'code_39_extended_mod_43']
37
+ CODE_93 = ['Code93', 'Code 93', 'code93', 'code_93']
38
+ CODE_93_EXTENDED = ['Code93Extended', 'Code 93 Extended', 'code93extended', 'code_93_extended']
39
+ CODE_128 = ['Code128', 'Code 128', 'code128', 'code_128']
40
+ EAN_8 = ['EAN8', 'EAN 8', 'EAN-8', 'ean8', 'ean_8']
41
+ EAN_13 = ['EAN13', 'EAN 13', 'EAN-13', 'ean13', 'ean_13']
42
42
  MSI = ['MSI', 'Modified Plessey', 'msi']
43
- MSI_MOD_10 = ['MSI Mod 10', 'Modified Plessey Mod 10', 'msimod10']
44
- MSI_MOD_11 = ['MSI Mod 11', 'Modified Plessey Mod 11', 'msimod11']
45
- STANDARD_2_OF_5 = ['Standard2of5', 'Standard 2 of 5', 'standard_2_of_5']
46
- STANDARD_2_OF_5_MOD_10 = ['Standard2of5Mod10', 'Standard 2 of 5 Mod 10', 'standard_2_of_5_mod_10']
47
- INTERLEAVED_2_OF_5 = ['Interleaved2of5', 'Interleaved 2 of 5', 'interleaved_2_of_5']
48
- INTERLEAVED_2_OF_5_MOD_10 = ['Interleaved2of5Mod10', 'Interleaved 2 of 5 Mod 10', 'interleaved_2_of_5_mod_10']
43
+ MSI_MOD_10 = ['MSI Mod 10', 'Modified Plessey Mod 10', 'msimod10', 'msi_mod_10']
44
+ MSI_MOD_11 = ['MSI Mod 11', 'Modified Plessey Mod 11', 'msimod11', 'msi_mod_11']
45
+ STANDARD_2_OF_5 = ['Standard2of5', 'Standard 2 of 5', 'standard2of5', 'standard_2_of_5']
46
+ STANDARD_2_OF_5_MOD_10 = ['Standard2of5Mod10', 'Standard 2 of 5 Mod 10', 'standard2of5mod10', 'standard_2_of_5_mod_10']
47
+ INTERLEAVED_2_OF_5 = ['Interleaved2of5', 'Interleaved 2 of 5', 'interleaved2of5', 'interleaved_2_of_5']
48
+ INTERLEAVED_2_OF_5_MOD_10 = ['Interleaved2of5Mod10', 'Interleaved 2 of 5 Mod 10', 'interleaved2of5mod10', 'interleaved_2_of_5_mod_10']
49
49
  PLANET = ['Planet', 'PLANET', 'planet']
50
50
  POSTNET = ['Postnet', 'POSTNET', 'postnet']
51
- UPC_A = ['UPCA', 'UPC-A', 'upc_a']
51
+ UPC_A = ['UPCA', 'UPC-A', 'upca', 'upc_a']
52
52
  end
53
53
  end
@@ -7,5 +7,5 @@
7
7
  #
8
8
  module Barcodes
9
9
  # Returns the current version
10
- VERSION = "0.0.6"
10
+ VERSION = "0.0.7"
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.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-02 00:00:00.000000000 Z
12
+ date: 2012-09-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -148,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
148
148
  version: '0'
149
149
  segments:
150
150
  - 0
151
- hash: 2407393715627331748
151
+ hash: 187278537168354622
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: 2407393715627331748
160
+ hash: 187278537168354622
161
161
  requirements: []
162
162
  rubyforge_project: barcodes
163
163
  rubygems_version: 1.8.24