Class: Gamefic::Sdk::Platform::Base
- Inherits:
-
Object
- Object
- Gamefic::Sdk::Platform::Base
- Defined in:
- lib/gamefic-sdk/platform/base.rb
Instance Attribute Summary collapse
- #config ⇒ Hash readonly
- #source_dir ⇒ Gamefic::Sdk::Debug::Plot readonly
Instance Method Summary collapse
- #build ⇒ Object
- #clean ⇒ Object
-
#defaults ⇒ Hash
Get a hash of default configuration values.
-
#initialize(source_dir, config = {}) ⇒ Base
constructor
A new instance of Base.
-
#metadata ⇒ Hash
Get a string of build metadata, represented as a hash.
- #plot ⇒ Object
- #plot_config ⇒ PlotConfig
Constructor Details
#initialize(source_dir, config = {}) ⇒ Base
Returns a new instance of Base.
13 14 15 16 17 18 19 20 21 |
# File 'lib/gamefic-sdk/platform/base.rb', line 13 def initialize source_dir, config = {} @source_dir = source_dir @config = defaults.merge(config) @config['target_dir'] ||= "release/#{config['name'] || self.class.to_s.split("::").last}" @config['build_dir'] ||= "build/#{config['name'] || self.class.to_s.split("::").last}" # Convert config directories into absolute paths @config['target_dir'] = File.absolute_path(@config['target_dir'], source_dir) @config['build_dir'] = File.absolute_path(@config['build_dir'], source_dir) end |
Instance Attribute Details
#config ⇒ Hash (readonly)
11 12 13 |
# File 'lib/gamefic-sdk/platform/base.rb', line 11 def config @config end |
#source_dir ⇒ Gamefic::Sdk::Debug::Plot (readonly)
8 9 10 |
# File 'lib/gamefic-sdk/platform/base.rb', line 8 def source_dir @source_dir end |
Instance Method Details
#build ⇒ Object
44 45 46 47 |
# File 'lib/gamefic-sdk/platform/base.rb', line 44 def build # Platforms need to build/compile the deployment here. raise "The base Platform class does not have a build method" end |
#clean ⇒ Object
49 50 51 |
# File 'lib/gamefic-sdk/platform/base.rb', line 49 def clean puts "Nothing to do for this platform." end |
#defaults ⇒ Hash
Get a hash of default configuration values. Platforms can overload this method to define their own defaults.
40 41 42 |
# File 'lib/gamefic-sdk/platform/base.rb', line 40 def defaults @defaults ||= Hash.new end |
#metadata ⇒ Hash
Get a string of build metadata, represented as a hash.
56 57 58 59 60 61 62 63 64 |
# File 'lib/gamefic-sdk/platform/base.rb', line 56 def hash = {} uuid = File.exist?(source_dir + '/.uuid') ? File.read(source_dir + '/.uuid').strip : '' hash[:uuid] = "#{uuid}" hash[:gamefic_version] = "#{Gamefic::VERSION}" hash[:sdk_version] = "#{Gamefic::Sdk::VERSION}" hash[:build_date] = "#{DateTime.now}" hash end |
#plot ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/gamefic-sdk/platform/base.rb', line 28 def plot if @plot.nil? paths = plot_config.script_paths + [Gamefic::Sdk::GLOBAL_SCRIPT_PATH] @plot = Gamefic::Sdk::Debug::Plot.new(Gamefic::Source::File.new(*paths)) @plot.script 'main' end @plot end |
#plot_config ⇒ PlotConfig
24 25 26 |
# File 'lib/gamefic-sdk/platform/base.rb', line 24 def plot_config @plot_config ||= PlotConfig.new("#{source_dir}/config.yaml") end |