Class: Jirify::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/jirify/config.rb

Class Method Summary collapse

Class Method Details

.always_verboseObject



41
42
43
# File 'lib/jirify/config.rb', line 41

def always_verbose
  options['verbose']
end

.atlassian_urlObject



45
46
47
# File 'lib/jirify/config.rb', line 45

def atlassian_url
  options['site']
end

.client_optionsObject



80
81
82
83
84
85
86
87
88
# File 'lib/jirify/config.rb', line 80

def client_options
  {
    username:     options['username'],
    password:     options['token'],
    site:         atlassian_url,
    context_path: '',
    auth_type:    :basic
  }
end

.config_fileObject



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

def config_file
  @config_file ||= "#{Dir.home}/.jirify"
end

.initialized?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/jirify/config.rb', line 6

def initialized?
  File.exist? config_file
end

.issue_browse_urlObject



53
54
55
# File 'lib/jirify/config.rb', line 53

def issue_browse_url
  "#{atlassian_url}/browse/"
end

.optionsObject



32
33
34
35
36
37
38
39
# File 'lib/jirify/config.rb', line 32

def options
  unless initialized?
    puts 'ERROR: You must initialize Jirify first!'.red
    exit(0)
  end

  @options ||= YAML.load_file(config_file)['options']
end

.statusesObject



57
58
59
60
61
62
63
64
65
# File 'lib/jirify/config.rb', line 57

def statuses
  options['statuses'] || {
    'blocked'     => 'Blocked',
    'todo'        => 'To Do',
    'in_progress' => 'In Progress',
    'in_review'   => 'In Review',
    'done'        => 'Closed'
  }
end

.transitionsObject



67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/jirify/config.rb', line 67

def transitions
  options['transitions'] || {
    'block'        => 'Blocked',
    'unblock'      => 'Unblock',
    'start'        => 'Start Progress',
    'stop'         => 'Stop Progress',
    'start_review' => 'Code Review',
    'stop_review'  => 'Back to In Progress',
    'close'        => 'Close',
    'reopen'       => 'Reopen'
  }
end

.usernameObject



49
50
51
# File 'lib/jirify/config.rb', line 49

def username
  options['username']
end

.verbose(value) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/jirify/config.rb', line 17

def verbose(value)
  unless initialized?
    puts 'ERROR: You must initialize Jirify first!'.red
    exit(0)
  end

  config = YAML.load_file(config_file)
  config['options']['verbose'] = value
  write(config)
end

.write(config) ⇒ Object



10
11
12
13
14
15
# File 'lib/jirify/config.rb', line 10

def write(config)
  puts 'Writing config:'
  puts config.to_yaml

  File.write(config_file, config.to_yaml)
end