Class: Sp2db::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/sp2db/config.rb

Constant Summary collapse

DEFAULT =
{
  personal_credential: "credentials/google_credentials.json",
  import_strategy: :truncate_all,
  export_location: "db/spreadsheets",
  default_file_extention: :csv,
  exception_handler: OpenStruct.new({
    row_import_error: :raise,
    table_import_error: :raise,
  }),
  non_model_tables: {}.with_indifferent_access,
  download_before_import: false,
  default_extensions: :csv,
  default_find_columns: [:id],
}
SUPPORTED_EXTENSIONS =
[:csv]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



37
38
39
# File 'lib/sp2db/config.rb', line 37

def initialize
  set_default
end

Instance Attribute Details

#client_idObject

Returns the value of attribute client_id.



4
5
6
# File 'lib/sp2db/config.rb', line 4

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



4
5
6
# File 'lib/sp2db/config.rb', line 4

def client_secret
  @client_secret
end

#credentialObject

Returns the value of attribute credential.



4
5
6
# File 'lib/sp2db/config.rb', line 4

def credential
  @credential
end

#default_extensionsObject

Returns the value of attribute default_extensions.



4
5
6
# File 'lib/sp2db/config.rb', line 4

def default_extensions
  @default_extensions
end

#default_file_extentionObject

Returns the value of attribute default_file_extention.



4
5
6
# File 'lib/sp2db/config.rb', line 4

def default_file_extention
  @default_file_extention
end

#default_find_columnsObject

Returns the value of attribute default_find_columns.



4
5
6
# File 'lib/sp2db/config.rb', line 4

def default_find_columns
  @default_find_columns
end

#download_before_importObject

Returns the value of attribute download_before_import.



4
5
6
# File 'lib/sp2db/config.rb', line 4

def download_before_import
  @download_before_import
end

#exception_handlerObject

Returns the value of attribute exception_handler.



4
5
6
# File 'lib/sp2db/config.rb', line 4

def exception_handler
  @exception_handler
end

#export_locationObject

Returns the value of attribute export_location.



4
5
6
# File 'lib/sp2db/config.rb', line 4

def export_location
  @export_location
end

#import_strategyObject

Returns the value of attribute import_strategy.



4
5
6
# File 'lib/sp2db/config.rb', line 4

def import_strategy
  @import_strategy
end

#non_model_tablesObject

Returns the value of attribute non_model_tables.



4
5
6
# File 'lib/sp2db/config.rb', line 4

def non_model_tables
  @non_model_tables
end

#personal_credentialObject

Returns the value of attribute personal_credential.



4
5
6
# File 'lib/sp2db/config.rb', line 4

def personal_credential
  @personal_credential
end

#spreadsheet_idObject

Returns the value of attribute spreadsheet_id.



4
5
6
# File 'lib/sp2db/config.rb', line 4

def spreadsheet_id
  @spreadsheet_id
end

Instance Method Details

#export_folderObject



47
48
49
50
# File 'lib/sp2db/config.rb', line 47

def export_folder
  FileUtils.mkdir_p export_location
  export_location
end