Skip to content

Commit

Permalink
Option -e implies now --calc
Browse files Browse the repository at this point in the history
  • Loading branch information
ngiger committed Mar 25, 2015
1 parent fa6ac9c commit 6659069
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
oddb2xml (2.0.2)
oddb2xml (2.0.3)
archive-tar-minitar (~> 0.5.2)
mechanize (~> 2.5.1)
nokogiri (~> 1.5.10)
Expand Down
4 changes: 4 additions & 0 deletions History.txt
@@ -1,3 +1,7 @@
=== 2.0.3 / 25.03.2015

* Option -e implies --calc, too.

=== 2.0.2 / 24.03.2015

* Fixed handling of chemicals and units with '%'
Expand Down
10 changes: 6 additions & 4 deletions lib/oddb2xml/cli.rb
Expand Up @@ -43,7 +43,7 @@ def initialize(args)
end
def run
threads = []
if @options[:calc]
if @options[:calc] and not @options[:extended]
threads << download(:package) # swissmedic
elsif @options[:address]
[:company, :person].each do |type|
Expand Down Expand Up @@ -94,10 +94,11 @@ def run
def build
Oddb2xml.log("Start build")
begin
@_files = {"calc"=>"oddb_calc.xml"} if @options[:calc]
# require 'pry'; binding.pry
@_files = {"calc"=>"oddb_calc.xml"} if @options[:calc] and not @options[:extended]
files.each_pair do |sbj, file|
builder = Builder.new(@options) do |builder|
if @options[:calc]
if @options[:calc] and not @options[:extended]
builder.packs = @packs
builder.subject = sbj
elsif @options[:address]
Expand Down Expand Up @@ -222,7 +223,7 @@ def download(what, type=nil, lang=nil)
@packs = SwissmedicExtractor.new(bin, :package).to_hash
Oddb2xml.log("SwissmedicExtractor added #{@packs.size} packs from #{bin}")
@packs
end unless @options[:calc]
end
end
when :bm_update
Thread.new do
Expand Down Expand Up @@ -296,6 +297,7 @@ def compress
def files
unless @_files
@_files = {}
@_files[:calc] = "oddb_calc.xml" if @options[:calc]
if @options[:address]
@_files[:company] = "#{prefix}_betrieb.xml"
@_files[:person] = "#{prefix}_medizinalperson.xml"
Expand Down
5 changes: 4 additions & 1 deletion lib/oddb2xml/options.rb
Expand Up @@ -31,7 +31,9 @@ def Options.help
produced files are found under data
-a, --append Additional target nonpharma
-c F, --compress=F Compress format F. {tar.gz|zip}
-e --extended pharma, non-pharma plus prices and non-pharma from zurrose. Products without EAN-Code will also be listed.
-e --extended pharma, non-pharma plus prices and non-pharma from zurrose.
Products without EAN-Code will also be listed.
File oddb_calc.xml will also be generated
-f F, --format=F File format F, default is xml. {xml|dat}
If F is given, -o option is ignored.
-I x, --increment=x Increment price by x percent. Forces -f dat -p zurrose.
Expand Down Expand Up @@ -63,6 +65,7 @@ def initialize
@parser.on('-e', '--extended') {|v| @opts[:extended] = true
@opts[:nonpharma] = true
@opts[:price] = :zurrose
@opts[:calc] = true
}
@parser.on('-f v', '--format v', /^xml|dat$/) {|v| @opts[:format] = v.intern }
@parser.on('--calc') {|v| @opts[:calc] = true }
Expand Down
2 changes: 1 addition & 1 deletion lib/oddb2xml/version.rb
@@ -1,3 +1,3 @@
module Oddb2xml
VERSION = "2.0.2"
VERSION = "2.0.3"
end
12 changes: 2 additions & 10 deletions spec/options_spec.rb
Expand Up @@ -92,16 +92,7 @@ def cli_capture(stream)
expected = Default_opts.clone
expected[:extended] = true
expected[:nonpharma] = true
expected[:price] = :zurrose
specify { expect(options.opts).to eq expected }
end

context 'when -e is given' do
options = Oddb2xml::Options.new
options.parser.parse!('-e'.split(' '))
expected = Default_opts.clone
expected[:extended] = true
expected[:nonpharma] = true
expected[:calc] = true
expected[:price] = :zurrose
specify { expect(options.opts).to eq expected }
end
Expand All @@ -112,6 +103,7 @@ def cli_capture(stream)
expected = Default_opts.clone
expected[:extended] = true
expected[:nonpharma] = true
expected[:calc] = true
expected[:price] = :zurrose
expected[:percent] = 80
specify { expect(options.opts).to eq expected }
Expand Down

0 comments on commit 6659069

Please sign in to comment.