Class: Dependabot::DependencyFile
- Inherits:
-
Object
- Object
- Dependabot::DependencyFile
- Defined in:
- lib/dependabot/dependency_file.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#directory ⇒ Object
Returns the value of attribute directory.
-
#name ⇒ Object
Returns the value of attribute name.
-
#support_file ⇒ Object
Returns the value of attribute support_file.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(name:, content:, directory: "/", type: "file", support_file: false) ⇒ DependencyFile
constructor
A new instance of DependencyFile.
- #path ⇒ Object
- #support_file? ⇒ Boolean
- #to_h ⇒ Object
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 17 18 19 20 21 22 |
# 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) @support_file = support_file # Type is used *very* sparingly. It lets the git_modules updater know that # a "file" is actually a submodule, and lets our Go updaters know which # file represents the main.go. # New use cases should be avoided if at all possible (and use the # support_file flag instead) @type = type end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
7 8 9 |
# File 'lib/dependabot/dependency_file.rb', line 7 def content @content end |
#directory ⇒ Object
Returns the value of attribute directory.
7 8 9 |
# File 'lib/dependabot/dependency_file.rb', line 7 def directory @directory end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/dependabot/dependency_file.rb', line 7 def name @name end |
#support_file ⇒ Object
Returns the value of attribute support_file.
7 8 9 |
# File 'lib/dependabot/dependency_file.rb', line 7 def support_file @support_file end |
#type ⇒ Object
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
38 39 40 41 42 43 44 |
# File 'lib/dependabot/dependency_file.rb', line 38 def ==(other) return false unless other.instance_of?(self.class) my_hash = to_h.reject { |k| k == "support_file" } their_hash = other.to_h.reject { |k| k == "support_file" } my_hash == their_hash end |
#eql?(other) ⇒ Boolean
50 51 52 |
# File 'lib/dependabot/dependency_file.rb', line 50 def eql?(other) self.==(other) end |
#hash ⇒ Object
46 47 48 |
# File 'lib/dependabot/dependency_file.rb', line 46 def hash to_h.hash end |
#path ⇒ Object
34 35 36 |
# File 'lib/dependabot/dependency_file.rb', line 34 def path Pathname.new(File.join(directory, name)).cleanpath.to_path end |
#support_file? ⇒ Boolean
54 55 56 |
# File 'lib/dependabot/dependency_file.rb', line 54 def support_file? @support_file end |
#to_h ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/dependabot/dependency_file.rb', line 24 def to_h { "name" => name, "content" => content, "directory" => directory, "type" => type, "support_file" => support_file } end |