jekyll-compose 0.0.0 → 0.1.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: 3514350c6a1c395e703ffd6aebd90ef137355a79
4
- data.tar.gz: 0cb9c75b373171a684a60a0bec1b57e971abcaa8
3
+ metadata.gz: c8dc9be859858bf16c82b9e73a3466fd1a7d405d
4
+ data.tar.gz: 03e9bbe08affa67d68ff96076af2d6fbee2a3f91
5
5
  SHA512:
6
- metadata.gz: d45bd0ac39b7ee16c55377b73c6eb4d31c56833e4d545e22d3185bfea93300bc44ff3160ac96b79118d698f461d05583bda1fc44ae0e90337e6f64f82dabde3f
7
- data.tar.gz: 5d51f1bc5de53ecaed4bde1ba2ed4a86c30cf1068c06cd5c52d0b9ee68de647f78cc6ae05e9356d544cf2e54e75f47419b16d35482122ba57efeb0b169f8356d
6
+ metadata.gz: 159bca1e89f742aabced58ecb2c40d2ced95fa18c80c0c23b27672a84a5d0a5ba282f31ad62c4a022469a2d39ef93c54b3b0f080174b72828405bd75f8f10349
7
+ data.tar.gz: aee319a385c768187ac90eaef97d44263aa8ff9825f45d44550944a329da35a2860060697304972bddbe4510d57b0a5be72fc1cc3964e1a2401516673bf0616c
@@ -0,0 +1,53 @@
1
+ module Jekyll
2
+ module Commands
3
+ class Draft < Command
4
+ def self.init_with_program(prog)
5
+ prog.command(:draft) do |c|
6
+ c.syntax 'draft NAME'
7
+ c.description 'Creates a new draft post with the given NAME'
8
+
9
+ c.option 'type', '-t TYPE', '--type TYPE', 'Specify the content type'
10
+ c.option 'layout', '-l LAYOUT', '--layout LAYOUT', 'Specify the post layout'
11
+ c.option 'force', '-f', '--force', 'Overwrite a draft if it already exists'
12
+
13
+ c.action do |args, options|
14
+ Jekyll::Commands::Draft.process(args, options)
15
+ end
16
+ end
17
+ end
18
+
19
+ def self.process(args, options = {})
20
+ raise ArgumentError.new('You must specify a name.') if args.empty?
21
+
22
+ type = options["type"].nil? ? "markdown" : options["type"]
23
+ layout = options["layout"].nil? ? "post" : options["layout"]
24
+
25
+ title = args.shift
26
+ name = title.gsub(' ', '-').downcase
27
+
28
+ draft_path = draft_name(name, type)
29
+
30
+ raise ArgumentError.new("A draft already exists at ./#{draft_path}") if File.exist?(draft_path) and !options["force"]
31
+
32
+ File.open(draft_path, "w") do |f|
33
+ f.puts(front_matter(layout, title))
34
+ end
35
+
36
+ puts "New draft created at ./#{draft_path}.\n"
37
+ end
38
+ # Internal: Gets the filename of the draft to be created
39
+ #
40
+ # Returns the filename of the draft, as a String
41
+ def self.draft_name(name, ext='markdown')
42
+ "_drafts/#{name}.#{ext}"
43
+ end
44
+
45
+ def self.front_matter(layout, title)
46
+ "---
47
+ layout: #{layout}
48
+ title: #{title}
49
+ ---"
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,56 @@
1
+ module Jekyll
2
+ module Commands
3
+ class Post < Command
4
+ def self.init_with_program(prog)
5
+ prog.command(:post) do |c|
6
+ c.syntax 'post NAME'
7
+ c.description 'Creates a new post with the given NAME'
8
+
9
+ c.option 'type', '-t TYPE', '--type TYPE', 'Specify the content type'
10
+ c.option 'layout', '-t LAYOUT', '--layout LAYOUT', 'Specify the post layout'
11
+ c.option 'date', '-d DATE', '--date DATE', 'Specify the post date'
12
+ c.option 'force', '-f', '--force', 'Overwrite a post if it already exists'
13
+
14
+ c.action do |args, options|
15
+ Jekyll::Commands::Post.process(args, options)
16
+ end
17
+ end
18
+ end
19
+
20
+ def self.process(args, options = {})
21
+ raise ArgumentError.new('You must specify a name.') if args.empty?
22
+
23
+ type = options["type"].nil? ? "markdown" : options["type"]
24
+ layout = options["layout"].nil? ? "post" : options["layout"]
25
+
26
+ date = options["date"].nil? ? Time.now : DateTime.parse(options["date"])
27
+
28
+ title = args.shift
29
+ name = title.gsub(' ', '-').downcase
30
+
31
+ post_path = file_name(name, type, date)
32
+
33
+ raise ArgumentError.new("A post already exists at ./#{post_path}") if File.exist?(post_path) and !options["force"]
34
+
35
+ File.open(post_path, "w") do |f|
36
+ f.puts(front_matter(layout, title))
37
+ end
38
+
39
+ puts "New post created at ./#{post_path}.\n"
40
+ end
41
+ # Internal: Gets the filename of the draft to be created
42
+ #
43
+ # Returns the filename of the draft, as a String
44
+ def self.file_name(name, ext, date)
45
+ "_posts/#{date.strftime('%Y-%m-%d')}-#{name}.#{ext}"
46
+ end
47
+
48
+ def self.front_matter(layout, title)
49
+ "---
50
+ layout: #{layout}
51
+ title: #{title}
52
+ ---"
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,42 @@
1
+ module Jekyll
2
+ module Commands
3
+ class Publish < Command
4
+ def self.init_with_program(prog)
5
+ prog.command(:publish) do |c|
6
+ c.syntax 'publish NAME'
7
+ c.description 'Moves a draft into the _posts directory and sets the date'
8
+
9
+ c.option 'date', '-d DATE', '--date DATE', 'Specify the post date'
10
+
11
+ c.action do |args, options|
12
+ Jekyll::Commands::Publish.process(args, options)
13
+ end
14
+ end
15
+ end
16
+
17
+ def self.process(args, options = {})
18
+ raise ArgumentError.new('You must specify a name.') if args.empty?
19
+
20
+ date = options["date"].nil? ? Date.today : Date.parse(options["date"])
21
+ file = args.shift
22
+
23
+ post_path = post_name(date, file)
24
+ FileUtils.mv(draft_name(file), post_path)
25
+
26
+ puts "Draft #{file} was published to ./#{post_path}"
27
+ end
28
+
29
+ # Internal: Gets the filename of the post to be created
30
+ #
31
+ # Returns the filename of the post, as a String
32
+ def self.post_name(date, name)
33
+ "_posts/#{date.strftime('%Y-%m-%d')}-#{name}"
34
+ end
35
+
36
+ def self.draft_name(name)
37
+ "_drafts/#{name}"
38
+ end
39
+
40
+ end
41
+ end
42
+ end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Compose
3
- VERSION = "0.0.0"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-compose
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Parker Moore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-10 00:00:00.000000000 Z
11
+ date: 2014-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -26,6 +26,34 @@ dependencies:
26
26
  version: '1.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: jekyll
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: shoulda
29
57
  requirement: !ruby/object:Gem::Requirement
30
58
  requirements:
31
59
  - - ">="
@@ -45,13 +73,9 @@ executables: []
45
73
  extensions: []
46
74
  extra_rdoc_files: []
47
75
  files:
48
- - ".gitignore"
49
- - Gemfile
50
- - History.markdown
51
- - LICENSE.txt
52
- - README.md
53
- - Rakefile
54
- - jekyll-compose.gemspec
76
+ - lib/jekyll/commands/draft.rb
77
+ - lib/jekyll/commands/post.rb
78
+ - lib/jekyll/commands/publish.rb
55
79
  - lib/jekyll/compose.rb
56
80
  - lib/jekyll/compose/version.rb
57
81
  homepage: https://github.com/jekyll/jekyll-compose
data/.gitignore DELETED
@@ -1,17 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in jekyll-compose.gemspec
4
- gemspec
data/History.markdown DELETED
@@ -1,5 +0,0 @@
1
- ## HEAD
2
-
3
- ## 0.0.0 / 2014-05-10
4
-
5
- * Birthday!
data/LICENSE.txt DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2014 Parker Moore
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md DELETED
@@ -1,29 +0,0 @@
1
- # Jekyll::Compose
2
-
3
- Streamline your writing in Jekyll with these commands.
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'jekyll-compose'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
- $ gem install jekyll-compose
18
-
19
- ## Usage
20
-
21
- Usage instructions go here.
22
-
23
- ## Contributing
24
-
25
- 1. Fork it ( http://github.com/<my-github-username>/jekyll-compose/fork )
26
- 2. Create your feature branch (`git checkout -b my-new-feature`)
27
- 3. Commit your changes (`git commit -am 'Add some feature'`)
28
- 4. Push to the branch (`git push origin my-new-feature`)
29
- 5. Create new Pull Request
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"
@@ -1,23 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'jekyll/compose/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "jekyll-compose"
8
- spec.version = Jekyll::Compose::VERSION
9
- spec.authors = ["Parker Moore"]
10
- spec.email = ["parkrmoore@gmail.com"]
11
- spec.summary = %q{Streamline your writing in Jekyll with these commands.}
12
- spec.description = %q{Streamline your writing in Jekyll with these commands.}
13
- spec.homepage = "https://github.com/jekyll/jekyll-compose"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_development_dependency "bundler", "~> 1.5"
22
- spec.add_development_dependency "rake"
23
- end