mr_poole 0.4.0 → 0.4.1

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: 67256569815765464405bb90b8428e79705ab4c8
4
- data.tar.gz: b8926eec3f3d7be762486da2e43f97c213d67461
3
+ metadata.gz: 4790b814a5e143fa4beae53dd72d2cd5d3a47798
4
+ data.tar.gz: a60ed789cd16fc12c57ff5ca566f0e34d489e413
5
5
  SHA512:
6
- metadata.gz: c225e8d61c813b6eadc0ffe9fee4d8cd5340a5ce6bc85422af4723806bffecead4dd490c095345499f4e153e3e6c1525704023b2d88de55a8a2bc5fc87e40033
7
- data.tar.gz: d5e0ea460ce3a45aa25ae8f07c09afd4de24462dcb35d1df738ec70de57b71ac44008f8ed46720a433bae40820118b3fc5f488e5fe48780e9713b1a613e9fe46
6
+ metadata.gz: cd29e6389bd96860c050412b85c8e4ae95fbfec6bcf58bba661c985d2e587f374d88a97c8430e085dbe31847f7c71037b4d327db5e71b37760ad128dd1b4f09d
7
+ data.tar.gz: 78b28c146104ff78506333b4ca1d33f86639ef4500ae6e60d5c0d17c4ff659432efb3445561ad160c8bd532a38a09649a42c7ccc637a27152239af89bc040e41
data/CHANGES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ### v0.4.1 (2013-12-25)
4
+
5
+ - Add custom source dir detection from _config.yml (Merry Christmas!)
6
+
3
7
  ### v0.4.0 (2013-09-28)
4
8
 
5
9
  - Add options for unpublish
@@ -1,3 +1,5 @@
1
+ require 'yaml'
2
+
1
3
  module MrPoole
2
4
  class Helper
3
5
 
@@ -8,7 +10,15 @@ module MrPoole
8
10
  # Check for a _posts directory in current directory
9
11
  # If we don't find one, puke an error message and die
10
12
  def ensure_jekyll_dir
11
- unless File.exists?('./_posts')
13
+ ok = File.exists?('./_posts')
14
+
15
+ # if it doesn't exist, check for a custom source dir in _config.yml
16
+ if !ok
17
+ check_custom_src_dir
18
+ ok = File.exists?('./_posts')
19
+ end
20
+
21
+ if !ok
12
22
  puts 'ERROR: Cannot locate _posts directory. Double check to make sure'
13
23
  puts ' that you are in a jekyll directory.'
14
24
  exit
@@ -128,5 +138,22 @@ module MrPoole
128
138
  exit
129
139
  end
130
140
 
141
+ # Private methods
142
+ #################
143
+ private
144
+
145
+ # If a user has a custom 'source' defined in their _config.yml, change
146
+ # to that directory for everything else
147
+ def check_custom_src_dir
148
+ srcdir = nil
149
+
150
+ if File.exists?('_config.yml')
151
+ yaml = YAML.load(File.read('_config.yml'))
152
+ srcdir = yaml['source']
153
+ end
154
+
155
+ Dir.chdir(srcdir) if srcdir
156
+ end
157
+
131
158
  end
132
159
  end
@@ -1,3 +1,3 @@
1
1
  module MrPoole
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
data/spec/cli_spec.rb CHANGED
@@ -17,6 +17,23 @@ module MrPoole
17
17
  expect { cli = CLI.new([]) }.not_to raise_error
18
18
  clean_tmp_files(tmpdir, olddir)
19
19
  end
20
+
21
+ context 'with _config.yml' do
22
+
23
+ it "should not exit if _config.yml has 'source' key" do
24
+ olddir, tmpdir = make_irregular_jekyll_dir
25
+ expect { cli = CLI.new([]) }.not_to raise_error
26
+ clean_tmp_files(tmpdir, olddir)
27
+ end
28
+
29
+ it "should exit if custom src dir doesn't have _posts dir" do
30
+ olddir, tmpdir = make_bad_irregular_jekyll_dir
31
+ expect {
32
+ capture_stdout { cli = CLI.new([]) }
33
+ }.to raise_error(SystemExit)
34
+ clean_tmp_files(tmpdir, olddir)
35
+ end
36
+ end
20
37
  end # context determine jekyll dir
21
38
 
22
39
  context 'no correct action' do
data/spec/spec_helper.rb CHANGED
@@ -35,7 +35,31 @@ def make_jekyll_dir
35
35
  Dir.mkdir(posts)
36
36
  Dir.chdir(newdir)
37
37
  return olddir, newdir
38
+ end
39
+
40
+ def make_irregular_jekyll_dir
41
+ olddir = Dir.pwd()
42
+ newdir = Dir.mktmpdir('jekyll')
43
+ srcdir = File.join(newdir, 'src')
44
+ posts = File.join(srcdir, '_posts')
45
+ Dir.mkdir(srcdir)
46
+ Dir.mkdir(posts)
47
+ Dir.chdir(newdir)
48
+ # ensure write custom yml file
49
+ write_config_file_custom_src_dir
50
+ return olddir, newdir
51
+ end
38
52
 
53
+ # make a dir with a custom source dir but with no _posts directory
54
+ def make_bad_irregular_jekyll_dir
55
+ olddir = Dir.pwd()
56
+ newdir = Dir.mktmpdir('jekyll')
57
+ srcdir = File.join(newdir, 'src')
58
+ Dir.mkdir(srcdir)
59
+ Dir.chdir(newdir)
60
+ # ensure write custom yml file
61
+ write_config_file_custom_src_dir
62
+ return olddir, newdir
39
63
  end
40
64
 
41
65
  def clean_tmp_files(tmpdir, restoredir)
@@ -130,3 +154,9 @@ def write_config_file_custom_extension
130
154
  c.puts " default_extension: textile"
131
155
  c.close
132
156
  end
157
+
158
+ def write_config_file_custom_src_dir
159
+ c = File.open('_config.yml', 'w')
160
+ c.puts 'source: src'
161
+ c.close
162
+ 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.0
4
+ version: 0.4.1
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-28 00:00:00.000000000 Z
11
+ date: 2013-12-25 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.1.4
116
+ rubygems_version: 2.0.6
117
117
  signing_key:
118
118
  specification_version: 4
119
119
  summary: A butler for Jekyll. Provides a command-line interface (called `poole`) for