Module: Orassh

Defined in:
lib/orassh/version.rb

Defined Under Namespace

Classes: Client=Module.new, CommandNotSpecified, ConfigNotFoundError, ConfigSyntaxError, GitHubTokenNotFoundError, MissingConfigItemError, MissingGistIdError, NgrokBadConfigError, NgrokNotFoundError, Server=Module.new, TunnelNotAvailable, TunnelsNotSpecifiedError, UnknownTunnelError

Constant Summary collapse

VERSION =
"0.1.1"
DEFAULT_NGROK_CONFIG =
case
when /cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM
 File.expand_path '~/AppData/Local/ngrok/ngrok.yml'
when /darwin/ =~ RUBY_PLATFORM
 File.expand_path '~/Library/Application Support/ngrok/ngrok.yml'
else
 File.expand_path '~/.config/ngrok/ngrok.yml'
end
DEFAULT_CONFIG =
"gist_id: YOUR_GIST_ID\ngist_filename: YOUR_FILENAME.json\nserver:\n  github_token: YOUR_GITHUB_TOKEN\n  ngrok_command: ngrok\n  ngrok_webhook_url: http://localhost:4040\n  ngrok_config:\n  - \"\#{Orassh::DEFAULT_NGROK_CONFIG}\"\nclient:\n  tunnels:\n    ssh:\n      command: ssh -p {PORT} {DOMAIN}\n    jupyter-notebook:\n      command: xdg-open {URL}\n"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject (readonly)

Returns the value of attribute config.



97
98
99
# File 'lib/orassh.rb', line 97

def config
  @config
end

.gist_filenameObject (readonly)

Returns the value of attribute gist_filename.



97
98
99
# File 'lib/orassh.rb', line 97

def gist_filename
  @gist_filename
end

.gist_idObject (readonly)

Returns the value of attribute gist_id.



97
98
99
# File 'lib/orassh.rb', line 97

def gist_id
  @gist_id
end

Class Method Details

.load_config(path) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/orassh.rb', line 99

def load_config path
  begin
    @config = YAML.load_file path
  rescue Errno::ENOENT
    raise Orassh::ConfigNotFoundError, "Config file is not found at #{path}"
  rescue JSON::ParserError => e
    raise Orassh::ConfigSyntaxError, e.message
  end
  unless @gist_id = @config['gist_id']
    raise Orassh::MissingGistIdError, '`gist_id` is not specified in config'
  end
  @gist_filename = @config['gist_filename'] || 'orassh.json'
end