Class: Apiwork::Export::Pipeline
- Inherits:
-
Object
- Object
- Apiwork::Export::Pipeline
- Defined in:
- lib/apiwork/export/pipeline.rb,
lib/apiwork/export/pipeline/writer.rb
Defined Under Namespace
Classes: Writer
Class Method Summary collapse
- .clean(output:) ⇒ Object
- .generate(export_name, api_base_path, format: nil, key_format: nil, locale: nil, version: nil) ⇒ Object
- .write(api_base_path: nil, export_name: nil, format: nil, key_format: nil, locale: nil, output:, version: nil) ⇒ Object
Class Method Details
.clean(output:) ⇒ Object
47 48 49 50 51 |
# File 'lib/apiwork/export/pipeline.rb', line 47 def clean(output:) raise ArgumentError, 'output path required' unless output Writer.clean(output:) end |
.generate(export_name, api_base_path, format: nil, key_format: nil, locale: nil, version: nil) ⇒ Object
7 8 9 |
# File 'lib/apiwork/export/pipeline.rb', line 7 def generate(export_name, api_base_path, format: nil, key_format: nil, locale: nil, version: nil) Export.generate(export_name, api_base_path, format:, key_format:, locale:, version:) end |
.write(api_base_path: nil, export_name: nil, format: nil, key_format: nil, locale: nil, output:, version: nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/apiwork/export/pipeline.rb', line 11 def write(api_base_path: nil, export_name: nil, format: nil, key_format: nil, locale: nil, output:, version: nil) raise ArgumentError, 'output path required' unless output if Writer.file_path?(output) && (api_base_path.nil? || export_name.nil?) raise ArgumentError, 'api_base_path and export_name required when output is a file' end api_classes = api_base_path ? [find_api_class(api_base_path)] : API.values start_time = Time.zone.now count = 0 Rails.logger.debug 'Generating artifacts...' api_classes.each do |api_class| available_exports = export_name ? [export_name.to_sym] : api_class.export_configs.keys available_exports.each do |name| count += generate_file( api_class:, format:, key_format:, locale:, output:, version:, export_name: name, ) end end Rails.logger.debug "\nGenerated #{count} file#{count == 1 ? '' : 's'} in #{(Time.zone.now - start_time).round(2)}s" count end |