Class: Git::Nebenan::Commands::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/git/nebenan/commands/command.rb

Direct Known Subclasses

Checkout, Config, Open

Instance Method Summary collapse

Instance Method Details

#configObject



5
6
7
8
9
10
11
12
13
14
# File 'lib/git/nebenan/commands/command.rb', line 5

def config
  @config ||= begin
    config = TTY::Config.new
    config.filename = ".git-nebenan"
    config.extname = ".toml"
    config.append_path Dir.home
    config.read if config.exist?
    config
  end
end

#jira_clientObject



20
21
22
23
24
25
26
27
28
# File 'lib/git/nebenan/commands/command.rb', line 20

def jira_client
  @jira_client ||= JIRA::Client.new(
    username:      config.fetch('jira.username'),
    password:      config.fetch('jira.password'),
    site:          config.fetch('jira.site'),
    context_path:  '',
    auth_type:     :basic,
  )
end

#loggerObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/git/nebenan/commands/command.rb', line 30

def logger
  @logger ||= TTY::Logger.new do |log|
    log.types = {
      remote:  { level: :info },
      local:   { level: :info },
      create:  { level: :info },
      command: { level: :info },
    }
    log.handlers = [
      [
        :console,
        {
          styles: {
            remote: { symbol: "", label: "remote", color: :yellow, levelpad: 0 },
            local: { symbol: "", label: "local", color: :green, levelpad: 0 },
            create: { symbol: "+", label: "create", color: :blue, levelpad: 0 },
            command: { symbol: " ", label: "   ", color: :dim, levelpad: 0 },
          }
        }
      ]
    ]
  end
end

#platformObject



54
55
56
# File 'lib/git/nebenan/commands/command.rb', line 54

def platform
  @platform ||= TTY::Platform.new
end

#promptObject



16
17
18
# File 'lib/git/nebenan/commands/command.rb', line 16

def prompt
  @prompt ||= TTY::Prompt.new(help_color: :cyan)
end