Sha256: c6084ba13982c9f84ec9e325c57c44b987a228a35fcc9ebfea44f822203a1a00

Contents?: true

Size: 878 Bytes

Versions: 4

Compression:

Stored size: 878 Bytes

Contents

module MetricFu
  class RailsBestPractices < Generator

    def self.verify_dependencies!
      `rails_best_practices --help`
      raise 'sudo gem install rails_best_practices # if you want the rails_best_practices tasks' unless $?.success?
    end

    
    def emit
      @output = `rails_best_practices .`
    end

    def analyze
      @matches = @output.chomp.split("\n").map{|m| m.split(" - ") }
      total = @matches.pop
      2.times { @matches.pop } # ignore wiki link
      @matches.reject! {|array| array.empty? }
      @matches.map! do |match|
        file, line = match[0].split(':')
        problem = match[1]
        {:file => file, :line => line, :problem => problem}
      end
      @rails_best_practices_results = {:total => total, :problems => @matches}
    end

    def to_h
      {:rails_best_practices => @rails_best_practices_results}
    end
  end
end

Version data entries

4 entries across 4 versions & 4 rubygems

Version Path
metric_fu-1.4.0 lib/generators/rails_best_practices.rb
devver-metric_fu-1.3.3 lib/generators/rails_best_practices.rb
edouard-metric_fu-1.2.1 lib/generators/rails_best_practices.rb
flyerhzm-metric_fu-1.0.0 lib/generators/rails_best_practices.rb