Class: Rabbit::AuthorConfiguration
- Inherits:
-
Object
- Object
- Rabbit::AuthorConfiguration
- Includes:
- GetText, PathManipulatable
- Defined in:
- lib/rabbit/author-configuration.rb
Constant Summary
Constants included from GetText
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#markup_language ⇒ Object
Returns the value of attribute markup_language.
-
#name ⇒ Object
Returns the value of attribute name.
-
#rubygems_user ⇒ Object
Returns the value of attribute rubygems_user.
-
#slideshare_user ⇒ Object
Returns the value of attribute slideshare_user.
-
#speaker_deck_user ⇒ Object
Returns the value of attribute speaker_deck_user.
Instance Method Summary collapse
- #clear ⇒ Object
-
#initialize(logger = nil) ⇒ AuthorConfiguration
constructor
A new instance of AuthorConfiguration.
- #load ⇒ Object
- #merge!(conf) ⇒ Object
- #save ⇒ Object
- #to_hash ⇒ Object
- #to_yaml ⇒ Object
Methods included from GetText
Constructor Details
#initialize(logger = nil) ⇒ AuthorConfiguration
Returns a new instance of AuthorConfiguration.
30 31 32 33 |
# File 'lib/rabbit/author-configuration.rb', line 30 def initialize(logger=nil) @logger = logger || Logger.default clear end |
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
28 29 30 |
# File 'lib/rabbit/author-configuration.rb', line 28 def email @email end |
#logger ⇒ Object
Returns the value of attribute logger.
27 28 29 |
# File 'lib/rabbit/author-configuration.rb', line 27 def logger @logger end |
#markup_language ⇒ Object
Returns the value of attribute markup_language.
28 29 30 |
# File 'lib/rabbit/author-configuration.rb', line 28 def markup_language @markup_language end |
#name ⇒ Object
Returns the value of attribute name.
28 29 30 |
# File 'lib/rabbit/author-configuration.rb', line 28 def name @name end |
#rubygems_user ⇒ Object
Returns the value of attribute rubygems_user.
29 30 31 |
# File 'lib/rabbit/author-configuration.rb', line 29 def rubygems_user @rubygems_user end |
#slideshare_user ⇒ Object
Returns the value of attribute slideshare_user.
29 30 31 |
# File 'lib/rabbit/author-configuration.rb', line 29 def @slideshare_user end |
#speaker_deck_user ⇒ Object
Returns the value of attribute speaker_deck_user.
29 30 31 |
# File 'lib/rabbit/author-configuration.rb', line 29 def speaker_deck_user @speaker_deck_user end |
Instance Method Details
#clear ⇒ Object
55 56 57 58 59 60 61 62 |
# 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 ⇒ Object
35 36 37 38 39 40 41 42 43 |
# 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, $!.]) end |
#merge!(conf) ⇒ Object
64 65 66 67 68 69 70 71 |
# 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 ⇒ Object
45 46 47 48 49 50 51 52 53 |
# 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, $!.]) end |
#to_hash ⇒ Object
73 74 75 76 77 78 79 80 81 82 |
# 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 ⇒ Object
84 85 86 |
# File 'lib/rabbit/author-configuration.rb', line 84 def to_yaml to_hash.to_yaml end |