Class: Gamefic::Sdk::Tasks::Ruby
- Inherits:
-
Object
- Object
- Gamefic::Sdk::Tasks::Ruby
- Includes:
- Common
- Defined in:
- lib/gamefic-sdk/tasks/ruby.rb
Overview
Tasks for running and building Ruby apps.
Instance Attribute Summary
Attributes included from Common
Instance Method Summary collapse
-
#build ⇒ Object
Build a distributable Ruby app.
-
#run ⇒ Object
Run a command-line Ruby app.
Methods included from Common
#absolute_path, #initialize, #plot_class, #string_to_constant
Instance Method Details
#build ⇒ Object
Build a distributable Ruby app.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/gamefic-sdk/tasks/ruby.rb', line 26 def build current = $LOADED_FEATURES.clone require_relative File.join(absolute_path, 'main') loaded = ($LOADED_FEATURES - current) exports = {} exports.merge! append_gem('gamefic') exports.merge! append_gem('gamefic-tty') loaded.each do |path| exports.merge! relativize(path) end files = {} exports.each_pair do |rel, full| files[rel] = Base64.encode64(Zlib::Deflate.deflate(File.read(full))) end program = program_code(files) FileUtils.mkdir_p File.join(absolute_path, 'ruby', 'build') File.write(File.join(absolute_path, 'ruby', 'build', "#{File.basename(absolute_path)}.rb"), program) end |
#run ⇒ Object
Run a command-line Ruby app.
19 20 21 22 |
# File 'lib/gamefic-sdk/tasks/ruby.rb', line 19 def run require_relative File.join(absolute_path, 'main') Gamefic::Tty::Engine.run(plot: plot_class.new) end |