Class: AdLocalize::Requests::ExportRequest
- Inherits:
-
Object
- Object
- AdLocalize::Requests::ExportRequest
- Defined in:
- lib/ad_localize/requests/export_request.rb
Constant Summary collapse
- SUPPORTED_PLATFORMS =
%w(ios android yml json properties csv).freeze
- DEFAULT_EXPORT_FOLDER =
'exports'.freeze
- CSV_CONTENT_TYPES =
%w(text/csv text/plain application/csv).freeze
- EMPTY_CONTENT_TYPE =
'inode/x-empty'.freeze
Instance Attribute Summary collapse
-
#csv_paths ⇒ Object
Returns the value of attribute csv_paths.
-
#g_spreadsheet_options ⇒ Object
readonly
Returns the value of attribute g_spreadsheet_options.
-
#locales ⇒ Object
readonly
Returns the value of attribute locales.
-
#merge_policy ⇒ Object
readonly
Returns the value of attribute merge_policy.
-
#output_path ⇒ Object
readonly
Returns the value of attribute output_path.
-
#platforms ⇒ Object
readonly
Returns the value of attribute platforms.
-
#verbose ⇒ Object
readonly
Returns the value of attribute verbose.
Instance Method Summary collapse
- #has_csv_files? ⇒ Boolean
- #has_empty_files? ⇒ Boolean
- #has_g_spreadsheet_options? ⇒ Boolean
-
#initialize(**args) ⇒ ExportRequest
constructor
A new instance of ExportRequest.
- #multiple_platforms? ⇒ Boolean
- #valid? ⇒ Boolean
- #verbose? ⇒ Boolean
Constructor Details
#initialize(**args) ⇒ ExportRequest
Returns a new instance of ExportRequest.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ad_localize/requests/export_request.rb', line 9 def initialize(**args) @locales = Array(args[:locales].presence) @platforms = args[:platforms].blank? ? SUPPORTED_PLATFORMS : Array(args[:platforms]) @csv_paths = Array(args[:csv_paths]) @g_spreadsheet_options = args[:g_spreadsheet_options] @verbose = args[:verbose].presence || false @output_path = Pathname.new(args[:output_path].presence || DEFAULT_EXPORT_FOLDER) if @csv_paths.size > 1 || @g_spreadsheet_options&.has_multiple_sheets? @merge_policy = MergePolicy.new(policy: args[:merge_policy].presence || MergePolicy::DEFAULT_POLICY) else @merge_policy = nil end end |
Instance Attribute Details
#csv_paths ⇒ Object
Returns the value of attribute csv_paths.
32 33 34 |
# File 'lib/ad_localize/requests/export_request.rb', line 32 def csv_paths @csv_paths end |
#g_spreadsheet_options ⇒ Object (readonly)
Returns the value of attribute g_spreadsheet_options.
23 24 25 |
# File 'lib/ad_localize/requests/export_request.rb', line 23 def @g_spreadsheet_options end |
#locales ⇒ Object (readonly)
Returns the value of attribute locales.
23 24 25 |
# File 'lib/ad_localize/requests/export_request.rb', line 23 def locales @locales end |
#merge_policy ⇒ Object (readonly)
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_path ⇒ Object (readonly)
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 |
#platforms ⇒ Object (readonly)
Returns the value of attribute platforms.
23 24 25 |
# File 'lib/ad_localize/requests/export_request.rb', line 23 def platforms @platforms end |
#verbose ⇒ Object (readonly)
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
#has_csv_files? ⇒ Boolean
34 35 36 |
# File 'lib/ad_localize/requests/export_request.rb', line 34 def has_csv_files? !@csv_paths.blank? && @csv_paths.all? { |csv_path| File.exist?(csv_path) && is_csv?(path: csv_path) } end |
#has_empty_files? ⇒ Boolean
38 39 40 |
# File 'lib/ad_localize/requests/export_request.rb', line 38 def has_empty_files? !@csv_paths.blank? && @csv_paths.all? { |csv_path| File.exist?(csv_path) && is_empty?(path: csv_path) } end |
#has_g_spreadsheet_options? ⇒ Boolean
42 43 44 |
# File 'lib/ad_localize/requests/export_request.rb', line 42 def @g_spreadsheet_options.present? end |
#multiple_platforms? ⇒ Boolean
46 47 48 |
# File 'lib/ad_localize/requests/export_request.rb', line 46 def multiple_platforms? @platforms.size > 1 end |
#valid? ⇒ Boolean
50 51 52 |
# File 'lib/ad_localize/requests/export_request.rb', line 50 def valid? valid_platforms? && ( || ) end |
#verbose? ⇒ Boolean
54 55 56 |
# File 'lib/ad_localize/requests/export_request.rb', line 54 def verbose? verbose end |