Class: Gamefic::Sdk::Platform::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/gamefic-sdk/platform/base.rb

Direct Known Subclasses

Gfic, Web

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config: Gamefic::Sdk::Config.new, target: {}) ⇒ Base

def initialize config, name = nil



15
16
17
18
19
20
21
22
# File 'lib/gamefic-sdk/platform/base.rb', line 15

def initialize config: Gamefic::Sdk::Config.new, target: {}
  #@source_dir = source_dir

  #@name = name

  #@config = config

  #@config.freeze

  @config = config
  @target = target
end

Instance Attribute Details

#configGamefic::Sdk::Config (readonly)



9
10
11
# File 'lib/gamefic-sdk/platform/base.rb', line 9

def config
  @config
end

#targetHash (readonly)



12
13
14
# File 'lib/gamefic-sdk/platform/base.rb', line 12

def target
  @target
end

Instance Method Details

#buildObject



47
48
49
50
# File 'lib/gamefic-sdk/platform/base.rb', line 47

def build
  # Platforms need to build/compile the deployment here.

  raise "The base Platform class does not have a build method"
end

#build_targetObject



28
29
30
# File 'lib/gamefic-sdk/platform/base.rb', line 28

def build_target
  @build_target ||= File.join(config.build_path, name)
end

#cleanObject



52
53
54
# File 'lib/gamefic-sdk/platform/base.rb', line 52

def clean
  puts "Nothing to do for this platform."
end

#metadataHash

Get a hash of build metadata.



59
60
61
62
63
64
65
66
# File 'lib/gamefic-sdk/platform/base.rb', line 59

def 
  hash = {}
  hash[:uuid] = config.uuid
  hash[:gamefic_version] = "#{Gamefic::VERSION}"
  hash[:sdk_version] = "#{Gamefic::Sdk::VERSION}"
  hash[:build_date] = "#{DateTime.now}"
  hash
end

#nameObject



24
25
26
# File 'lib/gamefic-sdk/platform/base.rb', line 24

def name
  @name ||= (target['name'] || self.class.to_s.split('::').last.downcase)
end

#plotGamefic::Plot



37
38
39
40
41
42
43
44
45
# File 'lib/gamefic-sdk/platform/base.rb', line 37

def plot
  if @plot.nil?
    paths = [config.script_path, config.import_path, Gamefic::Sdk::GLOBAL_SCRIPT_PATH]
    # @todo: Should really use Gamefic::Sdk::Debug::Plot or just Gamfic::Plot?

    @plot = Gamefic::Sdk::Debug::Plot.new(Gamefic::Source::File.new(*paths))
    @plot.script 'main'
  end
  @plot
end

#release_targetObject



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

def release_target
  @release_target ||= File.join(config.release_path, name)
end