From 1981678146bf1ee989c378852bc619004df0de45 Mon Sep 17 00:00:00 2001 From: Ben Balter Date: Tue, 6 Feb 2018 10:49:50 -0500 Subject: [PATCH] run rubocop --- lib/licensee/commands/detect.rb | 11 ++++--- lib/licensee/commands/diff.rb | 2 +- licensee.gemspec | 2 +- spec/bin_spec.rb | 54 ++++++++++++++++----------------- 4 files changed, 35 insertions(+), 34 deletions(-) diff --git a/lib/licensee/commands/detect.rb b/lib/licensee/commands/detect.rb index 60396ba..63225fe 100644 --- a/lib/licensee/commands/detect.rb +++ b/lib/licensee/commands/detect.rb @@ -23,7 +23,7 @@ class LicenseeCLI < Thor rows << if project.license ['License:', project.license.name] elsif !project.licenses.empty? - ["Licenses:", project.licenses.map(&:name)] + ['Licenses:', project.licenses.map(&:name)] else ['License:', set_color('None', :red)] end @@ -31,7 +31,7 @@ class LicenseeCLI < Thor unless project.matched_files.empty? rows << ['Matched files:', project.matched_files.map(&:filename).join(', ')] end - + print_table rows project.matched_files.each do |matched_file| @@ -62,9 +62,10 @@ class LicenseeCLI < Thor if project.license_file && (options[:license] || options[:diff]) license = options[:license] || closest_license_key(project.license_file) - invoke(:diff, nil, - license: license, license_to_diff: project.license_file - ) if license + if license + invoke(:diff, nil, + license: license, license_to_diff: project.license_file) + end end exit !project.licenses.empty? diff --git a/lib/licensee/commands/diff.rb b/lib/licensee/commands/diff.rb index 94a906d..6fe2f48 100644 --- a/lib/licensee/commands/diff.rb +++ b/lib/licensee/commands/diff.rb @@ -58,7 +58,7 @@ class LicenseeCLI < Thor if options[:license] error "#{options[:license]} is not a valid license" else - error "You must provide an expected license" + error 'You must provide an expected license' end error "Valid licenses: #{Licensee::License.all(hidden: true).map(&:key).join(', ')}" diff --git a/licensee.gemspec b/licensee.gemspec index 57501b7..350b460 100644 --- a/licensee.gemspec +++ b/licensee.gemspec @@ -18,10 +18,10 @@ Gem::Specification.new do |gem| gem.bindir = 'bin' gem.executables << 'licensee' + gem.add_dependency('dotenv', '~> 2.0') gem.add_dependency('octokit', '~> 4.8.0') gem.add_dependency('rugged', '~> 0.24') gem.add_dependency('thor', '~> 0.19') - gem.add_dependency('dotenv', '~> 2.0') gem.add_development_dependency('coveralls', '~> 0.8') gem.add_development_dependency('mustache', '>= 0.9', '< 2.0') diff --git a/spec/bin_spec.rb b/spec/bin_spec.rb index 609949c..b28606f 100644 --- a/spec/bin_spec.rb +++ b/spec/bin_spec.rb @@ -12,32 +12,32 @@ RSpec.describe 'command line invocation' do let(:status) { output[2] } let(:hash) { '46cdc03462b9af57968df67b450cc4372ac41f53' } - context "detection" do + context 'detection' do let(:subcommand) { 'detect' } - let(:expected) { + let(:expected) do { - "License" => "MIT License", - "Matched files" => "LICENSE.md, licensee.gemspec", - "LICENSE.md" => { - "Content hash" => hash, - "Attribution" => "Copyright (c) 2014-2017 Ben Balter", - "Confidence" => "100.00%", - "Matcher" => "Licensee::Matchers::Exact", - "License" => "MIT License" + 'License' => 'MIT License', + 'Matched files' => 'LICENSE.md, licensee.gemspec', + 'LICENSE.md' => { + 'Content hash' => hash, + 'Attribution' => 'Copyright (c) 2014-2017 Ben Balter', + 'Confidence' => '100.00%', + 'Matcher' => 'Licensee::Matchers::Exact', + 'License' => 'MIT License' }, - "licensee.gemspec" => { - "Confidence" => "90.00%", - "Matcher" => "Licensee::Matchers::Gemspec", - "License" => "MIT License" + 'licensee.gemspec' => { + 'Confidence' => '90.00%', + 'Matcher' => 'Licensee::Matchers::Gemspec', + 'License' => 'MIT License' } } - } + end { - "No arguments" => [], - "Project root" => [project_root], - "License path" => [File.expand_path('LICENSE.md', project_root)] + 'No arguments' => [], + 'Project root' => [project_root], + 'License path' => [File.expand_path('LICENSE.md', project_root)] }.each do |name, args| context "When given #{name}" do let(:arguments) { args } @@ -46,12 +46,12 @@ RSpec.describe 'command line invocation' do expect(status.exitstatus).to eql(0) end - it "returns the exected values" do + it 'returns the exected values' do hash = expected.dup - if name == "License path" - hash.delete("licensee.gemspec") - hash["Matched files"] = "LICENSE.md" + if name == 'License path' + hash.delete('licensee.gemspec') + hash['Matched files'] = 'LICENSE.md' end expect(parsed_output).to eql(hash) @@ -60,10 +60,10 @@ RSpec.describe 'command line invocation' do end end - context "version" do + context 'version' do let(:subcommand) { 'version' } - it "returns the version" do + it 'returns the version' do expect(stdout).to include(Licensee::VERSION) end @@ -72,12 +72,12 @@ RSpec.describe 'command line invocation' do end end - context "license-path" do + context 'license-path' do let(:subcommand) { 'license-path' } let(:arguments) { [project_root] } - it "returns the license path" do - expect(stdout).to match(File.join(project_root, "LICENSE.md")) + it 'returns the license path' do + expect(stdout).to match(File.join(project_root, 'LICENSE.md')) end it 'Returns a zero exit code' do