Permalink
Browse files

Autoload classes for simpler dependency management

Also moved `Configuration` class into a separate file.
  • Loading branch information...
1 parent 07dab3d commit 3b0151c4b96db57efa8e0034cfde68facc930bd6 Ian Lesperance committed Sep 14, 2012
Showing with 46 additions and 45 deletions.
  1. +11 −42 lib/license_finder.rb
  2. +34 −0 lib/license_finder/configuration.rb
  3. +1 −3 lib/license_finder/railtie.rb
View
@@ -4,38 +4,17 @@
module LicenseFinder
ROOT_PATH = Pathname.new(__FILE__).dirname
- class Configuration
- attr_reader :whitelist, :ignore_groups, :dependencies_dir
-
- def initialize
- config = {}
-
- if File.exists?(config_file_path)
- yaml = File.open(config_file_path).readlines.join
- config = YAML.load(yaml)
- end
-
- @whitelist = config['whitelist'] || []
- @ignore_groups = (config["ignore_groups"] || []).map(&:to_sym)
- @dependencies_dir = config['dependencies_file_dir'] || '.'
- end
-
- def config_file_path
- File.join('.', 'config', 'license_finder.yml')
- end
-
- def dependencies_yaml
- File.join(dependencies_dir, "dependencies.yml")
- end
-
- def dependencies_text
- File.join(dependencies_dir, "dependencies.txt")
- end
-
- def dependencies_html
- File.join(dependencies_dir, "dependencies.html")
- end
- end
+ autoload :Bundle, 'license_finder/bundle'
+ autoload :BundledGem, 'license_finder/bundled_gem'
+ autoload :CLI, 'license_finder/cli'
+ autoload :Configuration, 'license_finder/configuration'
+ autoload :Dependency, 'license_finder/dependency'
+ autoload :DependencyList, 'license_finder/dependency_list'
+ autoload :License, 'license_finder/license'
+ autoload :LicenseUrl, 'license_finder/license_url'
+ autoload :PossibleLicenseFile, 'license_finder/possible_license_file'
+ autoload :Reporter, 'license_finder/reporter'
+ autoload :Viewable, 'license_finder/viewable'
def self.config
@config ||= Configuration.new
@@ -47,13 +26,3 @@ def self.load_rake_tasks
end
require 'license_finder/railtie' if defined?(Rails)
-require 'license_finder/reporter'
-require 'license_finder/bundle'
-require 'license_finder/bundled_gem'
-require 'license_finder/license'
-require 'license_finder/possible_license_file'
-require 'license_finder/viewable'
-require 'license_finder/dependency'
-require 'license_finder/dependency_list'
-require 'license_finder/cli'
-require 'license_finder/license_url'
@@ -0,0 +1,34 @@
+module LicenseFinder
+ class Configuration
+ attr_reader :whitelist, :ignore_groups, :dependencies_dir
+
+ def initialize
+ config = {}
+
+ if File.exists?(config_file_path)
+ yaml = File.open(config_file_path).readlines.join
+ config = YAML.load(yaml)
+ end
+
+ @whitelist = config['whitelist'] || []
+ @ignore_groups = (config["ignore_groups"] || []).map(&:to_sym)
+ @dependencies_dir = config['dependencies_file_dir'] || '.'
+ end
+
+ def config_file_path
+ File.join('.', 'config', 'license_finder.yml')
+ end
+
+ def dependencies_yaml
+ File.join(dependencies_dir, "dependencies.yml")
+ end
+
+ def dependencies_text
+ File.join(dependencies_dir, "dependencies.txt")
+ end
+
+ def dependencies_html
+ File.join(dependencies_dir, "dependencies.html")
+ end
+ end
+end
@@ -1,9 +1,7 @@
-require 'license_finder'
-require 'rails'
module LicenseFinder
class Railtie < Rails::Railtie
rake_tasks do
load "tasks/license_finder.rake"
end
end
-end
+end

0 comments on commit 3b0151c

Please sign in to comment.