Class: RailsERD::CLI
- Inherits:
-
Object
- Object
- RailsERD::CLI
- Defined in:
- lib/rails_erd/cli.rb
Constant Summary collapse
- SYMBOL_OPTIONS =
Options that should be converted to symbols
%i[generator mermaid_style filetype notation orientation].freeze
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path, options) ⇒ CLI
constructor
A new instance of CLI.
- #start ⇒ Object
Constructor Details
#initialize(path, options) ⇒ CLI
Returns a new instance of CLI.
193 194 195 196 197 198 199 200 201 |
# File 'lib/rails_erd/cli.rb', line 193 def initialize(path, ) @path, @options = path, generator = [:generator] || RailsERD.[:generator] if generator == :mermaid require "rails_erd/diagram/mermaid" else require "rails_erd/diagram/graphviz" end end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
166 167 168 |
# File 'lib/rails_erd/cli.rb', line 166 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
166 167 168 |
# File 'lib/rails_erd/cli.rb', line 166 def path @path end |
Class Method Details
.start ⇒ Object
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/rails_erd/cli.rb', line 172 def start path = Choice.rest.first || Dir.pwd = Choice.choices.each_with_object({}) do |(key, value), opts| key_sym = key.to_sym if key.start_with? "no_" opts[key.gsub("no_", "").to_sym] = !value elsif value.to_s.include? "," opts[key_sym] = value.split(",").map(&:to_s) elsif SYMBOL_OPTIONS.include?(key_sym) && value.is_a?(String) opts[key_sym] = value.to_sym else opts[key_sym] = value end end if [:config_file] && [:config_file] != '' RailsERD. = RailsERD..merge(Config.load([:config_file])) end new(path, ).start end |
Instance Method Details
#start ⇒ Object
203 204 205 206 207 208 209 |
# File 'lib/rails_erd/cli.rb', line 203 def start load_application create_diagram rescue Exception => e $stderr.puts "Failed: #{e.class}: #{e.}" $stderr.puts e.backtrace.map { |t| " from #{t}" } if [:debug] end |