Class: Idid::Configuration
- Inherits:
-
Object
- Object
- Idid::Configuration
- Defined in:
- lib/idid/configuration.rb
Constant Summary collapse
- SMTP_DEFAULTS =
{ :address => 'smtp.gmail.com', :port => '587', :user_name => ENV['GMAIL_SMTP_USER'], :password => ENV['GMAIL_SMTP_PASSWORD'], :authentication => :plain, :enable_starttls_auto => true }
- EXIM_DEFAULTS =
{ :location => '/usr/bin/exim' }
Instance Attribute Summary collapse
-
#delivery ⇒ Object
Public: Email delivery configuration.
-
#email ⇒ Object
Public: Email address String to use when sending mail.
-
#project ⇒ Object
Public: Name of the project to post to (e.g. project.idonethis.com).
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Configuration
constructor
Public: configuration to use with iDoneThis.
- #read_config ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Configuration
Public: configuration to use with iDoneThis
options - Hash with configuration options
project - Name of the project to post to (e.g.
project.idonethis.com)
email - Email address to use when sending mail.
delivery - Email delivery configuration Hash:
method - Symbol (:smtp|:sendmail|:exim)
options - Configuration Hash for the
delivery method (see:
https://github.com/mikel/mail).
Returns a new Idid::Configuration instance
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/idid/configuration.rb', line 37 def initialize = {} = .merge(read_config) if read_config raise ArgumentError.new("Provide a project to use.") unless ['project'] raise ArgumentError.new("Provide an email address.") unless ['email'] raise ArgumentError.new("Provide a delivery method.") unless ['delivery'] @project = ['project'] @email = ['email'] @delivery = ['delivery'] end |
Instance Attribute Details
#delivery ⇒ Object
Public: Email delivery configuration
22 23 24 |
# File 'lib/idid/configuration.rb', line 22 def delivery @delivery end |
#email ⇒ Object
Public: Email address String to use when sending mail.
20 21 22 |
# File 'lib/idid/configuration.rb', line 20 def email @email end |
#project ⇒ Object
Public: Name of the project to post to (e.g. project.idonethis.com)
18 19 20 |
# File 'lib/idid/configuration.rb', line 18 def project @project end |
Class Method Details
.config_file ⇒ Object
70 71 72 |
# File 'lib/idid/configuration.rb', line 70 def self.config_file File.join( ENV['HOME'], '.idid.yml' ) end |
.read_config ⇒ Object
64 65 66 67 68 |
# File 'lib/idid/configuration.rb', line 64 def self.read_config if File.exist? config_file config = YAML.load_file config_file end end |
Instance Method Details
#read_config ⇒ Object
60 61 62 |
# File 'lib/idid/configuration.rb', line 60 def read_config @config ||= self.class.read_config end |
#write ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/idid/configuration.rb', line 48 def write config = { 'project' => project, 'email' => email, 'delivery' => delivery } File.open(self.class.config_file, 'w') do |f| f.write config.to_yaml end end |