Skip to content

Commit

Permalink
Merge branch 'master' of github.com:pivotal/LicenseFinder
Browse files Browse the repository at this point in the history
Conflicts:
	lib/license_finder/finder.rb
	spec/finder_spec.rb
  • Loading branch information
Travis Vachon committed Jun 21, 2012
2 parents 8fbb501 + 5c27b5b commit 8c44944
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 9 deletions.
3 changes: 2 additions & 1 deletion README.markdown
Expand Up @@ -23,6 +23,7 @@ Run 'rake license:action_items:ok'
This will return a non-zero exit status if there are unapproved dependencies. Great for CI.

As a standalone script:

cd ~
git clone http://github.com/pivotal/LicenseFinder.git license_finder
cd your/project
Expand Down Expand Up @@ -94,4 +95,4 @@ Please add a license to your gemspec!
Gem::Specification.new do |s|
s.name = "my_great_gem"
s.license = "MIT"
end
end
14 changes: 9 additions & 5 deletions lib/license_finder/finder.rb
Expand Up @@ -3,12 +3,16 @@ class Finder

attr_reader :whitelist, :ignore_groups
def initialize
if File.exists?('./config/license_finder.yml')
config = YAML.load(File.open('./config/license_finder.yml').readlines.join)
@whitelist = config['whitelist'] || []
@ignore_groups = config['ignore_groups'] ? config['ignore_groups'].map{|g| g.to_sym} : []
@dependencies_dir = config['dependencies_file_dir']
config = case
when File.exists?('./config/license_finder.yml')
YAML.load(File.open('./config/license_finder.yml').readlines.join)
else
{'whitelist' => [], 'ignore_groups' => []}
end

@whitelist = config['whitelist']
@ignore_groups = config['ignore_groups'].map{|g| g.to_sym}
@dependencies_dir = config['dependencies_file_dir']
end

def dependencies_dir
Expand Down
2 changes: 1 addition & 1 deletion lib/license_finder/version.rb
@@ -1,3 +1,3 @@
module LicenseFinder
VERSION = "0.3.0"
VERSION = "0.4.0"
end
11 changes: 9 additions & 2 deletions lib/tasks/license_finder.rake
Expand Up @@ -14,9 +14,16 @@ namespace :license do
puts "Dependencies that need approval:"
puts LicenseFinder::Finder.new.action_items
end

desc 'All gems approved for use'
task 'action_items:ok' => :generate_dependencies do
exit 1 unless LicenseFinder::Finder.new.action_items.size == 0
found = LicenseFinder::Finder.new.action_items
if found.size > 0
puts "Dependencies that need approval:"
puts found
else
puts "All gems are approved for use"
end
exit 1 unless found.size == 0
end
end
1 change: 1 addition & 0 deletions license_finder.gemspec
Expand Up @@ -15,6 +15,7 @@ Gem::Specification.new do |s|
s.rubyforge_project = "license_finder"
s.add_development_dependency 'rspec', '~>2.3'
s.add_development_dependency 'rr'
s.add_development_dependency 'rake'

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
Expand Down
8 changes: 8 additions & 0 deletions spec/finder_spec.rb
@@ -1,6 +1,14 @@
require 'spec_helper'

describe LicenseFinder::Finder do

it "should properly initialize whitelist and ignore_groups" do
stub(File).exists?('./config/license_finder.yml') {false}
finder = LicenseFinder::Finder.new
finder.whitelist.should_not be_nil
finder.ignore_groups.should_not be_nil
end

it "should generate a yml file and txt file" do
stub(File).exists?('./config/license_finder.yml') {false}
stub(File).exists?('./dependencies.yml') {false}
Expand Down

0 comments on commit 8c44944

Please sign in to comment.