Class: Dependabot::DependencyFile

Inherits:
Object
  • Object
show all
Defined in:
lib/dependabot/dependency_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, content:, directory: "/", type: "file", support_file: false) ⇒ DependencyFile

Returns a new instance of DependencyFile.



9
10
11
12
13
14
15
16
# File 'lib/dependabot/dependency_file.rb', line 9

def initialize(name:, content:, directory: "/", type: "file",
               support_file: false)
  @name = name
  @content = content
  @directory = clean_directory(directory)
  @type = type
  @support_file = support_file
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



7
8
9
# File 'lib/dependabot/dependency_file.rb', line 7

def content
  @content
end

#directoryObject

Returns the value of attribute directory.



7
8
9
# File 'lib/dependabot/dependency_file.rb', line 7

def directory
  @directory
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/dependabot/dependency_file.rb', line 7

def name
  @name
end

#support_fileObject

Returns the value of attribute support_file.



7
8
9
# File 'lib/dependabot/dependency_file.rb', line 7

def support_file
  @support_file
end

#typeObject

Returns the value of attribute type.



7
8
9
# File 'lib/dependabot/dependency_file.rb', line 7

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



31
32
33
# File 'lib/dependabot/dependency_file.rb', line 31

def ==(other)
  other.instance_of?(self.class) && to_h == other.to_h
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/dependabot/dependency_file.rb', line 39

def eql?(other)
  self.==(other)
end

#hashObject



35
36
37
# File 'lib/dependabot/dependency_file.rb', line 35

def hash
  to_h.hash
end

#pathObject



27
28
29
# File 'lib/dependabot/dependency_file.rb', line 27

def path
  Pathname.new(File.join(directory, name)).cleanpath.to_path
end

#support_file?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/dependabot/dependency_file.rb', line 43

def support_file?
  @support_file
end

#to_hObject



18
19
20
21
22
23
24
25
# File 'lib/dependabot/dependency_file.rb', line 18

def to_h
  {
    "name" => name,
    "content" => content,
    "directory" => directory,
    "type" => type
  }
end