class Rabbit::AuthorConfiguration
Attributes
email[RW]
logger[RW]
markup_language[RW]
name[RW]
rubygems_user[RW]
speaker_deck_user[RW]
Public Class Methods
new(logger=nil)
click to toggle source
# File lib/rabbit/author-configuration.rb, line 30 def initialize(logger=nil) @logger = logger || Logger.default clear end
Public Instance Methods
clear()
click to toggle source
# File lib/rabbit/author-configuration.rb, line 55 def clear @markup_language = nil @name = nil @email = nil @rubygems_user = nil @slideshare_user = nil @speaker_deck_user = nil end
load()
click to toggle source
# File lib/rabbit/author-configuration.rb, line 35 def load return unless File.exist?(path) conf = YAMLLoader.load(File.read(path)) clear merge!(conf) rescue format = _("Failed to read author configuration: %s: %s") @logger.error(format % [path, $!.message]) end
merge!(conf)
click to toggle source
# File lib/rabbit/author-configuration.rb, line 64 def merge!(conf) @markup_language = conf["markup_language"] || @markup_language @name = conf["name"] || @name @email = conf["email"] || @email @rubygems_user = conf["rubygems_user"] || @rubygems_user @slideshare_user = conf["slideshare_user"] || @slideshare_user @speaker_deck_user = conf["speaker_deck_user"] || @spearker_deck_user end
save()
click to toggle source
# File lib/rabbit/author-configuration.rb, line 45 def save create_directory(File.dirname(path)) create_file(path) do |conf_file| conf_file.print(to_yaml) end rescue format = _("Failed to write author configuration: %s: %s") @logger.error(format % [path, $!.message]) end
to_hash()
click to toggle source
# File lib/rabbit/author-configuration.rb, line 73 def to_hash { "markup_language" => @markup_language, "name" => @name, "email" => @email, "rubygems_user" => @rubygems_user, "slideshare_user" => @slideshare_user, "speaker_deck_user" => @speaker_deck_user, } end
to_yaml()
click to toggle source
# File lib/rabbit/author-configuration.rb, line 84 def to_yaml to_hash.to_yaml end
Private Instance Methods
path()
click to toggle source
# File lib/rabbit/author-configuration.rb, line 89 def path File.expand_path("~/.rabbit/author.yaml") end