Module: StoryTeller::Engine

Defined in:
lib/story_teller/engine.rb,
lib/story_teller/version.rb

Overview

module Engine

Defined Under Namespace

Modules: Config, Library

Constant Summary collapse

VERSION =
'1.2.2'.freeze

Class Method Summary collapse

Class Method Details

.default_configObject



72
73
74
# File 'lib/story_teller/engine.rb', line 72

def default_config
  @default_config ||= StoryTeller::Engine::Config::DEFAULTS
end

.default_environmentObject



96
97
98
# File 'lib/story_teller/engine.rb', line 96

def default_environment
  StoryTeller::Engine.default_config[:environment]
end

.default_invocation_propertiesObject



100
101
102
# File 'lib/story_teller/engine.rb', line 100

def default_invocation_properties
  StoryTeller::Engine.default_config.fetch(:properties, '').split.map(&:to_sym).freeze
end

.executableObject



92
93
94
# File 'lib/story_teller/engine.rb', line 92

def executable
  @executable
end

.executable=(executable) ⇒ Object



88
89
90
# File 'lib/story_teller/engine.rb', line 88

def executable=(executable)
  @executable = executable
end

.inform_code_prefixObject



76
77
78
# File 'lib/story_teller/engine.rb', line 76

def inform_code_prefix
  StoryTeller::Engine.default_config[:inform6lib_gem_code_prefix]
end

.invocation_contextObject



113
114
115
# File 'lib/story_teller/engine.rb', line 113

def invocation_context
  @invocation_context ||= Struct.new(*invocation_properties)
end

.invocation_propertiesObject



104
105
106
# File 'lib/story_teller/engine.rb', line 104

def invocation_properties
  @invocation_properties ||= default_invocation_properties
end

.invocation_properties=(properties) ⇒ Object



108
109
110
111
# File 'lib/story_teller/engine.rb', line 108

def invocation_properties=(properties)
  @invocation_properties = properties
  @invocation_context = nil
end

.language_nameObject



117
118
119
# File 'lib/story_teller/engine.rb', line 117

def language_name
  StoryTeller::Engine.default_config[:language]
end

.librariesObject



60
61
62
# File 'lib/story_teller/engine.rb', line 60

def libraries
  @libraries ||= {}
end

.main_objectObject



68
69
70
# File 'lib/story_teller/engine.rb', line 68

def main_object
  @main_object
end

.main_object=(obj) ⇒ Object



64
65
66
# File 'lib/story_teller/engine.rb', line 64

def main_object=(obj)
  @main_object = obj
end

.player?(obj) ⇒ Boolean

Returns:

  • (Boolean)


121
122
123
124
# File 'lib/story_teller/engine.rb', line 121

def player?(obj)
  return false unless defined?(StoryTeller::IO::Session) && StoryTeller::IO::Session.respond_to?(:players)
  StoryTeller::IO::Session.players.include?(obj)
end

.prime_dictionaryObject



126
127
128
129
130
# File 'lib/story_teller/engine.rb', line 126

def prime_dictionary
  Inform::Object.select_map(:name).compact.each do |n|
    StoryTeller::Dictionary.merge(n.split(/[,\s]+/).grep_v(/[^a-z]/i).map(&:downcase).map(&:to_sym))
  end
end

.project_dir_pathObject



80
81
82
83
84
85
86
# File 'lib/story_teller/engine.rb', line 80

def project_dir_path
  @project_dir_path ||= begin
    story_dir_path = File.expand_path(__dir__)
    lib_dir_path = File.expand_path(File.dirname(story_dir_path))
    File.expand_path(File.dirname(lib_dir_path))
  end
end