-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
29 lines (23 loc) · 754 Bytes
/
Rakefile
File metadata and controls
29 lines (23 loc) · 754 Bytes
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
require 'httparty'
require 'stringex'
desc "scrape a URL"
task :fetch_article, :url do |t, args|
end
desc %Q{Begin a new post in #{source_dir}/#{posts_dir}
usage: rake new_data["Some title"] }
task :new_data, :title do |t, args|
title = args.title
# mkdir_p "#{source_dir}/#{posts_dir}"
slug = title.to_url
filename = File.join(data_dir, sub_dir, slug) + ".yaml"
if File.exist?(filename)
abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
end
puts "Creating new data: #{filename}"
open(filename, 'w') do |f|
f.puts "---"
f.puts "title: \"#{title.gsub(/&/,'&')}\""
f.puts "created_at: #{Time.now.strftime('%Y-%m-%d %H:%M:%S %z')}"
f.puts "---"
end
end