Class: PgVerify::Cli::ShowCommand
- Inherits:
-
Thor
- Object
- Thor
- PgVerify::Cli::ShowCommand
- Defined in:
- lib/pg-verify/cli/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.select_components(only_arg, hide_arg, model) ⇒ Object
111 112 113 114 115 116 117 118 |
# File 'lib/pg-verify/cli/cli.rb', line 111 def self.select_components(only_arg, hide_arg, model) only = (only_arg || []).flatten.map(&:to_s).map(&:downcase) hide = (hide_arg || []).flatten.map(&:to_s).map(&:downcase) components = model.components.map(&:name) components = components.select { |c| only.include?(c.to_s.downcase) } unless only.empty? components = components.reject { |c| hide.include?(c.to_s.downcase) } unless hide.empty? return components end |
Instance Method Details
#json ⇒ Object
89 90 91 92 93 94 95 96 |
# File 'lib/pg-verify/cli/cli.rb', line 89 def json() models = CliUtils.load_models() models.each { |model| hash = Transform::HashTransformation.new.transform_graph(model) puts JSON.pretty_generate(hash) } end |
#nusmv ⇒ Object
102 103 104 105 106 107 108 109 |
# File 'lib/pg-verify/cli/cli.rb', line 102 def nusmv() models = CliUtils.load_models() models.each { |model| nusmv = Transform::NuSmvTransformation.new.transform_graph(model) puts nusmv } end |
#png ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/pg-verify/cli/cli.rb', line 50 def png() = { render_labels: ![:"hide-labels"], render_precons: ![:"hide-precons"], render_guards: ![:"hide-guards"], render_actions: ![:"hide-actions"] } models = CliUtils.load_models() models.each { |model| components = self.class.select_components([:only], [:hide], model) puml = Transform::PumlTransformation.new().transform_graph(model, only: components) png = PlantumlBuilder::Formats::PNG.new(puml).load out_name = model.name.to_s.gsub(/\W+/, '_').downcase + ".png" out_path = File.(out_name, Settings.outdir) FileUtils.mkdir_p(Settings.outdir) File.binwrite(out_path, png) puts "Wrote #{out_path.c_file}" } end |
#puml ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/pg-verify/cli/cli.rb', line 24 def puml() = { render_labels: ![:"hide-labels"], render_precons: ![:"hide-precons"], render_guards: ![:"hide-guards"], render_actions: ![:"hide-actions"] } models = CliUtils.load_models() models.each { |model| components = self.class.select_components([:only], [:hide], model) puml = Transform::PumlTransformation.new().transform_graph(model, only: components) puts puml } end |
#yaml ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/pg-verify/cli/cli.rb', line 76 def yaml() models = CliUtils.load_models() models.each { |model| hash = Transform::HashTransformation.new.transform_graph(model) puts hash.to_yaml } end |