Class: StructuredNoise::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/structured_noise/cli.rb

Instance Method Summary collapse

Constructor Details

#initialize(scriptname, args) ⇒ CLI

Returns a new instance of CLI.



3
4
5
# File 'lib/structured_noise/cli.rb', line 3

def initialize(scriptname, args)
  @options = StructuredNoise::Options.new(scriptname, args)
end

Instance Method Details

#die_if_no_schema!Object



23
24
25
26
27
28
29
30
# File 'lib/structured_noise/cli.rb', line 23

def die_if_no_schema!
  unless @options.schema
    puts "Please define a schema."
    puts ""
    puts @options.parser
    exit
  end
end

#operating_environmentObject



14
15
16
17
18
19
20
21
# File 'lib/structured_noise/cli.rb', line 14

def operating_environment
  @operating_environment ||=
    StructuredNoise::Generator.new(
      schema: @options.schema,
      base64: @options.base64,
      messages_per_second: @options.messages_per_second
  )
end

#run!Object



7
8
9
10
11
12
# File 'lib/structured_noise/cli.rb', line 7

def run!
  die_if_no_schema!

  operating_environment.load_schema
  operating_environment.generate_output
end