Class: Rant::CSharp::CompilerAdapterFactory
- Defined in:
- lib/rant/csharp/compiler_adapter_factory.rb
Instance Attribute Summary collapse
-
#compiler_map ⇒ Object
Returns the value of attribute compiler_map.
-
#context ⇒ Object
Returns the value of attribute context.
Instance Method Summary collapse
- #compiler ⇒ Object
-
#initialize(context) ⇒ CompilerAdapterFactory
constructor
A new instance of CompilerAdapterFactory.
Constructor Details
#initialize(context) ⇒ CompilerAdapterFactory
Returns a new instance of CompilerAdapterFactory.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rant/csharp/compiler_adapter_factory.rb', line 10 def initialize context @context = context @compiler = nil # Default compiler mappings @compiler_map ||= { "csc" => CscCompiler, "mcs" => McsCompiler, "gmcs" => GmcsCompiler } end |
Instance Attribute Details
#compiler_map ⇒ Object
Returns the value of attribute compiler_map.
8 9 10 |
# File 'lib/rant/csharp/compiler_adapter_factory.rb', line 8 def compiler_map @compiler_map end |
#context ⇒ Object
Returns the value of attribute context.
7 8 9 |
# File 'lib/rant/csharp/compiler_adapter_factory.rb', line 7 def context @context end |
Instance Method Details
#compiler ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rant/csharp/compiler_adapter_factory.rb', line 22 def compiler if !@compiler compiler_map.each_key do |key| if context.env.find_bin(key) @compiler = compiler_map[key].new(context) break end end if !@compiler raise Exception.new("Could not find C# compiler in path (csc, mcs, gmcs). " + "Please amend your path or explicitly define one with the :compiler option") end end @compiler end |