class JsonChecker::CheckableFile

Attributes

name[R]
path[R]
remotePath[R]

Public Class Methods

is_valid_representation?(representation) click to toggle source
# File lib/json_checker/checkable_file.rb, line 13
def self.is_valid_representation?(representation)
  json = JsonChecker::JSONFetcher.json_from_content(representation)
  unless json.nil?
      return (json.keys.include? 'name') && ((json.keys.include? 'path') || (json.keys.include? 'remote-path'))
  end
  return false
end
new(representation) click to toggle source
# File lib/json_checker/checkable_file.rb, line 7
 def initialize(representation)
     @name = representation['name']
     @path = representation['path']
     @remotePath = representation['remote-path']
end

Public Instance Methods

get_content() click to toggle source
# File lib/json_checker/checkable_file.rb, line 21
def get_content()
  if @path.nil? && @remotePath.nil?
    puts "[ERROR] path or remote-path not found"
    return nil
  end

  unless @content.nil?
    return @content
  end

  @content = @path.nil? ? JSONFetcher.json_from_url(@remotePath) : JSONFetcher.json_from_path(@path)

  return @content
end