Class: Jirify::Config

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

Class Method Summary collapse

Class Method Details

.atlassian_urlObject



26
27
28
# File 'lib/jirify/config.rb', line 26

def atlassian_url
  options['site']
end

.client_optionsObject



34
35
36
37
38
39
40
41
42
# File 'lib/jirify/config.rb', line 34

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

.config_fileObject



17
18
19
# File 'lib/jirify/config.rb', line 17

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.exists? config_file
end

.issue_browse_urlObject



30
31
32
# File 'lib/jirify/config.rb', line 30

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

.optionsObject

Raises:

  • (StandardError)


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

def options
  raise StandardError unless initialized?
  @options ||= YAML.load_file(config_file)['options']
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