hyla 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.
- data/.rakeTasks +7 -0
- data/.travis.yml +10 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +49 -0
- data/LICENSE.txt +22 -0
- data/README.adoc +136 -0
- data/Rakefile +61 -0
- data/archive/GruntFile.js +72 -0
- data/archive/watch_files.rb +70 -0
- data/bin/hyla +155 -0
- data/data/generated/A_Introduction_module/1_Chapter.adoc +42 -0
- data/data/generated/A_Introduction_module/2_Chapter.adoc +31 -0
- data/data/generated/A_Introduction_module/3_Chapter.adoc +23 -0
- data/data/generated/A_Introduction_module/A_Introduction_module_AllSlides.index +9 -0
- data/data/generated/B_Instruction_module/1_Chapter.adoc +27 -0
- data/data/generated/B_Instruction_module/B_Instruction_module_AllSlides.index +7 -0
- data/data/generated/C_Installation_module/1_Chapter.adoc +14 -0
- data/data/generated/C_Installation_module/2_Chapter.adoc +17 -0
- data/data/generated/C_Installation_module/C_Installation_module_AllSlides.index +8 -0
- data/data/generated/camel_AllSlides.index +9 -0
- data/data/js/livereload.js +1055 -0
- data/data/mime.types +85 -0
- data/data/toc.adoc +63 -0
- data/hyla.gemspec +37 -0
- data/hyla_frog.jpg +0 -0
- data/lib/hyla.rb +47 -0
- data/lib/hyla/command.rb +21 -0
- data/lib/hyla/commands/build.rb +40 -0
- data/lib/hyla/commands/create.rb +25 -0
- data/lib/hyla/commands/generate.rb +264 -0
- data/lib/hyla/commands/new.rb +82 -0
- data/lib/hyla/commands/publish.rb +8 -0
- data/lib/hyla/commands/reload.rb +109 -0
- data/lib/hyla/commands/serve.rb +59 -0
- data/lib/hyla/commands/watch.rb +172 -0
- data/lib/hyla/configuration.rb +47 -0
- data/lib/hyla/logger.rb +89 -0
- data/lib/hyla/project.rb +5 -0
- data/lib/hyla/training.rb +25 -0
- data/lib/hyla/websocket.rb +53 -0
- data/lib/templates/sample/asciidoc_article.adoc +64 -0
- data/lib/templates/sample/asciidoc_audio.adoc +4 -0
- data/lib/templates/sample/asciidoc_source_highlight.adoc +37 -0
- data/lib/templates/sample/asciidoc_video.adoc +4 -0
- data/lib/templates/sample/audio/ocean_waves.mp3 +0 -0
- data/lib/templates/sample/image/hyla_arborea.jpg +0 -0
- data/lib/templates/sample/slideshow_deckjs.adoc +186 -0
- data/lib/templates/sample/video/small.ogv +0 -0
- data/lib/templates/training-exercises/Gemfile +4 -0
- data/lib/templates/training-exercises/README.md +1 -0
- data/lib/templates/training-exercises/modules/introduction/docs/audio/ocean_waves.mp3 +0 -0
- data/lib/templates/training-exercises/modules/introduction/docs/video/small.ogv +0 -0
- data/lib/templates/training-exercises/modules/introduction/pom.xml +114 -0
- data/lib/templates/training-exercises/modules/introduction/src/main/java/HelloWorld.java +16 -0
- data/lib/templates/training-exercises/modules/introduction/src/test/java/HelloWorldTest.java +29 -0
- data/lib/templates/training-exercises/modules/pom.xml +61 -0
- data/lib/templates/training-exercises/modules/src/main/assembly/code.xml +31 -0
- data/lib/templates/training-exercises/modules/src/main/assembly/content.xml +16 -0
- data/lib/templates/training-exercises/pom.xml +157 -0
- data/lib/templates/training/GemFile +4 -0
- data/lib/templates/training/development/article.adoc +64 -0
- data/lib/templates/training/development/audio/ocean_waves.mp3 +0 -0
- data/lib/templates/training/development/image/hyla_frog.jpg +0 -0
- data/lib/templates/training/development/video/small.ogv +0 -0
- data/lib/templates/training/introduction/article.adoc +64 -0
- data/lib/templates/training/introduction/audio/ocean_waves.mp3 +0 -0
- data/lib/templates/training/introduction/image/hyla_frog.jpg +0 -0
- data/lib/templates/training/introduction/video/small.ogv +0 -0
- data/lib/templates/training/readme.adoc +1 -0
- data/scenario.adoc +59 -0
- data/test/my_test.rb +23 -0
- metadata +265 -0
data/data/mime.types
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# These are the same MIME types that GitHub Pages uses as of 17 Mar 2013.
|
|
2
|
+
|
|
3
|
+
text/html html htm shtml
|
|
4
|
+
text/css css
|
|
5
|
+
text/xml xml rss xsl
|
|
6
|
+
image/gif gif
|
|
7
|
+
image/jpeg jpeg jpg
|
|
8
|
+
application/x-javascript js
|
|
9
|
+
application/atom+xml atom
|
|
10
|
+
|
|
11
|
+
text/mathml mml
|
|
12
|
+
text/plain txt
|
|
13
|
+
text/vnd.sun.j2me.app-descriptor jad
|
|
14
|
+
text/vnd.wap.wml wml
|
|
15
|
+
text/x-component htc
|
|
16
|
+
text/cache-manifest manifest appcache
|
|
17
|
+
text/coffeescript coffee
|
|
18
|
+
text/plain pde
|
|
19
|
+
text/plain md markdown
|
|
20
|
+
|
|
21
|
+
image/png png
|
|
22
|
+
image/svg+xml svg
|
|
23
|
+
image/tiff tif tiff
|
|
24
|
+
image/vnd.wap.wbmp wbmp
|
|
25
|
+
image/x-icon ico
|
|
26
|
+
image/x-jng jng
|
|
27
|
+
image/x-ms-bmp bmp
|
|
28
|
+
|
|
29
|
+
application/json json
|
|
30
|
+
application/java-archive jar ear
|
|
31
|
+
application/mac-binhex40 hqx
|
|
32
|
+
application/msword doc
|
|
33
|
+
application/pdf pdf
|
|
34
|
+
application/postscript ps eps ai
|
|
35
|
+
application/rdf+xml rdf
|
|
36
|
+
application/rtf rtf
|
|
37
|
+
text/vcard vcf vcard
|
|
38
|
+
application/vnd.apple.pkpass pkpass
|
|
39
|
+
application/vnd.ms-excel xls
|
|
40
|
+
application/vnd.ms-powerpoint ppt
|
|
41
|
+
application/vnd.wap.wmlc wmlc
|
|
42
|
+
application/xhtml+xml xhtml
|
|
43
|
+
application/x-chrome-extension crx
|
|
44
|
+
application/x-cocoa cco
|
|
45
|
+
application/x-font-ttf ttf
|
|
46
|
+
application/x-java-archive-diff jardiff
|
|
47
|
+
application/x-java-jnlp-file jnlp
|
|
48
|
+
application/x-makeself run
|
|
49
|
+
application/x-ns-proxy-autoconfig pac
|
|
50
|
+
application/x-perl pl pm
|
|
51
|
+
application/x-pilot prc pdb
|
|
52
|
+
application/x-rar-compressed rar
|
|
53
|
+
application/x-redhat-package-manager rpm
|
|
54
|
+
application/x-sea sea
|
|
55
|
+
application/x-shockwave-flash swf
|
|
56
|
+
application/x-stuffit sit
|
|
57
|
+
application/x-tcl tcl tk
|
|
58
|
+
application/x-web-app-manifest+json webapp
|
|
59
|
+
application/x-x509-ca-cert der pem crt
|
|
60
|
+
application/x-xpinstall xpi
|
|
61
|
+
application/x-zip war
|
|
62
|
+
application/zip zip
|
|
63
|
+
|
|
64
|
+
application/octet-stream bin exe dll
|
|
65
|
+
application/octet-stream deb
|
|
66
|
+
application/octet-stream dmg
|
|
67
|
+
application/octet-stream eot
|
|
68
|
+
application/octet-stream iso img
|
|
69
|
+
application/octet-stream msi msp msm
|
|
70
|
+
|
|
71
|
+
audio/midi mid midi kar
|
|
72
|
+
audio/mpeg mp3
|
|
73
|
+
audio/x-realaudio ra
|
|
74
|
+
audio/ogg ogg
|
|
75
|
+
|
|
76
|
+
video/3gpp 3gpp 3gp
|
|
77
|
+
video/mpeg mpeg mpg
|
|
78
|
+
video/quicktime mov
|
|
79
|
+
video/x-flv flv
|
|
80
|
+
video/x-mng mng
|
|
81
|
+
video/x-ms-asf asx asf
|
|
82
|
+
video/x-ms-wmv wmv
|
|
83
|
+
video/x-msvideo avi
|
|
84
|
+
video/ogg ogv
|
|
85
|
+
video/webm webm
|
data/data/toc.adoc
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
= A. Introduction module
|
|
2
|
+
|
|
3
|
+
>> This is the module 'A. Introduction'
|
|
4
|
+
|
|
5
|
+
== 1. Chapter
|
|
6
|
+
|
|
7
|
+
This is a chapter about ...
|
|
8
|
+
|
|
9
|
+
== 2. Chapter
|
|
10
|
+
|
|
11
|
+
This is a Chapter about ...
|
|
12
|
+
|
|
13
|
+
=== 2.1. Section
|
|
14
|
+
|
|
15
|
+
This is a Section about ...
|
|
16
|
+
|
|
17
|
+
=== 2.2. Section
|
|
18
|
+
|
|
19
|
+
This is a Section about ...
|
|
20
|
+
|
|
21
|
+
== 3. Chapter
|
|
22
|
+
|
|
23
|
+
This is a Chapter about ...
|
|
24
|
+
|
|
25
|
+
=== 3.1. Section
|
|
26
|
+
|
|
27
|
+
This is a Section about ...
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
= B. Instruction module
|
|
32
|
+
|
|
33
|
+
>> This is the module 'B. Instruction module'
|
|
34
|
+
|
|
35
|
+
== 1. Chapter
|
|
36
|
+
|
|
37
|
+
This is a Chapter about ...
|
|
38
|
+
|
|
39
|
+
=== 1.1. Section
|
|
40
|
+
|
|
41
|
+
This is a Section about ...
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
= C. Installation module
|
|
46
|
+
|
|
47
|
+
>> This is the module 'C. Installation module'
|
|
48
|
+
|
|
49
|
+
== 1. Chapter
|
|
50
|
+
|
|
51
|
+
This is a Chapter about ...
|
|
52
|
+
|
|
53
|
+
=== 1.1. Section
|
|
54
|
+
|
|
55
|
+
This is a Section about ...
|
|
56
|
+
|
|
57
|
+
== 2. Chapter
|
|
58
|
+
|
|
59
|
+
This is a Chapter about ...
|
|
60
|
+
|
|
61
|
+
=== 2.1. Section
|
|
62
|
+
|
|
63
|
+
This is a Section about ...
|
data/hyla.gemspec
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'hyla/project'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
s.name = 'hyla'
|
|
8
|
+
s.version = Hyla::VERSION
|
|
9
|
+
s.authors = ["Charles Mouliard"]
|
|
10
|
+
s.email = ["ch007m@gmail.com"]
|
|
11
|
+
s.description = Hyla::DESCRIPTION
|
|
12
|
+
s.summary = Hyla::SUMMARY
|
|
13
|
+
s.homepage = "https://github.com/cmoulliard/hyla"
|
|
14
|
+
s.license = "Apache License 2.0"
|
|
15
|
+
|
|
16
|
+
s.files = `git ls-files`.split($/)
|
|
17
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
s.test_files = s.files.grep(%r{^(test|s|features)/})
|
|
19
|
+
s.require_paths = ['lib']
|
|
20
|
+
|
|
21
|
+
s.add_development_dependency 'bundler', '~> 1.3'
|
|
22
|
+
s.add_development_dependency 'rake', '~> 10.1'
|
|
23
|
+
s.add_development_dependency 'rdoc', '~> 3.11'
|
|
24
|
+
# TODO - Review if guard / listen are mandatory deps
|
|
25
|
+
# s.add_development_dependency 'guard', '~> 1.8.3'
|
|
26
|
+
s.add_development_dependency 'listen', '~> 2.0'
|
|
27
|
+
|
|
28
|
+
# Ruby command-line executables
|
|
29
|
+
s.add_runtime_dependency 'commander', '~> 4.1.3'
|
|
30
|
+
s.add_runtime_dependency 'asciidoctor', '~> 0.1.4'
|
|
31
|
+
s.add_runtime_dependency 'em-websocket', '~> 0.5'
|
|
32
|
+
s.add_runtime_dependency 'multi_json', '~> 1.8'
|
|
33
|
+
|
|
34
|
+
# Colorize Text Terminal
|
|
35
|
+
s.add_runtime_dependency 'colorator', '~> 0.1'
|
|
36
|
+
|
|
37
|
+
end
|
data/hyla_frog.jpg
ADDED
|
Binary file
|
data/lib/hyla.rb
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
$:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
|
|
2
|
+
|
|
3
|
+
# Require all of the Ruby files in the given directory.
|
|
4
|
+
#
|
|
5
|
+
# path - The String relative path from here to the directory.
|
|
6
|
+
#
|
|
7
|
+
# Returns nothing.
|
|
8
|
+
def require_all(path)
|
|
9
|
+
glob = File.join(File.dirname(__FILE__), path, '*.rb')
|
|
10
|
+
Dir[glob].each do |f|
|
|
11
|
+
require f
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# rubygems
|
|
16
|
+
require 'rubygems'
|
|
17
|
+
|
|
18
|
+
# 3rd party
|
|
19
|
+
require 'colorator'
|
|
20
|
+
require 'listen'
|
|
21
|
+
require 'guard'
|
|
22
|
+
require 'asciidoctor'
|
|
23
|
+
require 'eventmachine'
|
|
24
|
+
require 'em-websocket'
|
|
25
|
+
require 'http/parser'
|
|
26
|
+
require 'multi_json'
|
|
27
|
+
require 'webrick'
|
|
28
|
+
require 'find'
|
|
29
|
+
|
|
30
|
+
# internal requires
|
|
31
|
+
require 'hyla/logger'
|
|
32
|
+
require 'hyla/training'
|
|
33
|
+
require 'hyla/command'
|
|
34
|
+
require 'hyla/configuration'
|
|
35
|
+
require 'Hyla/WebSocket'
|
|
36
|
+
require 'hyla/logger'
|
|
37
|
+
|
|
38
|
+
# extensions
|
|
39
|
+
require_all 'hyla/commands'
|
|
40
|
+
|
|
41
|
+
module Hyla
|
|
42
|
+
|
|
43
|
+
def self.logger
|
|
44
|
+
@logger ||= Logger.new
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
data/lib/hyla/command.rb
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Hyla
|
|
2
|
+
class Command
|
|
3
|
+
|
|
4
|
+
def self.globs(source, destination)
|
|
5
|
+
Dir.chdir(source) do
|
|
6
|
+
dirs = Dir['*'].select { |x| File.directory?(x) }
|
|
7
|
+
dirs -= [destination, File.expand_path(destination), File.basename(destination)]
|
|
8
|
+
dirs = dirs.map { |x| "#{x}/**/*" }
|
|
9
|
+
dirs += ['*']
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
program :int_block do
|
|
14
|
+
# kill threads etc
|
|
15
|
+
# make sure to exit or abort, otherwise your program keeps running
|
|
16
|
+
Hyla::logger.warn "CTRL-C / Shutdown command received"
|
|
17
|
+
exit 1
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module Hyla
|
|
2
|
+
module Commands
|
|
3
|
+
class Build < Command
|
|
4
|
+
|
|
5
|
+
def process(options)
|
|
6
|
+
training = Hyla::Training.new(options)
|
|
7
|
+
build(training, options)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
#
|
|
11
|
+
#
|
|
12
|
+
#
|
|
13
|
+
def build(training, options)
|
|
14
|
+
source = options['source']
|
|
15
|
+
destination = options['destination']
|
|
16
|
+
Hyla.logger.info "Source: ", source
|
|
17
|
+
Hyla.logger.info "Destination: ", destination
|
|
18
|
+
print Hyla.logger.formatted_topic "Generating..."
|
|
19
|
+
self.process_training(training)
|
|
20
|
+
puts "done."
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Static: Run Training#process and catch errors
|
|
24
|
+
#
|
|
25
|
+
# training - the Hyla::Training object
|
|
26
|
+
#
|
|
27
|
+
# Returns nothing
|
|
28
|
+
def self.process_training(training)
|
|
29
|
+
training.process
|
|
30
|
+
rescue Hyla::FatalException => e
|
|
31
|
+
puts
|
|
32
|
+
Hyla.logger.error "ERROR:", "YOUR TRAINING COULD NOT BE BUILT:"
|
|
33
|
+
Hyla.logger.error "", "------------------------------------"
|
|
34
|
+
Hyla.logger.error "", e.message
|
|
35
|
+
exit(1)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end # class
|
|
39
|
+
end # module Commands
|
|
40
|
+
end # module Hyla
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Hyla
|
|
2
|
+
module Commands
|
|
3
|
+
class Create < Command
|
|
4
|
+
|
|
5
|
+
def self.process(args, options = {})
|
|
6
|
+
|
|
7
|
+
@config = Hyla::Configuration.new
|
|
8
|
+
|
|
9
|
+
destination = options[:destination]
|
|
10
|
+
artefact_type = options[:artefact_type]
|
|
11
|
+
type = options[:type]
|
|
12
|
+
|
|
13
|
+
copy_artefact(type, artefact_type, destination)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.copy_artefact(type, artefact_type, destination)
|
|
17
|
+
artefact_name = type + '_' + artefact_type + @config.ADOC_EXT
|
|
18
|
+
source = [@config.templates, 'sample', artefact_name] * '/'
|
|
19
|
+
destination = [destination] * '/'
|
|
20
|
+
FileUtils.cp(source, destination)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end # class
|
|
24
|
+
end # module Commands
|
|
25
|
+
end # module Hyla
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
module Hyla
|
|
2
|
+
module Commands
|
|
3
|
+
class Generate < Command
|
|
4
|
+
|
|
5
|
+
attr_reader :artefact
|
|
6
|
+
|
|
7
|
+
DEFAULT_OPTIONS = {
|
|
8
|
+
:watch_dir => '.',
|
|
9
|
+
:watch_ext => %w(ad adoc asc asciidoc txt index),
|
|
10
|
+
:run_on_start => false,
|
|
11
|
+
:backend => 'html5',
|
|
12
|
+
:eruby => 'erb',
|
|
13
|
+
:doctype => 'article',
|
|
14
|
+
:compact => false,
|
|
15
|
+
:attributes => {},
|
|
16
|
+
:always_build_all => false,
|
|
17
|
+
:safe => :unsafe,
|
|
18
|
+
:header_footer => true
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
def self.process(args, options = {})
|
|
22
|
+
|
|
23
|
+
@config = Hyla::Configuration.new
|
|
24
|
+
|
|
25
|
+
rendering = options[:rendering] if self.check_mandatory_option?('--r / --rendering', options[:rendering])
|
|
26
|
+
|
|
27
|
+
case rendering
|
|
28
|
+
when 'toc2html'
|
|
29
|
+
|
|
30
|
+
Hyla.logger.info "Rendering : Table of Content to HTML"
|
|
31
|
+
self.check_mandatory_option?('--t / --toc', options[:toc])
|
|
32
|
+
@toc_file = options[:toc]
|
|
33
|
+
@out_dir = options[:destination]
|
|
34
|
+
@project_name = options[:project_name]
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
self.table_of_content_to_asciidoc(@toc_file, @out_dir, @project_name)
|
|
38
|
+
|
|
39
|
+
when 'adoc2html'
|
|
40
|
+
|
|
41
|
+
Hyla.logger.info "Rendering : Asciidoc to HTML"
|
|
42
|
+
self.check_mandatory_option?('--s / --source', options[:source])
|
|
43
|
+
self.check_mandatory_option?('--d / --destination', options[:destination])
|
|
44
|
+
@destination = options[:destination]
|
|
45
|
+
@source = options[:source]
|
|
46
|
+
|
|
47
|
+
self.asciidoc_to_html(@source, @destination)
|
|
48
|
+
|
|
49
|
+
when 'adoc2slides'
|
|
50
|
+
Hyla.logger.info "Rendering : Asciidoc to SlideShow - NOT YET AVAILABLE"
|
|
51
|
+
else
|
|
52
|
+
Hyla.logger.error ">> Unknow rendering"
|
|
53
|
+
exit(1)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# From Table of Content File to Asciidoc directories and Files
|
|
57
|
+
# self.table_of_content_to_asciidoc(@toc_file, @out_dir, @project_name)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def self.asciidoc_to_html(source, destination)
|
|
61
|
+
|
|
62
|
+
options = DEFAULT_OPTIONS.clone
|
|
63
|
+
|
|
64
|
+
# Move to Source directory & Retrieve Asciidoctor files to be processed
|
|
65
|
+
source = File.expand_path source
|
|
66
|
+
@destination = File.expand_path destination
|
|
67
|
+
Hyla.logger.info ">> Source dir: #{source}"
|
|
68
|
+
Hyla.logger.info ">> Destination dir: #{@destination}"
|
|
69
|
+
|
|
70
|
+
Dir.chdir(source)
|
|
71
|
+
current_dir = Dir.pwd
|
|
72
|
+
Hyla.logger.info ">> Current dir: #{current_dir}"
|
|
73
|
+
|
|
74
|
+
# Delete destination directory
|
|
75
|
+
FileUtils.rm_rf(Dir.glob(@destination))
|
|
76
|
+
|
|
77
|
+
# Search for Asciidoc files and do the rendering
|
|
78
|
+
adoc_file_paths = []
|
|
79
|
+
Find.find(current_dir) do |path|
|
|
80
|
+
if path =~ /.*\.(?:adoc|txt|index)$/
|
|
81
|
+
path1 = Pathname.new(source)
|
|
82
|
+
path2 = Pathname.new(path)
|
|
83
|
+
relative_path = path2.relative_path_from(path1).to_s
|
|
84
|
+
Hyla.logger.debug ">> Relative path: #{relative_path}"
|
|
85
|
+
adoc_file_paths << relative_path
|
|
86
|
+
|
|
87
|
+
# Create directory in the destination directory
|
|
88
|
+
html_dir = @destination + '/' + File.dirname(relative_path)
|
|
89
|
+
Hyla.logger.info ">> Dir of html: #{html_dir}"
|
|
90
|
+
FileUtils.mkdir_p html_dir
|
|
91
|
+
|
|
92
|
+
# Render asciidoc to HTML
|
|
93
|
+
Hyla.logger.info ">> File to be rendered : #{path}"
|
|
94
|
+
options[:to_dir] = html_dir
|
|
95
|
+
Asciidoctor.render_file(path, options)
|
|
96
|
+
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# No asciidoc files retrieved
|
|
101
|
+
if adoc_file_paths.empty?
|
|
102
|
+
Hyla.logger.info " >> No asciidoc files retrieved."
|
|
103
|
+
exit(1)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
#
|
|
109
|
+
# Method parsing TOC File to generate directories and files
|
|
110
|
+
# Each Level 1 entry will become a directory
|
|
111
|
+
# and each Level 2 a file created under the directory
|
|
112
|
+
#
|
|
113
|
+
# @param [File Containing the Table of Content] toc_file
|
|
114
|
+
# @param [Directory where asciidoc files will be generated] out_dir
|
|
115
|
+
# @param [Project name used to create parent of index files] project_name
|
|
116
|
+
#
|
|
117
|
+
def self.table_of_content_to_asciidoc(toc_file, out_dir, project_name)
|
|
118
|
+
|
|
119
|
+
Hyla.logger.info '>> Project Name : ' + project_name + ' <<'
|
|
120
|
+
|
|
121
|
+
# Open file & parse it
|
|
122
|
+
f = File.open(toc_file, 'r')
|
|
123
|
+
|
|
124
|
+
# Re Create Directory of generated content
|
|
125
|
+
if Dir.exist? out_dir
|
|
126
|
+
FileUtils.rm_rf out_dir
|
|
127
|
+
FileUtils.mkdir_p out_dir
|
|
128
|
+
else
|
|
129
|
+
FileUtils.mkdir_p out_dir
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
#
|
|
133
|
+
# Move to 'generated' directory as we will
|
|
134
|
+
# create content relative to this directory
|
|
135
|
+
#
|
|
136
|
+
Dir.chdir out_dir
|
|
137
|
+
out_dir = Pathname.pwd
|
|
138
|
+
|
|
139
|
+
# Create index file of all index files
|
|
140
|
+
@project_index_file = self.create_index_file(project_name, @config.LEVEL_1)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
# File iteration
|
|
144
|
+
f.each do |line|
|
|
145
|
+
|
|
146
|
+
#
|
|
147
|
+
# Check level 1
|
|
148
|
+
# Create a directory where its name corresponds to 'Title Level 1' &
|
|
149
|
+
# where we have removed the leading '=' symbol and '.' and
|
|
150
|
+
# replaced ' ' by '_'
|
|
151
|
+
#
|
|
152
|
+
if line[/^=\s/]
|
|
153
|
+
|
|
154
|
+
# Create File
|
|
155
|
+
dir_name = remove_special_chars(2, line)
|
|
156
|
+
new_dir = [out_dir, dir_name].join('/')
|
|
157
|
+
Hyla.logger.info '>> Directory created : ' + new_dir + ' <<'
|
|
158
|
+
FileUtils.mkdir_p new_dir
|
|
159
|
+
Dir.chdir(new_dir)
|
|
160
|
+
|
|
161
|
+
# Add image directory
|
|
162
|
+
Dir.mkdir('image')
|
|
163
|
+
|
|
164
|
+
#
|
|
165
|
+
# Create an index file
|
|
166
|
+
# It is used to include files belonging to a module and will be used for SlideShows
|
|
167
|
+
# The file created contains a title (= Dir Name) and header with attributes
|
|
168
|
+
#
|
|
169
|
+
@index_file = create_index_file(dir_name, @config.LEVEL_2)
|
|
170
|
+
|
|
171
|
+
# Include index file created to parent index file
|
|
172
|
+
@project_index_file.puts @config.INCLUDE_PREFIX + dir_name + '/' + dir_name + @config.INDEX_SUFFIX + @config.INCLUDE_SUFFIX
|
|
173
|
+
|
|
174
|
+
# Move to next line record
|
|
175
|
+
next
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
#
|
|
179
|
+
# Check Level 2
|
|
180
|
+
# Create a file for each Title Level 2 where name corresponds to title (without '==' symbol) &
|
|
181
|
+
# where we have removed the leading '==' symbol and '.' and replace ' ' by '_'
|
|
182
|
+
#
|
|
183
|
+
if line[/^==\s/]
|
|
184
|
+
|
|
185
|
+
# Close File created previously if it exists
|
|
186
|
+
if !@previous_f.nil?
|
|
187
|
+
@previous_f.close
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# Create File
|
|
191
|
+
f_name = remove_special_chars(3, line)
|
|
192
|
+
Hyla.logger.info ' # File created : ' + f_name.to_s
|
|
193
|
+
f_name += '.adoc'
|
|
194
|
+
@new_f = File.new(f_name, 'w')
|
|
195
|
+
@new_f.puts @config.HEADER
|
|
196
|
+
|
|
197
|
+
@previous_f = @new_f
|
|
198
|
+
|
|
199
|
+
# Include file to index
|
|
200
|
+
@index_file.puts @config.INCLUDE_PREFIX + f_name + @config.INCLUDE_SUFFIX
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
#
|
|
204
|
+
# Add Content to file if it exists and line does not start with characters to be skipped
|
|
205
|
+
#
|
|
206
|
+
if !@new_f.nil? and !line.start_with?(@config.SKIP_CHARACTERS)
|
|
207
|
+
@new_f.puts line
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# method parse_file(f)
|
|
215
|
+
|
|
216
|
+
#
|
|
217
|
+
# Remove space, dot from a String
|
|
218
|
+
#
|
|
219
|
+
def self.remove_special_chars(pos, text)
|
|
220
|
+
return text[pos, text.length].strip.gsub(/\s/, '_').gsub('.', '')
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
#
|
|
224
|
+
# Add '/' at the end of the target path
|
|
225
|
+
# if the target path provided doesn't contain it
|
|
226
|
+
#
|
|
227
|
+
def self.check_slash_end(out_dir)
|
|
228
|
+
last_char = out_dir.to_s[-1, 1]
|
|
229
|
+
Hyla.logger.info '>> Last char : ' + last_char
|
|
230
|
+
if !last_char.equal? '/\//'
|
|
231
|
+
temp_dir = out_dir.to_s
|
|
232
|
+
out_dir = temp_dir + '/'
|
|
233
|
+
end
|
|
234
|
+
out_dir
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
#
|
|
238
|
+
# Create ascidoc index file
|
|
239
|
+
# containing references to asciidoc files part of a module
|
|
240
|
+
#
|
|
241
|
+
def self.create_index_file(file_name, level)
|
|
242
|
+
n_file_name = file_name + @config.INDEX_SUFFIX
|
|
243
|
+
index_file = File.new(n_file_name, 'w')
|
|
244
|
+
index_file.puts level + file_name
|
|
245
|
+
index_file.puts @config.HEADER_INDEX
|
|
246
|
+
|
|
247
|
+
index_file
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
#
|
|
251
|
+
# Check mandatory options
|
|
252
|
+
#
|
|
253
|
+
def self.check_mandatory_option?(key, value)
|
|
254
|
+
if value.nil? or value.empty?
|
|
255
|
+
Hyla.logger.warn "Mandatory option missing: #{key}"
|
|
256
|
+
exit(1)
|
|
257
|
+
else
|
|
258
|
+
true
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
end # class
|
|
263
|
+
end # module Commands
|
|
264
|
+
end # module Hyla
|