Class: Datadog::Statsd::Schema::Commands::Analyze

Inherits:
Dry::CLI::Command
  • Object
show all
Defined in:
lib/datadog/statsd/schema/commands/analyze.rb

Overview

Since:

  • 0.1.0

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.stderrObject

Since:

  • 0.1.0



12
13
14
# File 'lib/datadog/statsd/schema/commands/analyze.rb', line 12

def stderr
  @stderr
end

.stdoutObject

Since:

  • 0.1.0



12
13
14
# File 'lib/datadog/statsd/schema/commands/analyze.rb', line 12

def stdout
  @stdout
end

Instance Method Details

#call(**options) ⇒ void

This method returns an undefined value.

Parameters:

  • The options for the command

Options Hash (**options):

  • :file (String)

    The path to the schema file to analyze

  • :color (Boolean)

    Enable/Disable color output

Since:

  • 0.1.0



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/datadog/statsd/schema/commands/analyze.rb', line 29

def call(**options)
  file = options[:file]

  unless file
    warn "Error: --file option is required"
    warn "Usage: dss analyze --file <schema.rb>"
    exit 1
  end

  warn "Analyzing Schema File:"
  warn " • file   #{file.green}"
  warn " • color: #{(options[:color] ? "enabled" : "disabled").yellow}"
  warn " • formar #{options[:format].to_s.red}"
  @schema = ::Datadog::Statsd::Schema.load_file(file)
  ::Datadog::Statsd::Schema::Analyzer.new([@schema],
                                          format: (options[:format] || :text).to_sym,
                                          stdout: self.class.stdout,
                                          stderr: self.class.stderr,
                                          color: options[:color]).tap do |analyzer|
                                            puts analyzer.render
                                          end.analyze
end

#putsObject

Since:

  • 0.1.0



56
57
58
# File 'lib/datadog/statsd/schema/commands/analyze.rb', line 56

def puts(...)
  self.class.stdout.puts(...)
end

#warnObject

Since:

  • 0.1.0



52
53
54
# File 'lib/datadog/statsd/schema/commands/analyze.rb', line 52

def warn(...)
  self.class.stderr.puts(...)
end