Class: Thug::GemDetector
- Inherits:
-
Object
- Object
- Thug::GemDetector
- Defined in:
- lib/thug/gem_detector.rb
Instance Method Summary collapse
-
#has_gem? ⇒ Boolean
check if gemfile exists in the current directory.
-
#initialize ⇒ GemDetector
constructor
initialize gemfile path.
-
#list_gems ⇒ Object
lists gems in current project.
-
#update_lock ⇒ Object
update the .lock file without installing gems.
Constructor Details
#initialize ⇒ GemDetector
initialize gemfile path
5 6 7 8 |
# File 'lib/thug/gem_detector.rb', line 5 def initialize cwd = Dir.getwd @gemfile_path = cwd + "/Gemfile" end |
Instance Method Details
#has_gem? ⇒ Boolean
check if gemfile exists in the current directory
11 12 13 |
# File 'lib/thug/gem_detector.rb', line 11 def has_gem? File.file?(@gemfile_path) end |
#list_gems ⇒ Object
lists gems in current project
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/thug/gem_detector.rb', line 23 def list_gems self.update_lock @gemfile_path = File.(@gemfile_path) lockfile_path = "#{@gemfile_path}.lock" lockfile = Bundler::LockfileParser.new(Bundler.read_file(lockfile_path)) lockfile.specs.map(&:name) end |
#update_lock ⇒ Object
update the .lock file without installing gems
16 17 18 19 20 |
# File 'lib/thug/gem_detector.rb', line 16 def update_lock puts "updating gemfile.lock" `bundle lock` puts "updated" end |