Class: Gamefic::Sdk::Platform::Web::AppConfig

Inherits:
Object
  • Object
show all
Includes:
Plot::Theater
Defined in:
lib/gamefic-sdk/platform/web/app_config.rb

Defined Under Namespace

Classes: Data

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_dir, config, js) ⇒ AppConfig

Returns a new instance of AppConfig.

Parameters:

  • source_dir (String)

    The directory containing the resources (config file, HTML template, etc.) for this build



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gamefic-sdk/platform/web/app_config.rb', line 11

def initialize source_dir, config, js
  @javascripts = []
  @stylesheets = []
  @source_dir = source_dir
  @config = config
  @html_dir = resolve_html_dir
  #@game_config = PlotConfig.new("#{source_dir}/config.yaml")

  @resource_paths = ["#{html_dir}", Gamefic::Sdk::HTML_TEMPLATE_PATH]
  config_file = "#{html_dir}/index.rb"
  stage File.read(config_file), config_file
  javascripts.concat js
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/gamefic-sdk/platform/web/app_config.rb', line 7

def config
  @config
end

#html_dirObject (readonly)

Returns the value of attribute html_dir.



7
8
9
# File 'lib/gamefic-sdk/platform/web/app_config.rb', line 7

def html_dir
  @html_dir
end

#javascriptsObject (readonly)

Returns the value of attribute javascripts.



7
8
9
# File 'lib/gamefic-sdk/platform/web/app_config.rb', line 7

def javascripts
  @javascripts
end

#resource_pathsObject (readonly)

Returns the value of attribute resource_paths.



7
8
9
# File 'lib/gamefic-sdk/platform/web/app_config.rb', line 7

def resource_paths
  @resource_paths
end

#source_dirObject (readonly)

Returns the value of attribute source_dir.



7
8
9
# File 'lib/gamefic-sdk/platform/web/app_config.rb', line 7

def source_dir
  @source_dir
end

#stylesheetsObject (readonly)

Returns the value of attribute stylesheets.



7
8
9
# File 'lib/gamefic-sdk/platform/web/app_config.rb', line 7

def stylesheets
  @stylesheets
end

Instance Method Details

#dataBuildConfig::Data

Returns:

  • (BuildConfig::Data)


25
26
27
# File 'lib/gamefic-sdk/platform/web/app_config.rb', line 25

def data
  Data.new config, @javascripts, @stylesheets
end

#renderString

Render HTML using the build config data

Returns:

  • (String)

    The resulting HTML



32
33
34
35
# File 'lib/gamefic-sdk/platform/web/app_config.rb', line 32

def render
  erb = ERB.new(File.read(html_dir + "/index.html.erb"))
  erb.result data.get_binding
end