|
@@ -2,7 +2,8 @@ task default: %w(develop)
|
|
STORY_DIR=File.join(ENV['USERPROFILE'], 'Documents\\Twine\\Stories')
|
|
STORY_DIR=File.join(ENV['USERPROFILE'], 'Documents\\Twine\\Stories')
|
|
STORY_TITLE = 'Volleyball'
|
|
STORY_TITLE = 'Volleyball'
|
|
STORY_FORMAT = 'SugarCube'
|
|
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 = {
|
|
FILES = {
|
|
'01_intro' => '01 Intro',
|
|
'01_intro' => '01 Intro',
|
|
'02_transform' => '02 Transform',
|
|
'02_transform' => '02 Transform',
|
|
@@ -23,21 +24,29 @@ def files
|
|
end
|
|
end
|
|
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
|
|
end
|
|
|
|
|
|
-task watch: %w(bundle_install) do
|
|
|
|
|
|
+task watch: %w(bundle_install storyjs) do
|
|
sh 'start watch.html' # FIXME non-windows
|
|
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
|
|
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
|
|
end
|
|
|
|
|
|
desc 'export sub files to Twine 2'
|
|
desc 'export sub files to Twine 2'
|
|
-task export: %w(bundle_install) do
|
|
|
|
|
|
+task export: %w(bundle_install storyjs) do
|
|
files.each do |file|
|
|
files.each do |file|
|
|
IO.write file.wrapper_file, <<~EOF
|
|
IO.write file.wrapper_file, <<~EOF
|
|
::StoryTitle
|
|
::StoryTitle
|
|
@@ -45,9 +54,9 @@ task export: %w(bundle_install) do
|
|
|
|
|
|
::Twee2Settings [twee2]
|
|
::Twee2Settings [twee2]
|
|
@story_start_name = 'Start #{file.long_name}'
|
|
@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
|
|
::StoryIncludes
|
|
images.tw2
|
|
images.tw2
|
|
stylesheet.tw2
|
|
stylesheet.tw2
|
|
@@ -81,7 +90,7 @@ task import: %w(bundle_install) do
|
|
end
|
|
end
|
|
|
|
|
|
task :bundle_install do
|
|
task :bundle_install do
|
|
- sh 'bundle install'
|
|
|
|
|
|
+ sh 'bundle check || bundle install'
|
|
end
|
|
end
|
|
|
|
|
|
task :clean do
|
|
task :clean do
|
|
@@ -89,9 +98,8 @@ task :clean do
|
|
end
|
|
end
|
|
|
|
|
|
task :lint do
|
|
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|
|
|
twee_source.lines.each_with_index do |line, lineno|
|
|
lineno += 1
|
|
lineno += 1
|
|
line
|
|
line
|
|
@@ -100,18 +108,18 @@ task :lint do
|
|
.each do |link|
|
|
.each do |link|
|
|
case link.scan('->').length
|
|
case link.scan('->').length
|
|
when 0
|
|
when 0
|
|
- #puts("link contains no ->, probably not a problem")
|
|
|
|
|
|
+ #link contains no ->, probably not a problem
|
|
text = link
|
|
text = link
|
|
when 1
|
|
when 1
|
|
# no problem
|
|
# no problem
|
|
text, dest = link.split('->')
|
|
text, dest = link.split('->')
|
|
else
|
|
else
|
|
- puts("link contains multiple -> definitely a problem")
|
|
|
|
|
|
+ warn("link contains multiple -> definitely a problem")
|
|
next
|
|
next
|
|
end
|
|
end
|
|
if text.start_with?('\'')
|
|
if text.start_with?('\'')
|
|
if !text.end_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
|
|
next
|
|
end
|
|
end
|
|
text = text[1..-2]
|
|
text = text[1..-2]
|
|
@@ -120,12 +128,12 @@ task :lint do
|
|
.map {Regexp.last_match.offset(0)[0]}
|
|
.map {Regexp.last_match.offset(0)[0]}
|
|
.each do |offset|
|
|
.each do |offset|
|
|
if text[offset - 1] != '\\'
|
|
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
|
|
end
|
|
end
|
|
elsif text.start_with?('"')
|
|
elsif text.start_with?('"')
|
|
if !text.end_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
|
|
next
|
|
end
|
|
end
|
|
text = text[1..-2]
|
|
text = text[1..-2]
|
|
@@ -134,11 +142,11 @@ task :lint do
|
|
.map {Regexp.last_match.offset(0)[0]}
|
|
.map {Regexp.last_match.offset(0)[0]}
|
|
.each do |offset|
|
|
.each do |offset|
|
|
if text[offset - 1] != '\\'
|
|
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
|
|
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
|
|
end
|
|
end
|
|
end
|