Sha256: ce6226eade8eec0eacdca1a83ff1e6814e90383f913e60d2ba4d4fc016b0885c

Contents?: true

Size: 1.03 KB

Versions: 6

Compression:

Stored size: 1.03 KB

Contents

# encoding: utf-8
require 'rails_best_practices/reviews/review'

module RailsBestPractices
  module Reviews
    # Review view and helper files to make sure not use time_ago_in_words or distance_of_time_in_words_to_now.
    #
    # See the best practice details here http://rails-bestpractices.com/posts/105-not-use-time_ago_in_words.
    #
    # Implementation:
    #
    # Review process:
    #   check all fcall node to see if its message is time_ago_in_words and distance_of_time_in_words_to_now
    class NotUseTimeAgoInWordsReview < Review
      interesting_nodes :fcall
      interesting_files VIEW_FILES, HELPER_FILES

      def url
        "http://rails-bestpractices.com/posts/105-not-use-time_ago_in_words"
      end

      # check fcall node to see if its message is time_ago_in_words or distance_of_time_in_words_to_now
      def start_fcall(node)
        if "time_ago_in_words" == node.message.to_s || "distance_of_time_in_words_to_now" == node.message.to_s
          add_error "not use time_ago_in_words"
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
rails_best_practices-1.10.1 lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb
rails_best_practices-gorgeouscode-1.0.0 lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb
rails_best_practices-1.10.0 lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb
rails_best_practices-1.9.1 lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb
rails_best_practices-1.9.0 lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb
rails_best_practices-1.8.0 lib/rails_best_practices/reviews/not_use_time_ago_in_words_review.rb