Class: GitLab::CI::Lint::Serializer

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/lint/serializer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ Serializer

Returns a new instance of Serializer.



7
8
9
10
11
12
# File 'lib/gitlab/ci/lint/serializer.rb', line 7

def initialize content
  @content = content
  @sucess_message = "Your GitLab CI File is Okay.".colorize(:green)
  @failure_message = "Your GitLab CI File is Invalid.".colorize(:red)
  @serialize = serialize
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



5
6
7
# File 'lib/gitlab/ci/lint/serializer.rb', line 5

def content
  @content
end

Instance Method Details

#failureObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/gitlab/ci/lint/serializer.rb', line 27

def failure
  puts """
Result: #{@failure_message}

#{"Information".colorize(:yellow)}

* Status: #{@serialize[:status].colorize(:red)}
* Erros: #{@serialize[:errors].to_s.colorize(:red)}

Baaaaaad GitLab CI! Fuck man, you're a idiot...
  """
  puts "Error Details:\n".colorize(:yellow)
  @content["errors"].each_with_index do |value, index|
    puts "Error #{index} - #{value}"
  end
  puts
end

#serializeObject



45
46
47
48
49
50
# File 'lib/gitlab/ci/lint/serializer.rb', line 45

def serialize
  {
    :status => @content["status"],
    :error => @content["errors"]
  }
end

#successObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/gitlab/ci/lint/serializer.rb', line 14

def success
  puts """
Result: #{@sucess_message}

Information:

* Status: #{@serialize[:status]}
* Erros: #{@serialize[:errors]}

Yeaaaah!!!! Congrats!!!!
  """
end