Sha256: c26d9b0a10c07058e0ba75a8f732cc8b3634c0c5034206cea99b28b2eea61b9a

Contents?: true

Size: 1.64 KB

Versions: 4

Compression:

Stored size: 1.64 KB

Contents

#
# Copyright:: Copyright 2017, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require "license_scout/dependency_manager/base"

module LicenseScout
  module DependencyManager
    class Glide < Base

      def name
        "golang_glide"
      end

      def type
        "golang"
      end

      def signature
        "glide.lock file"
      end

      def install_command
        "glide install"
      end

      def detected?
        File.exist?(glide_lock_path)
      end

      def dependencies
        # We cannot use YAML.safe_load because Psych throws a fit about the
        # updated field. We should circle back and see what we can do to fix that.
        YAML.load(File.read(glide_lock_path))["imports"].map do |import|
          dep_name = import["name"]
          dep_version = import["version"]
          dep_path = gopath(dep_name)

          new_dependency(dep_name, dep_version, dep_path)
        end.compact
      end

      private

      def glide_lock_path
        File.join(directory, "glide.lock")
      end

      def gopath(pkg)
        "#{ENV['GOPATH']}/src/#{pkg}"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
license_scout-2.2.0 lib/license_scout/dependency_manager/glide.rb
license_scout-2.1.5 lib/license_scout/dependency_manager/glide.rb
license_scout-2.1.4 lib/license_scout/dependency_manager/glide.rb
license_scout-2.1.3 lib/license_scout/dependency_manager/glide.rb