jekyllpress 0.0.1 → 0.0.2
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
- data/README.md +95 -0
- data/lib/jekyllpress/version.rb +1 -1
- data/lib/jekyllpress.rb +1 -0
- data/spec/lib/jekyllpress_spec.rb +88 -60
- data/spec/spec_helper.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 625954e5d29b533a49daf60f58d4ed0b12a83589
|
4
|
+
data.tar.gz: a7a76f682448eb9a94fadb754681b9bedf8b8c84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b74b0248aaa5463ccfc6678fe1a461d46d3b43834b57ab9ce5c8dc80dc248e2e441ee39139e262617acd51e00a7e53cc38e5f9276f5562562bd60a797ba51675
|
7
|
+
data.tar.gz: 7a8ced63a9e6b5369cac84462f4e8840ad954afb1df9f0beac2912ab2a803b39349c20b0807e130a2edefa9fe483dad289846f4b4033d7f744aedc5910a58d74
|
data/README.md
CHANGED
@@ -8,7 +8,102 @@ A [Thor](http://whatisthor.com) script that provides several actions to help sup
|
|
8
8
|
|
9
9
|
## Usage
|
10
10
|
|
11
|
+
### New Post
|
12
|
+
|
13
|
+
Creating a new post is done with:
|
14
|
+
|
15
|
+
$ jekyllpress new_post 'This is my new post!!' --categories=new really --tags=so what
|
16
|
+
Configuration file: /Volumes/muis1t/Projects/rubystuff/jekyll/test_jekyll_2.1/_config.yml
|
17
|
+
create _posts/2014-07-28-this-is-my-new-post.markdown
|
18
|
+
|
19
|
+
This creates a new file in `_posts` with the current date stamp, and contents as:
|
20
|
+
|
21
|
+
```
|
22
|
+
---
|
23
|
+
layout: post
|
24
|
+
title: This is my new post!!
|
25
|
+
date: 2014-07-28 01:15
|
26
|
+
categories: ["new", "really"]
|
27
|
+
tags: ["so", "what"]
|
28
|
+
---
|
29
|
+
```
|
30
|
+
|
31
|
+
### New Page
|
32
|
+
|
33
|
+
Creating a new page is just as simple:
|
34
|
+
|
35
|
+
$ jekyllpress new_page "Some Page" --location=pages
|
36
|
+
Configuration file: /Volumes/muis1t/Projects/rubystuff/jekyll/test_jekyll_2.1/_config.yml
|
37
|
+
create pages/some-page/index.markdown
|
38
|
+
|
39
|
+
The content is:
|
40
|
+
|
41
|
+
```
|
42
|
+
---
|
43
|
+
layout: page
|
44
|
+
title: Some Page
|
45
|
+
date: 2014-07-28 01:17
|
46
|
+
---
|
47
|
+
```
|
48
|
+
|
49
|
+
### Getting Help
|
50
|
+
|
51
|
+
Actions and options can be seen by running `jekyllpress` with no paramters, or with the `help` action:
|
52
|
+
|
11
53
|
$ jekyllpress help
|
54
|
+
Jekyllpress::App commands:
|
55
|
+
jekyllpress help [COMMAND] # Describe available commands or one specific command
|
56
|
+
jekyllpress new_page TITLE # Create a new page with title TITLE
|
57
|
+
jekyllpress new_post TITLE # Create a new posts with title TITLE
|
58
|
+
jekyllpress setup # Set up templates
|
59
|
+
jekyllpress version # Display Jekyllpress::App version string
|
60
|
+
|
61
|
+
To see the options for `new_post`, enter:
|
62
|
+
|
63
|
+
$ jekyllpress help new_post
|
64
|
+
|
65
|
+
```
|
66
|
+
Usage:
|
67
|
+
jekyllpress new_post TITLE
|
68
|
+
|
69
|
+
Options:
|
70
|
+
-c, [--categories=one two three] # list of categories to assign this post
|
71
|
+
-t, [--tags=one two three] # list of tags to assign this post
|
72
|
+
|
73
|
+
Create a new post with title TITLE
|
74
|
+
```
|
75
|
+
|
76
|
+
* `categories` and `tags` are arrays. Give each category or tag item after the parameter.
|
77
|
+
* The equals sign after the option name is ... *optional*.
|
78
|
+
|
79
|
+
To see the options for `new_page`, enter:
|
80
|
+
|
81
|
+
$ jekyllpress help new_page
|
82
|
+
|
83
|
+
```
|
84
|
+
Usage:
|
85
|
+
jekyllpress new_page TITLE
|
86
|
+
|
87
|
+
Options:
|
88
|
+
-l, --loc, [--location=LOCATION] # Location for page to appear in directory
|
89
|
+
|
90
|
+
Create a new page with title TITLE
|
91
|
+
```
|
92
|
+
|
93
|
+
* the `location` option lets you specify a path down to where the page will live.
|
94
|
+
* the location *must* be relative, and will placed starting from the source folder.
|
95
|
+
|
96
|
+
### Setting Up Templates
|
97
|
+
|
98
|
+
If you don't have templates specified in your `_config.yml` file or in your `source` folder, you can create them with the `setup` action:
|
99
|
+
|
100
|
+
$ jekyllpress setup
|
101
|
+
Configuration file: /Volumes/muis1t/Projects/rubystuff/jekyll/test_jekyll_2.1/_config.yml
|
102
|
+
create _templates
|
103
|
+
create _templates/new_post.markdown
|
104
|
+
create _templates/new_page.markdown
|
105
|
+
|
106
|
+
You can edit the markdown templates to your heart's delight. :)
|
12
107
|
|
13
108
|
## Contributing
|
14
109
|
|
data/lib/jekyllpress/version.rb
CHANGED
data/lib/jekyllpress.rb
CHANGED
@@ -70,6 +70,7 @@ module Jekyllpress
|
|
70
70
|
@title = ask("Page title: ") if @title.empty?
|
71
71
|
|
72
72
|
location = options.fetch("location", nil)
|
73
|
+
raise "location can not be an absolute path: #{location}" if location[0] == ?/
|
73
74
|
|
74
75
|
with_config do |config|
|
75
76
|
filename = destination(source, location, page_dirname(title), index_name)
|
@@ -3,92 +3,120 @@ require 'spec_helper'
|
|
3
3
|
jekyll_match = %r[(gems/jekyll-.+/lib/jekyll)]
|
4
4
|
# load 'jekyllpress.rb'; STDERR.puts $".grep(jekyll_match); exit;
|
5
5
|
|
6
|
-
Dir.chdir('spec/test_site') do |test_dir|
|
6
|
+
Dir.chdir(Pathname.new('spec/test_site')) do |test_dir|
|
7
7
|
$".delete_if{|x| x.match(jekyll_match)} ; load 'jekyllpress.rb' # Have to load this *after* we're in the working directory
|
8
|
-
#
|
8
|
+
# STDERR.puts Jekyll::Configuration::DEFAULTS["source"]
|
9
|
+
|
9
10
|
describe Jekyllpress::App do
|
10
|
-
|
11
|
+
|
12
|
+
# it "should bloody well be in the damn spec/test_site directory!!!" do
|
13
|
+
# expect(Jekyll::Configuration::DEFAULTS["source"]).to include("spec/test_site")
|
14
|
+
# end
|
15
|
+
|
16
|
+
describe ":version" do
|
11
17
|
it {expect(Jekyllpress::App.start(%w[version])).to include(Jekyllpress::VERSION)}
|
12
18
|
it {expect(Jekyllpress::App.start(%w[-V])).to include(Jekyllpress::VERSION)}
|
13
19
|
it {expect(Jekyllpress::App.start(%w[--version])).to include(Jekyllpress::VERSION)}
|
14
20
|
end
|
15
21
|
|
16
|
-
describe ":new_post
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
describe ":new_post" do
|
23
|
+
before(:all) do
|
24
|
+
# STDERR.puts "test_dir is #{test_dir}"
|
25
|
+
Dir.chdir(test_dir) do |test_dir|
|
26
|
+
# binding.pry
|
27
|
+
@posts_dir = Pathname.new('_posts')
|
28
|
+
raise "#{@posts_dir} does not exist!" unless @posts_dir.directory?
|
29
|
+
@posts_dir.children.each(&:unlink)
|
30
|
+
@templates = Pathname.new('_templates')
|
31
|
+
@templates.rmtree if @templates.exist?
|
32
|
+
Jekyllpress::App.start(%w[setup])
|
33
|
+
@action, @title, @filename, @categories, @tags = Jekyllpress::App.start(%w[new_post A\ New\ Post -c=one two three -t=a b c])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
# it "should bloody well be in the damn spec/test_site directory!!!" do
|
37
|
+
# expect(Jekyll::Configuration::DEFAULTS["source"]).to include("spec/test_site")
|
38
|
+
# end
|
39
|
+
it {expect(@action).to eq :new_post}
|
40
|
+
it {expect(@title).to eq "A New Post"}
|
41
|
+
it {expect(@categories).to eq %w[one two three]}
|
42
|
+
it {expect(@tags).to eq %w[a b c]}
|
43
|
+
it {expect(@filename).to be_a String}
|
44
|
+
it {expect(@filename).not_to be_empty}
|
45
|
+
it {expect(@filename).to include("#{test_dir}/_posts/#{Time.now.strftime("%Y-%m-%d")}-a-new-post.markdown")}
|
27
46
|
end
|
28
47
|
|
29
|
-
describe ":new_page
|
30
|
-
|
31
|
-
|
48
|
+
describe ":new_page" do
|
49
|
+
it "should report an error if location is an absolute path" do
|
50
|
+
expect{Jekyllpress::App.start(%w[new_page bogus --location /pages])}.to raise_error(RuntimeError, "location can not be an absolute path: /pages")
|
51
|
+
end
|
32
52
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
53
|
+
context "create a new page" do
|
54
|
+
before(:all) do
|
55
|
+
Dir.chdir(test_dir) do |test_dir|
|
56
|
+
@pages_dir = Pathname.new('pages')
|
57
|
+
raise "#{@pages_dir} does not exist!" unless @pages_dir.directory?
|
58
|
+
@pages_dir.children.each(&:rmtree)
|
59
|
+
@templates = Pathname.new('_templates')
|
60
|
+
@templates.rmtree if @templates.exist?
|
61
|
+
Jekyllpress::App.start(%w[setup])
|
62
|
+
@action, @title, @filename, @location = Jekyllpress::App.start(%w[new_page A\ New\ Page -l=pages])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
it {expect(@action).to eq :new_page}
|
66
|
+
it {expect(@title).to eq "A New Page"}
|
67
|
+
it {expect(@location).to eq "pages"}
|
68
|
+
it {expect(@filename).to be_a String}
|
69
|
+
it {expect(@filename).not_to be_empty}
|
70
|
+
it {expect(@filename).to include("#{test_dir}/pages/a-new-page/index.markdown")}
|
71
|
+
end
|
39
72
|
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
Dir.chdir('tmp') do |test_dir|
|
44
73
|
|
45
|
-
|
46
|
-
raise "failed to erase blank" if File.directory?('blank')
|
47
|
-
x = `bundle exec jekyll new blank`
|
48
|
-
raise "jekyll new failed: #{x}" unless $?.success?
|
49
|
-
Dir.chdir('blank') do |blank|
|
50
|
-
$".delete_if{|x| x.match(jekyll_match)} ; load 'jekyllpress.rb' # Have to load this *after* we're in the working directory
|
51
|
-
describe "pristine jekyll installation" do
|
74
|
+
describe "no templates" do
|
52
75
|
|
53
|
-
|
54
|
-
|
76
|
+
before(:all) do
|
77
|
+
Dir.chdir(test_dir) do |test_dir|
|
78
|
+
@templates = Pathname.new('_templates')
|
79
|
+
@templates.rmtree if @templates.exist?
|
80
|
+
end
|
55
81
|
end
|
82
|
+
|
56
83
|
it "should abort when no templates are found" do
|
57
|
-
templates_dir = File.join(test_dir, blank, '_templates')
|
58
|
-
FileUtils.rm_rf templates_dir
|
59
84
|
expect{Jekyllpress::App.start(%w[new_page blah])}.to raise_error(::Errno::ENOENT)
|
60
|
-
expect(
|
85
|
+
expect(@templates.directory?).not_to eq(true)
|
61
86
|
end
|
62
|
-
|
63
|
-
|
87
|
+
|
88
|
+
context ":setup" do
|
64
89
|
before(:all) do
|
65
|
-
@
|
66
|
-
FileUtils.rm_rf @templates_dir
|
67
|
-
@result = Jekyllpress::App.start(%w[setup])
|
90
|
+
@action, @source, @template_dir, @new_post_template, @new_page_template = Jekyllpress::App.start(%w[setup])
|
68
91
|
end
|
69
|
-
|
70
|
-
it {expect(@
|
71
|
-
it {expect(@
|
72
|
-
it {expect(@
|
73
|
-
it {expect(@
|
74
|
-
it {expect(@
|
75
|
-
|
76
|
-
|
92
|
+
|
93
|
+
it { expect(@action).to eq(:setup) }
|
94
|
+
it { expect(@source).to include("spec/test_site") }
|
95
|
+
it { expect(@template_dir).to eq("_templates") }
|
96
|
+
it { expect(@new_post_template).to eq("new_post.markdown") }
|
97
|
+
it { expect(@new_page_template).to eq("new_page.markdown") }
|
98
|
+
|
99
|
+
it "templates directory created" do
|
100
|
+
Dir.chdir(test_dir) do |test_dir|
|
101
|
+
expect(File.directory?(@template_dir)).to eq true
|
102
|
+
end
|
77
103
|
end
|
78
|
-
|
79
|
-
|
80
|
-
|
104
|
+
|
105
|
+
it "new_post_template created" do
|
106
|
+
Dir.chdir(test_dir) do |test_dir|
|
107
|
+
expect(File.exist?(File.join(@template_dir, @new_post_template)))
|
81
108
|
end
|
82
109
|
end
|
83
|
-
|
84
|
-
|
85
|
-
|
110
|
+
|
111
|
+
it "new_page_template created" do
|
112
|
+
Dir.chdir(test_dir) do |test_dir|
|
113
|
+
expect(File.exist?(File.join(@template_dir, @new_page_template)))
|
86
114
|
end
|
87
115
|
end
|
116
|
+
|
88
117
|
end
|
89
|
-
end
|
90
118
|
|
119
|
+
end
|
91
120
|
|
92
121
|
end
|
93
|
-
|
94
122
|
end
|
data/spec/spec_helper.rb
CHANGED