mr_poole 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +5 -0
- data/README.md +2 -1
- data/lib/mr_poole/cli.rb +46 -39
- data/lib/mr_poole/commands.rb +2 -2
- data/lib/mr_poole/helper.rb +16 -0
- data/lib/mr_poole/version.rb +1 -1
- data/spec/command_spec.rb +71 -81
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0bb58fc7fc0fff02dd0be8fae3c1de6a74dd8a4
|
4
|
+
data.tar.gz: 7b4e5d81046fe6e405948da87c791745b22aa453
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 663fca7eb25273cae3c580d32ec9ae7c33b5cb44458ddba6558c5b0ee1b17894a0c950e6970d7c5ad19dad89f1466f49f6d43924b8795e626df947bc9ab46df7
|
7
|
+
data.tar.gz: cecba65c4d0ff57bc87ea30796cf4b1e69911a4c030712c11b30bdd967c5307e747297a78ed4cc818ee60772bddc69cda878fab434d913ee4fd83487c927c2a5
|
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -21,7 +21,7 @@ Mr. Poole is primarily a command-line application: the gem installs an
|
|
21
21
|
executable called `poole` in your path. It has four subcommands: post, draft,
|
22
22
|
publish, and unpublish. All four of these commands echo a filename to STDOUT,
|
23
23
|
so you can do something like `poole post "Title" | vim` and start editing
|
24
|
-
immediately.
|
24
|
+
immediately. Alternatively, you can also have Mr. Poole auto open new posts in your preferred `$EDITOR` (see [Configuration](#configuration)).
|
25
25
|
|
26
26
|
### Post
|
27
27
|
|
@@ -128,6 +128,7 @@ should provide a `poole` key, which may take the following subkeys:
|
|
128
128
|
- `default_layout` - path to a default layout to use
|
129
129
|
- `default_extension` - file extension to use
|
130
130
|
- `word_separator` - character to use for slug generation
|
131
|
+
- `auto_open` - set to `true`to automatically open new posts in your `$EDITOR`
|
131
132
|
|
132
133
|
Any options you provide in `_config.yml` will override poole's built-in
|
133
134
|
defaults. Mr. Poole defaults to using Markdown (with extension "md"), and the
|
data/lib/mr_poole/cli.rb
CHANGED
@@ -30,56 +30,40 @@ module MrPoole
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def handle_post
|
33
|
-
|
34
|
-
options.title ||= @params.first
|
35
|
-
|
36
|
-
@helper.post_usage unless options.title
|
37
|
-
fn = @commands.post(options)
|
38
|
-
puts "#{@src_dir}/#{fn}"
|
33
|
+
do_create('post')
|
39
34
|
end
|
40
35
|
|
41
36
|
def handle_draft
|
42
|
-
|
43
|
-
options.title ||= @params.first
|
44
|
-
|
45
|
-
@helper.draft_usage unless options.title
|
46
|
-
fn = @commands.draft(options)
|
47
|
-
puts "#{@src_dir}/#{fn}"
|
37
|
+
do_create('draft')
|
48
38
|
end
|
49
39
|
|
50
40
|
def handle_publish
|
51
|
-
|
52
|
-
opt_parser = OptionParser.new do |opts|
|
53
|
-
opts.on('-d', '--keep-draft', "Keep the draft post") do |d|
|
54
|
-
options.keep_draft = d
|
55
|
-
end
|
56
|
-
opts.on('-t', '--keep-timestamp', "Keep the existing timestamp") do |t|
|
57
|
-
options.keep_timestamp = t
|
58
|
-
end
|
59
|
-
end
|
60
|
-
opt_parser.parse! @params
|
61
|
-
|
62
|
-
path = @params.first
|
63
|
-
@helper.publish_usage unless path
|
64
|
-
fn = @commands.publish(path, options)
|
65
|
-
puts "#{@src_dir}/#{fn}"
|
41
|
+
do_move('publish')
|
66
42
|
end
|
67
43
|
|
68
44
|
def handle_unpublish
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
45
|
+
do_move('unpublish')
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
# action is a string, either 'post' or 'draft'
|
51
|
+
def do_create(action)
|
52
|
+
options = do_creation_options
|
53
|
+
options.title ||= @params.first
|
54
|
+
|
55
|
+
@helper.send("#{action}_usage") unless options.title
|
56
|
+
fn = @commands.send(action, options)
|
57
|
+
puts "#{@src_dir}/#{fn}"
|
58
|
+
end
|
79
59
|
|
60
|
+
# action is a string, either 'publish' or 'unpublish'
|
61
|
+
def do_move(action)
|
62
|
+
options = do_move_options(action)
|
80
63
|
path = @params.first
|
81
|
-
|
82
|
-
|
64
|
+
|
65
|
+
@helper.send("#{action}_usage") unless path
|
66
|
+
fn = @commands.send(action, path, options)
|
83
67
|
puts "#{@src_dir}/#{fn}"
|
84
68
|
end
|
85
69
|
|
@@ -109,5 +93,28 @@ module MrPoole
|
|
109
93
|
options
|
110
94
|
end
|
111
95
|
|
96
|
+
# pass a string, either publish or unpublish
|
97
|
+
def do_move_options(type)
|
98
|
+
options = OpenStruct.new
|
99
|
+
opt_parser = OptionParser.new do |opts|
|
100
|
+
if type == 'publish'
|
101
|
+
opts.on('-d', '--keep-draft', "Keep draft post") do |d|
|
102
|
+
options.keep_draft = d
|
103
|
+
end
|
104
|
+
else
|
105
|
+
opts.on('-p', '--keep-post', "Do not delete post") do |p|
|
106
|
+
options.keep_post = p
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
opts.on('-t', '--keep-timestamp', "Keep existing timestamp") do |t|
|
111
|
+
options.keep_timestamp = t
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
opt_parser.parse! @params
|
116
|
+
options
|
117
|
+
end
|
118
|
+
|
112
119
|
end
|
113
120
|
end
|
data/lib/mr_poole/commands.rb
CHANGED
@@ -34,7 +34,7 @@ module MrPoole
|
|
34
34
|
f = File.open(path, "w")
|
35
35
|
f.write(head)
|
36
36
|
f.close
|
37
|
-
|
37
|
+
@helper.open_in_editor(path) # open file if config key set
|
38
38
|
path # return the path, in case we want to do anything useful
|
39
39
|
end
|
40
40
|
|
@@ -62,7 +62,7 @@ module MrPoole
|
|
62
62
|
f = File.open(path, "w")
|
63
63
|
f.write(head)
|
64
64
|
f.close
|
65
|
-
|
65
|
+
@helper.open_in_editor(path) # open file if config key set
|
66
66
|
path # return the path, in case we want to do anything useful
|
67
67
|
end
|
68
68
|
|
data/lib/mr_poole/helper.rb
CHANGED
@@ -89,6 +89,22 @@ module MrPoole
|
|
89
89
|
exit
|
90
90
|
end
|
91
91
|
|
92
|
+
def open_in_editor(path)
|
93
|
+
# don't do anything if the user hasn't explicitly enabled the feature
|
94
|
+
return unless @config.auto_open
|
95
|
+
|
96
|
+
if editor = ENV['EDITOR']
|
97
|
+
`#{editor} #{path}`
|
98
|
+
else
|
99
|
+
puts "You have enabled the auto_open feature in your config.yml,"
|
100
|
+
puts "but have no editor configured."
|
101
|
+
puts ''
|
102
|
+
puts "Please set your $EDITOR environment variable to the "
|
103
|
+
puts "editor that poole should use to open new posts/drafts."
|
104
|
+
puts ''
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
92
108
|
def version_statement
|
93
109
|
puts ''
|
94
110
|
puts "This is Mr. Poole, version #{MrPoole::VERSION}, running on ruby version #{RUBY_VERSION}"
|
data/lib/mr_poole/version.rb
CHANGED
data/spec/command_spec.rb
CHANGED
@@ -13,44 +13,44 @@ module MrPoole
|
|
13
13
|
|
14
14
|
describe "#post" do
|
15
15
|
context 'title only' do
|
16
|
-
it "
|
16
|
+
it "creates a new post in the _posts directory" do
|
17
17
|
fn = c.post({:title => "test_post"})
|
18
18
|
expect(File.exists?(fn)).to be_true
|
19
19
|
end
|
20
20
|
|
21
|
-
it "
|
21
|
+
it "returns path to the newly created post" do
|
22
22
|
returned = c.post({:title => "test_post"})
|
23
23
|
determined = Dir.glob("_posts/*.md").first
|
24
24
|
expect(returned).to eq(determined)
|
25
25
|
end
|
26
26
|
|
27
|
-
it "
|
27
|
+
it "creates a timestamped post in the _posts directory" do
|
28
28
|
fn = c.post({:title => "test_post" })
|
29
29
|
expect(fn).to match(/#{date_regex}-test_post[.]md$/)
|
30
30
|
end
|
31
31
|
|
32
|
-
it "
|
32
|
+
it "downcases a title" do
|
33
33
|
fn = c.post({:title => "Test_Post_With_Uppercase"})
|
34
34
|
expect(fn).to match(/#{date_regex}-test_post_with_uppercase[.]md/)
|
35
35
|
end
|
36
36
|
|
37
|
-
it "
|
37
|
+
it "subs underscores for spaces in title" do
|
38
38
|
fn = c.post({:title => "Test Post with Spaces"})
|
39
39
|
expect(fn).to match(/#{date_regex}-test_post_with_spaces[.]md/)
|
40
40
|
end
|
41
41
|
|
42
|
-
it "
|
42
|
+
it "removes non-word characters for slug" do
|
43
43
|
fn = c.post({:title => "On (function() {}()) in JavaScript"})
|
44
44
|
expect(fn).to match(/#{date_regex}-on_function_in_javascript[.]md/)
|
45
45
|
end
|
46
46
|
|
47
|
-
it "
|
47
|
+
it "updates the title in the file itself" do
|
48
48
|
fn = c.post({:title => "Testing Post {}"})
|
49
49
|
content = File.open(fn, 'r').read
|
50
50
|
expect(content).to match(/title: Testing Post \{\}/)
|
51
51
|
end
|
52
52
|
|
53
|
-
it "
|
53
|
+
it "updates the date in the file itself" do
|
54
54
|
fn = c.post({:title => "Date test post"})
|
55
55
|
|
56
56
|
# date in filename should match date in file itself
|
@@ -61,17 +61,17 @@ module MrPoole
|
|
61
61
|
end # end context title only
|
62
62
|
|
63
63
|
context 'title and slug' do
|
64
|
-
it "
|
64
|
+
it "creates a post named for slug" do
|
65
65
|
fn = c.post({:title => "Test Post", :slug => 'unique_slug'})
|
66
66
|
expect(fn).to match(/#{date_regex}-unique_slug[.]md$/)
|
67
67
|
end
|
68
68
|
|
69
|
-
it "
|
69
|
+
it "subs any weird characters in slug" do
|
70
70
|
fn = c.post({:title => "Test Post with Spaces", :slug => "(stupid] {slüg/"})
|
71
71
|
expect(fn).to match(/#{date_regex}-stupid_slg[.]md/)
|
72
72
|
end
|
73
73
|
|
74
|
-
it "
|
74
|
+
it "updates the title in the file itself" do
|
75
75
|
fn = c.post({:title => "Testing Post {}", :slug => 'shouldnt_be_in_title'})
|
76
76
|
content = File.open(fn, 'r').read
|
77
77
|
expect(content).to match(/title: Testing Post \{\}/)
|
@@ -81,7 +81,7 @@ module MrPoole
|
|
81
81
|
context 'with custom layout' do
|
82
82
|
let(:layout_path) { write_custom_layout }
|
83
83
|
|
84
|
-
it "
|
84
|
+
it "exits if layout path doesn't exist" do
|
85
85
|
expect {
|
86
86
|
capture_stdout do
|
87
87
|
c.post({:title => 'test_post', :layout => 'bogus_path.md'})
|
@@ -89,13 +89,13 @@ module MrPoole
|
|
89
89
|
}.to raise_error(SystemExit)
|
90
90
|
end
|
91
91
|
|
92
|
-
it '
|
92
|
+
it 'does not use the default layout' do
|
93
93
|
fn = c.post({:title => 'test_post', :layout => layout_path})
|
94
94
|
content = File.open(fn, 'r').read
|
95
95
|
expect(content).not_to match(/layout: post/)
|
96
96
|
end
|
97
97
|
|
98
|
-
it '
|
98
|
+
it 'uses the custom layout' do
|
99
99
|
fn = c.post({:title => 'test_post', :layout => layout_path})
|
100
100
|
content = File.open(fn, 'r').read
|
101
101
|
expect(content).to match(/tags: testing/)
|
@@ -105,62 +105,62 @@ module MrPoole
|
|
105
105
|
|
106
106
|
describe "#draft" do
|
107
107
|
context 'title only' do
|
108
|
-
it "
|
108
|
+
it "creates a _drafts directory" do
|
109
109
|
c.draft({:title => 'draft post'})
|
110
110
|
expect(File.exists?('_drafts')).to be_true
|
111
111
|
end
|
112
112
|
|
113
|
-
it "
|
113
|
+
it "returns path to the newly created draft" do
|
114
114
|
returned = c.draft({:title => "test_draft"})
|
115
115
|
determined = Dir.glob("_drafts/*.md").first
|
116
116
|
expect(returned).to eq(determined)
|
117
117
|
end
|
118
118
|
|
119
|
-
it "
|
119
|
+
it "creates a new draft in the _drafts directory" do
|
120
120
|
fn = c.draft({:title => 'draft post'})
|
121
121
|
expect(File.exists?(fn)).to be_true
|
122
122
|
end
|
123
123
|
|
124
|
-
it "
|
124
|
+
it "creates a non-timestamped draft" do
|
125
125
|
fn = c.draft({:title => 'draft post'})
|
126
126
|
expect(fn).not_to match(/#{date_regex}/)
|
127
127
|
end
|
128
128
|
|
129
|
-
it "
|
129
|
+
it "downcases and underscore title for slug" do
|
130
130
|
fn = c.draft({:title => "Test Post with Spaces"})
|
131
131
|
expect(fn).to match(/test_post_with_spaces[.]md/)
|
132
132
|
end
|
133
133
|
|
134
|
-
it "
|
134
|
+
it "removes non-word characters for slug" do
|
135
135
|
fn = c.draft({:title => "On (function() {}()) in JavaScript"})
|
136
136
|
expect(fn).to match(/on_function_in_javascript[.]md/)
|
137
137
|
end
|
138
138
|
|
139
|
-
it "
|
139
|
+
it "updates the title in the file itself" do
|
140
140
|
fn = c.draft({:title => "Testing Draft {}"})
|
141
141
|
content = File.open(fn, 'r').read
|
142
142
|
expect(content).to match(/title: Testing Draft \{\}/)
|
143
143
|
end
|
144
144
|
|
145
|
-
it "
|
145
|
+
it "does not update the date in the file itself" do
|
146
146
|
fn = c.draft({:title => "Date test post"})
|
147
147
|
content = File.open(fn, 'r').read
|
148
|
-
expect(content).to match(/date:
|
148
|
+
expect(content).to match(/date: #{date_regex}/)
|
149
149
|
end
|
150
150
|
end # end context title only
|
151
151
|
|
152
152
|
context 'title and slug' do
|
153
|
-
it "
|
153
|
+
it "creates a draft named for slug" do
|
154
154
|
fn = c.draft({:title => "Test Draft", :slug => 'unique_slug'})
|
155
155
|
expect(fn).to match(/unique_slug[.]md$/)
|
156
156
|
end
|
157
157
|
|
158
|
-
it "
|
158
|
+
it "subs any weird characters in slug" do
|
159
159
|
fn = c.draft({:title => "Test Post with Spaces", :slug => "(stupid] {slüg/"})
|
160
160
|
expect(fn).to match(/stupid_slg[.]md/)
|
161
161
|
end
|
162
162
|
|
163
|
-
it "
|
163
|
+
it "updates the title in the file itself" do
|
164
164
|
fn = c.draft({:title => "Testing Post {}", :slug => 'shouldnt_be_in_title'})
|
165
165
|
content = File.open(fn, 'r').read
|
166
166
|
expect(content).to match(/title: Testing Post \{\}/)
|
@@ -170,7 +170,7 @@ module MrPoole
|
|
170
170
|
context 'with custom layout' do
|
171
171
|
let(:layout_path) { write_custom_layout }
|
172
172
|
|
173
|
-
it "
|
173
|
+
it "exits if layout path doesn't exist" do
|
174
174
|
expect {
|
175
175
|
capture_stdout do
|
176
176
|
c.draft({:title => 'test_post', :layout => 'bogus_path.md'})
|
@@ -178,80 +178,53 @@ module MrPoole
|
|
178
178
|
}.to raise_error(SystemExit)
|
179
179
|
end
|
180
180
|
|
181
|
-
it '
|
181
|
+
it 'does not use the default layout' do
|
182
182
|
fn = c.draft({:title => 'test_post', :layout => layout_path})
|
183
183
|
content = File.open(fn, 'r').read
|
184
184
|
expect(content).not_to match(/layout: post/)
|
185
185
|
end
|
186
186
|
|
187
|
-
it '
|
187
|
+
it 'uses the custom layout' do
|
188
188
|
fn = c.draft({:title => 'test_post', :layout => layout_path})
|
189
189
|
content = File.open(fn, 'r').read
|
190
190
|
expect(content).to match(/tags: testing/)
|
191
191
|
end
|
192
192
|
end # context custom layout
|
193
|
-
|
194
|
-
# I'm not sure why I originally decided to test all the slug generation
|
195
|
-
# code in the draft section, but here we go anyway.
|
196
|
-
context 'with custom word_separator in config file' do
|
197
|
-
before(:each) { write_config_file_custom_word_sep }
|
198
|
-
|
199
|
-
it "should downcase and underscore title for slug" do
|
200
|
-
fn = c.draft({:title => "Test Post with Spaces"})
|
201
|
-
expect(fn).to match(/test-post-with-spaces[.]md/)
|
202
|
-
end
|
203
|
-
|
204
|
-
it "should remove non-word characters for slug" do
|
205
|
-
fn = c.draft({:title => "On (function() {}()) in JavaScript"})
|
206
|
-
expect(fn).to match(/on-function-in-javascript[.]md/)
|
207
|
-
end
|
208
|
-
|
209
|
-
it "explicit slug overrides custom word_separator" do
|
210
|
-
fn = c.draft({:title => "Test Draft", :slug => 'unique_slug'})
|
211
|
-
expect(fn).to match(/unique_slug[.]md$/)
|
212
|
-
end
|
213
|
-
|
214
|
-
it "should sub any weird characters in slug" do
|
215
|
-
fn = c.draft({:title => "Test Post with Spaces", :slug => "(stupid] {slüg/"})
|
216
|
-
expect(fn).to match(/stupid-slg[.]md/)
|
217
|
-
end
|
218
|
-
|
219
|
-
end # end context custom word_separator
|
220
193
|
end # end describe draft
|
221
194
|
|
222
195
|
describe "#publish" do
|
223
196
|
let(:d_path) { c.draft({:title => 'test_draft'}) }
|
224
197
|
|
225
|
-
it '
|
198
|
+
it 'returns path to newly created post' do
|
226
199
|
returned = c.publish(d_path)
|
227
200
|
determined = Dir.glob("_posts/*.md").first
|
228
201
|
expect(returned).to eq(determined)
|
229
202
|
end
|
230
203
|
|
231
|
-
it '
|
204
|
+
it 'creates a timestamped post in the _posts folder' do
|
232
205
|
fn = c.publish(d_path)
|
233
206
|
expect(fn).to match(/#{date_regex}-test_draft[.]md$/)
|
234
207
|
end
|
235
208
|
|
236
|
-
it '
|
209
|
+
it 'removes file in the _drafts folder' do
|
237
210
|
c.publish(d_path)
|
238
211
|
expect(File.exist?(d_path)).to be_false
|
239
212
|
end
|
240
213
|
|
241
|
-
it '
|
214
|
+
it 'creates post with matching slug' do
|
242
215
|
post = c.publish(d_path)
|
243
216
|
draft_slug = File.basename(d_path, '.md')
|
244
217
|
post_slug = post.match(/#{date_regex}-(.*)[.]md/)[1]
|
245
218
|
expect(post_slug).to eq(draft_slug)
|
246
219
|
end
|
247
220
|
|
248
|
-
it '
|
221
|
+
it 'updates timestamp in actual file' do
|
249
222
|
post = c.publish(d_path)
|
250
223
|
content = File.open(post, 'r').read
|
251
224
|
expect(content).to match(/date: #{date_regex} \d{2}:\d{2}\n/)
|
252
225
|
end
|
253
226
|
|
254
|
-
it '
|
227
|
+
it 'copies contents of draft into post' do
|
255
228
|
# first add some content to the draft
|
256
229
|
f = File.open(d_path, 'a')
|
257
230
|
f.write("Some new content for my blog\n")
|
@@ -266,41 +239,41 @@ module MrPoole
|
|
266
239
|
describe "#unpublish" do
|
267
240
|
let(:p_path) { c.post({:title => 'test_post'}) }
|
268
241
|
|
269
|
-
it '
|
242
|
+
it 'returns path to newly created draft' do
|
270
243
|
returned = c.unpublish(p_path)
|
271
244
|
determined = Dir.glob("_drafts/*.md").first
|
272
245
|
expect(returned).to eq(determined)
|
273
246
|
end
|
274
247
|
|
275
|
-
it '
|
248
|
+
it 'creates a _drafts directory' do
|
276
249
|
c.unpublish(p_path)
|
277
250
|
expect(File.exists?('_drafts')).to be_true
|
278
251
|
end
|
279
252
|
|
280
|
-
it '
|
253
|
+
it 'creates an untimestamped draft in the _drafts folder' do
|
281
254
|
fn = c.unpublish(p_path)
|
282
255
|
expect(fn).not_to match(/#{date_regex}/)
|
283
256
|
end
|
284
257
|
|
285
|
-
it '
|
258
|
+
it 'removes file in the _posts folder' do
|
286
259
|
c.unpublish(p_path)
|
287
260
|
expect(File.exist?(p_path)).to be_false
|
288
261
|
end
|
289
262
|
|
290
|
-
it '
|
263
|
+
it 'creates draft with matching slug' do
|
291
264
|
draft = c.unpublish(p_path)
|
292
265
|
post_slug = p_path.match(/#{date_regex}-(.*)[.]md$/)[1]
|
293
266
|
draft_slug = File.basename(draft, '.md')
|
294
267
|
expect(draft_slug).to eq(post_slug)
|
295
268
|
end
|
296
269
|
|
297
|
-
it '
|
270
|
+
it 'deletes timestamp in actual file' do
|
298
271
|
draft = c.unpublish(p_path)
|
299
272
|
content = File.open(draft, 'r').read
|
300
273
|
expect(content).to match(/date:\s*\n/)
|
301
274
|
end
|
302
275
|
|
303
|
-
it '
|
276
|
+
it 'copies contents of post into draft' do
|
304
277
|
# first add some content to the draft
|
305
278
|
f = File.open(p_path, 'a')
|
306
279
|
f.write("Some new content for my blog\n")
|
@@ -316,47 +289,45 @@ module MrPoole
|
|
316
289
|
context 'with custom extension' do
|
317
290
|
let(:commands) { Commands.new('textile') }
|
318
291
|
|
319
|
-
it '
|
292
|
+
it 'uses custom extension for post' do
|
320
293
|
fn = commands.post({:title => 'post title'})
|
321
294
|
expect(fn).to match(/textile$/)
|
322
295
|
end
|
323
296
|
|
324
|
-
it '
|
297
|
+
it 'uses custom extension for draft' do
|
325
298
|
fn = commands.draft({:title => 'post title'})
|
326
299
|
expect(fn).to match(/textile$/)
|
327
300
|
end
|
328
301
|
|
329
|
-
it '
|
302
|
+
it 'uses custom extension for publish' do
|
330
303
|
draft_path = commands.draft({:title => 'post title'})
|
331
304
|
fn = commands.publish(draft_path)
|
332
305
|
expect(fn).to match(/textile$/)
|
333
306
|
end
|
334
307
|
|
335
|
-
it '
|
308
|
+
it 'uses custom extension for unpublish' do
|
336
309
|
post_path = commands.post({:title => 'post title'})
|
337
310
|
fn = commands.unpublish(post_path)
|
338
311
|
expect(fn).to match(/textile$/)
|
339
312
|
end
|
340
|
-
|
341
|
-
end
|
313
|
+
end # end context custom extension
|
342
314
|
|
343
315
|
context 'with layout override' do
|
344
|
-
|
345
|
-
it "post should inherit layout's file extension" do
|
316
|
+
it "inherit layout's file extension for post" do
|
346
317
|
layout_path = write_custom_layout_textile
|
347
318
|
fn = c.post({:title => 'post title', :layout => layout_path})
|
348
319
|
expect(fn).not_to match(/md/)
|
349
320
|
expect(fn).to match(/textile$/)
|
350
321
|
end
|
351
322
|
|
352
|
-
it "
|
323
|
+
it "inherits layout's file extension for draft" do
|
353
324
|
layout_path = write_custom_layout_textile
|
354
325
|
fn = c.draft({:title => 'post title', :layout => layout_path})
|
355
326
|
expect(fn).not_to match(/md/)
|
356
327
|
expect(fn).to match(/textile$/)
|
357
328
|
end
|
358
329
|
|
359
|
-
it "
|
330
|
+
it "inherits draft's extension for pubilsh" do
|
360
331
|
layout_path = write_custom_layout_textile
|
361
332
|
draft_path = c.draft({:title => 'post title', :layout => layout_path})
|
362
333
|
fn = c.publish(draft_path)
|
@@ -364,14 +335,33 @@ module MrPoole
|
|
364
335
|
expect(fn).to match(/textile$/)
|
365
336
|
end
|
366
337
|
|
367
|
-
it "
|
338
|
+
it "inherits post's extension for unpublish" do
|
368
339
|
layout_path = write_custom_layout_textile
|
369
340
|
post_path = c.post({:title => 'post title', :layout => layout_path})
|
370
341
|
fn = c.publish(post_path)
|
371
342
|
expect(fn).not_to match(/md/)
|
372
343
|
expect(fn).to match(/textile$/)
|
373
344
|
end
|
345
|
+
end # end context layout override
|
346
|
+
|
347
|
+
context 'with custom word_separator' do
|
348
|
+
before(:each) { write_config_file_custom_word_sep }
|
349
|
+
|
350
|
+
it "uses hyphens for post" do
|
351
|
+
fn = c.post({:title => "Test Post with Spaces"})
|
352
|
+
expect(fn).to match(/test-post-with-spaces[.]md/)
|
353
|
+
end
|
354
|
+
|
355
|
+
it "uses hyphens for draft" do
|
356
|
+
fn = c.draft({:title => "On (function() {}()) in JavaScript"})
|
357
|
+
expect(fn).to match(/on-function-in-javascript[.]md/)
|
358
|
+
end
|
359
|
+
|
360
|
+
it "is overidden by explicit slug" do
|
361
|
+
fn = c.post({:title => "Test Post", :slug => 'unique_slug'})
|
362
|
+
expect(fn).to match(/unique_slug[.]md$/)
|
363
|
+
end
|
374
364
|
|
375
|
-
end
|
365
|
+
end # end context custom word separator
|
376
366
|
end
|
377
367
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mr_poole
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael McClimon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02
|
11
|
+
date: 2014-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|