Module: Canals

Extended by:
Canals
Included in:
Canals
Defined in:
lib/canals.rb,
lib/canals/cli.rb,
lib/canals/core.rb,
lib/canals/config.rb,
lib/canals/options.rb,
lib/canals/session.rb,
lib/canals/version.rb,
lib/canals/cli/list.rb,
lib/canals/cli/setup.rb,
lib/canals/repository.rb,
lib/canals/cli/helpers.rb,
lib/canals/cli/session.rb,
lib/canals/environment.rb,
lib/canals/tools/assets.rb,
lib/canals/cli/environment.rb,
lib/canals/tools/completion.rb

Overview

a gem for managing ssh tunnel connections

Defined Under Namespace

Modules: Cli, Tools Classes: CanalEnvironmentError, CanalOptionError, CanalOptions, Config, Environment, Repository, Session

Constant Summary collapse

VERSION =

Canals gem current version

"0.8.5"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



14
15
16
# File 'lib/canals.rb', line 14

def logger
  @logger
end

Class Method Details

.create_tunnel(tunnel_opts) ⇒ Object



6
7
8
# File 'lib/canals/core.rb', line 6

def create_tunnel(tunnel_opts)
  Canals.repository.add tunnel_opts
end

.isalive?(tunnel_opts) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
37
38
# File 'lib/canals/core.rb', line 33

def isalive?(tunnel_opts)
  if tunnel_opts.instance_of? String
    tunnel_opts = Canals.repository.get(tunnel_opts)
  end
  !!tunnel_pid(tunnel_opts)
end

.restart(tunnel_opts) ⇒ Object



28
29
30
31
# File 'lib/canals/core.rb', line 28

def restart(tunnel_opts)
  stop(tunnel_opts)
  start(tunnel_opts)
end

.start(tunnel_opts) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/canals/core.rb', line 10

def start(tunnel_opts)
  if tunnel_opts.instance_of? String
    tunnel_opts = Canals.repository.get(tunnel_opts)
  end
  tunnel_start(tunnel_opts)
  pid = tunnel_pid(tunnel_opts)
  Canals.session.add({name: tunnel_opts.name, pid: pid, socket: socket_file(tunnel_opts)})
  pid.to_i
end

.stop(tunnel_opts) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/canals/core.rb', line 20

def stop(tunnel_opts)
  if tunnel_opts.instance_of? String
    tunnel_opts = Canals.repository.get(tunnel_opts)
  end
  tunnel_close(tunnel_opts)
  Canals.session.del(tunnel_opts.name)
end

Instance Method Details

#configObject



16
17
18
19
# File 'lib/canals.rb', line 16

def config
  return @config if defined?(@config)
  @config = Config.new(File.join(Dir.home, '.canals'))
end

#environmentsObject



26
27
28
29
30
# File 'lib/canals.rb', line 26

def environments
  return @repository.environments if defined?(@repository)
  @repository = Repository.new
  @repository.environments
end

#repositoryObject



21
22
23
24
# File 'lib/canals.rb', line 21

def repository
  return @repository if defined?(@repository)
  @repository = Repository.new
end

#sessionObject



32
33
34
35
# File 'lib/canals.rb', line 32

def session
  return @session if defined?(@session)
  @session = Session.new
end