Module: Doggy

Extended by:
Doggy
Included in:
Doggy
Defined in:
lib/doggy.rb,
lib/doggy/cli.rb,
lib/doggy/model.rb,
lib/doggy/version.rb,
lib/doggy/cli/edit.rb,
lib/doggy/cli/mute.rb,
lib/doggy/cli/pull.rb,
lib/doggy/cli/push.rb,
lib/doggy/cli/delete.rb,
lib/doggy/cli/unmute.rb,
lib/doggy/models/screen.rb,
lib/doggy/models/monitor.rb,
lib/doggy/models/dashboard.rb

Defined Under Namespace

Modules: Models Classes: CLI, DoggyError, Model

Constant Summary collapse

DOG_SKIP_REGEX =
/\xF0\x9F\x98\xB1|:scream:/i.freeze
MANAGED_BY_DOGGY_REGEX =
/\xF0\x9F\x90\xB6|:dog:/i.freeze
VERSION =
'2.0.41'

Instance Method Summary collapse

Instance Method Details

#api_keyObject



57
58
59
# File 'lib/doggy.rb', line 57

def api_key
  ENV['DATADOG_API_KEY'] || secrets['datadog_api_key']
end

#application_keyObject



61
62
63
# File 'lib/doggy.rb', line 61

def application_key
  ENV['DATADOG_APP_KEY'] || secrets['datadog_app_key']
end

#object_rootObject



40
41
42
# File 'lib/doggy.rb', line 40

def object_root
  @object_root ||= Pathname.new('objects').expand_path(repo_root)
end

#random_wordObject



28
29
30
# File 'lib/doggy.rb', line 28

def random_word
  (0...12).map { (97 + rand(26)).chr }.join
end

#repo_rootObject



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/doggy.rb', line 44

def repo_root
  # TODO: Raise error when root can't be found
  current_dir = Dir.pwd

  while current_dir != '/' do
    if File.exist?(File.join(current_dir, 'Gemfile')) then
      return Pathname.new(current_dir)
    else
      current_dir = File.expand_path('../', current_dir)
    end
  end
end

#resolve_path(path) ⇒ Object



65
66
67
68
69
70
71
# File 'lib/doggy.rb', line 65

def resolve_path(path)
  path     = Pathname.new(path)
  curr_dir = Pathname.new(Dir.pwd)
  resolved = object_root.relative_path_from(curr_dir)

  (curr_dir.expand_path(resolved + path) + path).to_s
end

#uiObject



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

def ui
  (defined?(@ui) && @ui) || (self.ui = Thor::Shell::Color.new)
end

#ui=(ui) ⇒ Object



36
37
38
# File 'lib/doggy.rb', line 36

def ui=(ui)
  @ui = ui
end