Class: Csa::Ccm::Cli::Command

Inherits:
Thor
  • Object
show all
Defined in:
lib/csa/ccm/cli/command.rb

Instance Method Summary collapse

Instance Method Details

#caiq2yaml(xslt_path) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/csa/ccm/cli/command.rb', line 46

def caiq2yaml(xslt_path)
  # if xslt_path.nil?
  #   puts 'Error: no filepath given as first argument.'
  #   exit 1
  # end

  # if Pathname.new(xslt_path).extname != ".xlsx"
  #   puts 'Error: filepath given must have extension .xlsx.'
  #   exit 1
  # end

  # workbook = Csa::Ccm::MatrixWorkbook.new(xslt_path)
  # workbook.glossary_info.metadata_section.structure
  # workbook.glossary_info.metadata_section.attributes

  # languages = {}

  # workbook.languages_supported.map do |lang|
  #   puts "************** WORKING ON LANGUAGE (#{lang})"
  #   sheet = workbook.language_sheet(lang)
  #   termsec = sheet.terms_section
  #   languages[sheet.language_code] = termsec.terms
  # end

  # collection = Csa::Ccm::ControlDomain.new

  # languages.each_pair do |lang, terms|
  #   terms.each do |term|
  #     collection.add_term(term)
  #   end
  # end

  # # collection[1206].inspect

  # # FIXME use  instea output dir
  # output_dir = options[:output_path] || Dir.pwd
  # output_file = options[:output_name] || File.join(output_dir, Pathname.new(filepath).basename.sub_ext(".yaml"))

  # collection.to_file(output_file)

  # collection_output_dir = File.join(output_dir, "concepts")

  # FileUtils.mkdir_p(collection_output_dir)

  # collection.keys.each do |id|
  #   collection[id].to_file(File.join(collection_output_dir, "concept-#{id}.yaml"))
  # end

  # french = workbook.language_sheet("French")
  # french.sections[3].structure
  # french.sections[3].terms

  # english = workbook.language_sheet("English")
  # english.terms_section
  # english.terms_section.terms

  #pry.binding
end

#ccm_yaml(version) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/csa/ccm/cli/command.rb', line 14

def ccm_yaml(version)
  input_files = Resource.lookup_version(version)

  unless input_files || !input_files.empty?
    UI.say("No file found for #{version} version")
    return
  end

  input_file = input_files.first

  unless File.exist? input_file
    UI.say('No file found for version')
    return
  end

  matrix = Matrix.from_xlsx(version, input_file)

  output_file = options[:output_file] || "caiq-#{version}.yaml"
  matrix.to_file(output_file)
end

#generate_with_answers(answers) ⇒ Object



107
108
109
# File 'lib/csa/ccm/cli/command.rb', line 107

def generate_with_answers(answers)
  raise 'Not implemented yet'
end

#xlsx2yaml(xslt_path) ⇒ Object



38
39
40
# File 'lib/csa/ccm/cli/command.rb', line 38

def xlsx2yaml(xslt_path)
  raise 'Not implemented yet'
end