|
@@ -2,7 +2,8 @@ task default: %w(develop)
|
|
|
STORY_DIR=File.join(ENV['USERPROFILE'], 'Documents\\Twine\\Stories')
|
|
|
STORY_TITLE = 'Volleyball'
|
|
|
STORY_FORMAT = 'SugarCube'
|
|
|
-STORY_FORMAT_VERSION = '2.25.0'
|
|
|
+STORY_FORMAT_PATH = "story_formats/sugarcube-2.28.2-for-twine-2.1-local/sugarcube-2"
|
|
|
+STORY_FORMAT_VERSION = '2.28.2'
|
|
|
FILES = {
|
|
|
'01_intro' => '01 Intro',
|
|
|
'02_transform' => '02 Transform',
|
|
@@ -23,21 +24,29 @@ def files
|
|
|
end
|
|
|
end
|
|
|
|
|
|
-task develop: %w(bundle_install) do
|
|
|
- sh "bundle exec twee2 build main.tw2 develop.html"
|
|
|
+task develop: %w(bundle_install storyjs) do
|
|
|
+ sh "bundle exec twee2 build '--format=#{STORY_FORMAT_PATH}' main.tw2 develop.html"
|
|
|
end
|
|
|
|
|
|
-task watch: %w(bundle_install) do
|
|
|
+task watch: %w(bundle_install storyjs) do
|
|
|
sh 'start watch.html' # FIXME non-windows
|
|
|
- sh "bundle exec twee2 watch main.tw2 watch.html"
|
|
|
+ sh "bundle exec twee2 watch '--format=#{STORY_FORMAT_PATH}' main.tw2 watch.html"
|
|
|
end
|
|
|
|
|
|
-task release: %w(bundle_install) do
|
|
|
- sh "bundle exec twee2 build main.tw2 release.html"
|
|
|
+task release: %w(bundle_install storyjs) do
|
|
|
+ sh "bundle exec twee2 build '--format=#{STORY_FORMAT_PATH}' main.tw2 release.html"
|
|
|
+end
|
|
|
+
|
|
|
+task :storyjs do
|
|
|
+ File.write(
|
|
|
+ 'storyjs.tw2',
|
|
|
+ File.read('storyjs.tw2')\
|
|
|
+ .sub(/\$STORY_FORMAT_VERSION = '[^']*'/, "$STORY_FORMAT_VERSION = '#{STORY_FORMAT_VERSION}'")
|
|
|
+ )
|
|
|
end
|
|
|
|
|
|
desc 'export sub files to Twine 2'
|
|
|
-task export: %w(bundle_install) do
|
|
|
+task export: %w(bundle_install storyjs) do
|
|
|
files.each do |file|
|
|
|
IO.write file.wrapper_file, <<~EOF
|
|
|
::StoryTitle
|
|
@@ -45,9 +54,9 @@ task export: %w(bundle_install) do
|
|
|
|
|
|
::Twee2Settings [twee2]
|
|
|
@story_start_name = 'Start #{file.long_name}'
|
|
|
- Twee2::build_config.story_format = 'SugarCube'
|
|
|
- Twee2::build_config.story_format_version = 'SugarCube2'
|
|
|
-
|
|
|
+ Twee2::build_config.story_format = '#{STORY_FORMAT}'
|
|
|
+ Twee2::build_config.story_format_version = '#{STORY_FORMAT_VERSION}'
|
|
|
+
|
|
|
::StoryIncludes
|
|
|
images.tw2
|
|
|
stylesheet.tw2
|
|
@@ -81,7 +90,7 @@ task import: %w(bundle_install) do
|
|
|
end
|
|
|
|
|
|
task :bundle_install do
|
|
|
- sh 'bundle install'
|
|
|
+ sh 'bundle check || bundle install'
|
|
|
end
|
|
|
|
|
|
task :clean do
|
|
@@ -89,9 +98,8 @@ task :clean do
|
|
|
end
|
|
|
|
|
|
task :lint do
|
|
|
- FILES.each do |short_name, long_name|
|
|
|
- filename = "#{short_name}.tw2"
|
|
|
- twee_source = IO.read(filename)
|
|
|
+ files.each do |file|
|
|
|
+ twee_source = IO.read(file.source_file)
|
|
|
twee_source.lines.each_with_index do |line, lineno|
|
|
|
lineno += 1
|
|
|
line
|
|
@@ -100,18 +108,18 @@ task :lint do
|
|
|
.each do |link|
|
|
|
case link.scan('->').length
|
|
|
when 0
|
|
|
- #puts("link contains no ->, probably not a problem")
|
|
|
+ #link contains no ->, probably not a problem
|
|
|
text = link
|
|
|
when 1
|
|
|
# no problem
|
|
|
text, dest = link.split('->')
|
|
|
else
|
|
|
- puts("link contains multiple -> definitely a problem")
|
|
|
+ warn("link contains multiple -> definitely a problem")
|
|
|
next
|
|
|
end
|
|
|
if text.start_with?('\'')
|
|
|
if !text.end_with?('\'')
|
|
|
- puts("#{filename}:#{lineno} link text (#{text.inspect}) does not end with single quote despite starting with one")
|
|
|
+ warn "#{file.source_file}:#{lineno} link text (#{text.inspect}) does not end with single quote despite starting with one"
|
|
|
next
|
|
|
end
|
|
|
text = text[1..-2]
|
|
@@ -120,12 +128,12 @@ task :lint do
|
|
|
.map {Regexp.last_match.offset(0)[0]}
|
|
|
.each do |offset|
|
|
|
if text[offset - 1] != '\\'
|
|
|
- puts "#{filename}:#{lineno} link text (#{text.inspect}) contains unquoted single quote in body"
|
|
|
+ warn "#{file.source_file}:#{lineno} link text (#{text.inspect}) contains unquoted single quote in body"
|
|
|
end
|
|
|
end
|
|
|
elsif text.start_with?('"')
|
|
|
if !text.end_with?('"')
|
|
|
- puts("#{filename}:#{lineno} link text (#{text.inspect}) does not end with double quote despite starting with one")
|
|
|
+ warn "#{file.source_file}:#{lineno} link text (#{text.inspect}) does not end with double quote despite starting with one"
|
|
|
next
|
|
|
end
|
|
|
text = text[1..-2]
|
|
@@ -134,11 +142,11 @@ task :lint do
|
|
|
.map {Regexp.last_match.offset(0)[0]}
|
|
|
.each do |offset|
|
|
|
if text[offset - 1] != '\\'
|
|
|
- puts "#{filename}:#{lineno} link text (#{text.inspect}) contains unquoted double quote in body"
|
|
|
+ warn "#{file.source_file}:#{lineno} link text (#{text.inspect}) contains unquoted double quote in body"
|
|
|
end
|
|
|
end
|
|
|
- elsif text =~ /\A[\[\]'"\\]*\Z/
|
|
|
- puts "#{filename}:#{lineno} link text (#{text.inspect}) contains special characters but is not quoted with single or double quotes"
|
|
|
+ elsif text =~ /\A[\[\]'"\\]*\z/
|
|
|
+ warn "#{file.source_file}:#{lineno} link text (#{text.inspect}) contains special characters but is not quoted with single or double quotes"
|
|
|
end
|
|
|
end
|
|
|
end
|