-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
348 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.classpath | ||
.project | ||
.settings/ | ||
target/ |
47 changes: 0 additions & 47 deletions
47
src/main/java/org/kinimod/asciidoctor/gherkin/GherkinBlockProcessor.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
src/main/java/org/kinimod/asciidoctor/gherkin/template/TemplateProcessor.java
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
src/main/java/org/kinimod/asciidoctor/gherkin/template/package-info.java
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
73 changes: 73 additions & 0 deletions
73
src/main/resources/com/github/domgold/asciidoctor/extension/gherkin/default_template.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
|
||
|
||
=== <%= feature['name'] %> | ||
|
||
<%if feature.key?('description') %> | ||
<%= feature['description'] %> | ||
<% end %> | ||
|
||
<%if feature.key?('background') %>==== <%= feature['background']['name'] %> | ||
<%if feature['background'].key?('description') %> | ||
<%= feature['background']['description'] %> | ||
<% end %><%if feature['background'].key?('steps') %> | ||
[.step-list]<% feature['background']['steps'].each do |step| %> | ||
* *<%= step['keyword'].strip %>* <%= step['name'] %><%if step.key?('doc_string') %> | ||
+ | ||
.... | ||
<%= step['doc_string']['value'] %> | ||
.... | ||
<% end %><%if step.key?('rows') %> | ||
+ | ||
|==== | ||
<% step['rows'].each_with_index do |row, index| %><% row['cells'].each do |cell| %>a| <%= cell %> <% end %> | ||
<% end %>|==== | ||
<% end %> | ||
|
||
<% end %> | ||
<% end %> | ||
|
||
<%if feature['background'].key?('examples') %> | ||
|
||
===== <%= feature['background']['examples']['keyword'].strip %> <%= feature['background']['examples']['name'] %> | ||
|
||
|==== | ||
<% feature['background']['examples']['rows'].each_with_index do |row, index| %><% row['cells'].each do |cell| %>a| <%= cell %> <% end %> | ||
<% if index == 0 %> | ||
<% end %><% end %>|==== | ||
<% end %> | ||
<% end %> | ||
|
||
<%if feature.key?('scenarios') %><% feature['scenarios'].each do |scenario| %>==== <%= scenario['name'] %> | ||
<%if scenario.key?('description') %> | ||
<%= scenario['description'] %> | ||
<% end %><%if scenario.key?('steps') %> | ||
[.step-list]<% scenario['steps'].each do |step| %> | ||
* *<%= step['keyword'].strip %>* <%= step['name'] %><%if step.key?('doc_string') %> | ||
+ | ||
.... | ||
<%= step['doc_string']['value'] %> | ||
.... | ||
<% end %><%if step.key?('rows') %> | ||
+ | ||
|==== | ||
<% step['rows'].each_with_index do |row, index| %><% row['cells'].each do |cell| %>a| <%= cell %> <% end %> | ||
<% end %>|==== | ||
<% end %> | ||
|
||
<% end %> | ||
<% end %> | ||
|
||
<%if scenario.key?('examples') %> | ||
|
||
===== <%= scenario['examples']['keyword'].strip %> <%= scenario['examples']['name'] %> | ||
|
||
|==== | ||
<% scenario['examples']['rows'].each_with_index do |row, index| %><% row['cells'].each do |cell| %>a| <%= cell %> <% end %> | ||
<% if index == 0 %> | ||
<% end %><% end %>|==== | ||
|
||
<% end %> | ||
|
||
<% end %> | ||
<% end %> | ||
|
43 changes: 43 additions & 0 deletions
43
src/main/resources/com/github/domgold/asciidoctor/extension/gherkin/gherkinblock.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require 'asciidoctor' | ||
require 'asciidoctor/extensions' | ||
require 'erb' | ||
require 'java' | ||
|
||
class GherkinIncludeProcessor < Asciidoctor::Extensions::IncludeProcessor | ||
|
||
def process doc, reader, target, attributes | ||
#get the default template from java resource | ||
template_content = org.kinimod.asciidoctor.gherkin.MapFormatter.getDefaultTemplate() | ||
|
||
if doc.attributes.key?('docdir') && attributes.key?('template') && File.exist?(File.expand_path(attributes['template'], doc.attributes['docdir'])) | ||
template_file = File.open(File.expand_path(attributes['template'], doc.attributes['docdir']), "rb") | ||
template_content = template_file.read | ||
else | ||
template_content = org.kinimod.asciidoctor.gherkin.MapFormatter.getDefaultTemplate() | ||
end | ||
|
||
erb_template = ERB.new(template_content) | ||
|
||
feature_file_name = target[8..-1] | ||
if doc.attributes.key?('docdir') | ||
feature_file_name = File.expand_path(feature_file_name, doc.attributes['docdir']) | ||
end | ||
|
||
file = File.open(feature_file_name, "rb") | ||
feature_file_content = file.read | ||
|
||
#parse feature and make the result available to the template via binding as 'feature' hash. | ||
feature = org.kinimod.asciidoctor.gherkin.MapFormatter.parse(feature_file_content) | ||
|
||
rendered_template_output = erb_template.result(binding()) | ||
|
||
reader.push_include rendered_template_output, target, target, 1, attributes | ||
|
||
reader | ||
end | ||
|
||
def handles? target | ||
target.start_with? 'gherkin:' | ||
end | ||
|
||
end |
Oops, something went wrong.