Class: ConceptQL::CLI

Inherits:
Thor
  • Object
show all
Includes:
Sequelizer
Defined in:
lib/conceptql/cli.rb

Instance Method Summary collapse

Instance Method Details

#convert(file) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/conceptql/cli.rb', line 71

def convert(file)
  require 'conceptql/converter'
  require 'json'
  begin
    puts JSON.pretty_generate(ConceptQL::Converter.new.convert(criteria_from_file(file)))
  rescue
    puts "Couldn't convert #{file}"
    puts $!.message
    puts $!.backtrace.join("\n")
  end
end

#fake_graph(file) ⇒ Object



59
60
61
62
63
# File 'lib/conceptql/cli.rb', line 59

def fake_graph(file)
  require_relative 'fake_grapher'
  ConceptQL::FakeGrapher.new.graph_it(criteria_from_file(file), '/tmp/graph')
  system('open /tmp/graph.pdf')
end

#metadataObject



66
67
68
# File 'lib/conceptql/cli.rb', line 66

def 
  File.write('/tmp/metadata.js', "var metadata = #{ConceptQL::Nodifier.new.to_metadata.to_json};")
end

#run_statement(statement_file) ⇒ Object



38
39
40
41
42
43
# File 'lib/conceptql/cli.rb', line 38

def run_statement(statement_file)
  q = ConceptQL::Query.new(db(options), criteria_from_file(statement_file))
  puts q.sql
  puts q.statement.to_yaml
  pp q.all
end

#show_and_tell_file(file) ⇒ Object



54
55
56
# File 'lib/conceptql/cli.rb', line 54

def show_and_tell_file(file)
  show_and_tell(criteria_from_file(file), options)
end

#show_graph(file) ⇒ Object



47
48
49
# File 'lib/conceptql/cli.rb', line 47

def show_graph(file)
  graph_it(criteria_from_file(file))
end