Class: Wooget::Templates::VisualStudio

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/wooget/template/visual_studio.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/wooget/template/visual_studio.rb', line 4

def options
  @options
end

Class Method Details

.source_rootObject



8
9
10
# File 'lib/wooget/template/visual_studio.rb', line 8

def self.source_root
  File.join(File.dirname(__FILE__), "files")
end

Instance Method Details

#create_project(options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/wooget/template/visual_studio.rb', line 14

def create_project options={}
  raise "name not provided" unless options[:name]

  @options = options #needed for erb binding
  @options[:guid] ||= `uuidgen`.chomp

  #src project defaults
  if @options[:src]
    @options[:src][:guid] ||= `uuidgen`.chomp
    @options[:src][:name] ||= options[:name]
    @options[:src][:files]||= []
    @options[:src][:files] << "DummyClass.cs"
  end

  template("assemblyinfo.erb", "#{options[:name]}/src/#{options[:name]}/Properties/AssemblyInfo.cs")
  template("class.erb", "#{options[:name]}/src/#{options[:name]}/DummyClass.cs")
  template("csproj.erb", "#{options[:name]}/src/#{options[:name]}/#{options[:name]}.csproj")
  create_file("#{options[:name]}/src/#{options[:name]}/#{options[:name]}.csproj.paket.references", "Wooga.Unity.DLLs")
  template("paket.binary.template.erb", "#{options[:name]}/src/#{options[:name]}/#{options[:name]}.csproj.paket.template")

  if @options[:tests]
    @options[:tests][:guid] ||= `uuidgen`.chomp
    @options[:tests][:files]||= []
    @options[:tests][:name] ||= options[:name]
    @options[:tests][:files] << "DummyTest.cs"

    #referencing src project from test project
    @options[:tests][:projects]||= []
    src_project = {:guid => @options[:src][:guid], :name => @options[:src][:name], :relative_location => "../src/#{options[:name]}/#{options[:name]}.csproj"}
    @options[:tests][:projects] << src_project

    template("test_file.erb", "#{options[:name]}/tests/DummyTest.cs")
    template("tests_csproj.erb", "#{options[:name]}/tests/#{options[:name]}.Tests.csproj")
    template("tests_assemblyinfo.erb", "#{options[:name]}/tests/Properties/AssemblyInfo.cs")
    template("paket.references.erb", "#{options[:name]}/tests/paket.references")
  end

  template("sln.erb", "#{options[:name]}/src/#{options[:name]}.sln")

end