mr_poole 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 60010ebbd261458b1cef4e8f5bcc0db1fe10739d
4
- data.tar.gz: 403a24571f75f6cd5e2e452123aafe83bf1c9548
3
+ metadata.gz: 67256569815765464405bb90b8428e79705ab4c8
4
+ data.tar.gz: b8926eec3f3d7be762486da2e43f97c213d67461
5
5
  SHA512:
6
- metadata.gz: 8f708900d1366bdb5ba468b66fcd0e584a6b7c060d4480ff23f21d6c3edba23e95107ee70de518a84c8a1977e0cd01ddba8374fa3c8499eb290358ab72e523ba
7
- data.tar.gz: 104ece8c3f20331977ee429002472ea238d32a8cf8936274906ed5fdf1784d87688938759cfdd0516c43cb8275197973c3c1a103ad68f9ab7d6d40e17d581995
6
+ metadata.gz: c225e8d61c813b6eadc0ffe9fee4d8cd5340a5ce6bc85422af4723806bffecead4dd490c095345499f4e153e3e6c1525704023b2d88de55a8a2bc5fc87e40033
7
+ data.tar.gz: d5e0ea460ce3a45aa25ae8f07c09afd4de24462dcb35d1df738ec70de57b71ac44008f8ed46720a433bae40820118b3fc5f488e5fe48780e9713b1a613e9fe46
data/CHANGES.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ### v0.4.0 (2013-09-28)
4
+
5
+ - Add options for unpublish
6
+
7
+ ### v0.3.2 (2013-09-24)
8
+
9
+ - Add '--version/-v' option
10
+ - Minor bugfixes, tests
11
+
3
12
  ### v0.3.1 (2013-09-22)
4
13
 
5
14
  - Bugfixes to work properly on ruby 1.8.7.
data/README.md CHANGED
@@ -107,9 +107,12 @@ The life, universe, and everything.
107
107
  The reverse of publish: moves a file from your _posts folder to the _drafts
108
108
  folder, renaming the file and removing the date in the header. This will
109
109
  rename a file called `_posts/yyyy-mm-dd-test_post.md` to
110
- `_drafts/test_post.md`. (TODO: add flags for no-delete post, no-update
111
- timestamp, and custom slug for unpublished draft (?))
110
+ `_drafts/test_post.md`.
112
111
 
112
+ ```
113
+ -p, --keep-post Do not delete the existing post'
114
+ -t, --keep-timestamp Do not update the existing timestamp'
115
+ ```
113
116
 
114
117
  ### Script usage
115
118
 
data/lib/mr_poole/cli.rb CHANGED
@@ -66,13 +66,18 @@ module MrPoole
66
66
  def handle_unpublish
67
67
  options = OpenStruct.new
68
68
  opt_parser = OptionParser.new do |opts|
69
- # eventually there will be options...not yet
69
+ opts.on('-p', '--keep-post', "Do not delete post") do |p|
70
+ options.keep_post = p
71
+ end
72
+ opts.on('-t', '--keep-timestamp', "Keep the existing timestamp") do |t|
73
+ options.keep_timestamp = t
74
+ end
70
75
  end
71
76
  opt_parser.parse! @params
72
77
 
73
78
  path = @params.first
74
79
  @helper.unpublish_usage unless path
75
- fn = @commands.unpublish(path)
80
+ fn = @commands.unpublish(path, options)
76
81
  puts fn
77
82
  end
78
83
 
@@ -71,7 +71,7 @@ module MrPoole
71
71
  # @param draftpath [String] path to the draft
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
- def publish(draftpath, opts = {})
74
+ def publish(draftpath, opts={})
75
75
  opts = @helper.ensure_open_struct(opts)
76
76
  tail = File.basename(draftpath)
77
77
 
@@ -99,7 +99,9 @@ module MrPoole
99
99
  outpath
100
100
  end
101
101
 
102
- def unpublish(inpath)
102
+ def unpublish(inpath, opts={})
103
+ opts = @helper.ensure_open_struct(opts)
104
+
103
105
  # the drafts folder might not exist yet...create it just in case
104
106
  FileUtils.mkdir_p(DRAFTS_FOLDER)
105
107
 
@@ -114,13 +116,13 @@ module MrPoole
114
116
  outfile = File.open(outpath, "w")
115
117
 
116
118
  infile.each_line do |line|
117
- l = line.sub(/^date:\s*.*$/, "date:")
118
- outfile.write(l)
119
+ line.sub!(/^date:\s*.*$/, "date:") unless opts.keep_timestamp
120
+ outfile.write(line)
119
121
  end
120
122
 
121
123
  infile.close
122
124
  outfile.close
123
- FileUtils.rm(inpath)
125
+ FileUtils.rm(inpath) unless opts.keep_post
124
126
 
125
127
  outpath
126
128
  end
@@ -123,7 +123,8 @@ module MrPoole
123
123
  puts ' poole unpublish PATH_TO_POST'
124
124
  puts ''
125
125
  puts 'Options:'
126
- puts ' (coming soon)'
126
+ puts ' -p, --keep-post Do not delete the existing post'
127
+ puts ' -t, --keep-timestamp Do not update the existing timestamp'
127
128
  exit
128
129
  end
129
130
 
@@ -1,3 +1,3 @@
1
1
  module MrPoole
2
- VERSION = '0.3.2'
2
+ VERSION = '0.4.0'
3
3
  end
data/spec/cli_spec.rb CHANGED
@@ -272,7 +272,7 @@ module MrPoole
272
272
  it 'should keep draft post if called with --keep-draft' do
273
273
  argv = ['publish', '--keep-draft', d_path]
274
274
  poole_no_stdout(argv).call
275
- expect(File.exists?(d_path)).to be(true)
275
+ expect(File.exists?(d_path)).to be_true
276
276
  end
277
277
  end
278
278
 
@@ -329,6 +329,36 @@ module MrPoole
329
329
  end
330
330
  end # context exit message
331
331
 
332
+ context 'keep post' do
333
+ it 'should not delete the post if called with --keep-post' do
334
+ argv = ['unpublish', '--keep-post', p_path]
335
+ poole_no_stdout(argv).call
336
+ expect(File.exists?(p_path)).to be_true
337
+ end
338
+
339
+ it 'should not delete the post if called with -p' do
340
+ argv = ['unpublish', '-p', p_path]
341
+ poole_no_stdout(argv).call
342
+ expect(File.exists?(p_path)).to be_true
343
+ end
344
+ end
345
+
346
+ context 'keep timestamp' do
347
+ it 'should not change timestamp if called with --keep-timestamp' do
348
+ argv = ['unpublish', '--keep-timestamp', p_path]
349
+ fn = poole_no_stdout(argv).call.chomp
350
+ content = File.open(fn, 'r').read
351
+ expect(content).to match(/^date: \d{4}-\d{2}-\d{2}/)
352
+ end
353
+
354
+ it 'should not change timestamp if called with -t' do
355
+ argv = ['unpublish', '-t', p_path]
356
+ fn = poole_no_stdout(argv).call.chomp
357
+ content = File.open(fn, 'r').read
358
+ expect(content).to match(/^date: \d{4}-\d{2}-\d{2}/)
359
+ end
360
+ end
361
+
332
362
  end # context action unpublish
333
363
 
334
364
  context 'with default extension in config file' do
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.3.2
4
+ version: 0.4.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: 2013-09-24 00:00:00.000000000 Z
11
+ date: 2013-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler