Class: Xumlidot::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/xumlidot/options.rb

Class Method Summary collapse

Class Method Details

.method_missing(m, *args, &block) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/xumlidot/options.rb', line 9

def self.method_missing(m, *args, &block)
  if @options.respond_to?(m)
    @options.send(m)
  else
    raise OptionsError.new("Unknown Option #{m}")
  end
end

.parse(args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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
# File 'lib/xumlidot/options.rb', line 17

def self.parse(args)
  @options = OpenStruct.new

  @options.title = 'Class Diagram'
  @options.model_name = 'My Model'
  @options.diagram_type = :dot
  @options.rails = false
  @options.debug = false
  @options.inheritance = true
  @options.composition = true
  @options.usage = true
  @options.split = 1
  @options.sequence = ''
  @options.exclude = ''

  ENV.delete("XUMLIDOT_DEBUG")

  opt_parser = OptionParser.new do |opts|
    opts.banner = "Usage: xumlidot.rb [options]"

    opts.separator ""
    opts.separator "Specific options:"

    opts.on("-t", "--title [TEXT]", "Title for the diagram") do |v|
      @options.title = v
    end

    opts.on("-m", "--model [TEXT]", "Model Name for the diagram") do |v|
      @options.model_name = v
    end

    opts.on("-d", "--dot", "Output diagram using dot (default)") do |v|
      @options.diagram_type = :dot
    end

    opts.on("-x", "--xmi", "Output diagram using xmi") do |v|
      @options.diagram_type = :xmi
    end

    opts.on("-d", "--debug", "Output debug information") do |v|
      @options.debug = true
      ENV["XUMLIDOT_DEBUG"] = '1'
    end

    opts.on("-i", "--no-inheritance", "Output inheritence links on the diagram") do |v|
      @options.inheritance = false
    end

    opts.on("-c", "--no-composition", "Output composition links on the diagram") do |v|
      @options.composition = false
    end

    opts.on("-r", "--rails", "Expect a Rails application") do |v|
      @options.rails = v
    end


    opts.on("-e", "--exclude [TEXT[", "Output usage links on the diagram") do |v|
      @options.exclude = v
    end

    opts.on("-u", "--[no-]usage", "Output usage links on the diagram") do |v|
      @options.usage = v
    end
    opts.separator ""

    opts.separator "Common options:"

    # No argument, shows at tail.  This will print an options summary.
    # Try it and see!
    opts.on_tail("-h", "--help", "Show this message") do
      puts opts
      exit
    end

    # Another typical switch to print the version.
    opts.on_tail("--version", "Show version") do
      puts ::Version.join('.')
      exit
    end
  end

  opt_parser.parse!(args)
  @options
end