Class: Structurizr::REPL::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/structurizr/repl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Application

Returns a new instance of Application.



37
38
39
# File 'lib/structurizr/repl.rb', line 37

def initialize(argv)
  @argv = argv
end

Instance Attribute Details

#argvObject (readonly)

Returns the value of attribute argv.



35
36
37
# File 'lib/structurizr/repl.rb', line 35

def argv
  @argv
end

#contextObject (readonly)

Returns the value of attribute context.



35
36
37
# File 'lib/structurizr/repl.rb', line 35

def context
  @context
end

#workspace_pathObject (readonly)

Returns the value of attribute workspace_path.



35
36
37
# File 'lib/structurizr/repl.rb', line 35

def workspace_path
  @workspace_path
end

Instance Method Details

#parse_workspace_path!Object



41
42
43
44
45
46
47
48
49
50
# File 'lib/structurizr/repl.rb', line 41

def parse_workspace_path!
  @workspace_path =
    if (input_path = argv.first) && File.file?(input_path)
      argv.first
    else
      puts 'Usage: structurizr-repl <path/to/structurizr.json>'

      raise InvalidWorkspaceFileError, 'Please specify a valid path'
    end
end

#prepare_context!Object



52
53
54
55
56
57
58
# File 'lib/structurizr/repl.rb', line 52

def prepare_context!
  @context = Structurizr::REPL::Context.new(
    Structurizr::Workspace.from_json(
      File.read(workspace_path)
    )
  )
end

#setup_pry!Object



60
61
62
63
# File 'lib/structurizr/repl.rb', line 60

def setup_pry!
  setup_welcome_message
  register_commands
end

#startObject



65
66
67
# File 'lib/structurizr/repl.rb', line 65

def start
  Pry.start(context)
end