Module: Instafavs::Config

Defined in:
lib/instafavs.rb

Class Method Summary collapse

Class Method Details

.instapaper_passwordObject



33
34
35
# File 'lib/instafavs.rb', line 33

def instapaper_password
  @config["instapaper_password"]
end

.instapaper_usernameObject



29
30
31
# File 'lib/instafavs.rb', line 29

def instapaper_username
  @config["instapaper_username"]
end

.last_seen_fav_idsObject



37
38
39
# File 'lib/instafavs.rb', line 37

def last_seen_fav_ids
  @last_seen_fav_ids ||= @config["last_seen_fav_ids"] || Set.new
end

.load!Object



20
21
22
23
# File 'lib/instafavs.rb', line 20

def load!
  raise "missing configuration file. run 'instafavs --configure'." unless File.exists?(CONFIG_FILENAME)
  @config = YAML.load_file(CONFIG_FILENAME)
end

.save!(config = nil) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/instafavs.rb', line 11

def save!(config=nil)
  config_to_save = config.nil? ? @config : config

  File.open(CONFIG_FILENAME, "w+") do |f|
    f.chmod(0600)
    f.write(YAML.dump(config_to_save))
  end
end

.twitter_usernameObject



25
26
27
# File 'lib/instafavs.rb', line 25

def twitter_username
  @config["twitter_username"]
end

.update_last_seen_fav_ids!(seen_fav_ids) ⇒ Object



41
42
43
44
# File 'lib/instafavs.rb', line 41

def update_last_seen_fav_ids!(seen_fav_ids)
  @config["last_seen_fav_ids"] = seen_fav_ids.to_a.join(",")
  save!
end