Class: Oddb2xml::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/oddb2xml/options.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptions



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/oddb2xml/options.rb', line 58

def initialize
  @parser = OptionParser.new
  @opts   = Options.default_opts
  @parser.on('-a',   '--append')                       {|v| @opts[:nonpharma] = true }
  @parser.on('-c v', '--compress v',   /^tar\.gz|zip$/){|v| @opts[:compress_ext] = v }
  @parser.on('-e', '--extended')                       {|v| @opts[:extended] = true
                                                          @opts[:nonpharma] = true
                                                          @opts[:price] = :zurrose
                                                        }
  @parser.on('-f v', '--format v',     /^xml|dat$/)    {|v| @opts[:format] = v.intern }
  @parser.on('--calc')                                 {|v| @opts[:calc] = true }
  @parser.on('-o',   '--option')                       {|v| @opts[:fi] = true }
  @parser.on('-I v', '--increment v',  /^[0-9]+$/)     {|v| @opts[:percent] = v ? v.to_i : 0
                                                            @opts[:price] = :zurrose
                                                       }
  @parser.on('-i',   '--include')                      {|v| @opts[:ean14] = true }
  @parser.on('-t v', '--tag-suffix v', /^[A-z0-9]*$/i) {|v| @opts[:tag_suffix] = v.upcase }
  @parser.on('-x v', '--context v',    /^addr(ess)*$/i){|v| @opts[:address] = true }
  @parser.on('-p', '--price')                          {|v| @opts[:price] = :zurrose }
  @parser.on('--skip-download')                        {|v| @opts[:skip_download] = true }
  @parser.on('--log')                                  {|v| @opts[:log] = true }
  @parser.on_tail('-h', '--help') { puts Options.help; exit }
end

Instance Attribute Details

#optsObject (readonly)

Returns the value of attribute opts.



7
8
9
# File 'lib/oddb2xml/options.rb', line 7

def opts
  @opts
end

#parserObject (readonly)

Returns the value of attribute parser.



7
8
9
# File 'lib/oddb2xml/options.rb', line 7

def parser
  @parser
end

Class Method Details

.default_optsObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/oddb2xml/options.rb', line 8

def Options.default_opts
  {
    :fi           => false,
    :adr          => false,
    :address      => false,
    :nonpharma    => false,
    :extended     => false,
    :compress_ext => nil,
    :format       => :xml,
    :calc         => false,
    :tag_suffix   => nil,
    :debug        => false,
    :ean14        => false,
    :skip_download=> false,
    :log          => false,
    :percent      => nil,
  }
end

.helpObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/oddb2xml/options.rb', line 26

def Options.help
  "\#$0 ver.\#{Oddb2xml::VERSION}\nUsage:\n  oddb2xml [option]\nproduced files are found under data\n-a,   --append       Additional target nonpharma\n-c F, --compress=F   Compress format F. {tar.gz|zip}\n-e    --extended     pharma, non-pharma plus prices and non-pharma from zurrose. Products without EAN-Code will also be listed.\n-f F, --format=F     File format F, default is xml. {xml|dat}\n                     If F is given, -o option is ignored.\n-I x, --increment=x  Increment price by x percent. Forces -f dat -p zurrose.\n-I x, --increment=x  create additional field price_resellerpub as\n                     price_extfactory incremented by x percent (rounded to the next 0.05 francs)\n                     in oddb_article.xml. In generated zurrose_transfer.dat PRPU is set to this price\n                     Forces -f dat -p zurrose.\n-i,   --include      Include target option for ean14  for 'dat' format.\n                     'xml' format includes always ean14 records.\n-o,   --option       Optional fachinfo output.\n-p,   --price        Price source (transfer.dat) from ZurRose\n-t S, --tag-suffix=S XML tag suffix S. Default is none. [A-z0-9]\n                     If S is given, it is also used as prefix of filename.\n-x N, --context=N    context N {product|address}. product is default.\n--calc               create only oddb_calc.xml with GTIN, name and galenic information\n\n                     For debugging purposes\n--skip-download      skips downloading files it the file is already under downloads.\n                     Downloaded files are saved under downloads\n--log                log important actions\n-h,   --help         Show this help message.\n"
end