Module: Twee2
- Defined in:
- lib/twee2.rb,
lib/twee2/version.rb,
lib/twee2/decompiler.rb,
lib/twee2/story_file.rb,
lib/twee2/build_config.rb,
lib/twee2/story_format.rb
Defined Under Namespace
Classes: BuildConfig, DecompilationFailedException, Decompiler, StoryFile, StoryFileNotFoundException, StoryFormat, StoryFormatNotFoundException
Constant Summary
collapse
- DEFAULT_FORMAT =
'Harlowe'
- VERSION =
"0.3.2"
Class Method Summary
collapse
Class Method Details
.build(input, output, options = {}) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/twee2.rb', line 14
def self.build(input, output, options = {})
build_config.story_format = StoryFormat::new(options[:format])
build_config.story_file = StoryFile::new(input)
File::open(output, 'w') do |out|
out.print build_config.story_format.compile
end
puts "Done"
end
|
.build_config ⇒ Object
15
16
17
|
# File 'lib/twee2/build_config.rb', line 15
def self.build_config
BuildConfig::instance
end
|
.buildpath(path) ⇒ Object
54
55
56
|
# File 'lib/twee2.rb', line 54
def self.buildpath(path)
File.join(File.dirname(File.expand_path(__FILE__)), "../#{path}")
end
|
.decompile(url, output) ⇒ Object
Reverse-engineers a Twee2/Twine 2 output HTML file into a Twee2 source file
42
43
44
45
46
47
|
# File 'lib/twee2.rb', line 42
def self.decompile(url, output)
File::open(output, 'w') do |out|
out.print Decompiler::decompile(url)
end
puts "Done"
end
|
36
37
38
39
|
# File 'lib/twee2.rb', line 36
def self.formats
puts "I understand the following output formats:"
puts StoryFormat.known_names.join("\n")
end
|
.help ⇒ Object
49
50
51
52
|
# File 'lib/twee2.rb', line 49
def self.help
puts "Twee2 #{Twee2::VERSION}"
puts File.read(buildpath('doc/usage.txt'))
end
|
.watch(input, output, options = {}) ⇒ Object
26
27
28
29
30
31
32
33
34
|
# File 'lib/twee2.rb', line 26
def self.watch(input, output, options = {})
puts "Compiling #{output}"
build(input, output, options)
puts "Watching #{input}"
FileWatcher.new(input).watch do
puts "Recompiling #{output}"
build(input, output, options)
end
end
|