Sha256: b82f50113aa6a0cc5a6201a8fd396ef3e14fd54b07e61b54ba8617b9ee16ac8a

Contents?: true

Size: 676 Bytes

Versions: 4

Compression:

Stored size: 676 Bytes

Contents

module Thug
	class GemDetector

		# initialize gemfile path
		def initialize
			cwd = Dir.getwd
			@gemfile_path = cwd + "/Gemfile"
		end

		# check if gemfile exists in the current directory
		def has_gem?
			File.file?(@gemfile_path)
		end

		# update the .lock file without installing gems
		def update_lock
			puts "updating gemfile.lock"
			`bundle lock`
			puts "updated"
		end

		# lists gems in current project
		def list_gems
			self.update_lock

			@gemfile_path = File.expand_path(@gemfile_path)

			lockfile_path = "#{@gemfile_path}.lock"
			lockfile = Bundler::LockfileParser.new(Bundler.read_file(lockfile_path))

			lockfile.specs.map(&:name)
		end
		
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
thug-0.2.3 lib/thug/gem_detector.rb
thug-0.2.2 lib/thug/gem_detector.rb
thug-0.2.1 lib/thug/gem_detector.rb
thug-0.2.0 lib/thug/gem_detector.rb