Class: AdLocalize::Requests::ExportRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/ad_localize/requests/export_request.rb

Constant Summary collapse

DEFAULTS =
{
  locales: [],
  bypass_empty_values: false,
  auto_escape_percent: false,
  skip_value_stripping: false,
  csv_paths: [],
  merge_policy: Interactors::MergeWordings::DEFAULT_POLICY,
  output_path: Pathname.new('exports'),
  spreadsheet_id: nil,
  sheet_ids: %w[0],
  export_all: false,
  verbose: false,
  platforms: Entities::Platform::SUPPORTED_PLATFORMS,
  downloaded_csvs: []
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeExportRequest

Returns a new instance of ExportRequest.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/ad_localize/requests/export_request.rb', line 39

def initialize
  @locales = DEFAULTS[:locales]
  @bypass_empty_values = DEFAULTS[:bypass_empty_values]
  @auto_escape_percent = DEFAULTS[:auto_escape_percent]
  @skip_value_stripping = DEFAULTS[:skip_value_stripping]
  @csv_paths = DEFAULTS[:csv_paths]
  @merge_policy = DEFAULTS[:merge_policy]
  @output_path = DEFAULTS[:output_path]
  @platforms = DEFAULTS[:platforms]
  @spreadsheet_id = DEFAULTS[:spreadsheet_id]
  @sheet_ids = DEFAULTS[:sheet_ids]
  @export_all = DEFAULTS[:export_all]
  @verbose = DEFAULTS[:verbose]
  @downloaded_csvs = DEFAULTS[:downloaded_csvs]
end

Instance Attribute Details

#auto_escape_percentObject

Returns the value of attribute auto_escape_percent.



23
24
25
# File 'lib/ad_localize/requests/export_request.rb', line 23

def auto_escape_percent
  @auto_escape_percent
end

#bypass_empty_valuesObject

Returns the value of attribute bypass_empty_values.



23
24
25
# File 'lib/ad_localize/requests/export_request.rb', line 23

def bypass_empty_values
  @bypass_empty_values
end

#csv_pathsObject

Returns the value of attribute csv_paths.



23
24
25
# File 'lib/ad_localize/requests/export_request.rb', line 23

def csv_paths
  @csv_paths
end

#downloaded_csvsObject

Returns the value of attribute downloaded_csvs.



23
24
25
# File 'lib/ad_localize/requests/export_request.rb', line 23

def downloaded_csvs
  @downloaded_csvs
end

#export_allObject

Returns the value of attribute export_all.



23
24
25
# File 'lib/ad_localize/requests/export_request.rb', line 23

def export_all
  @export_all
end

#localesObject

Returns the value of attribute locales.



23
24
25
# File 'lib/ad_localize/requests/export_request.rb', line 23

def locales
  @locales
end

#merge_policyObject

Returns the value of attribute merge_policy.



23
24
25
# File 'lib/ad_localize/requests/export_request.rb', line 23

def merge_policy
  @merge_policy
end

#output_dirObject

Returns the value of attribute output_dir.



21
22
23
# File 'lib/ad_localize/requests/export_request.rb', line 21

def output_dir
  @output_dir
end

#output_pathObject

Returns the value of attribute output_path.



23
24
25
# File 'lib/ad_localize/requests/export_request.rb', line 23

def output_path
  @output_path
end

#platformsObject

Returns the value of attribute platforms.



23
24
25
# File 'lib/ad_localize/requests/export_request.rb', line 23

def platforms
  @platforms
end

#sheet_idsObject

Returns the value of attribute sheet_ids.



23
24
25
# File 'lib/ad_localize/requests/export_request.rb', line 23

def sheet_ids
  @sheet_ids
end

#skip_value_strippingObject

Returns the value of attribute skip_value_stripping.



23
24
25
# File 'lib/ad_localize/requests/export_request.rb', line 23

def skip_value_stripping
  @skip_value_stripping
end

#spreadsheet_idObject

Returns the value of attribute spreadsheet_id.



23
24
25
# File 'lib/ad_localize/requests/export_request.rb', line 23

def spreadsheet_id
  @spreadsheet_id
end

#verboseObject

Returns the value of attribute verbose.



23
24
25
# File 'lib/ad_localize/requests/export_request.rb', line 23

def verbose
  @verbose
end

Instance Method Details

#all_csv_pathsObject



129
130
131
# File 'lib/ad_localize/requests/export_request.rb', line 129

def all_csv_paths
  csv_paths + downloaded_csvs.map(&:path)
end

#has_csv_paths?Boolean

Returns:

  • (Boolean)


121
122
123
# File 'lib/ad_localize/requests/export_request.rb', line 121

def has_csv_paths?
  all_csv_paths.present?
end

#has_sheets?Boolean

Returns:

  • (Boolean)


117
118
119
# File 'lib/ad_localize/requests/export_request.rb', line 117

def has_sheets?
  spreadsheet_id.present?
end

#many_platforms?Boolean

Returns:

  • (Boolean)


125
126
127
# File 'lib/ad_localize/requests/export_request.rb', line 125

def many_platforms?
  platforms.size > 1
end

#to_sObject



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/ad_localize/requests/export_request.rb', line 133

def to_s
  "locales: #{locales}, " \
    "bypass_empty_values: #{bypass_empty_values}, " \
    "auto_escape_percent: #{auto_escape_percent}, " \
    "skip_value_stripping: #{skip_value_stripping}, " \
    "csv_paths: #{csv_paths}, " \
    "merge_policy: #{merge_policy}, " \
    "output_path: #{output_path}, " \
    "spreadsheet_id: #{spreadsheet_id}, " \
    "sheet_ids: #{sheet_ids}, " \
    "export_all: #{export_all}, " \
    "verbose: #{verbose}, " \
    "platforms: #{platforms}, " \
    "downloaded_csvs: #{downloaded_csvs}"
end