Class: Travis::CLI::Setup::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/travis/cli/setup/service.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command) ⇒ Service

Returns a new instance of Service.



31
32
33
# File 'lib/travis/cli/setup/service.rb', line 31

def initialize(command)
  @command = command
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object



35
36
37
# File 'lib/travis/cli/setup/service.rb', line 35

def method_missing(*args, &block)
  @command.send(*args, &block)
end

Instance Attribute Details

#commandObject

Returns the value of attribute command.



29
30
31
# File 'lib/travis/cli/setup/service.rb', line 29

def command
  @command
end

Class Method Details

.description(description = nil) ⇒ Object



13
14
15
16
17
# File 'lib/travis/cli/setup/service.rb', line 13

def self.description(description = nil)
  @description ||= ''
  @description = description if description
  @description
end

.known_as?(name) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/travis/cli/setup/service.rb', line 25

def self.known_as?(name)
  normalized_name(service_name) == normalized_name(name)
end

.normalized_name(string) ⇒ Object



9
10
11
# File 'lib/travis/cli/setup/service.rb', line 9

def self.normalized_name(string)
  string.to_s.downcase.gsub(/[^a-z\d]/, '')
end

.service_name(service_name = nil) ⇒ Object



19
20
21
22
23
# File 'lib/travis/cli/setup/service.rb', line 19

def self.service_name(service_name = nil)
  @service_name ||= normalized_name(name[/[^:]+$/])
  @service_name = service_name if service_name
  @service_name
end