Module: RailsAssist::File::Gemfile
Instance Method Summary collapse
- #clean_gemfile ⇒ Object
- #gem_file ⇒ Object
- #gem_filepath ⇒ Object
- #has_gem?(name) ⇒ Boolean
- #has_gem_version?(name, version = nil) ⇒ Boolean
Instance Method Details
#clean_gemfile ⇒ Object
11 12 13 14 |
# File 'lib/rails_assist/file/gem_file.rb', line 11 def clean_gemfile clean_gemfile_content = read_gem_file.gsub(/('|"|end)\s*gem/m, "\\1\ngem") read_gem_file.replace clean_gemfile_content end |
#gem_file ⇒ Object
20 21 22 23 |
# File 'lib/rails_assist/file/gem_file.rb', line 20 def gem_file raise "No Gemfile found at #{gem_filepath}" if !File.exist? gem_filepath gem_filepath.new_file end |
#gem_filepath ⇒ Object
16 17 18 |
# File 'lib/rails_assist/file/gem_file.rb', line 16 def gem_filepath [RailsAssist::Directory::Root.root_dirpath, 'Gemfile'].file_join end |
#has_gem?(name) ⇒ Boolean
3 4 5 |
# File 'lib/rails_assist/file/gem_file.rb', line 3 def has_gem? name read_gem_file =~ /gem\s+('|")#{name}\1/ end |
#has_gem_version?(name, version = nil) ⇒ Boolean
7 8 9 |
# File 'lib/rails_assist/file/gem_file.rb', line 7 def has_gem_version? name, version = nil read_gem_file =~ /gem\s+('|")#{name}\1,\s*('|")#{version}\2/ end |