mr_poole 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +6 -0
- data/lib/mr_poole/cli.rb +7 -5
- data/lib/mr_poole/commands.rb +1 -1
- data/lib/mr_poole/helper.rb +19 -5
- data/lib/mr_poole/version.rb +1 -1
- data/spec/cli_spec.rb +57 -5
- data/spec/spec_helper.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eec4c40ee2d85be9a8dc6646397716f639dc7251
|
4
|
+
data.tar.gz: 5d5d5d3da895a594bed5bc5b315406f419b3a332
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79d2435f0d2c597b47fa137c0d02756c733c6003f67f065525605a7ebbb4c8d5e899fa35ed8fc7fb13b2240b83d1741e99d6fc7f3ce4e11478ceb2221adf6632
|
7
|
+
data.tar.gz: a92a2c785b51e9a013c9e51cb9301deb31c7e9232db59775d82d0e42402af83eac9a023f731b6833f4ad4a6415b0a1bbcc157483ec8426a7c2ef0d9bab728b80
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### v0.4.3 (2014-01-28)
|
4
|
+
|
5
|
+
- Make echoed paths reflect custom source directory. Now you can `poole post
|
6
|
+
"post title" | vim` even if you are using a custom source directory in your
|
7
|
+
`_config.yml`.
|
8
|
+
|
3
9
|
### v0.4.2 (2013-12-25)
|
4
10
|
|
5
11
|
- Change gemspec development dependencies (wouldn't release a new version
|
data/lib/mr_poole/cli.rb
CHANGED
@@ -6,7 +6,7 @@ module MrPoole
|
|
6
6
|
|
7
7
|
def initialize(args)
|
8
8
|
@helper = Helper.new
|
9
|
-
@helper.ensure_jekyll_dir
|
9
|
+
@src_dir = @helper.ensure_jekyll_dir
|
10
10
|
|
11
11
|
@params = args
|
12
12
|
@config = Config.new
|
@@ -25,6 +25,8 @@ module MrPoole
|
|
25
25
|
when '-v' then @helper.version_statement
|
26
26
|
else @helper.gen_usage
|
27
27
|
end
|
28
|
+
|
29
|
+
@helper.restore_orig_directory
|
28
30
|
end
|
29
31
|
|
30
32
|
def handle_post
|
@@ -33,7 +35,7 @@ module MrPoole
|
|
33
35
|
|
34
36
|
@helper.post_usage unless options.title
|
35
37
|
fn = @commands.post(options)
|
36
|
-
puts fn
|
38
|
+
puts "#{@src_dir}/#{fn}"
|
37
39
|
end
|
38
40
|
|
39
41
|
def handle_draft
|
@@ -42,7 +44,7 @@ module MrPoole
|
|
42
44
|
|
43
45
|
@helper.draft_usage unless options.title
|
44
46
|
fn = @commands.draft(options)
|
45
|
-
puts fn
|
47
|
+
puts "#{@src_dir}/#{fn}"
|
46
48
|
end
|
47
49
|
|
48
50
|
def handle_publish
|
@@ -60,7 +62,7 @@ module MrPoole
|
|
60
62
|
path = @params.first
|
61
63
|
@helper.publish_usage unless path
|
62
64
|
fn = @commands.publish(path, options)
|
63
|
-
puts fn
|
65
|
+
puts "#{@src_dir}/#{fn}"
|
64
66
|
end
|
65
67
|
|
66
68
|
def handle_unpublish
|
@@ -78,7 +80,7 @@ module MrPoole
|
|
78
80
|
path = @params.first
|
79
81
|
@helper.unpublish_usage unless path
|
80
82
|
fn = @commands.unpublish(path, options)
|
81
|
-
puts fn
|
83
|
+
puts "#{@src_dir}/#{fn}"
|
82
84
|
end
|
83
85
|
|
84
86
|
def do_creation_options
|
data/lib/mr_poole/commands.rb
CHANGED
@@ -68,7 +68,7 @@ module MrPoole
|
|
68
68
|
|
69
69
|
# Todo make this take a path instead?
|
70
70
|
#
|
71
|
-
# @param draftpath [String] path to the draft
|
71
|
+
# @param draftpath [String] path to the draft, relative to source directory
|
72
72
|
# @option options :keep_draft [Boolean] if true, keep the draft file
|
73
73
|
# @option options :keep_timestamp [Boolean] if true, don't change the timestamp
|
74
74
|
def publish(draftpath, opts={})
|
data/lib/mr_poole/helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'yaml'
|
2
|
+
require 'pathname'
|
2
3
|
|
3
4
|
module MrPoole
|
4
5
|
class Helper
|
@@ -7,24 +8,37 @@ module MrPoole
|
|
7
8
|
# nothing to do here
|
8
9
|
end
|
9
10
|
|
10
|
-
# Check for a _posts directory in current directory
|
11
|
-
#
|
11
|
+
# Check for a _posts directory in current directory. If there's not one,
|
12
|
+
# check for a _config.yml and look for a custom src directory. If we
|
13
|
+
# don't find one, puke an error message and die. If we do, return the name
|
14
|
+
# of the directory
|
12
15
|
def ensure_jekyll_dir
|
16
|
+
@orig_dir = Dir.pwd
|
17
|
+
start_path = Pathname.new(@orig_dir)
|
18
|
+
|
13
19
|
ok = File.exists?('./_posts')
|
20
|
+
new_path = nil
|
14
21
|
|
15
22
|
# if it doesn't exist, check for a custom source dir in _config.yml
|
16
23
|
if !ok
|
17
|
-
check_custom_src_dir
|
24
|
+
check_custom_src_dir!
|
18
25
|
ok = File.exists?('./_posts')
|
26
|
+
new_path = Pathname.new(Dir.pwd)
|
19
27
|
end
|
20
28
|
|
21
|
-
if
|
29
|
+
if ok
|
30
|
+
return (new_path ? new_path.relative_path_from(start_path) : '.')
|
31
|
+
else
|
22
32
|
puts 'ERROR: Cannot locate _posts directory. Double check to make sure'
|
23
33
|
puts ' that you are in a jekyll directory.'
|
24
34
|
exit
|
25
35
|
end
|
26
36
|
end
|
27
37
|
|
38
|
+
def restore_orig_directory
|
39
|
+
Dir.chdir(@orig_dir)
|
40
|
+
end
|
41
|
+
|
28
42
|
def ensure_open_struct(opts)
|
29
43
|
return opts.instance_of?(Hash) ? OpenStruct.new(opts) : opts
|
30
44
|
end
|
@@ -144,7 +158,7 @@ module MrPoole
|
|
144
158
|
|
145
159
|
# If a user has a custom 'source' defined in their _config.yml, change
|
146
160
|
# to that directory for everything else
|
147
|
-
def check_custom_src_dir
|
161
|
+
def check_custom_src_dir!
|
148
162
|
srcdir = nil
|
149
163
|
|
150
164
|
if File.exists?('_config.yml')
|
data/lib/mr_poole/version.rb
CHANGED
data/spec/cli_spec.rb
CHANGED
@@ -112,7 +112,7 @@ module MrPoole
|
|
112
112
|
it 'echoes path to newly created post on success' do
|
113
113
|
argv = ['post', 'post title']
|
114
114
|
output = poole_no_stdout(argv).call.chomp
|
115
|
-
determined = Dir.glob("_posts/*.md").first
|
115
|
+
determined = Dir.glob("./_posts/*.md").first
|
116
116
|
expect(output).to eq(determined)
|
117
117
|
end
|
118
118
|
|
@@ -198,7 +198,7 @@ module MrPoole
|
|
198
198
|
it 'echoes path to newly created post on success' do
|
199
199
|
argv = ['draft', 'post title']
|
200
200
|
output = poole_no_stdout(argv).call.chomp
|
201
|
-
determined = Dir.glob("_drafts/*.md").first
|
201
|
+
determined = Dir.glob("./_drafts/*.md").first
|
202
202
|
expect(output).to eq(determined)
|
203
203
|
end
|
204
204
|
end # context exit message
|
@@ -280,7 +280,7 @@ module MrPoole
|
|
280
280
|
it 'echoes path to newly created post on success' do
|
281
281
|
argv = ['publish', d_path]
|
282
282
|
output = poole_no_stdout(argv).call.chomp
|
283
|
-
determined = Dir.glob("_posts/*.md").first
|
283
|
+
determined = Dir.glob("./_posts/*.md").first
|
284
284
|
expect(output).to eq(determined)
|
285
285
|
end
|
286
286
|
end # context exit message
|
@@ -301,7 +301,7 @@ module MrPoole
|
|
301
301
|
expect(content).to match(/^date: \d{4}-\d{2}-\d{2}$/)
|
302
302
|
end
|
303
303
|
end
|
304
|
-
end
|
304
|
+
end # describe publish
|
305
305
|
|
306
306
|
describe "action 'unpublish'" do
|
307
307
|
let(:p_path) { Commands.new.post({:title => 'test_post'}) }
|
@@ -341,7 +341,7 @@ module MrPoole
|
|
341
341
|
it 'echoes path to newly created post on success' do
|
342
342
|
argv = ['unpublish', p_path]
|
343
343
|
output = poole_no_stdout(argv).call.chomp
|
344
|
-
determined = Dir.glob("_drafts/*.md").first
|
344
|
+
determined = Dir.glob("./_drafts/*.md").first
|
345
345
|
expect(output).to eq(determined)
|
346
346
|
end
|
347
347
|
end # context exit message
|
@@ -404,5 +404,57 @@ module MrPoole
|
|
404
404
|
|
405
405
|
end
|
406
406
|
|
407
|
+
context 'with custom source directory' do
|
408
|
+
before(:each) do
|
409
|
+
@olddir, @tmpdir = make_irregular_jekyll_dir
|
410
|
+
end
|
411
|
+
|
412
|
+
after(:each) { clean_tmp_files(@tmpdir, @olddir) }
|
413
|
+
|
414
|
+
it "'post' echoes correct path with custom source directory" do
|
415
|
+
argv = ['post', 'post_title']
|
416
|
+
output = poole_no_stdout(argv).call.chomp
|
417
|
+
determined = Dir.glob("src/_posts/*.md").first
|
418
|
+
expect(output).to eq(determined)
|
419
|
+
end
|
420
|
+
|
421
|
+
it "'draft' echoes correct path with custom source directory" do
|
422
|
+
argv = ['draft', 'post_title']
|
423
|
+
output = poole_no_stdout(argv).call.chomp
|
424
|
+
determined = Dir.glob("src/_drafts/*.md").first
|
425
|
+
expect(output).to eq(determined)
|
426
|
+
end
|
427
|
+
|
428
|
+
it "'publish' echoes correct path with custom source directory" do
|
429
|
+
# make a draft first
|
430
|
+
Dir.chdir('src')
|
431
|
+
draft_path = Commands.new.draft({:title => 'test_draft'})
|
432
|
+
Dir.chdir('..')
|
433
|
+
|
434
|
+
argv = ['publish', draft_path]
|
435
|
+
output = poole_no_stdout(argv).call.chomp
|
436
|
+
|
437
|
+
determined = Dir.glob("src/_posts/*.md").first
|
438
|
+
expect(output).to eq(determined)
|
439
|
+
end
|
440
|
+
|
441
|
+
it "'unpublish' echoes correct path with custom source directory" do
|
442
|
+
olddir, tmpdir = make_irregular_jekyll_dir
|
443
|
+
|
444
|
+
# make a post in the src directory
|
445
|
+
Dir.chdir('src')
|
446
|
+
post_path = Commands.new.post({:title => 'touch_post'})
|
447
|
+
Dir.chdir('..')
|
448
|
+
|
449
|
+
argv = ['unpublish', post_path]
|
450
|
+
output = poole_no_stdout(argv).call.chomp
|
451
|
+
|
452
|
+
determined = Dir.glob("src/_drafts/*.md").first
|
453
|
+
expect(output).to eq(determined)
|
454
|
+
|
455
|
+
clean_tmp_files(tmpdir, olddir)
|
456
|
+
end
|
457
|
+
|
458
|
+
end
|
407
459
|
end
|
408
460
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -42,8 +42,10 @@ def make_irregular_jekyll_dir
|
|
42
42
|
newdir = Dir.mktmpdir('jekyll')
|
43
43
|
srcdir = File.join(newdir, 'src')
|
44
44
|
posts = File.join(srcdir, '_posts')
|
45
|
+
drafts = File.join(srcdir, '_drafts')
|
45
46
|
Dir.mkdir(srcdir)
|
46
47
|
Dir.mkdir(posts)
|
48
|
+
Dir.mkdir(drafts)
|
47
49
|
Dir.chdir(newdir)
|
48
50
|
# ensure write custom yml file
|
49
51
|
write_config_file_custom_src_dir
|
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.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael McClimon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
113
|
version: '0'
|
114
114
|
requirements: []
|
115
115
|
rubyforge_project:
|
116
|
-
rubygems_version: 2.
|
116
|
+
rubygems_version: 2.2.1
|
117
117
|
signing_key:
|
118
118
|
specification_version: 4
|
119
119
|
summary: A butler for Jekyll. Provides a command-line interface (called `poole`) for
|