-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
46 lines (36 loc) · 858 Bytes
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#
# HatenaDiary
#
require File.join(File.dirname(__FILE__), 'hatena_diary')
client = nil
task :default => :environment
task :environment do
require "highline"
hatena_id = ENV['ID']
passwd = ENV['PW']
if hatena_id.nil? or hatena_id.empty?
hatena_id = HighLine.new.ask('ID: ')
end
if passwd.nil? or passwd.empty?
passwd = HighLine.new.ask('Password: ') {|q| q.echo = '*' }
end
client = HatenaDiary::Client.new hatena_id, passwd
end
namespace :draft do
task :delete => :environment do
HatenaDiary::Entry.entry_files do |f|
HatenaDiary::Entry.delete(f)
end
end
task :pull => :delete do
client.list(false).each do |e|
e.save
end
end
task :push => :environment do
HatenaDiary::Entry.entry_files do |f|
entry = HatenaDiary::Entry.load(f)
client.update(entry)
end
end
end