Class: LicenseAuto::Matcher::FilepathName

Inherits:
Object
  • Object
show all
Defined in:
lib/license_auto/matcher.rb

Constant Summary collapse

LICENSE_PATTERN =
/(((?<license_name>.*)[-_])?licen[sc]e|copying|copyright|copyleft)+/i
NOTICE_PATTERN =
/notice/i
README_PATTERN =
/readme(?<extension>\..*)?/i
/^[^\/]+\/debian\/copyright$/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ FilepathName

Returns a new instance of FilepathName.



74
75
76
# File 'lib/license_auto/matcher.rb', line 74

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



61
62
63
# File 'lib/license_auto/matcher.rb', line 61

def name
  @name
end

Instance Method Details

#match_license_fileObject



78
79
80
# File 'lib/license_auto/matcher.rb', line 78

def match_license_file()
  LICENSE_PATTERN.match(@name)
end

#match_notice_fileObject



86
87
88
# File 'lib/license_auto/matcher.rb', line 86

def match_notice_file()
  NOTICE_PATTERN.match(@name)
end

#match_readme_fileObject



82
83
84
# File 'lib/license_auto/matcher.rb', line 82

def match_readme_file()
  README_PATTERN.match(@name)
end

#match_the_ref(ref) ⇒ Object

git ref: commit hash/branch/tag



92
93
94
95
# File 'lib/license_auto/matcher.rb', line 92

def match_the_ref(ref)
  version_pattern = /[vV]?#{@name.gsub(/\./, '\.').gsub(/\//, '\/')}$/i
  version_pattern.match(ref)
end