vimwiki_markdown 0.0.5 → 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: 8f189d3c34ff57222d67797a78f3128fef429d34
4
- data.tar.gz: aeac3deaea9af1d8cf4354faf8ac04f3202c47ff
3
+ metadata.gz: ea0a2a3a06fdc81312423b662f55ba51a29c8042
4
+ data.tar.gz: 08a9b1299039ad604b01ce28bb49aa54c1dd15f3
5
5
  SHA512:
6
- metadata.gz: 2944bc41ac7329606d3a09fd93302e63bd2cf707c6b690e3f67a762e0be86eed755464d64ff981540e0ac21b51acf7f60edd0a8be86b8ee92aefa25b34e0dc85
7
- data.tar.gz: 32bfaa7451342d1f1ea17d4e45ec9b11c03a1d57cbb114b7a79e85826766344abe86ac4b01fc064b4df0ffe47bbfe7048106adfbd484110f02e694a918e59317
6
+ metadata.gz: 6718d352d95532346c3906d9e5e77b2a3f08644ec9d2dad3a02a772a7173a34ffcabd7f69082ef84e86b38a36366de11269f2ae5a58aa7c1f7917dbbb774a027
7
+ data.tar.gz: 466403cd9dd22997cf5e340d6d118f45d6a89202026638810690ca70f1d459bc83be4f28c5db4271a36e7a7c32789c8adfcf3366fa17974c9a079908018d4c72
data/README.md CHANGED
@@ -20,6 +20,12 @@ for the generation of html. This was added on the master branch in [this commit
20
20
 
21
21
  Currently you will need to make sure you are running the dev branch of vimwiki, or add that commit in yourself
22
22
 
23
+ ## Druby
24
+
25
+ The version 0.1 introduced Druby which we use to greatly speed up the process. You might want to stick
26
+ with the 0.0.x version if things get interesting.
27
+
28
+
23
29
  ## Setup
24
30
 
25
31
  Ensure that your vimiwiki directive in your .vimrc is setup for markdown. For
data/bin/vimwiki_markdown CHANGED
@@ -1,4 +1,42 @@
1
- require 'vimwiki_markdown'
1
+ require 'drb/drb'
2
+ require "vimwiki_markdown/options"
2
3
 
3
- VimwikiMarkdown.convert_wikimarkdown_to_html
4
+ def port_open?(ip, port, timeout)
5
+ start_time = Time.now
6
+ current_time = start_time
7
+ while (current_time - start_time) <= timeout
8
+ begin
9
+ TCPSocket.new(ip, port)
10
+ return true
11
+ rescue Errno::ECONNREFUSED
12
+ sleep 0.1
13
+ end
14
+ current_time = Time.now
15
+ end
4
16
 
17
+ return false
18
+ end
19
+
20
+ unless port_open?("127.0.0.1", 8787, 1)
21
+ server = fork do
22
+ exec "vimwiki_server"
23
+ end
24
+
25
+ Process.detach(server)
26
+ sleep(1)
27
+ end
28
+
29
+ options = VimwikiMarkdown::Options.new
30
+
31
+ # The URI to connect to
32
+ SERVER_URI="druby://localhost:8787"
33
+
34
+ # Start a local DRbServer to handle callbacks.
35
+ #
36
+ # Not necessary for this small example, but will be required
37
+ # as soon as we pass a non-marshallable object as an argument
38
+ # to a dRuby call.
39
+ DRb.start_service
40
+
41
+ vimwiki_service = DRbObject.new_with_uri(SERVER_URI)
42
+ vimwiki_service.generate_html(options)
@@ -0,0 +1,22 @@
1
+ require 'drb/drb'
2
+ require 'vimwiki_markdown'
3
+
4
+ # The URI for the server to connect to
5
+ URI="druby://localhost:8787"
6
+
7
+ class VimwikiMarkdownService
8
+
9
+ def generate_html(options)
10
+ VimwikiMarkdown.convert_wikimarkdown_to_html(options)
11
+ end
12
+
13
+ end
14
+
15
+ # The object that handles requests on the server
16
+ FRONT_OBJECT=VimwikiMarkdownService.new
17
+
18
+ # $SAFE = 1 # disable eval() and friends
19
+
20
+ DRb.start_service(URI, FRONT_OBJECT)
21
+ # Wait for the drb server thread to finish before exiting.
22
+ DRb.thread.join
data/changelog.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.1.0 [April 18th 2015]
2
+ * Quite a major change, we now spin up a Druby server in the background
3
+ and then send the files across the wire to it. This is somewhat
4
+ invasive, but, on the plus side, takes the compilation time from
5
+ several minutes down to seconds as we're not having to start
6
+ up and require a whole bunch of files all the time.
1
7
  ## 0.0.4 [Dec 9th 2014]
2
8
  * Use Github::Markup to prerender the markdown
3
9
 
@@ -72,6 +72,13 @@ module VimwikiMarkdown
72
72
  "#{output_dir}#{title.parameterize}.html"
73
73
  end
74
74
 
75
+ def unmodified?
76
+ return false unless File.exist?(output_fullpath)
77
+
78
+ File.mtime(input_file) < File.mtime(output_fullpath)
79
+ end
80
+
81
+
75
82
  private
76
83
 
77
84
  def arguments
@@ -1,3 +1,3 @@
1
1
  module VimwikiMarkdown
2
- VERSION = "0.0.5"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -5,16 +5,16 @@ require "vimwiki_markdown/wiki_body"
5
5
  require "vimwiki_markdown/exceptions"
6
6
 
7
7
  module VimwikiMarkdown
8
- def self.convert_wikimarkdown_to_html
8
+ def self.convert_wikimarkdown_to_html(options = Options.new)
9
9
  ::I18n.enforce_available_locales = false
10
10
 
11
- options = Options.new
12
- template_html = Template.new(options)
13
- body_html = WikiBody.new(options)
14
- combined_body_template = template_html.to_s.gsub('%content%', body_html.to_s)
15
-
16
- File.write(options.output_fullpath, combined_body_template)
11
+ if !options.unmodified?
12
+ template_html = Template.new(options)
13
+ body_html = WikiBody.new(options)
14
+ combined_body_template = template_html.to_s.gsub('%content%', body_html.to_s)
17
15
 
16
+ File.write(options.output_fullpath, combined_body_template)
17
+ end
18
18
  rescue MissingRequiredParamError => e
19
19
  warn e.message
20
20
  exit(0)
@@ -3,7 +3,7 @@ require 'vimwiki_markdown/options'
3
3
 
4
4
  module VimwikiMarkdown
5
5
  describe Options do
6
- subject { Options.new }
6
+ let(:options) { Options.new }
7
7
 
8
8
  context "no options passed" do
9
9
  before do
@@ -15,5 +15,25 @@ module VimwikiMarkdown
15
15
  its(:output_fullpath) { should eq("#{subject.output_dir}#{subject.title.parameterize}.html") }
16
16
  its(:template_filename) { should eq('/home/patrick/vimwiki/templates/default.tpl') }
17
17
  end
18
+
19
+ context "with an already existing html output" do
20
+ let(:path) { options.output_fullpath }
21
+
22
+ before do
23
+ allow(Options).to receive(:arguments).and_return(Options::DEFAULTS)
24
+ end
25
+
26
+ it "#unmodified? should return false if the file does not exist" do
27
+ allow(File).to receive(:exist?).with(path) { false }
28
+ expect(options.unmodified?).to be(false)
29
+ end
30
+
31
+ it "#unmodified? should return true" do
32
+ allow(File).to receive(:exist?).with(path) { true }
33
+ allow(File).to receive(:mtime).with(path) { Date.today }
34
+ allow(File).to receive(:mtime).with(options.input_file) { Date.today - 1 }
35
+ expect(options.unmodified?).to be(true)
36
+ end
37
+ end
18
38
  end
19
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vimwiki_markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Davey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-15 00:00:00.000000000 Z
11
+ date: 2015-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -198,6 +198,7 @@ email:
198
198
  - patrick.davey@gmail.com
199
199
  executables:
200
200
  - vimwiki_markdown
201
+ - vimwiki_server
201
202
  extensions: []
202
203
  extra_rdoc_files: []
203
204
  files:
@@ -209,6 +210,7 @@ files:
209
210
  - README.md
210
211
  - Rakefile
211
212
  - bin/vimwiki_markdown
213
+ - bin/vimwiki_server
212
214
  - changelog.md
213
215
  - example_files/default.tpl
214
216
  - lib/vimwiki_markdown.rb
@@ -242,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
244
  version: '0'
243
245
  requirements: []
244
246
  rubyforge_project:
245
- rubygems_version: 2.2.2
247
+ rubygems_version: 2.4.6
246
248
  signing_key:
247
249
  specification_version: 4
248
250
  summary: Converts a github flavoured markdown vimwiki file into html.