Module: LibPtgBox

Defined in:
app/modules/lib_ptg_box/marshaller.rb,
app/modules/lib_ptg_box.rb,
app/modules/lib_ptg_box/work.rb,
app/modules/lib_ptg_box/catalog.rb,
app/modules/lib_ptg_box/product.rb,
app/modules/lib_ptg_box/lib_ptg_box.rb,
app/modules/lib_ptg_box/unmarshaller.rb,
app/modules/lib_ptg_box/product_family.rb,
app/modules/lib_ptg_box/unmarshaller/marc.rb,
app/modules/lib_ptg_box/unmarshaller/kbart.rb,
app/modules/lib_ptg_box/unmarshaller/marc_file.rb,
app/modules/lib_ptg_box/unmarshaller/kbart_file.rb,
app/modules/lib_ptg_box/unmarshaller/marc_folder.rb,
app/modules/lib_ptg_box/unmarshaller/root_folder.rb,
app/modules/lib_ptg_box/unmarshaller/kbart_folder.rb,
app/modules/lib_ptg_box/unmarshaller/family_folder.rb

Overview

require_relative 'unmarshaller/unmarshaller'

Defined Under Namespace

Modules: Marshaller, Unmarshaller Classes: Catalog, LibPtgBox, Product, ProductFamily, Work

Constant Summary collapse

BOX_LIB_PTG_BOX_PATH =
'/Library PTG Box'
TMP_LIB_PTG_BOX_PATH =
Rails.root.join('tmp', 'lib_ptg_box')
TMP_DOWNLOAD_PATH =
Rails.root.join('tmp', 'lib_ptg_box', 'download')
TMP_UPLOAD_PATH =
Rails.root.join('tmp', 'lib_ptg_box', 'upload')

Class Method Summary collapse

Class Method Details

.downloadObject

rubocop:disable Metrics/MethodLength, Metrics/AbcSize


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
# File 'app/modules/lib_ptg_box.rb', line 30

def download # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
  FileUtils.rm_rf(TMP_LIB_PTG_BOX_PATH) if Dir.exist?(TMP_LIB_PTG_BOX_PATH)
  Dir.mkdir(TMP_LIB_PTG_BOX_PATH)
  Dir.mkdir(TMP_DOWNLOAD_PATH)
  Dir.chdir(TMP_DOWNLOAD_PATH) do
    Box::Service.new.folder(BOX_LIB_PTG_BOX_PATH).folders.each do |product_family_folder|
      Dir.mkdir(product_family_folder.name)
      Dir.chdir(product_family_folder.name) do
        product_family_folder.folders.each do |folder|
          Dir.mkdir(folder.name)
          Dir.chdir(folder.name) do
            folder.files.each do |file|
              # FileUtils.touch(file.name)
              File.open(file.name, "wb") do |f|
                f.write(file.content)
                f.close
              end
            end
          end
        end
      end
    end
  end
  FileUtils.cp_r(TMP_DOWNLOAD_PATH, TMP_UPLOAD_PATH)
end

.testObject

rubocop:disable Metrics/AbcSize


18
19
20
21
22
23
24
25
26
27
28
# File 'app/modules/lib_ptg_box.rb', line 18

def test # rubocop:disable Metrics/AbcSize
  LibPtgBox.new.product_families.each do |product_family|
    puts product_family.name
    product_family.products.each do |product|
      puts "--> " + product.name + " " + product.yyyy + '-' + product.mm + '-' + product.dd
      product.works.each do |work|
        puts "----> #{work.doi}" unless work.marc?
      end
    end
  end
end

.uploadObject


56
# File 'app/modules/lib_ptg_box.rb', line 56

def upload; end