class Ordinare::Check
Public Class Methods
gemfile_sorted?(path = "Gemfile")
click to toggle source
# File lib/ordinare/check.rb, line 3 def self.gemfile_sorted?(path = "Gemfile") new(path).gemfile_sorted? end
new(path)
click to toggle source
# File lib/ordinare/check.rb, line 7 def initialize(path) @path = path end
Public Instance Methods
gemfile_sorted?()
click to toggle source
# File lib/ordinare/check.rb, line 11 def gemfile_sorted? unless File.file?(@path) abort "No Gemfile found in the current directory, is this a Rails project with Gemfile?" end ordered_content = Ordinare::Sort.sort_content(@path, File.readlines(@path)) read_content = File.readlines(@path) if read_content == ordered_content puts "Gemfile is sorted properly" true else abort "Gemfile is not sorted" end end