Class: Playmo::Recipes::ApplicationHelperRecipe

Inherits:
Playmo::Recipe
  • Object
show all
Defined in:
lib/playmo/recipes/application_helper_recipe.rb

Instance Attribute Summary

Attributes inherited from Playmo::Recipe

#application_name, #question_instance, #silents

Instance Method Summary collapse

Methods inherited from Playmo::Recipe

#cook!, #question, #retrieve, #silently, #store

Instance Method Details

#setupObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/playmo/recipes/application_helper_recipe.rb', line 6

def setup
  silently do
    remove_file 'app/helpers/application_helper.rb'
    copy_file   'application_helper.rb', 'app/helpers/application_helper.rb'

    # TODO: Add version for prototype and Jquery
    # TODO: Translate flash_messages.js to CoffeeScript
    copy_file   'flash_messages.js', 'app/assets/javascripts/flash_messages.js'

    Event.events.listen(:after_install) do
      gsub_file 'app/assets/javascripts/application.js', '//= require_tree .' do
        <<-CONTENT.gsub(/^ {16}/, '')
          //= require flash_messages
          //= require_tree .
        CONTENT
      end
    end

    gsub_file 'config/locales/en.yml', 'en:' do
      <<-CONTENT.gsub(/^ {14}/, '')
        en:
          helpers:
            application:
              link_to_delete:
                link_text: Delete?
                confirmation: Are you sure?
      CONTENT
    end
  end
end