Class: SnapshotUI::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/snapshot_ui/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_root_directory:, storage_directory:, web_url:, live_websocket_url:) ⇒ Configuration

Returns a new instance of Configuration.



10
11
12
13
14
15
# File 'lib/snapshot_ui/configuration.rb', line 10

def initialize(project_root_directory:, storage_directory:, web_url:, live_websocket_url:)
  @project_root_directory = project_root_directory
  @storage_directory = storage_directory
  @web_url = web_url
  @live_websocket_url = live_websocket_url
end

Instance Attribute Details

#live_websocket_urlObject

Returns the value of attribute live_websocket_url.



8
9
10
# File 'lib/snapshot_ui/configuration.rb', line 8

def live_websocket_url
  @live_websocket_url
end

#project_root_directoryObject



21
22
23
# File 'lib/snapshot_ui/configuration.rb', line 21

def project_root_directory
  Pathname.new(@project_root_directory) if @project_root_directory
end

#storage_directoryObject



17
18
19
# File 'lib/snapshot_ui/configuration.rb', line 17

def storage_directory
  Pathname.new(@storage_directory) if @storage_directory
end

#web_urlObject

Returns the value of attribute web_url.



8
9
10
# File 'lib/snapshot_ui/configuration.rb', line 8

def web_url
  @web_url
end

Instance Method Details

#exit_if_not_configured!Object

Raises:

  • (SystemExit)


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/snapshot_ui/configuration.rb', line 25

def exit_if_not_configured!
  return unless project_root_directory.nil? || storage_directory.nil? || web_url.nil?

  puts Colorize.red("Looks like SnapshotUI is not configured yet. Example configuration:\n")

  puts <<~CONFIG
    #{Colorize.green("SnapshotUI.configure do |config|")}
      #{Colorize.green('config.storage_directory = "/path/to/tmp/snapshot_ui"')} #{Colorize.red("# Current value is `#{storage_directory.inspect}`")}
      #{Colorize.green('config.project_root_directory = "/path/to/project/root"')} #{Colorize.red("# Current value is `#{project_root_directory.inspect}`")}
      #{Colorize.green("config.web_url = \"#{web_url}\"")} #{Colorize.red("# Current value is `#{web_url.inspect}`")}
    #{Colorize.green("end")}

  CONFIG

  raise SystemExit.new(1)
end