Class: InchCI::Worker::BuildJSON::JSONDump

Inherits:
Object
  • Object
show all
Defined in:
lib/inch_ci/worker/build_json.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ JSONDump

Returns a new instance of JSONDump.



13
14
15
16
17
18
19
20
21
# File 'lib/inch_ci/worker/build_json.rb', line 13

def initialize(filename)
  contents = File.read(filename, :encoding => 'utf-8')
  @json = JSON[contents]
  @language    = @json['language']
  @branch_name = @json['branch_name'] || @json['travis_branch']
  @revision    = @json['revision'] || @json['travis_commit']
  @nwo         = @json['nwo'] || @json['travis_repo_slug']
  @url         = @json['git_repo_url']
end

Instance Attribute Details

#branch_nameObject (readonly)

Returns the value of attribute branch_name.



11
12
13
# File 'lib/inch_ci/worker/build_json.rb', line 11

def branch_name
  @branch_name
end

#languageObject (readonly)

Returns the value of attribute language.



11
12
13
# File 'lib/inch_ci/worker/build_json.rb', line 11

def language
  @language
end

#nwoObject (readonly)

Returns the value of attribute nwo.



11
12
13
# File 'lib/inch_ci/worker/build_json.rb', line 11

def nwo
  @nwo
end

#revisionObject (readonly)

Returns the value of attribute revision.



11
12
13
# File 'lib/inch_ci/worker/build_json.rb', line 11

def revision
  @revision
end

#urlObject (readonly)

Returns the value of attribute url.



11
12
13
# File 'lib/inch_ci/worker/build_json.rb', line 11

def url
  @url
end

Instance Method Details

#circleci?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/inch_ci/worker/build_json.rb', line 27

def circleci?
  !@json['circleci'].nil?
end

#shell?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/inch_ci/worker/build_json.rb', line 23

def shell?
  !@json['shell'].nil?
end

#to_h(include_objects: true) ⇒ Object



35
36
37
38
39
# File 'lib/inch_ci/worker/build_json.rb', line 35

def to_h(include_objects: true)
  h = @json.dup
  h.delete('objects') unless include_objects
  h
end

#travis?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/inch_ci/worker/build_json.rb', line 31

def travis?
  !@json['travis'].nil?
end