harp2hugo 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: acd385214e2d36499c19cccace11256be6671f95
4
+ data.tar.gz: f051416c749d50dfd15bd9ca30243a325ad724f6
5
+ SHA512:
6
+ metadata.gz: 6ec9da460d8389ea79a6068a7ce8e2ba5aef260c8c6b2adedf6de96bb5a7f8532290ee210a5d3f4a945aa0058f69e11e193afc840fd15c12e70ae616d1c095c3
7
+ data.tar.gz: d031ba88b01abacfd64cb05424795508c08e543f2c46f0cccfa8cd590ee96a6bc3bdfc25d0ced9ddb732dbf4805fc858d555acdbd0d12ddd97013e6e359bd866
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .idea
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+ *.bundle
20
+ *.so
21
+ *.o
22
+ *.a
23
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in harp2hugo.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Yun Zhi Lin
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 ADDED
@@ -0,0 +1,31 @@
1
+ # Harp2hugo
2
+
3
+ Gem for converting posts from [Harp](https://github.com/sintaxi/harp) to [Hugo](https://github.com/spf13/hugo)
4
+
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:
10
+
11
+ gem 'harp2hugo'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install harp2hugo
20
+
21
+ ## Usage
22
+
23
+ TBA
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/yunspace/harp2hugo/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/harp2hugo.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'harp2hugo/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "harp2hugo"
8
+ spec.version = Harp2hugoVersion::VERSION
9
+ spec.authors = ["Yun Zhi Lin"]
10
+ spec.email = ["yun@yunspace.com"]
11
+ spec.summary = %q{harp to hugo converter}
12
+ spec.description = %q{converts your Harp _data.json meta data into Hugo's format}
13
+ spec.homepage = ""
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.6"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ end
data/harp2hugo.iml ADDED
@@ -0,0 +1,29 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="FacetManager">
4
+ <facet type="gem" name="Ruby Gem">
5
+ <configuration>
6
+ <option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
7
+ <option name="GEM_APP_TEST_PATH" value="$MODULE_DIR$/test" />
8
+ <option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
9
+ </configuration>
10
+ </facet>
11
+ </component>
12
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
13
+ <exclude-output />
14
+ <content url="file://$MODULE_DIR$">
15
+ <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
16
+ <sourceFolder url="file://$MODULE_DIR$/lib" isTestSource="false" />
17
+ </content>
18
+ <orderEntry type="jdk" jdkName="rbenv: 2.2.2" jdkType="RUBY_SDK" />
19
+ <orderEntry type="sourceFolder" forTests="false" />
20
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.10.5, rbenv: 2.2.2) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, rbenv: 2.2.2) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="rake (v10.4.2, rbenv: 2.2.2) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.3.0, rbenv: 2.2.2) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.3.1, rbenv: 2.2.2) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.3.0, rbenv: 2.2.2) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.3.1, rbenv: 2.2.2) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.3.0, rbenv: 2.2.2) [gem]" level="application" />
28
+ </component>
29
+ </module>
data/lib/harp2hugo.rb ADDED
@@ -0,0 +1,3 @@
1
+ require "harp2hugo/version"
2
+ require "harp2hugo/meta_data"
3
+ require "harp2hugo/harp2hugo"
@@ -0,0 +1,24 @@
1
+ require "json"
2
+
3
+ class Harp2hugo
4
+
5
+ def initialize input_file
6
+ @data_json = JSON.parse(File.read input_file)
7
+ end
8
+
9
+ def convert output_dir
10
+
11
+ @data_json.delete("feed")
12
+
13
+ Dir.mkdir(output_dir) unless Dir.exist?output_dir
14
+ @data_json.each {|key, value|
15
+ post_content = File.read("#{key}.md")
16
+ File.open("#{output_dir}/#{key}.md", 'w') { |output_file|
17
+ output_file.write MetaData.new(value).to_yaml
18
+ output_file.write post_content
19
+ }
20
+ }
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,14 @@
1
+ require "yaml"
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"
12
+ end
13
+
14
+ end
@@ -0,0 +1,3 @@
1
+ class Harp2hugoVersion
2
+ VERSION = "0.0.1"
3
+ end
data/spec/_data.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "feed": {
3
+ "layout": false
4
+ },
5
+ "dropwizard-https-jerseyclient-with-runtime-jssecacerts": {
6
+ "title": "Dropwizard HTTPS JerseyClient with runtime JSSE CA Certificates",
7
+ "date": "2015-05-16",
8
+ "tags": [
9
+ "dropwizard",
10
+ "ssl",
11
+ "jersey"
12
+ ],
13
+ "author": "yunspace"
14
+ }
15
+ }
data/spec/data.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ date: 2015-05-16
3
+ linktitle: Dropwizard HTTPS JerseyClient with runtime JSSE CA Certificates
4
+ title: Dropwizard HTTPS JerseyClient with runtime JSSE CA Certificates
5
+ author: yunspace
6
+ tags: ["dropwizard", "ssl", "jersey"]
7
+ ---
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+ require 'harp2hugo'
3
+
4
+ describe(Harp2hugo) do
5
+
6
+ it "should load json data and create a new file" do
7
+ Dir.chdir("spec")
8
+ harp2hugo = Harp2hugo.new "_data.json"
9
+
10
+ harp2hugo.convert "output"
11
+
12
+ result_file = "output/dropwizard-https-jerseyclient-with-runtime-jssecacerts.md"
13
+ expect(File.exists?result_file).to be_truthy
14
+
15
+ expected_file = "output.md"
16
+ expect(FileUtils.compare_file(result_file, expected_file)).to be_truthy
17
+ end
18
+
19
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+ require 'harp2hugo'
3
+
4
+ describe(MetaData) do
5
+
6
+ expected_yaml = <<-eos
7
+ ---
8
+ title: Dropwizard HTTPS JerseyClient with runtime JSSE CA Certificates
9
+ date: '2015-05-16'
10
+ tags:
11
+ - dropwizard
12
+ - ssl
13
+ - jersey
14
+ author: yunspace
15
+ linktitle: Dropwizard HTTPS JerseyClient with runtime JSSE CA Certificates
16
+ ---
17
+ eos
18
+
19
+ it "should convert json to yaml" do
20
+ json_data = {"title" => "Dropwizard HTTPS JerseyClient with runtime JSSE CA Certificates",
21
+ "date" => "2015-05-16",
22
+ "tags" => ["dropwizard", "ssl", "jersey"],
23
+ "author" => "yunspace"}
24
+ metadata = MetaData.new(json_data)
25
+
26
+ expect(metadata.to_yaml).to eq(expected_yaml)
27
+ end
28
+ end
data/spec/output.md ADDED
@@ -0,0 +1,28 @@
1
+ ---
2
+ title: Dropwizard HTTPS JerseyClient with runtime JSSE CA Certificates
3
+ date: '2015-05-16'
4
+ tags:
5
+ - dropwizard
6
+ - ssl
7
+ - jersey
8
+ author: yunspace
9
+ linktitle: Dropwizard HTTPS JerseyClient with runtime JSSE CA Certificates
10
+ ---
11
+
12
+ For Jersey Client (or any Java web client for that matter) to connect to a SSL endpoint, the target server certificate must be
13
+ installed as `jssecacerts` files into your JRE truststore at `$JAVA_HOME\jre\lib\security`. This is painful if you don't have access
14
+ to infrastructure, or don't want to patch/update your server/base Docker container everytime your SSL certificate changes. I will
15
+ show you a more elegant solution for JerseyClient/Dropwizard JerseyClient, where the certificate is loaded from file during runtime
16
+ and doesn't need to live in the JRE.
17
+
18
+ 1. Extract server certificate in JSSE format - Mkyong has a very good tutorial on [extracting server certificate into jssecacerts][mkyong] using [InstallCert][InstallCert].
19
+ 2. Once you have the `jssecacerts` file, put it inside your application's `src/main/resources` folder.
20
+ 3. For a vanillar Jersey Client, you can enable HTTPS following this [answer][answer] and referenced links.
21
+ 4. Dropwizard JerseyClient is built using its own `JerseyClientBuilder`, which you need to confirm to. The answer can be found [JerseyClientBuilderTest][test].
22
+ Simply replace the default `SSLSocketConnectionFactory` with one initialised using your `jssecacerts` TrustStore. A gist is worth a thounsand words:
23
+ <script src="https://gist.github.com/yunspace/7687f67a8eeade0c92d5.js"></script>
24
+
25
+ [mkyong]: http://www.mkyong.com/webservices/jax-ws/suncertpathbuilderexception-unable-to-find-valid-certification-path-to-requested-target/
26
+ [InstallCert]: https://github.com/escline/InstallCert
27
+ [answer]: http://stackoverflow.com/questions/2145431/https-using-jersey-client
28
+ [test]: https://github.com/dropwizard/dropwizard/blob/7ce0d065133cf68191389cf129dffa157c239cb0/dropwizard-client/src/test/java/io/dropwizard/client/JerseyClientBuilderTest.java#L280
@@ -0,0 +1,2 @@
1
+ $:.unshift File.expand_path("../../lib", __FILE__)
2
+
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: harp2hugo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Yun Zhi Lin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: converts your Harp _data.json meta data into Hugo's format
56
+ email:
57
+ - yun@yunspace.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".idea/.name"
64
+ - ".idea/compiler.xml"
65
+ - ".idea/copyright/profiles_settings.xml"
66
+ - ".idea/encodings.xml"
67
+ - ".idea/misc.xml"
68
+ - ".idea/modules.xml"
69
+ - ".idea/scopes/scope_settings.xml"
70
+ - ".idea/vcs.xml"
71
+ - ".idea/workspace.xml"
72
+ - Gemfile
73
+ - LICENSE.txt
74
+ - README.md
75
+ - Rakefile
76
+ - harp2hugo.gemspec
77
+ - harp2hugo.iml
78
+ - lib/harp2hugo.rb
79
+ - lib/harp2hugo/harp2hugo.rb
80
+ - lib/harp2hugo/meta_data.rb
81
+ - lib/harp2hugo/version.rb
82
+ - spec/_data.json
83
+ - spec/data.yml
84
+ - spec/harp2hugo_spec.rb
85
+ - spec/meta_data_spec.rb
86
+ - spec/output.md
87
+ - spec/spec_helper.rb
88
+ homepage: ''
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.4.5
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: harp to hugo converter
112
+ test_files:
113
+ - spec/_data.json
114
+ - spec/data.yml
115
+ - spec/harp2hugo_spec.rb
116
+ - spec/meta_data_spec.rb
117
+ - spec/output.md
118
+ - spec/spec_helper.rb