Class: GovFakeNotify::Cli::Root

Inherits:
Thor
  • Object
show all
Defined in:
lib/gov_fake_notify/cli/root.rb

Overview

Root of all commands

Instance Method Summary collapse

Instance Method Details

#create_templateObject



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/gov_fake_notify/cli/root.rb', line 48

def create_template
  data = {
    id: options.template_id,
    message: File.read(options.path),
    name: options.name,
    subject: options.subject
  }
  res = Net::HTTP.post(URI("#{GovFakeNotify.config.base_url}/control/templates"), JSON.generate(data),
                       { 'Content-Type' => 'application/json', 'Accept' => 'application/json' })
  puts res.body
end

#startObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/gov_fake_notify/cli/root.rb', line 27

def start
  if options.config
    GovFakeNotify.config do |c|
      c.from(YAML.parse(File.read(options.config)).to_ruby.merge(options.slice(*(options.keys - ['config']))))
    end
  end

  conf = Puma::Configuration.new do |user_config|
    user_config.threads 1, 1
    user_config.workers 1
    user_config.port GovFakeNotify.config.port
    user_config.app { GovFakeNotify::RootApp }
  end
  Puma::Launcher.new(conf, log_writer: Puma::LogWriter.stdio).run
end