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.



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

def initialize(command)
  @command = command
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object



33
34
35
# File 'lib/travis/cli/setup/service.rb', line 33

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

Instance Attribute Details

#commandObject

Returns the value of attribute command.



27
28
29
# File 'lib/travis/cli/setup/service.rb', line 27

def command
  @command
end

Class Method Details

.description(description = nil) ⇒ Object



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

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

.known_as?(name) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/travis/cli/setup/service.rb', line 23

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

.normalized_name(string) ⇒ Object



7
8
9
# File 'lib/travis/cli/setup/service.rb', line 7

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

.service_name(service_name = nil) ⇒ Object



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

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