Class: Ruby::Reforge::RailsRules

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/reforge/rails_rules.rb

Constant Summary collapse

RAILS_DEPRECATIONS =
{
  "before_filter" => "before_action",
  "after_filter" => "after_action",
  "around_filter" => "around_action",
  "skip_before_filter" => "skip_before_action",
  "skip_after_filter" => "skip_after_action",
  "skip_around_filter" => "skip_around_action",
  "update_attributes" => "update",
  "update_attributes!" => "update!",
  "render :text" => "render plain:",
  "render :nothing" => "head :ok"
}.freeze
RAILS_PATTERNS =
{
  /before_filter/ => "before_action",
  /after_filter/ => "after_action",
  /around_filter/ => "around_action",
  /skip_before_filter/ => "skip_before_action",
  /skip_after_filter/ => "skip_after_action",
  /skip_around_filter/ => "skip_around_action",
  /\.update_attributes\(/ => ".update(",
  /\.update_attributes!/ => ".update!",
  /render\s+:text\s*=>/ => "render plain:",
  /render\s+:nothing/ => "head :ok"
}.freeze

Class Method Summary collapse

Class Method Details

.deprecated_methodsObject



32
33
34
# File 'lib/ruby/reforge/rails_rules.rb', line 32

def self.deprecated_methods
  RAILS_DEPRECATIONS
end

.deprecated_patternsObject



36
37
38
# File 'lib/ruby/reforge/rails_rules.rb', line 36

def self.deprecated_patterns
  RAILS_PATTERNS
end

.detect_rails_project?(root_path) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
43
# File 'lib/ruby/reforge/rails_rules.rb', line 40

def self.detect_rails_project?(root_path)
  File.exist?(File.join(root_path, "config", "application.rb")) ||
    File.exist?(File.join(root_path, "Gemfile")) && File.read(File.join(root_path, "Gemfile")).include?("rails")
end