Sha256: 9faf6da521404f064fdb9dcd6cb9dd0dc5536097595d5b3c6c86789e5033fb3d

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

# encoding: utf-8

require 'yaml'
require_relative '../formatter/question_hash_formatter'

# Use to export data from ConceptIA to YAML format
module ConceptAIYAMLExporter
  ##
  # Export array of ConceptAI objects from Project to YAML output file
  # @param concepts_ai (Array)
  # @param project (Project)
  def self.export_all(concepts_ai, project)
    questions = []
    concepts_ai.each do |concept_ai|
      questions += get_questions_from concept_ai
    end
    params = { lang: project.get(:lang) ,
               projectname: project.get(:projectname) }
    output = { params: params, questions: questions }
    project.get(:yamlfile).write(output.to_yaml)
  end

  private_class_method def self.get_questions_from(concept_ai)
    data = []
    return data unless concept_ai.process?

    Application.instance.config['questions']['stages'].each do |stage|
      concept_ai.questions[stage].each do |question|
        question.lang = concept_ai.lang
        data << QuestionHashFormatter.to_hash(question)
      end
    end
    data
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
asker-tool-2.1.7 lib/asker/exporter/concept_ai_yaml_exporter.rb
asker-tool-2.1.6 lib/asker/exporter/concept_ai_yaml_exporter.rb