-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1501 from seek4science/license-extraction
License extraction
- Loading branch information
Showing
18 changed files
with
464 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Licensee | ||
module Projects | ||
# Custom Project class because the default GitProject class does not allow Repos with `head_unborn?`, even though | ||
# it's OK in our case since we are passing an explicit revision. | ||
class GitVersionProject < ::Licensee::Projects::GitProject | ||
def initialize(git_version, detect_packages: false, detect_readme: false) | ||
@detect_packages = detect_packages | ||
@detect_readme = detect_readme | ||
@git_version = git_version | ||
end | ||
|
||
# The Rugged::Repository for the Git::Version | ||
def repository | ||
@git_version.git_repository.git_base.base | ||
end | ||
|
||
# The Rugged::Commit for the Git::Version | ||
def commit | ||
@git_version.commit_object | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module Licensee | ||
module Projects | ||
# Project class for finding license files in an RO-Crate | ||
class RoCrateProject < ::Licensee::Projects::Project | ||
def initialize(ro_crate, **args) | ||
@ro_crate = ro_crate | ||
super(**args) | ||
end | ||
|
||
def files | ||
@files ||= @ro_crate.entries.each.map do |path, entry| | ||
next if entry.remote? | ||
next if entry.directory? | ||
split = path.split('/') | ||
name = split.last | ||
if split.length > 1 | ||
dir = split[0..-2].join('/') | ||
else | ||
dir = '' | ||
end | ||
{ name: name, dir: dir } | ||
end.compact | ||
end | ||
|
||
def load_file(file) | ||
path = file[:dir].blank? ? file[:name] : "#{file[:dir]}/#{file[:name]}" | ||
entry = @ro_crate.entries[path] | ||
entry.read | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.