Class: Lamma::Runtime

Inherits:
Object
  • Object
show all
Defined in:
lib/lamma/runtime.rb

Constant Summary collapse

C_SHARP =
10
JAVA_8 =
20
NODE_43 =
30
EDGE_NODE_43 =
31
PYTHON_27 =
40
PYTHON_36 =
41
NAME =
{
  C_SHARP => 'dotnetcore1.0',
  JAVA_8 => 'java8',
  NODE_43 => 'nodejs4.3',
  EDGE_NODE_43 => 'nodejs4.3-edge',
  PYTHON_27 => 'python2.7',
  PYTHON_36 => 'python3.6',
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ Runtime

Returns a new instance of Runtime.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/lamma/runtime.rb', line 16

def initialize(str)
  @type =
    case str
    when /^c[s#](harp)?$/i
      ::Lamma::Runtime::C_SHARP
    when /^java([-_\.\s]*8?)?$/i
      ::Lamma::Runtime::JAVA_8
    when /^node([-_\.\s]*4(\.?3)?)?$/i
      ::Lamma::Runtime::NODE_43
    when /^edge[-_\.\s]*node(\s*4(\.?3)?)?$/i
      ::Lamma::Runtime::EDGE_NODE_43
    when /^python([-_\.\s]*2(\.?7)?)?$/i
      ::Lamma::Runtime::PYTHON_27
    when /^python([-_\.\s]*3(\.?6)?)?$/i
      ::Lamma::Runtime::PYTHON_36
    else
      raise ArgumentError.new("invalid runtime. #{str}")
    end
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/lamma/runtime.rb', line 3

def type
  @type
end

Class Method Details

.allObject



5
6
7
# File 'lib/lamma/runtime.rb', line 5

def self.all
  self.constants.map{|n| [n, self.const_get(n)] }.to_h
end

Instance Method Details

#to_dirnameObject



49
50
51
# File 'lib/lamma/runtime.rb', line 49

def to_dirname
  NAME[@type].gsub(/[\.-]/, '_')
end

#to_sObject



45
46
47
# File 'lib/lamma/runtime.rb', line 45

def to_s
  NAME[@type]
end