This repository has been archived by the owner on Jun 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRakefile
79 lines (66 loc) · 1.5 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# coding: utf-8
require "colorize"
require "date"
require "octokit"
require "yaml"
require "os"
require "spacifier"
require "terminal-table"
# require "wunderlist"
Dir.glob('rake/**.rake').each do |f|
import f
end
def show_success
show_info("Success.")
end
def show_info(message)
puts "[INFO] #{message}".green
end
def show_message_on_article(level, message, article, highlight_item)
puts "[#{level}] #{message.capitalize}:"
article.each do |key, item|
line = case key
when :file_name
" Filename: #{article[:file_name]}"
when :index
" Item: #{article[:index]}"
when :title
" Title: #{article[:title]}"
when :link
" Link: #{article[:link]}"
when :referrer
" Referrer: #{article[:referrer]}"
when :comment
" Comment: #{article[:comment]}"
when :tags
" Tags: #{article[:tags]}"
end
if key == highlight_item
case level
when "ERROR"
line = line.red
when "WARNING"
line = line.yellow
end
end
puts line
end
end
def find_latest_weekly
Dir.entries("_weekly").reject do |entry|
entry == "." || entry == ".."
end.sort_by do |x|
Date.strptime(x.split("-weekly.md").at(0), "%Y-%m-%d").to_time.to_i
end.last
end
def get_access_token
access_token = ENV["ACCESS_TOKEN"]
if access_token == nil || access_token.empty?
puts "[ERROR] No ACCESS_TOKEN is set.".red
return false
end
access_token
end
def get_weekly_repo
"msbu-tech/weekly".freeze
end