harp2hugo 0.0.1 → 0.0.2

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: acd385214e2d36499c19cccace11256be6671f95
4
- data.tar.gz: f051416c749d50dfd15bd9ca30243a325ad724f6
3
+ metadata.gz: e13c075322caf10a5ba653cbcd64dbfc14dfaacd
4
+ data.tar.gz: 82e092b47e5d4e124529d5e4ef3dcb5934dfe75f
5
5
  SHA512:
6
- metadata.gz: 6ec9da460d8389ea79a6068a7ce8e2ba5aef260c8c6b2adedf6de96bb5a7f8532290ee210a5d3f4a945aa0058f69e11e193afc840fd15c12e70ae616d1c095c3
7
- data.tar.gz: d031ba88b01abacfd64cb05424795508c08e543f2c46f0cccfa8cd590ee96a6bc3bdfc25d0ced9ddb732dbf4805fc858d555acdbd0d12ddd97013e6e359bd866
6
+ metadata.gz: f7e3fc132004c1a5c0f588538dfd679d4474309c268fa016eed705b8f47c803df4a9cffacd6dfd40858b858c29a009c5398dc33404a5fe2e84cf9be1dca721ce
7
+ data.tar.gz: 1feabba3006d38955f230bdba59ed99f4499a204b61cb37e11e6ac44b5e2a669f906ab141d6bf0ee89cfd3920716f883864c96529f7862264c29d56e335d5632
data/.gitignore CHANGED
@@ -3,7 +3,6 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
- .idea
7
6
  Gemfile.lock
8
7
  InstalledFiles
9
8
  _yardoc
@@ -21,3 +20,7 @@ tmp
21
20
  *.o
22
21
  *.a
23
22
  mkmf.log
23
+
24
+ *.iml
25
+ out
26
+ .idea
data/README.md CHANGED
@@ -1,26 +1,28 @@
1
1
  # Harp2hugo
2
+ [![Gem Version](https://badge.fury.io/rb/harp2hugo.svg)](http://badge.fury.io/rb/harp2hugo)
2
3
 
3
- Gem for converting posts from [Harp](https://github.com/sintaxi/harp) to [Hugo](https://github.com/spf13/hugo)
4
+ Gem for converting posts from [Harp](https://github.com/sintaxi/harp) [metadata json](http://harpjs.com/docs/development/metadata)
5
+ into [Hugo](https://github.com/spf13/hugo) [Front Matter](https://gohugo.io/content/front-matter/) format.
4
6
 
5
- Currently still work in progress. Written with plenty of help from @nagliyvred
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
7
+ ## Usage
10
8
 
11
- gem 'harp2hugo'
9
+ $ gem install harp2hugo
10
+ $ harp2hugo [input_file] [output_dir]
12
11
 
13
- And then execute:
12
+ Where input_file defaults to `_data.json` and output_dir defaults to `output`.
13
+ NOTE: the output dir will be created relative to your input file directory.
14
14
 
15
- $ bundle
15
+ $ harp2hugo public/posts/_data.json output
16
16
 
17
- Or install it yourself as:
17
+ Logic is to loop through each post specified in `_data.json` file:
18
18
 
19
- $ gem install harp2hugo
19
+ 1. Reads in the metadata in JSON format
20
+ 2. Convert metadata to YAML format and prepend to the post
21
+ 3. Write the new post with prepended metadata into output directory.
20
22
 
21
- ## Usage
23
+ ## Disclaimer
22
24
 
23
- TBA
25
+ Currently still work in progress. Written with plenty of help from [@nagliyvred](https://github.com/nagliyvred)
24
26
 
25
27
  ## Contributing
26
28
 
data/bin/harp2hugo ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ require "rubygems"
3
+ require "thor"
4
+ require "harp2hugo/cli"
5
+
6
+ Harp2Hugo::CLI.start
data/harp2hugo.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.summary = %q{harp to hugo converter}
12
12
  spec.description = %q{converts your Harp _data.json meta data into Hugo's format}
13
13
  spec.homepage = ""
14
- spec.license = "MIT"
14
+ spec.license = "Apache2"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.6"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "rspec"
24
+ spec.add_runtime_dependency "thor", "~> 0.19"
24
25
  end
@@ -0,0 +1,12 @@
1
+ require "harp2hugo"
2
+
3
+ module Harp2Hugo
4
+ class CLI < Thor
5
+ desc "convert [input_file] [output_dir]", "convert [input_file](default: _data.json) file into [output_dir](default: output) directory"
6
+ def convert(input_file="_data.json", output_dir="output")
7
+ puts "Converting: #{input_file}"
8
+ Dir.chdir(File.dirname(input_file))
9
+ Harp2Hugo::Converter.new(File.basename(input_file)).convert(output_dir)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,26 @@
1
+ require "json"
2
+
3
+ module Harp2Hugo
4
+ class Converter
5
+
6
+ def initialize input_file
7
+ @data_json = JSON.parse(File.read input_file)
8
+ end
9
+
10
+ def convert output_dir
11
+
12
+ @data_json.delete("feed")
13
+
14
+ Dir.mkdir(output_dir) unless Dir.exist? output_dir
15
+ @data_json.each { |key, value|
16
+ post_content = File.read("#{key}.md")
17
+ File.open("#{output_dir}/#{key}.md", 'w') { |output_file|
18
+ output_file.write MetaData.new(value).to_yaml
19
+ output_file.write post_content
20
+ }
21
+ }
22
+
23
+ end
24
+
25
+ end
26
+ end
@@ -1,14 +1,14 @@
1
1
  require "yaml"
2
2
 
3
- class MetaData
4
-
5
- def initialize json_data
6
- @json_data = json_data
7
- end
8
-
9
- def to_yaml
10
- @json_data["linktitle"] = @json_data["title"]
11
- "#{@json_data.to_yaml}---\n"
3
+ module Harp2Hugo
4
+ class MetaData
5
+ def initialize json_data
6
+ @json_data = json_data
7
+ end
8
+
9
+ def to_yaml
10
+ @json_data["linktitle"] = @json_data["title"]
11
+ "#{@json_data.to_yaml}---\n"
12
+ end
12
13
  end
13
-
14
14
  end
@@ -1,3 +1,3 @@
1
1
  class Harp2hugoVersion
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/harp2hugo.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  require "harp2hugo/version"
2
2
  require "harp2hugo/meta_data"
3
- require "harp2hugo/harp2hugo"
3
+ require "harp2hugo/converter"
@@ -0,0 +1,18 @@
1
+
2
+ For Jersey Client (or any Java web client for that matter) to connect to a SSL endpoint, the target server certificate must be
3
+ installed as `jssecacerts` files into your JRE truststore at `$JAVA_HOME\jre\lib\security`. This is painful if you don't have access
4
+ to infrastructure, or don't want to patch/update your server/base Docker container everytime your SSL certificate changes. I will
5
+ show you a more elegant solution for JerseyClient/Dropwizard JerseyClient, where the certificate is loaded from file during runtime
6
+ and doesn't need to live in the JRE.
7
+
8
+ 1. Extract server certificate in JSSE format - Mkyong has a very good tutorial on [extracting server certificate into jssecacerts][mkyong] using [InstallCert][InstallCert].
9
+ 2. Once you have the `jssecacerts` file, put it inside your application's `src/main/resources` folder.
10
+ 3. For a vanillar Jersey Client, you can enable HTTPS following this [answer][answer] and referenced links.
11
+ 4. Dropwizard JerseyClient is built using its own `JerseyClientBuilder`, which you need to confirm to. The answer can be found [JerseyClientBuilderTest][test].
12
+ Simply replace the default `SSLSocketConnectionFactory` with one initialised using your `jssecacerts` TrustStore. A gist is worth a thounsand words:
13
+ <script src="https://gist.github.com/yunspace/7687f67a8eeade0c92d5.js"></script>
14
+
15
+ [mkyong]: http://www.mkyong.com/webservices/jax-ws/suncertpathbuilderexception-unable-to-find-valid-certification-path-to-requested-target/
16
+ [InstallCert]: https://github.com/escline/InstallCert
17
+ [answer]: http://stackoverflow.com/questions/2145431/https-using-jersey-client
18
+ [test]: https://github.com/dropwizard/dropwizard/blob/7ce0d065133cf68191389cf129dffa157c239cb0/dropwizard-client/src/test/java/io/dropwizard/client/JerseyClientBuilderTest.java#L280
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
  require 'harp2hugo'
3
3
 
4
- describe(Harp2hugo) do
4
+ describe(Harp2Hugo::Converter) do
5
5
 
6
6
  it "should load json data and create a new file" do
7
7
  Dir.chdir("spec")
8
- harp2hugo = Harp2hugo.new "_data.json"
8
+ harp2hugo = Harp2Hugo::Converter.new "_data.json"
9
9
 
10
10
  harp2hugo.convert "output"
11
11
 
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'harp2hugo'
3
3
 
4
- describe(MetaData) do
4
+ describe(Harp2Hugo::MetaData) do
5
5
 
6
6
  expected_yaml = <<-eos
7
7
  ---
@@ -21,7 +21,7 @@ linktitle: Dropwizard HTTPS JerseyClient with runtime JSSE CA Certificates
21
21
  "date" => "2015-05-16",
22
22
  "tags" => ["dropwizard", "ssl", "jersey"],
23
23
  "author" => "yunspace"}
24
- metadata = MetaData.new(json_data)
24
+ metadata = Harp2Hugo::MetaData.new(json_data)
25
25
 
26
26
  expect(metadata.to_yaml).to eq(expected_yaml)
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: harp2hugo
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
  - Yun Zhi Lin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-19 00:00:00.000000000 Z
11
+ date: 2015-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,10 +52,25 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: thor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.19'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.19'
55
69
  description: converts your Harp _data.json meta data into Hugo's format
56
70
  email:
57
71
  - yun@yunspace.com
58
- executables: []
72
+ executables:
73
+ - harp2hugo
59
74
  extensions: []
60
75
  extra_rdoc_files: []
61
76
  files:
@@ -68,26 +83,27 @@ files:
68
83
  - ".idea/modules.xml"
69
84
  - ".idea/scopes/scope_settings.xml"
70
85
  - ".idea/vcs.xml"
71
- - ".idea/workspace.xml"
72
86
  - Gemfile
73
87
  - LICENSE.txt
74
88
  - README.md
75
89
  - Rakefile
90
+ - bin/harp2hugo
76
91
  - harp2hugo.gemspec
77
- - harp2hugo.iml
78
92
  - lib/harp2hugo.rb
79
- - lib/harp2hugo/harp2hugo.rb
93
+ - lib/harp2hugo/cli.rb
94
+ - lib/harp2hugo/converter.rb
80
95
  - lib/harp2hugo/meta_data.rb
81
96
  - lib/harp2hugo/version.rb
82
97
  - spec/_data.json
83
98
  - spec/data.yml
99
+ - spec/dropwizard-https-jerseyclient-with-runtime-jssecacerts.md
84
100
  - spec/harp2hugo_spec.rb
85
101
  - spec/meta_data_spec.rb
86
102
  - spec/output.md
87
103
  - spec/spec_helper.rb
88
104
  homepage: ''
89
105
  licenses:
90
- - MIT
106
+ - Apache2
91
107
  metadata: {}
92
108
  post_install_message:
93
109
  rdoc_options: []
@@ -112,6 +128,7 @@ summary: harp to hugo converter
112
128
  test_files:
113
129
  - spec/_data.json
114
130
  - spec/data.yml
131
+ - spec/dropwizard-https-jerseyclient-with-runtime-jssecacerts.md
115
132
  - spec/harp2hugo_spec.rb
116
133
  - spec/meta_data_spec.rb
117
134
  - spec/output.md