Class: QiitaMail::CliCore

Inherits:
Object
  • Object
show all
Defined in:
lib/qiita_mail/cli_core.rb

Instance Method Summary collapse

Constructor Details

#initializeCliCore

Returns a new instance of CliCore.



17
18
19
20
# File 'lib/qiita_mail/cli_core.rb', line 17

def initialize
  @settings = Settings.new
  @storage  = Storage.new
end

Instance Method Details

#deliverObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/qiita_mail/cli_core.rb', line 33

def deliver
  # ピックアップ
  puts "-- #{Time.now} --"
  puts "Pickup <---- Qiita.com"
  mail_body = pickup_and_format(:html)
  
  # メールの送信
  puts "Send mail -> #{@settings.email}"
  mailer = Mailer.new(@settings.email_from, @settings.email, mail_body)
  mailer.deliver
end

#file(format, filename = nil) ⇒ Object



45
46
47
48
49
50
51
52
53
54
# File 'lib/qiita_mail/cli_core.rb', line 45

def file(format, filename = nil)
  # ピックアップ
  puts "-- #{Time.now} --"
  puts "Pickup  <------ Qiita.com"
  mail_body = pickup_and_format(format)
  
  # ファイルに書き込み
  puts "Write '#{format.to_s}' -> #{filename}"
  write_or_puts(filename, mail_body)
end

#initObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/qiita_mail/cli_core.rb', line 22

def init
  if (@settings.empty?)
    @settings.save
    puts "Create -> #{Settings.default_filename}"
    puts "Please edit YAML settings!"
  else
    puts "Already exists '#{Settings.default_filename}'."
    puts "Please edit YAML settings!"
  end
end