blog-tools 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/blog-tools/commands/generate.rb +2 -1
- data/lib/blog-tools/commands/lists.rb +33 -5
- data/lib/blog-tools/storage.rb +15 -14
- data/lib/blog-tools/version.rb +5 -0
- data.tar.gz.sig +0 -0
- metadata +2 -1
- metadata.gz.sig +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7653d790bc62101631922de1c8288efe77d7ec2563c1ed1a0822aca09010f3b0
|
|
4
|
+
data.tar.gz: dabe65fa231806eae07ed1e3a20b69a0dfa1c51074a033561c492848c366b024
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a8bca7ed225b601cf99e6a46f6169a1b747f30a3487e908524c4bbe98d01c7743f34e99e3433e5fbc55fdaa7e5461e656f6355351ad208c0cd19d1502d7c22a9
|
|
7
|
+
data.tar.gz: b4bf5beb81654f40805b3d68ef412abebf8befa235aa55a533e8f834b301ec4e9859abe82efcfaf47c7511617ca34564397d8f0c0a43b8020aa535d3642f4f9c
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
|
@@ -33,7 +33,8 @@ module BlogTools
|
|
|
33
33
|
content: options[:content] ? File.read(File.expand_path(options[:content])) : ''
|
|
34
34
|
)
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
dir_path = "#{options[:output]}/"
|
|
37
|
+
output_filename = options[:output] ? "#{dir_path}#{title}.md" : "#{title.downcase.strip.gsub(/\s+/, '_')}.md"
|
|
37
38
|
File.write(output_filename, result)
|
|
38
39
|
|
|
39
40
|
puts "[✓] Post generated at #{output_filename}"
|
|
@@ -18,6 +18,7 @@ module BlogTools
|
|
|
18
18
|
method_option :completed, type: :boolean, default: false, desc: 'Show only completed posts'
|
|
19
19
|
method_option :in_progress, type: :boolean, default: false, desc: 'show only in-progress posts'
|
|
20
20
|
method_option :status, type: :boolean, default: false, desc: 'Show post status as well'
|
|
21
|
+
# TODO: all option for all information about the post
|
|
21
22
|
def list(list)
|
|
22
23
|
return puts('[!] List not found') unless @lists[list]
|
|
23
24
|
|
|
@@ -72,7 +73,7 @@ module BlogTools
|
|
|
72
73
|
Storage.write_lists(@lists)
|
|
73
74
|
puts "[✓] Deleted '#{list}' list"
|
|
74
75
|
when 'n', ''
|
|
75
|
-
puts '[i] Cancelled.'
|
|
76
|
+
puts '[i] Cancelled deletion.'
|
|
76
77
|
else
|
|
77
78
|
puts '[!] Invalid input. Not deleting.'
|
|
78
79
|
end
|
|
@@ -92,22 +93,27 @@ module BlogTools
|
|
|
92
93
|
Storage.write_lists(@lists)
|
|
93
94
|
puts "[✓] Deleted '#{post_name}' post"
|
|
94
95
|
when 'n', ''
|
|
95
|
-
puts '[i] Cancelled.'
|
|
96
|
+
puts '[i] Cancelled deletion.'
|
|
96
97
|
else
|
|
97
98
|
puts '[!] Invalid input. Not deleting.'
|
|
98
99
|
end
|
|
99
100
|
end
|
|
100
101
|
|
|
101
|
-
desc 'update LIST POST', 'Update the status of a blog post idea
|
|
102
|
-
method_option :
|
|
102
|
+
desc 'update LIST POST', 'Update the status of a blog post idea'
|
|
103
|
+
method_option :completed, type: :boolean, default: false, desc: 'Mark as complete'
|
|
103
104
|
method_option :in_progress, type: :boolean, default: false, desc: 'Mark as in progress'
|
|
105
|
+
method_option :path, type: :string, desc: 'Path to the post contents'
|
|
106
|
+
method_option :tags, type: :array
|
|
104
107
|
def update(list, post_name)
|
|
108
|
+
unless options[:completed] || options[:in_progress] || options[:tags] || options[:path]
|
|
109
|
+
return puts('[!] Please specify a status. Type "blog-tools lists help update" for more info.')
|
|
110
|
+
end
|
|
105
111
|
return puts('[!] List not found') unless @lists[list]
|
|
106
112
|
return puts('[!] Post not found') unless @lists[list][:posts].key?(post_name)
|
|
107
113
|
|
|
108
114
|
post = @lists[list][:posts][post_name]
|
|
109
115
|
|
|
110
|
-
if options[:
|
|
116
|
+
if options[:completed]
|
|
111
117
|
if post[:completed]
|
|
112
118
|
puts('[!] Post already marked as complete')
|
|
113
119
|
else
|
|
@@ -124,9 +130,31 @@ module BlogTools
|
|
|
124
130
|
puts("[✓] Marked '#{post_name}' as in progress")
|
|
125
131
|
end
|
|
126
132
|
end
|
|
133
|
+
post[:tags] = options[:tags] if options[:tags]
|
|
134
|
+
puts "Added the following tags to the post: #{options[:tags]}" if options[:tags]
|
|
135
|
+
post[:path] = options[:path] if options[:path]
|
|
136
|
+
puts "The post content is located at: #{options[:path]}" if options[:path]
|
|
127
137
|
|
|
128
138
|
Storage.write_lists(@lists)
|
|
129
139
|
end
|
|
140
|
+
|
|
141
|
+
private
|
|
142
|
+
|
|
143
|
+
def show_statuses
|
|
144
|
+
if options[:status]
|
|
145
|
+
status =
|
|
146
|
+
if data[:completed]
|
|
147
|
+
'[✓]'
|
|
148
|
+
elsif data[:in_progress]
|
|
149
|
+
'[~]'
|
|
150
|
+
else
|
|
151
|
+
'[ ]'
|
|
152
|
+
end
|
|
153
|
+
puts "- #{status} #{item}"
|
|
154
|
+
else
|
|
155
|
+
puts "- #{item}"
|
|
156
|
+
end
|
|
157
|
+
end
|
|
130
158
|
end
|
|
131
159
|
end
|
|
132
160
|
end
|
data/lib/blog-tools/storage.rb
CHANGED
|
@@ -12,6 +12,18 @@ module BlogTools
|
|
|
12
12
|
CONFIG_FILE = File.join(CONFIG_DIR, 'config.yml')
|
|
13
13
|
TEMPLATES_DIR = File.join(CONFIG_DIR, 'templates/')
|
|
14
14
|
DEFAULT_TEMPLATE_FILE = File.join(TEMPLATES_DIR, 'post.md')
|
|
15
|
+
DEFAULT_TEMPLATE = <<~'MARKDOWN'
|
|
16
|
+
---
|
|
17
|
+
title: "<%= title %>"
|
|
18
|
+
date: <%= date %>
|
|
19
|
+
author: <%= author %>
|
|
20
|
+
tags: [<%= tags.map { |t| "\"#{t}\"" }.join(", ") %>]
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
# <%= title %>
|
|
24
|
+
|
|
25
|
+
<%= content %>
|
|
26
|
+
MARKDOWN
|
|
15
27
|
|
|
16
28
|
# Ensure required directories and files exist.
|
|
17
29
|
def self.setup!
|
|
@@ -52,6 +64,8 @@ module BlogTools
|
|
|
52
64
|
def self.create_config_file
|
|
53
65
|
return if File.exist?(CONFIG_FILE)
|
|
54
66
|
|
|
67
|
+
FileUtils.mkdir_p(File.dirname(CONFIG_FILE))
|
|
68
|
+
|
|
55
69
|
puts '[!] No configuration file found, generating now...'
|
|
56
70
|
|
|
57
71
|
default_config = {
|
|
@@ -66,20 +80,7 @@ module BlogTools
|
|
|
66
80
|
def self.create_default_template
|
|
67
81
|
return unless Dir.empty?(TEMPLATES_DIR)
|
|
68
82
|
|
|
69
|
-
|
|
70
|
-
---
|
|
71
|
-
title: "<%= title %>"
|
|
72
|
-
date: <%= date %>
|
|
73
|
-
author: <%= author %>
|
|
74
|
-
tags: [<%= tags.map { |t| "\"#{t}\"" }.join(", ") %>]
|
|
75
|
-
---
|
|
76
|
-
|
|
77
|
-
# <%= title %>
|
|
78
|
-
|
|
79
|
-
<%= content %>
|
|
80
|
-
MARKDOWN
|
|
81
|
-
|
|
82
|
-
File.write(DEFAULT_TEMPLATE_FILE, default_template)
|
|
83
|
+
File.write(DEFAULT_TEMPLATE_FILE, DEFAULT_TEMPLATE)
|
|
83
84
|
puts "[+] Created default template: #{DEFAULT_TEMPLATE_FILE}"
|
|
84
85
|
end
|
|
85
86
|
end
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: blog-tools
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Slavetomints
|
|
@@ -64,6 +64,7 @@ files:
|
|
|
64
64
|
- lib/blog-tools/commands/generate.rb
|
|
65
65
|
- lib/blog-tools/commands/lists.rb
|
|
66
66
|
- lib/blog-tools/storage.rb
|
|
67
|
+
- lib/blog-tools/version.rb
|
|
67
68
|
- lib/blog_tools.rb
|
|
68
69
|
homepage: https://rubygems.org/gems/blog-tools
|
|
69
70
|
licenses:
|
metadata.gz.sig
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
yKvKm�<Ҫ��nb�2X��z��2V��&����T��ͱU�X��צ��]�~k��5�p�Q ��ӊ�\�Y�[�:����H�9�_��Ca�Έ߳a���� �qybR?�Tt��h6r6����_+��!�$L�������B+B�1E.�5MJ��z�#��Qao�H,z��犠E�L���U:�v�m�}o�ޅ�D��OCy��b��������狓�/}�� 9$�j�S�}�H^��9�H|�}��x\��G�ƬB�Q����1�8\�'1g�*_�A��-n�nX
|
|
2
|
+
L
|