+# frozen_string_literal: true
class Author
+ attr_accessor :grouping
+ attr_accessor :reading_order
+ attr_accessor :sort_order
+
def initialize(grouping, reading_order, sort_order)
@grouping = grouping
@reading_order = reading_order
end
end
- def grouping
- @grouping
- end
-
- def reading_order
- @reading_order
- end
-
- def sort_order
- @sort_order
- end
-
def inspect
- result = '(Author:'
- if nil != @grouping
- result += ' grouping="' + @grouping + '"'
- end
- if nil != @reading_order
- result += ' reading_order="' + @reading_order + '"'
- end
- if nil != @sort_order
- result += ' sort_order="' + @sort_order + '"'
- end
- result += ')'
+ field_info = [
+ grouping.nil? ? nil : "grouping=\"#{grouping}\"",
+ reading_order.nil? ? nil : "reading_order=\"#{reading_order}\"",
+ sort_order.nil? ? nil : "sort_order=\"#{sort_order}\"",
+ ].compact.join(" ")
- return result
+ "(Author: #{field_info})"
end
def to_s
inspect
end
- protected
+ private
+
def reading_to_sort_order(reading_order)
sort_order = reading_order
end
def inspect
- data = []
- if nil != @author
- data.push('author="' + @author.inspect + '"')
- end
- if nil != @series_id
- data.push('series_id="' + @series_id.to_s() + '"')
- end
- if nil != @volume
- data.push('volume="' + @volume + '"')
- end
- if nil != @title
- data.push('title="' + @title + '"')
- end
- if nil != @cover
- data.push(@cover.inspect())
- end
- if nil != @path
- data.push('path="' + @path + '"')
- end
- return '(Book:' + data.join(',') + ')'
+ field_info = [
+ author.nil? ? nil : "author=\"#{author.inspect}",
+ series_id.nil? ? nil : "series_id=\"#{series_id.inspect}",
+ volume.nil? ? nil : "volume=\"#{volume.inspect}",
+ title.nil? ? nil : "title=\"#{title.inspect}",
+ cover.nil? ? nil : "cover=\"#{cover.inspect}",
+ path.nil? ? nil : "path=\"#{path.inspect}",
+ ].compact.join(" ")
+
+ return "(Book: #{field_info})"
end
def to_s
end
def title_grouping
- if nil == @path
- return nil
- end
+ return if path.nil?
- return File.basename(@path, '.*')
+ File.basename(@path, '.*')
end
- protected
+ private
+
def isUpper?(c)
- return /[[:upper:]]/.match(c)
+ /[[:upper:]]/.match(c)
end
- protected
def massage_author(input)
if nil == input
return nil
reading_order += c
end
- return reading_order
+ reading_order
end
# Returns (series, volumeNo, titleText)
- protected
def processTitle(input)
if nil == input
return nil
return series, vol, title
end
- protected
def parse_file_name!(file_name)
category = nil # e.g., non-fiction, fan-fiction
grouping = ''
end
end
- protected
def scanEpub!(fileName)
#puts 'Scanning "' + fileName.to_s + '"...'
begin
end
end
- protected
def scan_pdf!(file_name)
- #puts 'Scanning "' + file_name.to_s + '"...'
-
pdf_path = File.expand_path(file_name).to_s
if ! pdf_path.end_with?('.pdf')
puts 'Unexpected internal error: path "' + file_name.to_s + '" does not end with ".pdf".'
end
end
-
- protected
def scanOpf!(zipfile, opfPath)
coverId = nil
@cover = load_cover(zipfile, opfPath, opfDoc, coverId)
end
- protected
def load_cover(zipfile, opfPath, opfDoc, coverId)
if nil == coverId
coverId = "cover-image"
end
end
end
- return nil
+
+ nil
end
end
+# frozen_string_literal: true
require_relative 'book'
require_relative 'store'
+# frozen_string_literal: true
class Classification
+ attr_accessor :id, :ddc, :lcc, :author_grouping, :author, :title_grouping, :title
+
def initialize(ddc, lcc, author_grouping, author, title_grouping, title)
@id = nil
@ddc = ddc
@title = title
end
- def id
- @id
- end
- def id=(value)
- @id = value
- end
-
- def ddc
- @ddc
- end
- def lcc
- @lcc
- end
- def author_grouping
- @author_grouping
- end
- def author
- @author
- end
-
def inspect
- data = []
-
- if nil != @ddc
- data.push('Dewey=' + @ddc.to_s.inspect)
- end
- if nil != @lcc
- data.push('LCC=' + @lcc.to_s.inspect)
- end
- if nil != @author_grouping
- data.push('author_grouping=' + @author_grouping.to_s.inspect)
- end
- if nil != @author
- data.push('author=' + @author.to_s.inspect)
- end
- if nil != @title_grouping
- data.push('title_grouping=' + @title_grouping.to_s.inspect)
- end
- if nil != @title
- data.push('title=' + @title.inspect)
- end
+ field_info = [
+ ddc.nil? ? nil : "Dewey=#{ddc.inspect}",
+ lcc.nil? ? nil : "LCC=#{lcc.inspect}",
+ author_grouping.nil? ? nil : "author_grouping=#{author_grouping.inspect}",
+ author.nil? ? nil : "author=#{author.inspect}",
+ title_grouping.nil? ? nil : "title_grouping=#{title_grouping.inspect}",
+ title.nil? ? nil : "title=#{title.inspect}",
+ ].compact.join(", ")
- return '(Classification: ' + data.join(', ') + ')'
+ return "(Classification: #{field_info})"
end
def to_s
inspect
end
- protected
+ private
+
def reading_to_sort_order(reading_order)
sort_order = reading_order
+# frozen_string_literal: true
class Cover
attr_reader :path
end
def inspect
- info = []
- if nil != @data
- info.push('size=' + @data.length.to_s)
- else
- info.push('empty')
- end
- if nil != @path
- info.push('path="' + @path + '"')
- end
- if nil != @mimeType
- info.push('mimeType="' + @mimeType + '"')
- end
- return '(Cover:' + info.join(',') + ')'
+ field_info = [
+ @data.nil? ? nil : "size=#{@data.length.to_s}",
+ @path.nil? ? nil : "path=#{@path.inspect}",
+ @mimeType.nil? ? nil : "mime_type=#{@mimeType.inspect}",
+ ].compact.join(" ")
+
+ "(Cover: #{field_info})"
end
def read_image(filename)
open(outputDir + '/' + filename, 'wb') do |fd|
fd.write(@data)
end
+
return filename, @mimeType
end
- protected
+ private
+
def getExt
pos = @path.rindex('.')
if nil == pos
return '.img'
end
- return @path.slice(pos, @path.length)
+
+ @path.slice(pos, @path.length)
end
end
+# frozen_string_literal: true
+
require_relative 'navigator'
require_relative 'page'
require_relative 'store'
class Series
+ attr_reader :id
+
+ attr_accessor :age
+ attr_accessor :code
+ attr_accessor :descr
+ attr_accessor :genre
+ attr_accessor :grouping
+
def initialize(id)
@age = nil
@genre = nil
@id = id
end
- def age
- @age
- end
-
- def age=(value)
- @age = value
- end
-
- def code
- @code
- end
-
- def code=(value)
- @code = value
- end
-
- def descr
- @descr
- end
-
- def descr=(value)
- @descr = value
- end
-
- def genre
- @genre
- end
-
- def genre=(value)
- @genre = value
- end
-
- def grouping
- @grouping
- end
-
- def grouping=(value)
- @grouping = value
- end
-
- def id
- @id
- end
-
def inspect
- data = []
- if nil != @age
- data.push('age=' + @age.inspect)
- end
- if nil != @code
- data.push('code=' + @code.inspect)
- end
- if nil != @descr
- data.push('descr="' + @descr + '"')
- end
- if nil != @genre
- data.push('genre="' + @genre + '"')
- end
- if nil != @grouping
- data.push('grouping="' + @grouping + '"')
- end
- return '(Series: ' + data.join(' ') + ')'
+ field_info = [
+ age.nil? ? nil : "age=#{age.inspect}",
+ code.nil? ? nil : "code=#{code.inspect}",
+ descr.nil? ? nil : "descr=#{descr.inspect}",
+ genre.nil? ? nil : "genre=#{genre.inspect}",
+ grouping.nil? ? nil : "grouping=#{grouping.inspect}",
+ ].compact.join(" ")
+
+ "(Series: #{field_info})"
end
def key
if nil != grouping and nil != code
return grouping.to_s + '_' + code.to_s
end
- return id.to_s
+
+ id.to_s
end
def to_s
- return inspect()
+ inspect
end
end
+# frozen_string_literal: true
require 'csv'
require 'fileutils'
end
def cross_reference_lists
-puts "@@@@@@@@@@@ CROSS-REF START @@@@@@@@@@@"
exec_update("TRUNCATE TABLE Lists CASCADE;", [])
populate_lists_table
-puts "@@@@@@@@@@@ CROSS-REF DONE @@@@@@@@@@@"
end
def create_schema(skip_class)