Sha256: 253d7233bccef4dff8e1ed27ce5feb8c6dde11fb2632302e6f499ecfb1315ab4

Contents?: true

Size: 701 Bytes

Versions: 4

Compression:

Stored size: 701 Bytes

Contents

module LicenseFinder
  class DependencyReport
    def self.underscored_name
      @underscored_name ||= begin
        str = name.dup
        str.sub!(/.*::/, '')
        str.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
        str.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
        str.downcase!
      end
    end

    def initialize(dependencies=[])
      @dependencies = Array dependencies
    end

    def to_s
      filename = ROOT_PATH.join('templates', "#{self.class.underscored_name}.erb")
      template = ERB.new(File.read(filename), 0, '-')
      template.result(binding)
    end

    private
    attr_reader :dependencies

    def sorted_dependencies
      dependencies.sort_by(&:name)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
license_finder-0.9.0-java lib/license_finder/reports/dependency_report.rb
license_finder-0.9.0 lib/license_finder/reports/dependency_report.rb
license_finder-0.8.2-java lib/license_finder/reports/dependency_report.rb
license_finder-0.8.2 lib/license_finder/reports/dependency_report.rb