jekyllpress 1.0.0 → 1.1.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: 40003eab401d98373cda9aa83d94274f39f0ec45
4
- data.tar.gz: e8b16da84b7c7faea06f24c4a100251cae354796
3
+ metadata.gz: f0d47d00a72a498e56cb38afbc882595b0f3d8d4
4
+ data.tar.gz: 406dfeb00c94677776c785ed4ca4bbd671f75835
5
5
  SHA512:
6
- metadata.gz: 6dd9f62443222eed5addde8334ae8daf67b9c90b2dfc16c1e55edbb5f3c75546223e8a3ec13d2200a49449ed4eba19f66b942829de986ffc584f2df5ebae1c11
7
- data.tar.gz: 983810146b58fac82a5cf32e71b230d31c84e9309a8d9ee55be7941ef164921108de3ff3e7eae774e4fdb5752f98fc70d3bb63496cbf92b584ec7181a53100e6
6
+ metadata.gz: d8adf1efd5f87f1e2d91755d0e92eb1d492cb2375b285ccda81d389767288f3b542a26d15b22b05175a432cf392f6104f51b858c6514b2ab69637b0f9a378732
7
+ data.tar.gz: d652cea47db6747ce0308d6a872067ab76b7fc2c311022937ac91ab7f58a6ffc1d545301b8abd09eeef202b60b6d83f14affc61d007add7e93478766b7013794
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
1
  --format documentation
2
- --color
2
+ --no-color
data/jekyllpress.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_dependency "thor", ">= 0.19"
21
- spec.add_dependency "jekyll", ">= 2.1"
21
+ spec.add_dependency "jekyll"
22
22
  spec.add_dependency "stringex", ">= 2"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.6"
@@ -1,3 +1,3 @@
1
1
  module Jekyllpress
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/jekyllpress.rb CHANGED
@@ -28,17 +28,16 @@ module Jekyllpress
28
28
  '---
29
29
  layout: <%= @layout %>
30
30
  title: "<%= @title %>"
31
- date: <%= Time.now.strftime("%Y-%m-%d %H:%M") %>
31
+ date: <%= @date %> <%= @time %>
32
32
  categories: <%= Array(@categories) %>
33
33
  tags: <%= Array(@tags) %>
34
34
  source: "<%= @url %>"
35
35
  ---
36
36
  '.gsub(/^\s*/,''))
37
- create_file(File.join(source, template_dir, new_page_template),
37
+ create_file(File.join(source, template_dir, new_page_template),
38
38
  '---
39
39
  layout: <%= @layout %>
40
40
  title: "<%= @title %>"
41
- date: <%= Time.now.strftime("%Y-%m-%d %H:%M") %>
42
41
  ---
43
42
  '.gsub(/^\s*/,''))
44
43
  [__method__, source, template_dir, new_post_template, new_page_template]
@@ -51,24 +50,28 @@ module Jekyllpress
51
50
  method_option :layout, :desc => "specify an alternate layout for the post", :type => :string, :aliases => %w[-l], :default => "post"
52
51
  method_option :url, :desc => "source URL for blog post", :type => :string
53
52
  method_option :template, :desc => "specify an alternate template to use for the post", :type => :string
53
+ method_option :date, :desc => "provide an alternate date for the post", :type => :string, :default => Date.today.iso8601
54
+ method_option :time, :desc => "provide an alternate time of day for the post", :type => :string, :default => Time.now.strftime("%H:%M")
54
55
  def new_post(title="")
55
56
  check_templates
56
57
  @title = title.to_s
57
58
  @title = ask("Title for your post: ") if @title.empty?
58
59
 
60
+ @date = options.fetch("date", Date.today.iso8601)
61
+ @time = options.fetch("time", Time.now.strftime("%H:%M"))
59
62
  @categories = options.fetch("categories", [])
60
63
  @tags = options.fetch("tags", [])
61
64
  @layout = options[:layout]
62
65
  @url = options[:url]
63
66
  @template = options.fetch("template") { new_post_template }
64
-
67
+
65
68
  with_config do |config|
66
69
  check_templates
67
- @filename = destination(source, posts_dir, post_filename(title))
70
+ @filename = destination(source, posts_dir, post_filename(@title, @date))
68
71
 
69
72
  template(File.join(template_dir, @template), @filename)
70
73
 
71
- [__method__, @title, @filename, @categories, @tags, @layout, @url, @template]
74
+ [__method__, @title, @date, @time, @filename, @categories, @tags, @layout, @url, @template]
72
75
  end
73
76
  end
74
77
 
@@ -84,7 +87,7 @@ module Jekyllpress
84
87
  raise "location can not be an absolute path: #{location}" if location[0] == ?/
85
88
 
86
89
  with_config do |config|
87
- @filename = destination(source, location, page_dirname(title), index_name)
90
+ @filename = destination(source, location, page_dirname(@title), index_name)
88
91
 
89
92
  template(File.join(template_dir, new_page_template), @filename)
90
93
 
@@ -104,7 +107,7 @@ module Jekyllpress
104
107
  with_posts({"permalink" => permalink_template}) do |post|
105
108
  if post.data.has_key?("redirect_from") && !force_redirect
106
109
  say "skipping #{post.name} - redirect_from detected"
107
- next
110
+ next
108
111
  end
109
112
 
110
113
  time_now = Time.now
@@ -179,8 +182,8 @@ redirect_from:
179
182
  jekyll_config['source']
180
183
  end
181
184
 
182
- def post_filename(title)
183
- "#{Time.now.strftime("%Y-%m-%d")}-#{title.to_url}.#{new_ext}"
185
+ def post_filename(title, date=Date.today.iso8601)
186
+ "#{date}-#{title.to_url}.#{new_ext}"
184
187
  end
185
188
 
186
189
  def page_dirname(title)
@@ -7,7 +7,7 @@ def kill_jekyll
7
7
  # I'm not altogether sure why I have to do this, but apparently
8
8
  # the way thor, rspec, and jekyll all meld, something goes haywire.
9
9
  $".delete_if{|x| x.match(%r[(/gems/jekyll-.+/lib/jekyll)])}
10
- # run `load 'jekyllpress.rb'` in each test setup where you have a
10
+ # run `load 'jekyllpress.rb'` in each test setup where you have a
11
11
  # jekyll test directory to work with
12
12
  end
13
13
 
@@ -22,7 +22,7 @@ describe "my Jekyllpress Thor script" do
22
22
  it {expect(Jekyllpress::App.start(%w[version])).to include(Jekyllpress::VERSION)}
23
23
  it {expect(Jekyllpress::App.start(%w[-V])).to include(Jekyllpress::VERSION)}
24
24
  it {expect(Jekyllpress::App.start(%w[--version])).to include(Jekyllpress::VERSION)}
25
- end
25
+ end
26
26
 
27
27
  describe ":new_post" do
28
28
  before(:all) do
@@ -43,13 +43,31 @@ describe "my Jekyllpress Thor script" do
43
43
  end
44
44
  end
45
45
 
46
+ context "when using all defaults" do
47
+ before(:all) do
48
+ @action, @title, @date, @time, @filename, @categories, @tags, @layout, @url, @template =
49
+ Jekyllpress::App.start(%w[new_post Using\ The\ Defaults])
50
+ end
51
+ it {expect(@action).to eq :new_post}
52
+ it {expect(@title).to eq "Using The Defaults"}
53
+ it {expect(@date).to eq Date.today.iso8601}
54
+ it {expect(@categories).to eq []}
55
+ it {expect(@tags).to eq []}
56
+ it {expect(@template).to eq 'new_post.markdown'}
57
+ it {expect(@filename).to be_a String}
58
+ it {expect(@filename).not_to be_empty}
59
+ it {expect(@filename).to match %r{/_posts/.*-using-the-defaults\.markdown} }
60
+ end
61
+
46
62
  context "when using the default template" do
47
63
  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])
64
+ @action, @title, @date, @time, @filename, @categories, @tags, @layout, @url, @template = Jekyllpress::App.start(%w[new_post A\ New\ Post --date=2001-01-01 --time=11:15 -c one two three -t able baker charlie -l post2 --url=https://github.com/tamouse])
49
65
  end
50
66
 
51
67
  it {expect(@action).to eq :new_post}
52
68
  it {expect(@title).to eq "A New Post"}
69
+ it {expect(@date).to eq '2001-01-01'}
70
+ it {expect(@time).to eq '11:15'}
53
71
  it {expect(@categories).to eq %w[one two three]}
54
72
  it {expect(@tags).to eq %w[able baker charlie]}
55
73
  it {expect(@layout).to eq 'post2'}
@@ -57,7 +75,7 @@ describe "my Jekyllpress Thor script" do
57
75
  it {expect(@template).to eq 'new_post.markdown'}
58
76
  it {expect(@filename).to be_a String}
59
77
  it {expect(@filename).not_to be_empty}
60
- it {expect(@filename).to include("/_posts/#{Time.now.strftime("%Y-%m-%d")}-a-new-post.markdown")}
78
+ it {expect(@filename).to include("/_posts/2001-01-01-a-new-post.markdown")}
61
79
  end
62
80
 
63
81
 
@@ -77,12 +95,14 @@ EOF
77
95
 
78
96
 
79
97
  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])
98
+
99
+ @action, @title, @date, @time, @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 --date=2001-01-01 --time=11:15])
82
100
  end
83
101
 
84
102
  it {expect(@action).to eq :new_post}
85
103
  it {expect(@title).to eq "A New Post With Alt Template"}
104
+ it {expect(@date).to eq '2001-01-01'}
105
+ it {expect(@time).to eq '11:15'}
86
106
  it {expect(@categories).to eq %w[one two three]}
87
107
  it {expect(@tags).to eq %w[able baker charlie]}
88
108
  it {expect(@layout).to eq 'link'}
@@ -90,7 +110,7 @@ EOF
90
110
  it {expect(@template).to eq "alt_post.markdown"}
91
111
  it {expect(@filename).to be_a String}
92
112
  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")}
113
+ it {expect(@filename).to include("/_posts/2001-01-01-a-new-post-with-alt-template.markdown")}
94
114
  end
95
115
  end
96
116
 
@@ -203,9 +223,9 @@ EOF
203
223
  load 'jekyllpress.rb'
204
224
  File.open(File.join("_posts","2013-12-31-an-old-post.markdown"), 'w') do |post|
205
225
  frontmatter = {
206
- "title" => "An old post",
226
+ "title" => "An old post",
207
227
  "date" => "2013-12-31 12:31",
208
- "layout" => "post",
228
+ "layout" => "post",
209
229
  "redirect_from" => Array("/oldsite/2013/12/31/an-old-post/")
210
230
  }
211
231
  post.puts frontmatter.to_yaml
@@ -236,7 +256,7 @@ EOF
236
256
  expect(@posts.count).to eq(1)
237
257
  @posts.each do |post|
238
258
  post_content = File.read post[:file]
239
- expect(post_content).to match(%r{^redirect_from:$})
259
+ expect(post_content).to match(%r{^redirect_from:$})
240
260
  expect(post_content).to match(%r{^ - /BLOG/})
241
261
  end
242
262
  end
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: 1.0.0
4
+ version: 1.1.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: 2015-03-09 00:00:00.000000000 Z
11
+ date: 2015-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '2.1'
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '2.1'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: stringex
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -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.4.6
211
+ rubygems_version: 2.4.5
212
212
  signing_key:
213
213
  specification_version: 4
214
214
  summary: Thor utility to do neat jekyll stuff.