Module: Oddb2xml
- Defined in:
- lib/oddb2xml.rb,
lib/oddb2xml/cli.rb,
lib/oddb2xml/calc.rb,
lib/oddb2xml/util.rb,
lib/oddb2xml/builder.rb,
lib/oddb2xml/options.rb,
lib/oddb2xml/version.rb,
lib/oddb2xml/extractor.rb,
lib/oddb2xml/compressor.rb,
lib/oddb2xml/downloader.rb
Defined Under Namespace
Modules: DownloadMethod, TxtExtractorMethods
Classes: BMUpdateDownloader, BMUpdateExtractor, BagXmlDownloader, BagXmlExtractor, Builder, Calc, Cli, Compressor, Downloader, EphaDownloader, EphaExtractor, Extractor, GalenicForm, GalenicGroup, LppvDownloader, LppvExtractor, MedregbmDownloader, MedregbmExtractor, MigelDownloader, MigelExtractor, Options, SwissIndexDownloader, SwissIndexExtractor, SwissmedicDownloader, SwissmedicExtractor, SwissmedicInfoDownloader, SwissmedicInfoExtractor, ZurroseDownloader, ZurroseExtractor
Constant Summary
collapse
- WorkDir =
Dir.pwd
- Downloads =
"#{Dir.pwd}/downloads"
- XML_OPTIONS =
{
'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'xmlns' => 'http://wiki.oddb.org/wiki.php?pagename=Swissmedic.Datendeklaration',
'CREATION_DATETIME' => Time.new.strftime('%FT%T%z'),
'PROD_DATE' => Time.new.strftime('%FT%T%z'),
'VALID_DATE' => Time.new.strftime('%FT%T%z')
}
- VERSION =
"2.0.6"
- Strip_For_Sax_Machine =
'<?xml version="1.0" encoding="utf-8"?>'+"\n"
Class Method Summary
collapse
Class Method Details
.calc_checksum(str) ⇒ Object
2
3
4
5
6
7
8
9
10
11
|
# File 'lib/oddb2xml/util.rb', line 2
def Oddb2xml.calc_checksum(str)
str = str.strip
sum = 0
val = str.split(//u)
12.times do |idx|
fct = ((idx%2)*2)+1
sum += fct*val[idx].to_i
end
((10-(sum%10))%10).to_s
end
|
.download_finished(file, remove_file = true) ⇒ Object
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/oddb2xml/util.rb', line 42
def Oddb2xml.download_finished(file, remove_file = true)
src = "#{WorkDir}/#{File.basename(file)}"
dest = "#{Downloads}/#{File.basename(file)}"
FileUtils.makedirs(Downloads)
return unless file and File.exists?(file)
return if File.expand_path(file).eql?(dest)
FileUtils.cp(src, dest, :verbose => false)
Oddb2xml.log("download_finished saved as #{dest} #{File.size(dest)} bytes.")
end
|
.log(msg) ⇒ Object
19
20
21
22
23
|
# File 'lib/oddb2xml/util.rb', line 19
def Oddb2xml.log(msg)
return unless @options[:log]
$stdout.puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}: #{msg}"
$stdout.flush
end
|
.save_options(options) ⇒ Object
25
26
27
|
# File 'lib/oddb2xml/util.rb', line 25
def Oddb2xml.save_options(options)
@options = options
end
|
.skip_download(file) ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/oddb2xml/util.rb', line 33
def Oddb2xml.skip_download(file)
dest = "#{Downloads}/#{File.basename(file)}"
if File.exists?(dest)
FileUtils.cp(dest, file, :verbose => false, :preserve => true) unless File.expand_path(file).eql?(dest)
return true
end
false
end
|
.skip_download? ⇒ Boolean
29
30
31
|
# File 'lib/oddb2xml/util.rb', line 29
def Oddb2xml.skip_download?
@options[:skip_download]
end
|