jekylljournal 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f835a1773f09b6ee8ba46cd8a3c29c91e1d070ac
4
- data.tar.gz: 098daacada742740aaf6b35889af98dcc9242aef
3
+ metadata.gz: a44abe75dfa7920dce9b4666ab647e2ed0a0948a
4
+ data.tar.gz: c0520e4ef5b764a402918a62a8c5de7273b169ac
5
5
  SHA512:
6
- metadata.gz: 993af8726b882b8621becd9ed00665326348d795b2b21918076de5b87e994956d3ba833752db768d2dad6104fb062a2c02ce10eafd71406833271195457e2aaf
7
- data.tar.gz: 8033b59ad8ec22fc7ba27b6eb909288b5fa2ab9196c9ad7ceea5136859139548047a52f1fdcac03a0db7b7127fdbf3d7d726f374d55d6edaafb0cd36e7eb0287
6
+ metadata.gz: 80b49507ed639b3cc5f23d025230031701c9a790dc8e1f137c2caa1bb366c7d17e1c75d5f8f5ea2ac7607212fe8696c793c11850e03ad6bcc29b93fa42ddb098
7
+ data.tar.gz: 7a7f8d27caf9f670a64721e469252fe7cfa894a1782625f0e15dae50578110f0591e5f43ddbab5b37ec05765a660e317422d64ac067092a90accf2f1691f33b1
data/README.rdoc CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  A super awesome way of writing daily blog posts with Jekyll.
4
4
 
5
+ {<img src="https://badge.fury.io/rb/jekylljournal.svg" alt="Gem Version" />}[https://badge.fury.io/rb/jekylljournal]
6
+ {<img src="https://codeclimate.com/github/lorentrogers/jekylljournal/badges/gpa.svg" />}[https://codeclimate.com/github/lorentrogers/jekylljournal]
7
+ {<img src="https://codeclimate.com/github/lorentrogers/jekylljournal/badges/coverage.svg" />}[https://codeclimate.com/github/lorentrogers/jekylljournal/coverage]
8
+ {<img src="https://gemnasium.com/lorentrogers/jekylljournal.svg" alt="Dependency Status" />}[https://gemnasium.com/lorentrogers/jekylljournal]
9
+
5
10
  It's based on this proof of concept, built with bash:
6
11
  https://github.com/lorentrogers/Journal.sh
7
12
 
data/bin/jekylljournal CHANGED
@@ -2,6 +2,7 @@
2
2
  require 'gli'
3
3
  require 'yaml'
4
4
  require 'date'
5
+ require './lib/jekylljournal'
5
6
 
6
7
  include GLI::App
7
8
 
@@ -14,21 +15,14 @@ arguments :strict
14
15
  desc 'Opens a post for the blog'
15
16
  command :open do |c|
16
17
  c.action do |global_options,options,args|
17
- today = Date.today.strftime '%Y-%m-%d'
18
- file_name = "#{@options[:blog_location]}/_posts/#{today}-#{today}.md"
19
- # create the file if it doesn't exist
20
- frontmatter = <<eol
21
- ---
22
- layout: post
23
- title: #{today}
24
- ---
25
-
26
- eol
27
-
28
- File.write file_name, frontmatter unless File.file? file_name
18
+ @journal_handler.open
19
+ end
20
+ end
29
21
 
30
- puts "Opening #{file_name}"
31
- system 'vim', file_name
22
+ desc 'Adds all posts to git and commits them'
23
+ command :save do |c|
24
+ c.action do
25
+ @journal_handler.save
32
26
  end
33
27
  end
34
28
 
@@ -40,21 +34,8 @@ pre do |global,command,options,args|
40
34
  # chosen command
41
35
  # Use skips_pre before a command to skip this block
42
36
  # on that command only
43
-
44
- @options = { }
45
-
46
- CONFIG_FILE = File.join(ENV['HOME'],'.jekylljournal.yaml')
47
- if File.exists? CONFIG_FILE
48
- config_options = YAML.load_file(CONFIG_FILE)
49
- if !config_options
50
- puts 'Config file empty, please see the readme.'
51
- else
52
- @options.merge!(config_options)
53
- end
54
- else
55
- puts 'Config file not found, please create one.'
56
- end
57
-
37
+ @journal_handler = Journalhandler.new
38
+ return false unless @journal_handler
58
39
  true
59
40
  end
60
41
 
@@ -0,0 +1,12 @@
1
+ Feature: Prepend yaml to posts
2
+
3
+ Posts should have yaml frontmatter prepended to them.
4
+
5
+ Background:
6
+ Given a valid dotfile exists
7
+
8
+ Scenario: Create a new post with default yaml
9
+ Given the blog post for today does not exist
10
+ When I run `jekylljournal`
11
+ Then it should create the post for today
12
+ And the file should have the default yaml frontmatter
@@ -8,6 +8,7 @@ spec = Gem::Specification.new do |s|
8
8
  s.homepage = 'http://www.lorentrogers.com'
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.summary = 'A super awesome way of writing daily blog posts with Jekyll.'
11
+ s.license = 'GPL-3.0'
11
12
  s.files = `git ls-files`.split("
12
13
  ")
13
14
  s.require_paths << 'lib'
data/lib/jekylljournal.rb CHANGED
@@ -1 +1,2 @@
1
1
  require 'jekylljournal/version.rb'
2
+ require 'jekylljournal/journalhandler.rb'
@@ -0,0 +1,66 @@
1
+ # This class is used to handle Jekyll Journals.
2
+ # It is generally called from the command line wrapper.
3
+ class Journalhandler
4
+
5
+ # Loads the config dotfile from the default directory and sets the
6
+ # application options
7
+ def initialize
8
+ @options = { }
9
+
10
+ config_file = File.join(ENV['HOME'],'.jekylljournal.yaml')
11
+ if File.exists? config_file
12
+ config_options = YAML.load_file(config_file)
13
+ if !config_options
14
+ puts 'Config file empty, please see the readme.'
15
+ else
16
+ @options.merge!(config_options)
17
+ end
18
+ else
19
+ puts 'Config file not found, please create one.'
20
+ end
21
+ end
22
+
23
+ # Opens today's post if it exists, otherwise
24
+ # it creates a new post, populates it with
25
+ # the default yaml frontmatter, then opens
26
+ # this newly created file.
27
+ def open
28
+ today = Date.today.strftime '%Y-%m-%d'
29
+ file_name = "#{@options[:blog_location]}/_posts/#{today}-#{today}.md"
30
+ # create the file if it doesn't exist
31
+ frontmatter = <<eol
32
+ ---
33
+ layout: post
34
+ title: #{today}
35
+ ---
36
+
37
+ eol
38
+
39
+ File.write file_name, frontmatter unless File.file? file_name
40
+
41
+ puts "Opening #{file_name}"
42
+ system 'vim', file_name
43
+ end
44
+
45
+ # Adds and commits all new posts and assets to git, then
46
+ # pushes to the default repositories.
47
+ # TODO
48
+ def save
49
+ puts 'Saving...'
50
+ run_git_cmd 'add _posts/*'
51
+ run_git_cmd 'add assets/*'
52
+ # TODO: this should use more flexible values.
53
+ # Date format should be a dotfile option
54
+ # Message format should be a dotfile option
55
+ run_git_cmd "commit -m \"Save: #{Date.today.strftime '%Y-%m-%d'}\""
56
+ run_git_cmd 'push'
57
+ puts 'done.'
58
+ end
59
+
60
+ private
61
+
62
+ def run_git_cmd cmd
63
+ location = @options[:blog_location]
64
+ `git --git-dir=#{location}/.git --work-tree=#{location} #{cmd}`
65
+ end
66
+ end
@@ -1,3 +1,3 @@
1
1
  module Jekylljournal
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekylljournal
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
  - Loren Rogers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-21 00:00:00.000000000 Z
11
+ date: 2016-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -92,11 +92,13 @@ files:
92
92
  - jekylljournal.gemspec
93
93
  - jekylljournal.rdoc
94
94
  - lib/jekylljournal.rb
95
+ - lib/jekylljournal/journalhandler.rb
95
96
  - lib/jekylljournal/version.rb
96
97
  - test/default_test.rb
97
98
  - test/test_helper.rb
98
99
  homepage: http://www.lorentrogers.com
99
- licenses: []
100
+ licenses:
101
+ - GPL-3.0
100
102
  metadata: {}
101
103
  post_install_message:
102
104
  rdoc_options: