jekyllpress 0.1.4 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a05da1c5d837f760d088d87a3dd9f7ee3ad71319
4
- data.tar.gz: 8cdd262990c8988d80710cdaaba27b29840ad8d5
3
+ metadata.gz: 40003eab401d98373cda9aa83d94274f39f0ec45
4
+ data.tar.gz: e8b16da84b7c7faea06f24c4a100251cae354796
5
5
  SHA512:
6
- metadata.gz: 6374d5f07ed37b9406e4c9395d820bb10fe1c25be92c200be161dcb53552b9ef0c1ada997495d772a269454823521038095c70f1bfba66164f0eacae89d7d583
7
- data.tar.gz: 74f5bcf18f9de5f22da424541cd2eb121472fafbf1952baacf0718a2eb7f391109c2866378c1e3bbae1a2456ac264f0933b997c0deb2fa718c7ae9f6d50f2ed8
6
+ metadata.gz: 6dd9f62443222eed5addde8334ae8daf67b9c90b2dfc16c1e55edbb5f3c75546223e8a3ec13d2200a49449ed4eba19f66b942829de986ffc584f2df5ebae1c11
7
+ data.tar.gz: 983810146b58fac82a5cf32e71b230d31c84e9309a8d9ee55be7941ef164921108de3ff3e7eae774e4fdb5752f98fc70d3bb63496cbf92b584ec7181a53100e6
@@ -1,3 +1,3 @@
1
1
  module Jekyllpress
2
- VERSION = "0.1.4"
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/jekyllpress.rb CHANGED
@@ -25,21 +25,22 @@ module Jekyllpress
25
25
  with_config do |config|
26
26
  empty_directory(File.join(source, template_dir))
27
27
  create_file(File.join(source, template_dir, new_post_template),
28
- %q{---
29
- layout: post
30
- title: "<%= @title %>"
31
- date: <%= Time.now.strftime("%Y-%m-%d %H:%M") %>
32
- categories: [<%= Array(@categories).join(", ") %>]
33
- tags: [<%= Array(@tags).join(", ") %>]
34
- ---
35
- }.gsub(/^\s*/,''))
28
+ '---
29
+ layout: <%= @layout %>
30
+ title: "<%= @title %>"
31
+ date: <%= Time.now.strftime("%Y-%m-%d %H:%M") %>
32
+ categories: <%= Array(@categories) %>
33
+ tags: <%= Array(@tags) %>
34
+ source: "<%= @url %>"
35
+ ---
36
+ '.gsub(/^\s*/,''))
36
37
  create_file(File.join(source, template_dir, new_page_template),
37
- %q{---
38
- layout: page
39
- title: "<%= @title %>"
40
- date: <%= Time.now.strftime("%Y-%m-%d %H:%M") %>
41
- ---
42
- }.gsub(/^\s*/,''))
38
+ '---
39
+ layout: <%= @layout %>
40
+ title: "<%= @title %>"
41
+ date: <%= Time.now.strftime("%Y-%m-%d %H:%M") %>
42
+ ---
43
+ '.gsub(/^\s*/,''))
43
44
  [__method__, source, template_dir, new_post_template, new_page_template]
44
45
  end
45
46
  end
@@ -47,6 +48,9 @@ module Jekyllpress
47
48
  desc "new_post TITLE", "Create a new posts with title TITLE"
48
49
  method_option :categories, :desc => "list of categories to assign this post", :type => :array, :aliases => %w[-c]
49
50
  method_option :tags, :desc => "list of tags to assign this post", :type => :array, :aliases => %w[-t]
51
+ method_option :layout, :desc => "specify an alternate layout for the post", :type => :string, :aliases => %w[-l], :default => "post"
52
+ method_option :url, :desc => "source URL for blog post", :type => :string
53
+ method_option :template, :desc => "specify an alternate template to use for the post", :type => :string
50
54
  def new_post(title="")
51
55
  check_templates
52
56
  @title = title.to_s
@@ -54,33 +58,37 @@ module Jekyllpress
54
58
 
55
59
  @categories = options.fetch("categories", [])
56
60
  @tags = options.fetch("tags", [])
57
-
61
+ @layout = options[:layout]
62
+ @url = options[:url]
63
+ @template = options.fetch("template") { new_post_template }
64
+
58
65
  with_config do |config|
59
66
  check_templates
60
- filename = destination(source, posts_dir, post_filename(title))
67
+ @filename = destination(source, posts_dir, post_filename(title))
61
68
 
62
- template(File.join(template_dir,new_post_template), filename)
69
+ template(File.join(template_dir, @template), @filename)
63
70
 
64
- [__method__, @title, filename, @categories, @tags]
71
+ [__method__, @title, @filename, @categories, @tags, @layout, @url, @template]
65
72
  end
66
73
  end
67
74
 
68
75
  desc "new_page TITLE", "Create a new page with title TITLE"
69
76
  method_option :location, :desc => "Location for page to appear in directory", :type => :string, :aliases => %w[-l --loc]
77
+ method_option :layout, :desc => "specify an alternate layout for the page", :type => :string, :default => "page"
70
78
  def new_page(title="")
71
79
  check_templates
72
80
  @title = title.to_s
73
81
  @title = ask("Page title: ") if @title.empty?
74
-
82
+ @layout = options["layout"]
75
83
  location = options.fetch("location", nil)
76
84
  raise "location can not be an absolute path: #{location}" if location[0] == ?/
77
85
 
78
86
  with_config do |config|
79
- filename = destination(source, location, page_dirname(title), index_name)
87
+ @filename = destination(source, location, page_dirname(title), index_name)
80
88
 
81
- template(File.join(template_dir, new_page_template), filename)
89
+ template(File.join(template_dir, new_page_template), @filename)
82
90
 
83
- [__method__, @title, filename, location]
91
+ [__method__, @title, @filename, location, @layout]
84
92
  end
85
93
  end
86
94
 
@@ -196,7 +204,7 @@ redirect_from:
196
204
  end
197
205
 
198
206
  def new_post_template
199
- jekyll_config["templates"]["new_post_template"]
207
+ jekyll_config["templates"]["new_post_template"]
200
208
  end
201
209
 
202
210
  def new_page_template
@@ -33,7 +33,6 @@ describe "my Jekyllpress Thor script" do
33
33
  Dir.chdir(TEST_SITE) do |test_site|
34
34
  load 'jekyllpress.rb'
35
35
  Jekyllpress::App.start(%w[setup])
36
- @action, @title, @filename, @categories, @tags = Jekyllpress::App.start(%w[new_post A\ New\ Post -c one two three -t able baker charlie])
37
36
  end
38
37
  end
39
38
  end
@@ -44,13 +43,55 @@ describe "my Jekyllpress Thor script" do
44
43
  end
45
44
  end
46
45
 
47
- it {expect(@action).to eq :new_post}
48
- it {expect(@title).to eq "A New Post"}
49
- it {expect(@categories).to eq %w[one two three]}
50
- it {expect(@tags).to eq %w[able baker charlie]}
51
- it {expect(@filename).to be_a String}
52
- it {expect(@filename).not_to be_empty}
53
- it {expect(@filename).to include("/_posts/#{Time.now.strftime("%Y-%m-%d")}-a-new-post.markdown")}
46
+ context "when using the default template" do
47
+ before(:all) do
48
+ @action, @title, @filename, @categories, @tags, @layout, @url, @template = Jekyllpress::App.start(%w[new_post A\ New\ Post -c one two three -t able baker charlie -l post2 --url=https://github.com/tamouse])
49
+ end
50
+
51
+ it {expect(@action).to eq :new_post}
52
+ it {expect(@title).to eq "A New Post"}
53
+ it {expect(@categories).to eq %w[one two three]}
54
+ it {expect(@tags).to eq %w[able baker charlie]}
55
+ it {expect(@layout).to eq 'post2'}
56
+ it {expect(@url).to eq 'https://github.com/tamouse'}
57
+ it {expect(@template).to eq 'new_post.markdown'}
58
+ it {expect(@filename).to be_a String}
59
+ it {expect(@filename).not_to be_empty}
60
+ it {expect(@filename).to include("/_posts/#{Time.now.strftime("%Y-%m-%d")}-a-new-post.markdown")}
61
+ end
62
+
63
+
64
+ context "when giving an alternate template" do
65
+ before(:all) do
66
+ alt_template = <<-EOF
67
+ --
68
+ layout: link
69
+ title: <%= @title %>
70
+ date: <%= Time.now.strftime("%Y-%m-%d %H:%M") %>
71
+ ---
72
+ alternate template
73
+
74
+ EOF
75
+ test_dir = File.expand_path('../../',__FILE__)
76
+ alt_template_file = File.join(test_dir, TEST_SITE, "_templates", "alt_post.markdown")
77
+
78
+
79
+ File.write(alt_template_file, alt_template)
80
+
81
+ @action, @title, @filename, @categories, @tags, @layout, @url, @template = Jekyllpress::App.start(%w[new_post A\ New\ Post\ With\ Alt\ Template -c one two three -t able baker charlie -l link --url=https://github.com/tamouse --template=alt_post.markdown])
82
+ end
83
+
84
+ it {expect(@action).to eq :new_post}
85
+ it {expect(@title).to eq "A New Post With Alt Template"}
86
+ it {expect(@categories).to eq %w[one two three]}
87
+ it {expect(@tags).to eq %w[able baker charlie]}
88
+ it {expect(@layout).to eq 'link'}
89
+ it {expect(@url).to eq 'https://github.com/tamouse'}
90
+ it {expect(@template).to eq "alt_post.markdown"}
91
+ it {expect(@filename).to be_a String}
92
+ it {expect(@filename).not_to be_empty}
93
+ it {expect(@filename).to include("/_posts/#{Time.now.strftime("%Y-%m-%d")}-a-new-post-with-alt-template.markdown")}
94
+ end
54
95
  end
55
96
 
56
97
  describe ":new_page" do
@@ -79,7 +120,7 @@ describe "my Jekyllpress Thor script" do
79
120
 
80
121
  context "create a new page" do
81
122
  before(:all) do
82
- @action, @title, @filename, @location = Jekyllpress::App.start(%w[new_page A\ New\ Page -l=pages])
123
+ @action, @title, @filename, @location, @layout = Jekyllpress::App.start(%w[new_page A\ New\ Page -l=pages --layout=page2])
83
124
  end
84
125
 
85
126
  after(:all) do
@@ -88,6 +129,7 @@ describe "my Jekyllpress Thor script" do
88
129
 
89
130
  it {expect(@action).to eq :new_page}
90
131
  it {expect(@title).to eq "A New Page"}
132
+ it {expect(@layout).to eq "page2"}
91
133
  it {expect(@location).to eq "pages"}
92
134
  it {expect(@filename).to be_a String}
93
135
  it {expect(@filename).not_to be_empty}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyllpress
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tamara Temple
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-26 00:00:00.000000000 Z
11
+ date: 2015-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -208,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
208
  version: '0'
209
209
  requirements: []
210
210
  rubyforge_project:
211
- rubygems_version: 2.2.2
211
+ rubygems_version: 2.4.6
212
212
  signing_key:
213
213
  specification_version: 4
214
214
  summary: Thor utility to do neat jekyll stuff.