Class: Limelight::Templates::PlayerTemplater

Inherits:
Templater
  • Object
show all
Defined in:
lib/limelight/templates/player_templater.rb

Instance Attribute Summary collapse

Attributes inherited from Templater

#logger, #source_root, #target_root

Instance Method Summary collapse

Methods inherited from Templater

clarify, #directory, #file, source_dir

Constructor Details

#initialize(player_name) ⇒ PlayerTemplater

Returns a new instance of PlayerTemplater.



11
12
13
14
15
16
17
18
# File 'lib/limelight/templates/player_templater.rb', line 11

def initialize(player_name)
  super(".")
  @tokens = {}
  @tokens[:PLAYER_NAME] = player_name
  clean_name = player_name.gsub(/[\?\*!'\-.;:]/, "").gsub(" ", "_").downcase
  @filename = @tokens[:FILENAME] = clean_name
  @tokens[:CLASSNAME] = clean_name.camalized
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



9
10
11
# File 'lib/limelight/templates/player_templater.rb', line 9

def filename
  @filename
end

#tokensObject (readonly)

Returns the value of attribute tokens.



9
10
11
# File 'lib/limelight/templates/player_templater.rb', line 9

def tokens
  @tokens
end

Instance Method Details

#generateObject

Generates the files



22
23
24
25
26
27
28
# File 'lib/limelight/templates/player_templater.rb', line 22

def generate
  file(File.join(filename, "Rakefile"), "Rakefile.template", @tokens)
  file(File.join(filename, "Battleship.Rakefile"), "Battleship.Rakefile.template", @tokens)
  file(File.join(filename, "lib", filename, "#{filename}.rb"), "player.template", @tokens)
  file(File.join(filename, "spec", "spec_helper.rb"), "spec_helper.template", @tokens) 
  file(File.join(filename, "spec", filename, "#{filename}_spec.rb"), "player_spec.template", @tokens)
end