jekyll_ghost_importer 0.0.1 → 0.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: 1833d123223d208f0aeaf22abc79440becb6f239
4
- data.tar.gz: cdbb09beb04d3c3774273877d9fb6622df0c4148
3
+ metadata.gz: 1f4e1614379288009878b6b78cc1c2ff88ad2e58
4
+ data.tar.gz: b853b18df8322d55a5e8a883bab607d55f6f5d70
5
5
  SHA512:
6
- metadata.gz: b7b4f97329b14c3edddfa96ce8550c75a84f03b22818ab45a795ead459080e02f2a77ba0a59777078d8b1afd90a8cfdc8cccb96b67a385a44b2579c06f8935b1
7
- data.tar.gz: 49205b9df30c666a1ef1e6ca2816ec260a0aea222b81ee277a898be1d7da365eefd84ae04d852fcb8e6a013d26f97adc12d21f63353a117d1c472cf6a242c783
6
+ metadata.gz: 1e734942234ef4b488c73a4c95b6f2dc32f8133141cfeaab15fab6e0b5e4352c9cd5dc881540129edd7e56977a553a2786a23f7798937776facc7330838bc684
7
+ data.tar.gz: 6c241ec90f74a420f37a9a14795d3f0661016b1a9ac54a11a02e9dde309ffa5371ad715357c6a55e91569241b96fcef402950ed95ddec304b2d523fd6b16b7f6
data/Guardfile CHANGED
@@ -1,9 +1,9 @@
1
1
  # A sample Guardfile
2
2
  # More info at https://github.com/guard/guard#readme
3
3
 
4
- guard 'cucumber' do
4
+ guard 'cucumber', bundler: false do
5
5
  watch(%r{^features/.+\.feature$})
6
- watch(%r{^features/support/.+$}) { 'features' }
7
- watch(%r{^bin/.+$}) { 'features' }
8
- watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
6
+ watch(%r{^features/support/.+$}) { 'features' }
7
+ watch(%r{^bin/.+$}) { 'features' }
8
+ watch(%r{^features/step_definitions/.+\.rb$}) { 'features' }
9
9
  end
@@ -3,6 +3,7 @@
3
3
  require 'fileutils'
4
4
  require 'json'
5
5
  require 'date'
6
+ require 'yaml'
6
7
 
7
8
  FileUtils.mkdir_p("_posts")
8
9
  FileUtils.mkdir_p("_drafts")
@@ -12,17 +13,23 @@ json = JSON.parse File.read(ARGV.pop), symbolize_names: true
12
13
  posts = json[:data][:posts]
13
14
 
14
15
  posts.each do |post|
15
- date = Date.parse(post[:published_at]).strftime('%Y-%m-%d') if post[:published_at]
16
+ date = DateTime.parse(post[:published_at]) if post[:published_at]
16
17
  slug = post[:slug]
17
- body = post[:markdown]
18
+ front_matter_hash = {
19
+ 'layout' => "post",
20
+ 'title' => post[:title]
21
+ }
22
+ front_matter_hash['date'] = date.strftime('%Y-%m-%d %H:%M:%S') if date
23
+
24
+ body = front_matter_hash.to_yaml + "---\n\n" + post[:markdown]
18
25
  draft = post[:status] == 'draft'
19
26
  basename = if draft
20
27
  "#{ slug }.markdown"
21
28
  else
22
- "#{ date }-#{ slug }.markdown"
29
+ "#{ date.strftime('%Y-%m-%d') }-#{ slug }.markdown"
23
30
  end
24
31
  folder = draft ? '_drafts' : '_posts'
25
32
  filename = File.join folder, basename
26
- puts filename, basename
33
+ puts "Importing filename..."
27
34
  File.write filename, body
28
35
  end
@@ -10,8 +10,11 @@ Feature: Import posts
10
10
  "data": {
11
11
  "posts": [
12
12
  {
13
+ "title": "Welcome to Ghost",
13
14
  "slug": "welcome-to-ghost",
14
15
  "markdown": "You're live!",
16
+ "featured": 0,
17
+ "status": "published",
15
18
  "published_at": "2014-02-21T01:14:57.000Z"
16
19
  }
17
20
  ]
@@ -22,6 +25,12 @@ Feature: Import posts
22
25
  Then a directory named "_posts" should exist
23
26
  Then the file "_posts/2014-02-21-welcome-to-ghost.markdown" should contain:
24
27
  """
28
+ ---
29
+ layout: post
30
+ title: Welcome to Ghost
31
+ date: '2014-02-21 01:14:57'
32
+ ---
33
+
25
34
  You're live!
26
35
  """
27
36
 
@@ -1,4 +1,3 @@
1
1
  module JekyllGhostImporter
2
- VERSION = "0.0.1"
3
- # Your code goes here...
2
+ VERSION = "0.1.0"
4
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_ghost_importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eloy Espinaco
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-29 00:00:00.000000000 Z
11
+ date: 2014-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -141,4 +141,3 @@ summary: Import your posts from a ghost backup file.
141
141
  test_files:
142
142
  - features/import_posts.feature
143
143
  - features/support/requires.rb
144
- has_rdoc: