Module: DataShift

Defined in:
lib/datashift/binder.rb,
lib/datashift.rb,
lib/datashift.rb,
lib/datashift/guards.rb,
lib/datashift/header.rb,
lib/datashift/headers.rb,
lib/datashift/logging.rb,
lib/datashift/version.rb,
lib/datashift/querying.rb,
lib/datashift/mandatory.rb,
lib/datashift/delimiters.rb,
lib/datashift/excel_base.rb,
lib/datashift/exceptions.rb,
lib/tasks/thor_behaviour.rb,
lib/datashift/doc_context.rb,
lib/datashift/load_object.rb,
lib/datashift/node_context.rb,
lib/datashift/column_packer.rb,
lib/datashift/configuration.rb,
lib/datashift/node_collection.rb,
lib/datashift/progress_monitor.rb,
lib/datashift/applications/excel.rb,
lib/datashift/loaders/csv_loader.rb,
lib/datashift/inbound_data/column.rb,
lib/datashift/loaders/file_loader.rb,
lib/datashift/loaders/loader_base.rb,
lib/datashift/populators/has_many.rb,
lib/datashift/loaders/excel_loader.rb,
lib/datashift/loaders/failure_data.rb,
lib/datashift/mapping/mapper_utils.rb,
lib/datashift/populators/populator.rb,
lib/datashift/loaders/configuration.rb,
lib/datashift/transformation/remove.rb,
lib/datashift/exporters/csv_exporter.rb,
lib/datashift/loaders/loader_factory.rb,
lib/datashift/model_methods/operator.rb,
lib/datashift/transformation/factory.rb,
lib/datashift/exporters/configuration.rb,
lib/datashift/exporters/exporter_base.rb,
lib/datashift/model_methods/catalogue.rb,
lib/datashift/exporters/excel_exporter.rb,
lib/datashift/generators/csv_generator.rb,
lib/datashift/mapping/data_flow_schema.rb,
lib/datashift/model_methods/collection.rb,
lib/datashift/generators/generator_base.rb,
lib/datashift/generators/excel_generator.rb,
lib/datashift/loaders/reporters/reporter.rb,
lib/datashift/model_methods/model_method.rb,
lib/datashift/generators/config_generator.rb,
lib/datashift/inbound_data/lookup_support.rb,
lib/datashift/inbound_data/method_binding.rb,
lib/datashift/populators/populator_factory.rb,
lib/datashift/loaders/paperclip/image_loading.rb,
lib/datashift/populators/insistent_assignment.rb,
lib/datashift/loaders/paperclip/attachment_loader.rb,
lib/datashift/model_methods/model_methods_manager.rb,
lib/datashift/loaders/paperclip/datashift_paperclip.rb,
lib/datashift/loaders/reporters/basic_stdout_reporter.rb

Overview

Copyright

© Autotelik Media Ltd 2016

Author

Tom Statter

License

MIT

Details

Very basic report to dump out loading report stats

Defined Under Namespace

Modules: ColumnPacker, Delimiters, ExcelBase, ExcelProxy, Exporters, FileLoader, Guards, ImageLoading, InboundData, Loader, Loaders, Logging, ModelMethods, Paperclip, Populators, Querying, Reporters, ThorBehavior, Transformation Classes: BadConfig, BadFile, BadRuby, BadUri, Binder, ConfigGenerator, Configuration, CsvExporter, CsvGenerator, CsvLoader, DataFlowSchema, DataShiftException, DocContext, EmptyContext, Excel, ExcelExporter, ExcelGenerator, ExcelLoader, ExporterBase, FailureData, GeneratorBase, Header, Headers, InternalMethodBinding, LoadObject, LoaderBase, Mandatory, MapperUtils, MappingDefinitionError, MethodBinding, MissingHeadersError, MissingMandatoryError, ModelMethod, NoMethodBinding, NodeCollection, NodeContext, Object, Operator, PathError, Populator, PopulatorFactory, ProgressMonitor, RuntimeError, UnsupportedFileType

Constant Summary collapse

VERSION =
'0.40.4'.freeze

Class Method Summary collapse

Class Method Details

.gem_nameObject



36
37
38
# File 'lib/datashift.rb', line 36

def self.gem_name
  'datashift'
end

.library_pathObject



44
45
46
# File 'lib/datashift.rb', line 44

def self.library_path
  File.expand_path("#{File.dirname(__FILE__)}/../lib")
end

.load_commandsObject

Load all public datashift Thor commands and make them available throughout app



126
127
128
129
130
131
132
133
# File 'lib/datashift.rb', line 126

def self.load_commands
  base = File.join(library_path, 'tasks')

  Dir["#{base}/*.thor"].each do |f|
    next unless File.file?(f)
    Thor::Util.load_thorfile(f)
  end
end

.load_tasksObject

Load all the datashift tasks and make them available throughout app



117
118
119
120
121
122
# File 'lib/datashift.rb', line 117

def self.load_tasks
  # Long parameter lists so ensure rake -T produces nice wide output
  ENV['RAKE_COLUMNS'] = '180'
  base = File.join(root_path, 'tasks', '**')
  Dir["#{base}/*.rake"].sort.each { |ext| load ext }
end

.require_librariesObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/datashift.rb', line 48

def self.require_libraries

  loader_libs = %w[lib]

  # Base search paths - these will be searched recursively
  loader_paths = []

  loader_libs.each { |l| loader_paths << File.join(root_path, l) }

  # Define require search paths, any dir in here will be added to LOAD_PATH

  loader_paths.each do |base|
    $LOAD_PATH.unshift base if File.directory?(base)
    Dir[File.join(base, '**', '**')].each do |p|
      $LOAD_PATH.unshift p if File.directory?(p)
    end
  end

  begin
    require_relative 'datashift/delimiters'
    require_relative 'datashift/load_object'
    require_relative 'datashift/generators/generator_base'
    require_relative 'datashift/loaders/reporters/reporter'
    require_relative 'datashift/loaders/loader_base'
    require_relative 'datashift/exporters/exporter_base'
  rescue StandardError => x
    puts "Problem initializing gem #{x.inspect}"
  end

  require_libs = %w[
    datashift/core_ext
    datashift
    datashift/mapping
    datashift/model_methods
    datashift/transformation
    datashift/inbound_data
    datashift/loaders
    datashift/loaders/reporters
    datashift/exporters
    datashift/generators
    datashift/helpers
    datashift/applications
    datashift/populators
  ]

  require_libs.each do |base|
    Dir[File.join(library_path, base, '*.rb')].each do |rb|
      # puts rb
      begin
        require_relative rb unless File.directory?(rb)
      rescue StandardError => x
        puts "WARNING - Problem loading datashift file #{rb} - #{x.inspect}"
        puts x.backtrace
      end
    end
  end

  if(DataShift::Guards.jruby?)
    require 'jexcel_file'
    JExcelFile
  else
    require 'spreadsheet'
    require 'spreadsheet_extensions'
    Spreadsheet
  end

end

.root_pathObject



40
41
42
# File 'lib/datashift.rb', line 40

def self.root_path
  File.expand_path("#{File.dirname(__FILE__)}/..")
end