mirror of https://github.com/licensee/licensee.git
correct rubocop offenses
This commit is contained in:
parent
2db291b3c5
commit
aa9bec6256
2
Gemfile
2
Gemfile
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gemspec
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'dotenv/load'
|
||||
require 'thor'
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require_relative 'licensee/version'
|
||||
require 'forwardable'
|
||||
require 'pathname'
|
||||
|
@ -19,7 +21,7 @@ module Licensee
|
|||
CONFIDENCE_THRESHOLD = 98
|
||||
|
||||
# Base domain from which to build license URLs
|
||||
DOMAIN = 'http://choosealicense.com'.freeze
|
||||
DOMAIN = 'http://choosealicense.com'
|
||||
|
||||
class << self
|
||||
attr_writer :confidence_threshold
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class LicenseeCLI < Thor
|
||||
# Methods to call when displaying information about ProjectFiles
|
||||
MATCHED_FILE_METHODS = %i[
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'tmpdir'
|
||||
|
||||
class LicenseeCLI < Thor
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class LicenseeCLI < Thor
|
||||
desc 'license-path [PATH]', "Returns the path to the given project's license file"
|
||||
def license_path(_path)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class LicenseeCLI < Thor
|
||||
desc 'version', 'Return the Licensee version'
|
||||
def version
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'set'
|
||||
require 'digest'
|
||||
|
||||
|
@ -89,9 +91,7 @@ module Licensee
|
|||
|
||||
# A set of each word in the license, without duplicates
|
||||
def wordset
|
||||
@wordset ||= if content_normalized
|
||||
content_normalized.scan(/(?:\w(?:'s|(?<=s)')?)+/).to_set
|
||||
end
|
||||
@wordset ||= content_normalized&.scan(/(?:\w(?:'s|(?<=s)')?)+/)&.to_set
|
||||
end
|
||||
|
||||
# Number of characteres in the normalized content
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
module HashHelper
|
||||
def to_h
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'uri'
|
||||
|
||||
module Licensee
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
class LicenseField < Struct.new(:name, :description)
|
||||
class << self
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
class LicenseMeta < Struct.new(
|
||||
:title, :spdx_id, :source, :description, :how, :conditions, :permissions,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
# Exposes #conditions, #permissions, and #limitation arrays of LicenseRules
|
||||
class LicenseRules < Struct.new(:conditions, :permissions, :limitations)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
module Matchers
|
||||
autoload :Matcher, 'licensee/matchers/matcher'
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
module Matchers
|
||||
class Cabal < Licensee::Matchers::Package
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
module Matchers
|
||||
class Cargo < Licensee::Matchers::Package
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
module Matchers
|
||||
class Copyright < Licensee::Matchers::Matcher
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
module Matchers
|
||||
class Cran < Licensee::Matchers::Package
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
module Matchers
|
||||
class Dice < Licensee::Matchers::Matcher
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
module Matchers
|
||||
class DistZilla < Licensee::Matchers::Package
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
module Matchers
|
||||
class Exact < Licensee::Matchers::Matcher
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
module Matchers
|
||||
class Gemspec < Licensee::Matchers::Package
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
module Matchers
|
||||
class Matcher
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
module Matchers
|
||||
class NpmBower < Licensee::Matchers::Package
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
module Matchers
|
||||
class Package < Licensee::Matchers::Matcher
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
module Matchers
|
||||
# Matches README files that include a license by reference
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
module Matchers
|
||||
class Spdx < Licensee::Matchers::Package
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
module ProjectFiles
|
||||
autoload :ProjectFile, 'licensee/project_files/project_file'
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
module ProjectFiles
|
||||
class LicenseFile < Licensee::ProjectFiles::ProjectFile
|
||||
|
@ -72,11 +74,11 @@ module Licensee
|
|||
end
|
||||
|
||||
def gpl?
|
||||
license && license.gpl?
|
||||
license&.gpl?
|
||||
end
|
||||
|
||||
def license
|
||||
if matcher && matcher.match
|
||||
if matcher&.match
|
||||
matcher.match
|
||||
else
|
||||
License.find('other')
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
module ProjectFiles
|
||||
class PackageManagerFile < Licensee::ProjectFiles::ProjectFile
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# A project file is a file within a project that contains license information
|
||||
# Currently extended by LicenseFile, PackageManagerFile, and ReadmeFile
|
||||
#
|
||||
|
@ -32,7 +34,7 @@ module Licensee
|
|||
#
|
||||
# Returns a new Licensee::ProjectFile
|
||||
def initialize(content, metadata = {})
|
||||
@content = content
|
||||
@content = content.dup
|
||||
@content.force_encoding(ENCODING)
|
||||
unless @content.valid_encoding?
|
||||
@content.encode!(ENCODING, ENCODING_OPTIONS)
|
||||
|
@ -70,17 +72,17 @@ module Licensee
|
|||
|
||||
# Returns the percent confident with the match
|
||||
def confidence
|
||||
matcher && matcher.confidence
|
||||
matcher&.confidence
|
||||
end
|
||||
|
||||
def license
|
||||
matcher && matcher.match
|
||||
matcher&.match
|
||||
end
|
||||
|
||||
alias match license
|
||||
|
||||
def matched_license
|
||||
license.spdx_id if license
|
||||
license&.spdx_id
|
||||
end
|
||||
|
||||
# Is this file a COPYRIGHT file with only a copyright statement?
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
module ProjectFiles
|
||||
class ReadmeFile < Licensee::ProjectFiles::LicenseFile
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
module Projects
|
||||
autoload :Project, 'licensee/projects/project'
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Filesystem-based project
|
||||
#
|
||||
# Analyze a folder on the filesystem for license information
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Git-based project
|
||||
#
|
||||
# Analyze a given (bare) Git repository for license information
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# GitHub project
|
||||
#
|
||||
# Analyses a remote GitHub repository for license information
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Licensee::Project represents an open source project on disk
|
||||
# It is not used directly, but rather is extended by FSProject and GitProject
|
||||
# depending on the type of file system access available
|
||||
|
@ -113,7 +115,7 @@ module Licensee
|
|||
return [] if files.empty? || files.nil?
|
||||
|
||||
found = files.map { |file| file.merge(score: yield(file[:name])) }
|
||||
found.select! { |file| file[:score] > 0 }
|
||||
found.select! { |file| file[:score].positive? }
|
||||
found.sort { |a, b| b[:score] <=> a[:score] }
|
||||
end
|
||||
|
||||
|
@ -137,7 +139,7 @@ module Licensee
|
|||
# Returns an array of LicenseFiles with LPGL first
|
||||
def prioritize_lgpl(files)
|
||||
return files if files.empty?
|
||||
return files unless files.first.license && files.first.license.gpl?
|
||||
return files unless files.first.license&.gpl?
|
||||
|
||||
lesser = files.find_index(&:lgpl?)
|
||||
files.unshift(files.delete_at(lesser)) if lesser
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
class Rule
|
||||
attr_reader :tag, :label, :description, :group
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Licensee
|
||||
VERSION = '9.11.0'.freeze
|
||||
VERSION = '9.11.0'
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require File.expand_path('lib/licensee/version', __dir__)
|
||||
|
||||
Gem::Specification.new do |gem|
|
||||
|
@ -32,7 +34,7 @@ Gem::Specification.new do |gem|
|
|||
gem.add_development_dependency('simplecov', '~> 0.16')
|
||||
gem.add_development_dependency('webmock', '~> 3.1')
|
||||
|
||||
gem.required_ruby_version = '> 2.2'
|
||||
gem.required_ruby_version = '> 2.3'
|
||||
|
||||
# ensure the gem is built out of versioned files
|
||||
gem.files = Dir[
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'json'
|
||||
require 'licensee'
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative '../spec/spec_helper.rb'
|
||||
|
||||
|
@ -14,7 +15,7 @@ fixtures.each do |fixture|
|
|||
if project.license_file
|
||||
expectations['hash'] = project.license_file.content_hash
|
||||
|
||||
if project.license_file.matcher && project.license_file.matcher.name
|
||||
if project.license_file.matcher&.name
|
||||
expectations['matcher'] = project.license_file.matcher.name.to_s
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Write current license hashes to spec/fixtures/license-hashes.json
|
||||
|
||||
require 'json'
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe 'command line invocation' do
|
||||
let(:command) { ['bundle', 'exec', 'bin/licensee', 'help'] }
|
||||
let(:arguments) { [] }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe 'fixture test' do
|
||||
fixtures.each do |fixture|
|
||||
let(:options) { { detect_packages: true, detect_readme: true } }
|
||||
|
@ -8,13 +10,14 @@ RSpec.describe 'fixture test' do
|
|||
let(:none) { Licensee::License.find('none') }
|
||||
let(:expectations) { fixture_licenses[fixture] || {} }
|
||||
let(:license_file) { subject.license_file }
|
||||
let(:matcher) { license_file.matcher if license_file }
|
||||
let(:matcher) { license_file&.matcher }
|
||||
|
||||
subject { Licensee.project(path, options) }
|
||||
|
||||
it 'has an expected license in fixtures-licenses.yml' do
|
||||
msg = "Expected an entry in `#{fixture_path('fixtures-licenses.yml')}` "
|
||||
msg << "for the `#{fixture}` fixture. Please run "
|
||||
msg = 'Expected an entry in `'.dup
|
||||
msg << fixture_path('fixtures-licenses.yml')
|
||||
msg << "` for the `#{fixture}` fixture. Please run "
|
||||
msg << 'script/dump-fixture-licenses and confirm the output.'
|
||||
expect(fixture_licenses).to have_key(fixture), msg
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe 'integration test' do
|
||||
[
|
||||
Licensee::Projects::FSProject,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe 'detect command' do
|
||||
let(:command) { ['bundle', 'exec', 'bin/licensee', 'detect'] }
|
||||
let(:arguments) { [] }
|
||||
|
@ -68,7 +70,7 @@ RSpec.describe 'detect command' do
|
|||
end
|
||||
|
||||
it 'returns the expected output' do
|
||||
msg = '`licensee detect --json` output did not match expectations. '
|
||||
msg = '`licensee detect --json` output did not match expectations. '.dup
|
||||
msg << 'Run `script/dump-detect-json-fixture` and verify the output.'
|
||||
expect(JSON.parse(stdout)).to eql(expected), msg
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe 'license-path command' do
|
||||
let(:command) { ['bundle', 'exec', 'bin/licensee', 'license-path'] }
|
||||
let(:arguments) { [project_root] }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe 'version command' do
|
||||
let(:command) { ['bundle', 'exec', 'bin/licensee', 'version'] }
|
||||
let(:arguments) { [] }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ContentHelperTestHelper
|
||||
include Licensee::ContentHelper
|
||||
attr_accessor :content, :data
|
||||
|
@ -14,7 +16,7 @@ end
|
|||
|
||||
RSpec.describe Licensee::ContentHelper do
|
||||
let(:content) do
|
||||
<<-LICENSE.freeze.gsub(/^\s*/, '')
|
||||
<<-LICENSE.gsub(/^\s*/, '')
|
||||
# The MIT License
|
||||
=================
|
||||
|
||||
|
@ -186,7 +188,7 @@ RSpec.describe Licensee::ContentHelper do
|
|||
end
|
||||
|
||||
it 'normalize the content' do
|
||||
expected = 'the made up license. this license provided "as is". '
|
||||
expected = 'the made up license. this license provided "as is". '.dup
|
||||
expected << "please respect the contributors' wishes when implementing "
|
||||
expected << "the license's \"software\"."
|
||||
expect(normalized_content).to eql(expected)
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::HashHelper do
|
||||
class HashHelperSpecFixture
|
||||
include Licensee::HashHelper
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::LicenseField do
|
||||
let(:expected_count) { 7 }
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::LicenseMeta do
|
||||
subject { Licensee::License.find('mit').meta }
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::LicenseRules do
|
||||
let(:mit) { Licensee::License.find('mit') }
|
||||
subject { mit.rules }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::License do
|
||||
let(:license_count) { 37 }
|
||||
let(:hidden_license_count) { 25 }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::Matchers::Cabal do
|
||||
let(:content) { 'license: mit' }
|
||||
let(:file) { Licensee::ProjectFiles::LicenseFile.new(content, 'LICENSE.txt') }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::Matchers::Cargo do
|
||||
let(:mit) { Licensee::License.find('mit') }
|
||||
let(:content) { 'license = "MIT"' }
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::Matchers::Copyright do
|
||||
let(:content) { 'Copyright 2015 Ben Balter' }
|
||||
let(:content) { 'Copyright 2015 Ben Balter'.dup }
|
||||
let(:file) { Licensee::ProjectFiles::LicenseFile.new(content, 'LICENSE.txt') }
|
||||
let(:mit) { Licensee::License.find('mit') }
|
||||
let(:no_license) { Licensee::License.find('no-license') }
|
||||
|
@ -28,7 +30,7 @@ RSpec.describe Licensee::Matchers::Copyright do
|
|||
'ASCII-8BIT encoded' => "Copyright \xC2\xA92015 Ben Balter`",
|
||||
'No year' => 'Copyright Ben Balter',
|
||||
'Multiline' => "Copyright Ben Balter\nCopyright Another Entity"
|
||||
.force_encoding('ASCII-8BIT')
|
||||
.dup.force_encoding('ASCII-8BIT')
|
||||
}.each do |description, notice|
|
||||
context "with a #{description} notice" do
|
||||
let(:content) { notice }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::Matchers::Cran do
|
||||
let(:mit) { Licensee::License.find('mit') }
|
||||
let(:gpl2) { Licensee::License.find('gpl-2.0') }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::Matchers::Dice do
|
||||
let(:mit) { Licensee::License.find('mit') }
|
||||
let(:gpl) { Licensee::License.find('gpl-3.0') }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::Matchers::DistZilla do
|
||||
let(:mit) { Licensee::License.find('mit') }
|
||||
let(:content) { 'license = MIT' }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::Matchers::Exact do
|
||||
let(:mit) { Licensee::License.find('mit') }
|
||||
let(:content) { sub_copyright_info(mit) }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::Matchers::Gemspec do
|
||||
let(:mit) { Licensee::License.find('mit') }
|
||||
let(:content) { "s.license = 'mit'" }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::Matchers::Matcher do
|
||||
let(:mit) { Licensee::License.find('mit') }
|
||||
let(:content) { sub_copyright_info(mit) }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::Matchers::NpmBower do
|
||||
let(:content) { '"license": "mit"' }
|
||||
let(:file) { Licensee::ProjectFiles::LicenseFile.new(content, 'LICENSE.txt') }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::Matchers::Package do
|
||||
let(:mit) { Licensee::License.find('mit') }
|
||||
let(:content) { '' }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::Matchers::Reference do
|
||||
let(:content) { 'Copyright 2015 Ben Balter' }
|
||||
let(:file) { Licensee::ProjectFiles::LicenseFile.new(content, 'LICENSE.txt') }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::Matchers::Spdx do
|
||||
let(:content) { 'PackageLicenseDeclared: MIT' }
|
||||
let(:file) do
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::ProjectFiles::LicenseFile do
|
||||
let(:filename) { 'LICENSE.txt' }
|
||||
let(:gpl) { Licensee::License.find('gpl-3.0') }
|
||||
|
@ -20,7 +22,7 @@ RSpec.describe Licensee::ProjectFiles::LicenseFile do
|
|||
end
|
||||
|
||||
context 'with an non-UTF-8-encoded license' do
|
||||
let(:content) { "\x91License\x93".force_encoding('windows-1251') }
|
||||
let(:content) { "\x91License\x93".dup.force_encoding('windows-1251') }
|
||||
|
||||
it "doesn't blow up " do
|
||||
expect(subject.attribution).to be_nil
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::ProjectFiles::PackageManagerFile do
|
||||
let(:content) { '' }
|
||||
let(:filename) { '' }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::ProjectFiles::ProjectFile do
|
||||
let(:filename) { 'LICENSE.txt' }
|
||||
let(:mit) { Licensee::License.find('mit') }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::ProjectFiles::ReadmeFile do
|
||||
let(:filename) { 'README.md' }
|
||||
let(:content) { '' }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
[
|
||||
Licensee::Projects::FSProject,
|
||||
Licensee::Projects::GitProject,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::Projects::GitProject do
|
||||
let(:fixture) { 'mit' }
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::Projects::GitHubProject do
|
||||
let(:repo) { 'benbalter/licensee' }
|
||||
let(:github_url) { "https://github.com/#{repo}" }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee::Rule do
|
||||
let(:groups) { %w[permissions conditions limitations] }
|
||||
subject do
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe Licensee do
|
||||
let(:project_path) { fixture_path('mit') }
|
||||
let(:license_path) { fixture_path('mit/LICENSE.txt') }
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'simplecov'
|
||||
SimpleCov.start
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe 'vendored licenses' do
|
||||
let(:filename) { 'LICENSE.txt' }
|
||||
let(:license_file) do
|
||||
Licensee::ProjectFiles::LicenseFile.new(content, filename)
|
||||
end
|
||||
let(:detected_license) { license_file.license if license_file }
|
||||
let(:detected_license) { license_file&.license }
|
||||
let(:wtfpl) { Licensee::License.find('wtfpl') }
|
||||
|
||||
Licensee.licenses(hidden: true).each do |license|
|
||||
|
@ -15,7 +17,7 @@ RSpec.describe 'vendored licenses' do
|
|||
let(:content) { content_with_copyright }
|
||||
let(:expected_hash) { license_hashes[license.key] }
|
||||
let(:hash_change_msg) do
|
||||
msg = 'Did you update a vendored license? Run'
|
||||
msg = 'Did you update a vendored license? Run'.dup
|
||||
msg << ' bundle exec script/hash-licenses'
|
||||
msg << 'Changes in license hashes must be a MINOR (or MAJOR) bump.'
|
||||
msg
|
||||
|
|
Loading…
Reference in New Issue