jekyllpress 0.0.1 → 0.0.2

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: cfb2cb90d22fa0b368ec4e7def04966f91fa9cce
4
- data.tar.gz: 44b872c9516a654f601a496c42957498c2f85f4f
3
+ metadata.gz: 625954e5d29b533a49daf60f58d4ed0b12a83589
4
+ data.tar.gz: a7a76f682448eb9a94fadb754681b9bedf8b8c84
5
5
  SHA512:
6
- metadata.gz: c213b8d99c204c76c21c1332a9a472d88d873d76153dee373e21fc1ea489db75e9709803dcd5a00cfcf807f57e090bde1ad8fd9f719f232132078ce1d8fd71f3
7
- data.tar.gz: 098b81d69ea6f71156d4b75acec098b1c20448ecf6f7efbbc4f0ef212d05bd62214b302bb5ea0109b0ca642da1fed1edeb36a1fd22cab4e9b5db81e89b265a28
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
 
@@ -1,3 +1,3 @@
1
1
  module Jekyllpress
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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
- # load 'jekyllpress.rb'
8
+ # STDERR.puts Jekyll::Configuration::DEFAULTS["source"]
9
+
9
10
  describe Jekyllpress::App do
10
- describe ":version returns the version string" do
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 returns the title, categories and tags" do
17
- FileUtils.rm_rf "_posts/"
18
- action, title, filename, categories, tags = Jekyllpress::App.start(%w[new_post A\ New\ Post -c=one two three -t=a b c])
19
-
20
- it {expect(action).to eq :new_post}
21
- it {expect(title).to eq "A New Post"}
22
- it {expect(categories).to eq %w[one two three]}
23
- it {expect(tags).to eq %w[a b c]}
24
- it {expect(filename).to be_a String}
25
- it {expect(filename).not_to be_empty}
26
- it {expect(filename).to include("#{test_dir}/_posts/#{Time.now.strftime("%Y-%m-%d")}-a-new-post.markdown")}
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 returns title, filename, location" do
30
- FileUtils.rm_rf "pages/a-new-page"
31
- action, title, filename, location = Jekyllpress::App.start(%w[new_page A\ New\ Page -l=pages])
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
- it {expect(action).to eq :new_page}
34
- it {expect(title).to eq "A New Page"}
35
- it {expect(location).to eq "pages"}
36
- it {expect(filename).to be_a String}
37
- it {expect(filename).not_to be_empty}
38
- it {expect(filename).to include("#{test_dir}/pages/a-new-page/index.markdown")}
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
- FileUtils.rm_rf 'blank'
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
- it "should bloody well be inside the blank directory!!!" do
54
- expect(Jekyll::Configuration::DEFAULTS["source"]).to include("blank")
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(File.directory?(templates_dir)).not_to eq(true)
85
+ expect(@templates.directory?).not_to eq(true)
61
86
  end
62
-
63
- describe ":setup creates the template directory and contents" do
87
+
88
+ context ":setup" do
64
89
  before(:all) do
65
- @templates_dir = File.join(test_dir, blank, '_templates')
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(@result[0]).to eq(:setup)}
71
- it {expect(@result[1]).to include('blank')}
72
- it {expect(@result[2]).to eq("_templates")}
73
- it {expect(@result[4]).to eq("new_page.markdown")}
74
- it {expect(@result[3]).to eq("new_post.markdown")}
75
- it "templates directory exists" do
76
- expect(File.directory?(@templates_dir)).to eq(true)
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
- it "new_page_template exists" do
79
- Dir.chdir(@templates_dir) do |templates_dir|
80
- expect(File.exist?("new_page.markdown")).to eq(true)
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
- it "new_post_template exists" do
84
- Dir.chdir(@templates_dir) do |templates_dir|
85
- expect(File.exist?("new_post.markdown")).to eq(true)
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
@@ -1,4 +1,5 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
2
  require 'pry'
3
3
  require 'fileutils'
4
+ require 'pathname'
4
5
  $0 = 'jekyllpress'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyllpress
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tamara Temple