Class: Settings

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/settings.rb

Instance Method Summary collapse

Constructor Details

#initializeSettings

Returns a new instance of Settings.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/settings.rb', line 8

def initialize
  @config_file = File.join(
    Dir.home,
    '.git_review.yml'
  )

  @config = if File.exists?(@config_file)
    YAML.load_file(@config_file) || {}
  else
    {}
  end
end

Instance Method Details

#oauth_tokenObject



31
32
33
# File 'lib/settings.rb', line 31

def oauth_token
  @config['oauth_token']
end

#oauth_token=(token) ⇒ Object



35
36
37
# File 'lib/settings.rb', line 35

def oauth_token=(token)
  @config['oauth_token'] = token
end

#review_modeObject



27
28
29
# File 'lib/settings.rb', line 27

def review_mode
  @config['review_mode']
end

#save!Object



21
22
23
24
25
# File 'lib/settings.rb', line 21

def save!
  File.open(@config_file, 'w') do |file|
    file.write(YAML.dump(@config))
  end
end

#usernameObject



39
40
41
# File 'lib/settings.rb', line 39

def username
  @config['username']
end

#username=(username) ⇒ Object



43
44
45
# File 'lib/settings.rb', line 43

def username=(username)
  @config['username'] = username
end