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).freeze
- DEFAULT_EXPORT_FOLDER =
'exports'.freeze
- CSV_CONTENT_TYPES =
%w(text/csv text/plain application/csv).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_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.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ad_localize/requests/export_request.rb', line 8 def initialize(**args) @locales = Array(args[:locales].presence) @platforms = args[:platforms].blank? ? SUPPORTED_PLATFORMS : Array(args[:platforms]) @csv_paths = Array(args[:csv_paths]) = 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 || &.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.
31 32 33 |
# File 'lib/ad_localize/requests/export_request.rb', line 31 def csv_paths @csv_paths end |
#g_spreadsheet_options ⇒ Object (readonly)
Returns the value of attribute g_spreadsheet_options.
22 23 24 |
# File 'lib/ad_localize/requests/export_request.rb', line 22 def end |
#locales ⇒ Object (readonly)
Returns the value of attribute locales.
22 23 24 |
# File 'lib/ad_localize/requests/export_request.rb', line 22 def locales @locales end |
#merge_policy ⇒ Object (readonly)
Returns the value of attribute merge_policy.
22 23 24 |
# File 'lib/ad_localize/requests/export_request.rb', line 22 def merge_policy @merge_policy end |
#output_path ⇒ Object (readonly)
Returns the value of attribute output_path.
22 23 24 |
# File 'lib/ad_localize/requests/export_request.rb', line 22 def output_path @output_path end |
#platforms ⇒ Object (readonly)
Returns the value of attribute platforms.
22 23 24 |
# File 'lib/ad_localize/requests/export_request.rb', line 22 def platforms @platforms end |
#verbose ⇒ Object (readonly)
Returns the value of attribute verbose.
22 23 24 |
# File 'lib/ad_localize/requests/export_request.rb', line 22 def verbose @verbose end |
Instance Method Details
#has_csv_files? ⇒ Boolean
33 34 35 |
# File 'lib/ad_localize/requests/export_request.rb', line 33 def has_csv_files? !@csv_paths.blank? && @csv_paths.all? { |csv_path| File.exist?(csv_path) && is_csv?(path: csv_path) } end |
#has_g_spreadsheet_options? ⇒ Boolean
37 38 39 |
# File 'lib/ad_localize/requests/export_request.rb', line 37 def .present? end |
#multiple_platforms? ⇒ Boolean
41 42 43 |
# File 'lib/ad_localize/requests/export_request.rb', line 41 def multiple_platforms? @platforms.size > 1 end |
#valid? ⇒ Boolean
45 46 47 |
# File 'lib/ad_localize/requests/export_request.rb', line 45 def valid? valid_platforms? && ( || ) end |
#verbose? ⇒ Boolean
49 50 51 |
# File 'lib/ad_localize/requests/export_request.rb', line 49 def verbose? verbose end |