bujo 0.1.3 → 0.2.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 +4 -4
- data/lib/bujo/plugins/build_plugin.rb +2 -2
- data/lib/bujo/plugins/edit_plugin.rb +1 -1
- data/lib/bujo/utils/converter.rb +28 -4
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2a25780a5bb46d60c4ab81971f3a50458e78f182b5936a6d4da48e4eb52df9f1
|
|
4
|
+
data.tar.gz: 1896a3b5766b0c5e5b6a1161cc09ec0648b4dd18a615c3290495b8eab96ded1a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5e904702b522a6e56bd28a88606c23acdd5221394ede72a52e1c1707ec8d812e2d4363ae6eb49523496ce2c6b14a4969bd1464fb32b51770024128edd0e5e548
|
|
7
|
+
data.tar.gz: 679f3911b5c95a160218c8bdac1272939c649ec3d74f7eabaed4a0ddcb374e62733832a49f16627fd9047e2272ff0c8ccccd7b8e2b2ef944c692ffdd4e5e00d2
|
|
@@ -35,8 +35,8 @@ module Plugins
|
|
|
35
35
|
def convert_files
|
|
36
36
|
puts "Converting to HTML..."
|
|
37
37
|
Dir.glob(File.join(Configuration::Structure.sources_path, "**/*"))
|
|
38
|
-
.
|
|
39
|
-
.each { |
|
|
38
|
+
.filter { |item| File.file?(item) }
|
|
39
|
+
.each { |file| Utils::Converter.for(file).convert }
|
|
40
40
|
end
|
|
41
41
|
end
|
|
42
42
|
end
|
data/lib/bujo/utils/converter.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
module Utils
|
|
2
2
|
# Ruby
|
|
3
|
+
require 'fileutils'
|
|
3
4
|
require 'asciidoctor'
|
|
4
5
|
|
|
5
6
|
# Own
|
|
@@ -7,12 +8,35 @@ module Utils
|
|
|
7
8
|
require 'bujo/configuration/globals'
|
|
8
9
|
|
|
9
10
|
class Converter
|
|
10
|
-
def self.
|
|
11
|
+
def self.for(source_path)
|
|
12
|
+
source_path =~ /.*\.adoc$/ ? AsciidocFileConverter.new(source_path) : RegularFileConverter.new(source_path)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private def initialize(source_path)
|
|
16
|
+
@source_path = source_path
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def convert
|
|
20
|
+
raise NotImplementedError
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class RegularFileConverter < Converter
|
|
25
|
+
def convert
|
|
26
|
+
source_relative_path = Pathname.new(File.expand_path(@source_path)).relative_path_from(Pathname.new(Configuration::Structure.sources_path))
|
|
27
|
+
target_path = File.join(Configuration::Structure.targets_path, source_relative_path.to_s)
|
|
28
|
+
puts "Converting #{@source_path} to #{target_path}..." if Configuration::Globals.verbose
|
|
29
|
+
FileUtils.copy_file(@source_path, target_path)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
class AsciidocFileConverter < Converter
|
|
34
|
+
def convert
|
|
11
35
|
begin
|
|
12
|
-
source_relative_path = Pathname.new(File.expand_path(source_path)).relative_path_from(Pathname.new(Configuration::Structure.sources_path))
|
|
13
|
-
source_file = File.open(source_path)
|
|
36
|
+
source_relative_path = Pathname.new(File.expand_path(@source_path)).relative_path_from(Pathname.new(Configuration::Structure.sources_path))
|
|
37
|
+
source_file = File.open(@source_path)
|
|
14
38
|
target_path = File.join(Configuration::Structure.targets_path, source_relative_path.to_s.gsub(/\.adoc/, ".html"))
|
|
15
|
-
puts "Converting #{source_path} to #{target_path}..." if Configuration::Globals.verbose
|
|
39
|
+
puts "Converting #{@source_path} to #{target_path}..." if Configuration::Globals.verbose
|
|
16
40
|
Asciidoctor.convert(
|
|
17
41
|
source_file,
|
|
18
42
|
{
|