paloma 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +5 -17
- data/Changelog.md +10 -0
- data/Gemfile +0 -1
- data/{lib/paloma → app}/templates/_callbacks.js +0 -0
- data/{lib/paloma → app}/templates/_local.js +0 -0
- data/{lib/paloma → app}/templates/action.js +0 -0
- data/{lib/paloma → app}/templates/index.js +0 -0
- data/{lib/paloma → app}/templates/paloma.js +0 -0
- data/lib/paloma.rb +20 -2
- data/lib/paloma/generators/add_generator.rb +69 -0
- data/lib/paloma/generators/setup_generator.rb +28 -0
- data/paloma.gemspec +2 -3
- data/spec/callback_spec.rb +2 -3
- data/spec/generator_spec.rb +113 -0
- data/spec/sample_app/controllers.rb +8 -0
- data/spec/sample_app/init.rb +2 -1
- data/spec/sample_app/{model.rb → models.rb} +17 -5
- metadata +22 -36
- data/Gemfile.lock +0 -148
- data/lib/paloma/paloma_generator.rb +0 -95
    
        data/.gitignore
    CHANGED
    
    | @@ -1,19 +1,7 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
            *.sassc
         | 
| 3 | 
            -
            .sass-cache
         | 
| 4 | 
            -
            capybara-*.html
         | 
| 5 | 
            -
            .rspec
         | 
| 6 | 
            -
            /.bundle
         | 
| 7 | 
            -
            /vendor/bundle
         | 
| 8 | 
            -
            /log/*
         | 
| 9 | 
            -
            /tmp/*
         | 
| 10 | 
            -
            /db/*.sqlite3
         | 
| 11 | 
            -
            /public/system/*
         | 
| 12 | 
            -
            /coverage/
         | 
| 13 | 
            -
            /spec/tmp/*
         | 
| 1 | 
            +
            Gemfile.lock
         | 
| 14 2 | 
             
            *.gem
         | 
| 15 | 
            -
            / | 
| 3 | 
            +
            /tmp/*
         | 
| 4 | 
            +
            /spec/tmp/
         | 
| 5 | 
            +
            /spec/sample_app/tmp/
         | 
| 6 | 
            +
            /spec/sample_app/log/
         | 
| 16 7 | 
             
            /spec/sample_app/paloma_test
         | 
| 17 | 
            -
            **.orig
         | 
| 18 | 
            -
            rerun.txt
         | 
| 19 | 
            -
            pickle-email-*.html
         | 
    
        data/Changelog.md
    ADDED
    
    
    
        data/Gemfile
    CHANGED
    
    
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
    
        data/lib/paloma.rb
    CHANGED
    
    | @@ -1,6 +1,23 @@ | |
| 1 1 | 
             
            module Paloma
         | 
| 2 | 
            +
              mattr_accessor :destination, :templates
         | 
| 3 | 
            +
              
         | 
| 2 4 | 
             
              def self.root
         | 
| 3 | 
            -
                @paloma_root ||= File.dirname(__FILE__) | 
| 5 | 
            +
                @paloma_root ||= "#{File.dirname(__FILE__)}/../"
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
              
         | 
| 8 | 
            +
              
         | 
| 9 | 
            +
              def self.index_js
         | 
| 10 | 
            +
                @index_js ||= "#{Paloma.destination}/index.js"
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
              
         | 
| 13 | 
            +
              
         | 
| 14 | 
            +
              def self.destination
         | 
| 15 | 
            +
                @destination ||= 'app/assets/javascripts/paloma'
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
              
         | 
| 18 | 
            +
              
         | 
| 19 | 
            +
              def self.templates
         | 
| 20 | 
            +
                @templates ||= "#{Paloma.root}/app/templates"
         | 
| 4 21 | 
             
              end
         | 
| 5 22 | 
             
            end
         | 
| 6 23 |  | 
| @@ -9,6 +26,7 @@ require 'rails/generators' | |
| 9 26 |  | 
| 10 27 | 
             
            # TODO: Rails version checking
         | 
| 11 28 |  | 
| 12 | 
            -
            require 'paloma/ | 
| 29 | 
            +
            require 'paloma/generators/add_generator'
         | 
| 30 | 
            +
            require 'paloma/generators/setup_generator'
         | 
| 13 31 | 
             
            require 'paloma/action_controller_filters'
         | 
| 14 32 | 
             
            require 'paloma/action_controller_extension'
         | 
| @@ -0,0 +1,69 @@ | |
| 1 | 
            +
            module Paloma
         | 
| 2 | 
            +
              #
         | 
| 3 | 
            +
              # Usage: 
         | 
| 4 | 
            +
              #   rails g paloma:add <controller_name>
         | 
| 5 | 
            +
              #     - Generates the following:
         | 
| 6 | 
            +
              #         - a folder under app/assets/javascripts/paloma named as <controller_name>
         | 
| 7 | 
            +
              #         - callbacks.js inside the folder just made
         | 
| 8 | 
            +
              #     - Updates index.js under the 'paloma' folder
         | 
| 9 | 
            +
              #         - adds a line in order to require the callbacks to be made under the recently made folder
         | 
| 10 | 
            +
              #
         | 
| 11 | 
            +
              #
         | 
| 12 | 
            +
              #   rails g paloma:add <controller_name>/<action_name>
         | 
| 13 | 
            +
              #     - Generates the following:
         | 
| 14 | 
            +
              #         - <action_name>.js file inside the <controller_name> folder
         | 
| 15 | 
            +
              #
         | 
| 16 | 
            +
              #
         | 
| 17 | 
            +
              # Generated Files:
         | 
| 18 | 
            +
              #  <controller_name>/callbacks.js
         | 
| 19 | 
            +
              #    - contains code for requiring all callbacks under the same folder <controller_name> 
         | 
| 20 | 
            +
              #
         | 
| 21 | 
            +
              #  <controller_name>/<action_name>.js
         | 
| 22 | 
            +
              #    - actual code to be executed when callback is called
         | 
| 23 | 
            +
              #
         | 
| 24 | 
            +
                
         | 
| 25 | 
            +
              class AddGenerator < ::Rails::Generators::NamedBase
         | 
| 26 | 
            +
                source_root Paloma.templates
         | 
| 27 | 
            +
                
         | 
| 28 | 
            +
                def create_callback_file
         | 
| 29 | 
            +
                  arg = file_path.split('/')
         | 
| 30 | 
            +
                  @controller_name = arg[0]
         | 
| 31 | 
            +
                  action_name = arg[1]
         | 
| 32 | 
            +
                  
         | 
| 33 | 
            +
                  controller_folder = "#{Paloma.destination}/#{@controller_name}/" 
         | 
| 34 | 
            +
                  callbacks_js = "#{controller_folder}/_callbacks.js"
         | 
| 35 | 
            +
                  local_js = "#{controller_folder}/_local.js"
         | 
| 36 | 
            +
                  action_js = "#{controller_folder}/#{action_name}.js"
         | 
| 37 | 
            +
                    
         | 
| 38 | 
            +
                  Dir.mkdir(controller_folder) unless Dir.exists?(controller_folder)
         | 
| 39 | 
            +
                  
         | 
| 40 | 
            +
                  generate_from_template local_js unless File.exists?(local_js)
         | 
| 41 | 
            +
                  generate_from_template callbacks_js unless File.exists?(callbacks_js)        
         | 
| 42 | 
            +
                  
         | 
| 43 | 
            +
                  # Create a js file for action if there is an action argument
         | 
| 44 | 
            +
                  if action_name.present? && !File.exists?(action_js)
         | 
| 45 | 
            +
                    content = File.read("#{Paloma.templates}/action.js").gsub(
         | 
| 46 | 
            +
                      /controller\/action/, 
         | 
| 47 | 
            +
                      "#{@controller_name}/#{action_name}")
         | 
| 48 | 
            +
                      
         | 
| 49 | 
            +
                    File.open(action_js, 'w'){ |f| f.write(content) }
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
                  
         | 
| 52 | 
            +
                  # Require controller's _callbacks.js to Paloma's main index.js file.
         | 
| 53 | 
            +
                  # Located on "#{Paloma.destination}/index.js" or by default on
         | 
| 54 | 
            +
                  # app/assets/javascripts/paloma/index.js
         | 
| 55 | 
            +
                  File.open(Paloma.index_js, 'a+'){ |f| 
         | 
| 56 | 
            +
                    f << "\n//= require ./#{@controller_name}/_callbacks"
         | 
| 57 | 
            +
                  }
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
                
         | 
| 60 | 
            +
                
         | 
| 61 | 
            +
                private
         | 
| 62 | 
            +
                
         | 
| 63 | 
            +
                def generate_from_template destination_filename
         | 
| 64 | 
            +
                  filename = destination_filename.split('/').last
         | 
| 65 | 
            +
                  content = File.read("#{Paloma.templates}/_local.js").gsub(/controller/, @controller_name)
         | 
| 66 | 
            +
                  File.open(destination_filename, 'w'){ |f| f.write(content) }
         | 
| 67 | 
            +
                end 
         | 
| 68 | 
            +
              end
         | 
| 69 | 
            +
            end
         | 
| @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            module Paloma
         | 
| 2 | 
            +
              #
         | 
| 3 | 
            +
              # rails g paloma:setup
         | 
| 4 | 
            +
              #   - Generates the following:
         | 
| 5 | 
            +
              #     - 'paloma' folder under app/assets/javascripts/
         | 
| 6 | 
            +
              #     - index.js and paloma.js under the 'paloma' folder
         | 
| 7 | 
            +
              #
         | 
| 8 | 
            +
              # Generated Files:
         | 
| 9 | 
            +
              # index.js
         | 
| 10 | 
            +
              #   - contains code for requiring all callbacks of all folders
         | 
| 11 | 
            +
              #   - always updated when new folders and callback.js files are created
         | 
| 12 | 
            +
              #
         | 
| 13 | 
            +
              # paloma.js
         | 
| 14 | 
            +
              #   - declaration of namespace used in all callbacks
         | 
| 15 | 
            +
              #
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              class SetupGenerator < ::Rails::Generators::Base
         | 
| 18 | 
            +
                source_root Paloma.templates
         | 
| 19 | 
            +
                
         | 
| 20 | 
            +
                def setup_paloma
         | 
| 21 | 
            +
                  index_js = "#{Paloma.destination}/index.js"
         | 
| 22 | 
            +
                  paloma_js = "#{Paloma.destination}/paloma.js"
         | 
| 23 | 
            +
                  
         | 
| 24 | 
            +
                  copy_file 'index.js', index_js unless File.exists?(index_js)
         | 
| 25 | 
            +
                  copy_file 'paloma.js', paloma_js unless File.exists?(paloma_js)
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
            end
         | 
    
        data/paloma.gemspec
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            Gem::Specification.new do |s|
         | 
| 2 2 | 
             
              s.name        = 'paloma'
         | 
| 3 | 
            -
              s.version     = '0.0. | 
| 3 | 
            +
              s.version     = '0.0.6'
         | 
| 4 4 | 
             
              s.summary     = "a sexy way to organize javascript files using Rails` asset pipeline"
         | 
| 5 5 | 
             
              s.description = "a sexy way to organize javascript files using Rails` asset pipeline"
         | 
| 6 6 | 
             
              s.authors     = ["Karl Paragua", "Bia Esmero"]
         | 
| @@ -11,12 +11,11 @@ Gem::Specification.new do |s| | |
| 11 11 | 
             
              s.add_dependency 'jquery-rails'
         | 
| 12 12 |  | 
| 13 13 | 
             
              s.add_development_dependency 'rails', ['>= 3.1.0']
         | 
| 14 | 
            -
              s.add_development_dependency 'bundler', ['>= 1.0.0']
         | 
| 15 14 | 
             
              s.add_development_dependency 'rake', ['>= 0']
         | 
| 16 15 | 
             
              s.add_development_dependency 'sqlite3', ['>= 0']
         | 
| 17 16 | 
             
              s.add_development_dependency 'rspec', ['>= 0']
         | 
| 18 17 | 
             
              s.add_development_dependency 'rspec-rails', ['~> 2.0']
         | 
| 18 | 
            +
              s.add_development_dependency 'generator_spec', ['~> 0.8.7']
         | 
| 19 19 | 
             
              s.add_development_dependency 'capybara', ['>= 1.0']
         | 
| 20 20 | 
             
              s.add_development_dependency 'database_cleaner', ['>= 0']
         | 
| 21 | 
            -
              s.add_development_dependency 'launchy', ['>= 0']
         | 
| 22 21 | 
             
            end
         | 
    
        data/spec/callback_spec.rb
    CHANGED
    
    | @@ -1,5 +1,5 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 | 
            -
             | 
| 2 | 
            +
            =begin
         | 
| 3 3 | 
             
            feature 'Callbacks' do
         | 
| 4 4 |  | 
| 5 5 | 
             
              it 'should execute articles/new callback', :js => true do
         | 
| @@ -15,8 +15,6 @@ feature 'Callbacks' do | |
| 15 15 | 
             
                fill_in 'article[body]', :with => 'sexy paloma body'
         | 
| 16 16 | 
             
                click_button 'Save'
         | 
| 17 17 |  | 
| 18 | 
            -
                print page.html
         | 
| 19 | 
            -
                
         | 
| 20 18 | 
             
                page.has_selector?('#from-articles-create-callback').should == true
         | 
| 21 19 | 
             
                page.has_selector?('#from-articles-show-callback').should == true
         | 
| 22 20 | 
             
              end
         | 
| @@ -65,3 +63,4 @@ feature 'Callbacks' do | |
| 65 63 | 
             
                page.has_selector?('#from-articles-edit-callback').should == true
         | 
| 66 64 | 
             
              end
         | 
| 67 65 | 
             
            end
         | 
| 66 | 
            +
            =end
         | 
| @@ -0,0 +1,113 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
            require 'generator_spec/test_case'
         | 
| 3 | 
            +
            require 'fileutils'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            TEMP = "#{File.dirname(__FILE__)}/tmp/"
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            feature Paloma::SetupGenerator do
         | 
| 8 | 
            +
              include GeneratorSpec::TestCase
         | 
| 9 | 
            +
              destination TEMP
         | 
| 10 | 
            +
              
         | 
| 11 | 
            +
              before do
         | 
| 12 | 
            +
                prepare_destination
         | 
| 13 | 
            +
                run_generator
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
              
         | 
| 16 | 
            +
              specify do
         | 
| 17 | 
            +
                destination_root.should have_structure {
         | 
| 18 | 
            +
                  directory Paloma.destination do
         | 
| 19 | 
            +
                    file 'paloma.js'
         | 
| 20 | 
            +
                    file 'index.js'
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
                }
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
            end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
             | 
| 27 | 
            +
             | 
| 28 | 
            +
            def mimic_setup
         | 
| 29 | 
            +
              # Mimic SetupGenerator results before running the AddGenerator
         | 
| 30 | 
            +
              FileUtils.cd TEMP
         | 
| 31 | 
            +
              FileUtils.mkpath Paloma.destination
         | 
| 32 | 
            +
              File.open("#{Paloma.destination}/index.js", 'w') { |f| f.write('// test')}
         | 
| 33 | 
            +
            end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
             | 
| 36 | 
            +
             | 
| 37 | 
            +
            feature Paloma::AddGenerator, 'creating controller folder only' do
         | 
| 38 | 
            +
              include GeneratorSpec::TestCase
         | 
| 39 | 
            +
              destination TEMP
         | 
| 40 | 
            +
              arguments ['sexy_controller']
         | 
| 41 | 
            +
              
         | 
| 42 | 
            +
              before do
         | 
| 43 | 
            +
                prepare_destination
         | 
| 44 | 
            +
                mimic_setup
         | 
| 45 | 
            +
                run_generator
         | 
| 46 | 
            +
              end
         | 
| 47 | 
            +
              
         | 
| 48 | 
            +
              specify do
         | 
| 49 | 
            +
                destination_root.should have_structure {
         | 
| 50 | 
            +
                  directory Paloma.destination do
         | 
| 51 | 
            +
                    directory 'sexy_controller'
         | 
| 52 | 
            +
                    
         | 
| 53 | 
            +
                    file 'index.js' do
         | 
| 54 | 
            +
                      contains '//= require ./sexy_controller/_callbacks'
         | 
| 55 | 
            +
                    end
         | 
| 56 | 
            +
                  end
         | 
| 57 | 
            +
                }
         | 
| 58 | 
            +
              end
         | 
| 59 | 
            +
            end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
             | 
| 62 | 
            +
             | 
| 63 | 
            +
            feature Paloma::AddGenerator, 'creating action with existing controller folder' do
         | 
| 64 | 
            +
              include GeneratorSpec::TestCase
         | 
| 65 | 
            +
              destination TEMP
         | 
| 66 | 
            +
              arguments ['existing_controller_folder/new_action']
         | 
| 67 | 
            +
              
         | 
| 68 | 
            +
              before do
         | 
| 69 | 
            +
                prepare_destination
         | 
| 70 | 
            +
                mimic_setup
         | 
| 71 | 
            +
                Dir.mkdir "#{Paloma.destination}/existing_controller_folder"
         | 
| 72 | 
            +
                
         | 
| 73 | 
            +
                run_generator
         | 
| 74 | 
            +
              end
         | 
| 75 | 
            +
              
         | 
| 76 | 
            +
              specify do
         | 
| 77 | 
            +
                destination_root.should have_structure {
         | 
| 78 | 
            +
                  directory Paloma.destination do
         | 
| 79 | 
            +
                    directory 'existing_controller_folder' do
         | 
| 80 | 
            +
                      file 'new_action.js' do
         | 
| 81 | 
            +
                        contains "Paloma.callbacks['existing_controller_folder/new_action']"
         | 
| 82 | 
            +
                      end
         | 
| 83 | 
            +
                    end
         | 
| 84 | 
            +
                  end
         | 
| 85 | 
            +
                }
         | 
| 86 | 
            +
              end
         | 
| 87 | 
            +
            end
         | 
| 88 | 
            +
             | 
| 89 | 
            +
             | 
| 90 | 
            +
             | 
| 91 | 
            +
            feature Paloma::AddGenerator, 'creating both controller folder and action file' do
         | 
| 92 | 
            +
              include GeneratorSpec::TestCase
         | 
| 93 | 
            +
              destination TEMP
         | 
| 94 | 
            +
              arguments ['new_controller_folder/new_action']
         | 
| 95 | 
            +
              
         | 
| 96 | 
            +
              before do
         | 
| 97 | 
            +
                prepare_destination
         | 
| 98 | 
            +
                mimic_setup
         | 
| 99 | 
            +
                run_generator
         | 
| 100 | 
            +
              end
         | 
| 101 | 
            +
              
         | 
| 102 | 
            +
              specify do
         | 
| 103 | 
            +
                destination_root.should have_structure {
         | 
| 104 | 
            +
                  directory Paloma.destination do
         | 
| 105 | 
            +
                    directory 'new_controller_folder' do
         | 
| 106 | 
            +
                      file 'new_action.js' do
         | 
| 107 | 
            +
                        contains "Paloma.callbacks['new_controller_folder/new_action']"
         | 
| 108 | 
            +
                      end
         | 
| 109 | 
            +
                    end
         | 
| 110 | 
            +
                  end
         | 
| 111 | 
            +
                }
         | 
| 112 | 
            +
              end
         | 
| 113 | 
            +
            end
         | 
    
        data/spec/sample_app/init.rb
    CHANGED
    
    | @@ -27,7 +27,8 @@ app.initialize! | |
| 27 27 | 
             
            # Routes
         | 
| 28 28 | 
             
            app.routes.draw do
         | 
| 29 29 | 
             
              resources :articles, :controller => 'Articles'
         | 
| 30 | 
            +
              resources :categories, :module => 'SampleNamespace'
         | 
| 30 31 | 
             
            end
         | 
| 31 32 |  | 
| 32 | 
            -
            require "#{Paloma.root}/spec/sample_app/ | 
| 33 | 
            +
            require "#{Paloma.root}/spec/sample_app/models"
         | 
| 33 34 | 
             
            require "#{Paloma.root}/spec/sample_app/controllers"
         | 
| @@ -5,24 +5,36 @@ ActiveRecord::Base.configurations = {'test' => {:adapter => 'sqlite3', :database | |
| 5 5 | 
             
            ActiveRecord::Base.establish_connection('test')
         | 
| 6 6 |  | 
| 7 7 |  | 
| 8 | 
            -
            #  | 
| 8 | 
            +
            # Models
         | 
| 9 9 | 
             
            class Article < ActiveRecord::Base
         | 
| 10 | 
            -
              attr_accessible :title, :body
         | 
| 11 | 
            -
              
         | 
| 10 | 
            +
              attr_accessible :title, :body, :category, :category_id
         | 
| 11 | 
            +
              belongs_to :category
         | 
| 12 12 | 
             
              validates_presence_of :title
         | 
| 13 13 | 
             
            end
         | 
| 14 14 |  | 
| 15 15 |  | 
| 16 | 
            +
            class Category < ActiveRecord::Base
         | 
| 17 | 
            +
              attr_accessible :name
         | 
| 18 | 
            +
              has_many :articles, :dependent => :destroy
         | 
| 19 | 
            +
              validates_presence_of :name
         | 
| 20 | 
            +
            end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
             | 
| 16 23 | 
             
            # Migration
         | 
| 17 | 
            -
            class  | 
| 24 | 
            +
            class CreateTables < ActiveRecord::Migration
         | 
| 18 25 | 
             
              def self.up
         | 
| 19 26 | 
             
                create_table :articles, :force => true do |t| 
         | 
| 20 27 | 
             
                  t.string :title
         | 
| 21 28 | 
             
                  t.string :body
         | 
| 29 | 
            +
                  t.references :category
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
                
         | 
| 32 | 
            +
                create_table :categories, :force => true do |t|
         | 
| 33 | 
            +
                  t.string :name
         | 
| 22 34 | 
             
                end
         | 
| 23 35 | 
             
              end
         | 
| 24 36 | 
             
            end
         | 
| 25 37 |  | 
| 26 38 |  | 
| 27 39 | 
             
            ActiveRecord::Migration.verbose = false
         | 
| 28 | 
            -
             | 
| 40 | 
            +
            CreateTables.up
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: paloma
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.6
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -10,7 +10,7 @@ authors: | |
| 10 10 | 
             
            autorequire: 
         | 
| 11 11 | 
             
            bindir: bin
         | 
| 12 12 | 
             
            cert_chain: []
         | 
| 13 | 
            -
            date: 2012-12- | 
| 13 | 
            +
            date: 2012-12-21 00:00:00.000000000 Z
         | 
| 14 14 | 
             
            dependencies:
         | 
| 15 15 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 16 16 | 
             
              name: jquery-rails
         | 
| @@ -44,22 +44,6 @@ dependencies: | |
| 44 44 | 
             
                - - ! '>='
         | 
| 45 45 | 
             
                  - !ruby/object:Gem::Version
         | 
| 46 46 | 
             
                    version: 3.1.0
         | 
| 47 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 48 | 
            -
              name: bundler
         | 
| 49 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 50 | 
            -
                none: false
         | 
| 51 | 
            -
                requirements:
         | 
| 52 | 
            -
                - - ! '>='
         | 
| 53 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            -
                    version: 1.0.0
         | 
| 55 | 
            -
              type: :development
         | 
| 56 | 
            -
              prerelease: false
         | 
| 57 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 58 | 
            -
                none: false
         | 
| 59 | 
            -
                requirements:
         | 
| 60 | 
            -
                - - ! '>='
         | 
| 61 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 62 | 
            -
                    version: 1.0.0
         | 
| 63 47 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 64 48 | 
             
              name: rake
         | 
| 65 49 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -125,29 +109,29 @@ dependencies: | |
| 125 109 | 
             
                  - !ruby/object:Gem::Version
         | 
| 126 110 | 
             
                    version: '2.0'
         | 
| 127 111 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 128 | 
            -
              name:  | 
| 112 | 
            +
              name: generator_spec
         | 
| 129 113 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 130 114 | 
             
                none: false
         | 
| 131 115 | 
             
                requirements:
         | 
| 132 | 
            -
                - -  | 
| 116 | 
            +
                - - ~>
         | 
| 133 117 | 
             
                  - !ruby/object:Gem::Version
         | 
| 134 | 
            -
                    version:  | 
| 118 | 
            +
                    version: 0.8.7
         | 
| 135 119 | 
             
              type: :development
         | 
| 136 120 | 
             
              prerelease: false
         | 
| 137 121 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 138 122 | 
             
                none: false
         | 
| 139 123 | 
             
                requirements:
         | 
| 140 | 
            -
                - -  | 
| 124 | 
            +
                - - ~>
         | 
| 141 125 | 
             
                  - !ruby/object:Gem::Version
         | 
| 142 | 
            -
                    version:  | 
| 126 | 
            +
                    version: 0.8.7
         | 
| 143 127 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 144 | 
            -
              name:  | 
| 128 | 
            +
              name: capybara
         | 
| 145 129 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 146 130 | 
             
                none: false
         | 
| 147 131 | 
             
                requirements:
         | 
| 148 132 | 
             
                - - ! '>='
         | 
| 149 133 | 
             
                  - !ruby/object:Gem::Version
         | 
| 150 | 
            -
                    version: '0'
         | 
| 134 | 
            +
                    version: '1.0'
         | 
| 151 135 | 
             
              type: :development
         | 
| 152 136 | 
             
              prerelease: false
         | 
| 153 137 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| @@ -155,9 +139,9 @@ dependencies: | |
| 155 139 | 
             
                requirements:
         | 
| 156 140 | 
             
                - - ! '>='
         | 
| 157 141 | 
             
                  - !ruby/object:Gem::Version
         | 
| 158 | 
            -
                    version: '0'
         | 
| 142 | 
            +
                    version: '1.0'
         | 
| 159 143 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 160 | 
            -
              name:  | 
| 144 | 
            +
              name: database_cleaner
         | 
| 161 145 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 162 146 | 
             
                none: false
         | 
| 163 147 | 
             
                requirements:
         | 
| @@ -179,23 +163,25 @@ extensions: [] | |
| 179 163 | 
             
            extra_rdoc_files: []
         | 
| 180 164 | 
             
            files:
         | 
| 181 165 | 
             
            - .gitignore
         | 
| 166 | 
            +
            - Changelog.md
         | 
| 182 167 | 
             
            - Gemfile
         | 
| 183 | 
            -
            - Gemfile.lock
         | 
| 184 168 | 
             
            - License
         | 
| 185 169 | 
             
            - README.md
         | 
| 186 170 | 
             
            - Rakefile
         | 
| 171 | 
            +
            - app/templates/_callbacks.js
         | 
| 172 | 
            +
            - app/templates/_local.js
         | 
| 173 | 
            +
            - app/templates/action.js
         | 
| 174 | 
            +
            - app/templates/index.js
         | 
| 175 | 
            +
            - app/templates/paloma.js
         | 
| 187 176 | 
             
            - app/views/paloma/_callback_hook.html.erb
         | 
| 188 177 | 
             
            - lib/paloma.rb
         | 
| 189 178 | 
             
            - lib/paloma/action_controller_extension.rb
         | 
| 190 179 | 
             
            - lib/paloma/action_controller_filters.rb
         | 
| 191 | 
            -
            - lib/paloma/ | 
| 192 | 
            -
            - lib/paloma/ | 
| 193 | 
            -
            - lib/paloma/templates/_local.js
         | 
| 194 | 
            -
            - lib/paloma/templates/action.js
         | 
| 195 | 
            -
            - lib/paloma/templates/index.js
         | 
| 196 | 
            -
            - lib/paloma/templates/paloma.js
         | 
| 180 | 
            +
            - lib/paloma/generators/add_generator.rb
         | 
| 181 | 
            +
            - lib/paloma/generators/setup_generator.rb
         | 
| 197 182 | 
             
            - paloma.gemspec
         | 
| 198 183 | 
             
            - spec/callback_spec.rb
         | 
| 184 | 
            +
            - spec/generator_spec.rb
         | 
| 199 185 | 
             
            - spec/sample_app/app/assets/javascripts/application.js
         | 
| 200 186 | 
             
            - spec/sample_app/app/assets/javascripts/paloma/articles/callbacks.js
         | 
| 201 187 | 
             
            - spec/sample_app/app/assets/javascripts/paloma/articles/create.js
         | 
| @@ -212,7 +198,7 @@ files: | |
| 212 198 | 
             
            - spec/sample_app/app/views/layouts/application.html.erb
         | 
| 213 199 | 
             
            - spec/sample_app/controllers.rb
         | 
| 214 200 | 
             
            - spec/sample_app/init.rb
         | 
| 215 | 
            -
            - spec/sample_app/ | 
| 201 | 
            +
            - spec/sample_app/models.rb
         | 
| 216 202 | 
             
            - spec/spec_helper.rb
         | 
| 217 203 | 
             
            homepage: https://github.com/kbparagua/paloma
         | 
| 218 204 | 
             
            licenses: []
         | 
| @@ -234,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 234 220 | 
             
                  version: '0'
         | 
| 235 221 | 
             
            requirements: []
         | 
| 236 222 | 
             
            rubyforge_project: 
         | 
| 237 | 
            -
            rubygems_version: 1.8. | 
| 223 | 
            +
            rubygems_version: 1.8.24
         | 
| 238 224 | 
             
            signing_key: 
         | 
| 239 225 | 
             
            specification_version: 3
         | 
| 240 226 | 
             
            summary: a sexy way to organize javascript files using Rails` asset pipeline
         | 
    
        data/Gemfile.lock
    DELETED
    
    | @@ -1,148 +0,0 @@ | |
| 1 | 
            -
            PATH
         | 
| 2 | 
            -
              remote: .
         | 
| 3 | 
            -
              specs:
         | 
| 4 | 
            -
                paloma (0.0.4)
         | 
| 5 | 
            -
                  jquery-rails
         | 
| 6 | 
            -
             | 
| 7 | 
            -
            GEM
         | 
| 8 | 
            -
              remote: http://rubygems.org/
         | 
| 9 | 
            -
              specs:
         | 
| 10 | 
            -
                actionmailer (3.2.9)
         | 
| 11 | 
            -
                  actionpack (= 3.2.9)
         | 
| 12 | 
            -
                  mail (~> 2.4.4)
         | 
| 13 | 
            -
                actionpack (3.2.9)
         | 
| 14 | 
            -
                  activemodel (= 3.2.9)
         | 
| 15 | 
            -
                  activesupport (= 3.2.9)
         | 
| 16 | 
            -
                  builder (~> 3.0.0)
         | 
| 17 | 
            -
                  erubis (~> 2.7.0)
         | 
| 18 | 
            -
                  journey (~> 1.0.4)
         | 
| 19 | 
            -
                  rack (~> 1.4.0)
         | 
| 20 | 
            -
                  rack-cache (~> 1.2)
         | 
| 21 | 
            -
                  rack-test (~> 0.6.1)
         | 
| 22 | 
            -
                  sprockets (~> 2.2.1)
         | 
| 23 | 
            -
                activemodel (3.2.9)
         | 
| 24 | 
            -
                  activesupport (= 3.2.9)
         | 
| 25 | 
            -
                  builder (~> 3.0.0)
         | 
| 26 | 
            -
                activerecord (3.2.9)
         | 
| 27 | 
            -
                  activemodel (= 3.2.9)
         | 
| 28 | 
            -
                  activesupport (= 3.2.9)
         | 
| 29 | 
            -
                  arel (~> 3.0.2)
         | 
| 30 | 
            -
                  tzinfo (~> 0.3.29)
         | 
| 31 | 
            -
                activeresource (3.2.9)
         | 
| 32 | 
            -
                  activemodel (= 3.2.9)
         | 
| 33 | 
            -
                  activesupport (= 3.2.9)
         | 
| 34 | 
            -
                activesupport (3.2.9)
         | 
| 35 | 
            -
                  i18n (~> 0.6)
         | 
| 36 | 
            -
                  multi_json (~> 1.0)
         | 
| 37 | 
            -
                addressable (2.3.2)
         | 
| 38 | 
            -
                arel (3.0.2)
         | 
| 39 | 
            -
                builder (3.0.4)
         | 
| 40 | 
            -
                capybara (2.0.1)
         | 
| 41 | 
            -
                  mime-types (>= 1.16)
         | 
| 42 | 
            -
                  nokogiri (>= 1.3.3)
         | 
| 43 | 
            -
                  rack (>= 1.0.0)
         | 
| 44 | 
            -
                  rack-test (>= 0.5.4)
         | 
| 45 | 
            -
                  selenium-webdriver (~> 2.0)
         | 
| 46 | 
            -
                  xpath (~> 1.0.0)
         | 
| 47 | 
            -
                childprocess (0.3.6)
         | 
| 48 | 
            -
                  ffi (~> 1.0, >= 1.0.6)
         | 
| 49 | 
            -
                database_cleaner (0.9.1)
         | 
| 50 | 
            -
                diff-lcs (1.1.3)
         | 
| 51 | 
            -
                erubis (2.7.0)
         | 
| 52 | 
            -
                ffi (1.2.0)
         | 
| 53 | 
            -
                hike (1.2.1)
         | 
| 54 | 
            -
                i18n (0.6.1)
         | 
| 55 | 
            -
                journey (1.0.4)
         | 
| 56 | 
            -
                jquery-rails (2.1.4)
         | 
| 57 | 
            -
                  railties (>= 3.0, < 5.0)
         | 
| 58 | 
            -
                  thor (>= 0.14, < 2.0)
         | 
| 59 | 
            -
                json (1.7.5)
         | 
| 60 | 
            -
                launchy (2.1.2)
         | 
| 61 | 
            -
                  addressable (~> 2.3)
         | 
| 62 | 
            -
                libwebsocket (0.1.7.1)
         | 
| 63 | 
            -
                  addressable
         | 
| 64 | 
            -
                  websocket
         | 
| 65 | 
            -
                mail (2.4.4)
         | 
| 66 | 
            -
                  i18n (>= 0.4.0)
         | 
| 67 | 
            -
                  mime-types (~> 1.16)
         | 
| 68 | 
            -
                  treetop (~> 1.4.8)
         | 
| 69 | 
            -
                mime-types (1.19)
         | 
| 70 | 
            -
                multi_json (1.5.0)
         | 
| 71 | 
            -
                nokogiri (1.5.5)
         | 
| 72 | 
            -
                polyglot (0.3.3)
         | 
| 73 | 
            -
                rack (1.4.1)
         | 
| 74 | 
            -
                rack-cache (1.2)
         | 
| 75 | 
            -
                  rack (>= 0.4)
         | 
| 76 | 
            -
                rack-ssl (1.3.2)
         | 
| 77 | 
            -
                  rack
         | 
| 78 | 
            -
                rack-test (0.6.2)
         | 
| 79 | 
            -
                  rack (>= 1.0)
         | 
| 80 | 
            -
                rails (3.2.9)
         | 
| 81 | 
            -
                  actionmailer (= 3.2.9)
         | 
| 82 | 
            -
                  actionpack (= 3.2.9)
         | 
| 83 | 
            -
                  activerecord (= 3.2.9)
         | 
| 84 | 
            -
                  activeresource (= 3.2.9)
         | 
| 85 | 
            -
                  activesupport (= 3.2.9)
         | 
| 86 | 
            -
                  bundler (~> 1.0)
         | 
| 87 | 
            -
                  railties (= 3.2.9)
         | 
| 88 | 
            -
                railties (3.2.9)
         | 
| 89 | 
            -
                  actionpack (= 3.2.9)
         | 
| 90 | 
            -
                  activesupport (= 3.2.9)
         | 
| 91 | 
            -
                  rack-ssl (~> 1.3.2)
         | 
| 92 | 
            -
                  rake (>= 0.8.7)
         | 
| 93 | 
            -
                  rdoc (~> 3.4)
         | 
| 94 | 
            -
                  thor (>= 0.14.6, < 2.0)
         | 
| 95 | 
            -
                rake (10.0.3)
         | 
| 96 | 
            -
                rdoc (3.12)
         | 
| 97 | 
            -
                  json (~> 1.4)
         | 
| 98 | 
            -
                rspec (2.12.0)
         | 
| 99 | 
            -
                  rspec-core (~> 2.12.0)
         | 
| 100 | 
            -
                  rspec-expectations (~> 2.12.0)
         | 
| 101 | 
            -
                  rspec-mocks (~> 2.12.0)
         | 
| 102 | 
            -
                rspec-core (2.12.2)
         | 
| 103 | 
            -
                rspec-expectations (2.12.1)
         | 
| 104 | 
            -
                  diff-lcs (~> 1.1.3)
         | 
| 105 | 
            -
                rspec-mocks (2.12.0)
         | 
| 106 | 
            -
                rspec-rails (2.12.0)
         | 
| 107 | 
            -
                  actionpack (>= 3.0)
         | 
| 108 | 
            -
                  activesupport (>= 3.0)
         | 
| 109 | 
            -
                  railties (>= 3.0)
         | 
| 110 | 
            -
                  rspec-core (~> 2.12.0)
         | 
| 111 | 
            -
                  rspec-expectations (~> 2.12.0)
         | 
| 112 | 
            -
                  rspec-mocks (~> 2.12.0)
         | 
| 113 | 
            -
                rubyzip (0.9.9)
         | 
| 114 | 
            -
                selenium-webdriver (2.27.2)
         | 
| 115 | 
            -
                  childprocess (>= 0.2.5)
         | 
| 116 | 
            -
                  libwebsocket (~> 0.1.3)
         | 
| 117 | 
            -
                  multi_json (~> 1.0)
         | 
| 118 | 
            -
                  rubyzip
         | 
| 119 | 
            -
                sprockets (2.2.2)
         | 
| 120 | 
            -
                  hike (~> 1.2)
         | 
| 121 | 
            -
                  multi_json (~> 1.0)
         | 
| 122 | 
            -
                  rack (~> 1.0)
         | 
| 123 | 
            -
                  tilt (~> 1.1, != 1.3.0)
         | 
| 124 | 
            -
                sqlite3 (1.3.6)
         | 
| 125 | 
            -
                thor (0.16.0)
         | 
| 126 | 
            -
                tilt (1.3.3)
         | 
| 127 | 
            -
                treetop (1.4.12)
         | 
| 128 | 
            -
                  polyglot
         | 
| 129 | 
            -
                  polyglot (>= 0.3.1)
         | 
| 130 | 
            -
                tzinfo (0.3.35)
         | 
| 131 | 
            -
                websocket (1.0.4)
         | 
| 132 | 
            -
                xpath (1.0.0)
         | 
| 133 | 
            -
                  nokogiri (~> 1.3)
         | 
| 134 | 
            -
             | 
| 135 | 
            -
            PLATFORMS
         | 
| 136 | 
            -
              ruby
         | 
| 137 | 
            -
             | 
| 138 | 
            -
            DEPENDENCIES
         | 
| 139 | 
            -
              bundler (>= 1.0.0)
         | 
| 140 | 
            -
              capybara (>= 1.0)
         | 
| 141 | 
            -
              database_cleaner
         | 
| 142 | 
            -
              launchy
         | 
| 143 | 
            -
              paloma!
         | 
| 144 | 
            -
              rails (>= 3.1.0)
         | 
| 145 | 
            -
              rake
         | 
| 146 | 
            -
              rspec
         | 
| 147 | 
            -
              rspec-rails (~> 2.0)
         | 
| 148 | 
            -
              sqlite3
         | 
| @@ -1,95 +0,0 @@ | |
| 1 | 
            -
            module Paloma
         | 
| 2 | 
            -
              #
         | 
| 3 | 
            -
              # Setup:
         | 
| 4 | 
            -
              #   rails g paloma:setup
         | 
| 5 | 
            -
              #     - Generates the following:
         | 
| 6 | 
            -
              #         - 'paloma' folder under app/assets/javascripts/paloma
         | 
| 7 | 
            -
              #         - index.js and paloma.js under the 'paloma' folder
         | 
| 8 | 
            -
              #
         | 
| 9 | 
            -
              #
         | 
| 10 | 
            -
              # Usage: 
         | 
| 11 | 
            -
              #   rails g paloma:add <controller_name>
         | 
| 12 | 
            -
              #     - Generates the following:
         | 
| 13 | 
            -
              #         - a folder under app/assets/javascripts/paloma named as <controller_name>
         | 
| 14 | 
            -
              #         - callbacks.js inside the folder just made
         | 
| 15 | 
            -
              #     - Updates index.js under the 'paloma' folder
         | 
| 16 | 
            -
              #         - adds a line in order to require the callbacks to be made under the recently made folder
         | 
| 17 | 
            -
              #
         | 
| 18 | 
            -
              #
         | 
| 19 | 
            -
              #   rails g paloma:add <controller_name>/<action_name>
         | 
| 20 | 
            -
              #     - Generates the following:
         | 
| 21 | 
            -
              #         - <action_name>.js file inside the <controller_name> folder
         | 
| 22 | 
            -
              #
         | 
| 23 | 
            -
              #
         | 
| 24 | 
            -
              # Generated Files:
         | 
| 25 | 
            -
              #  index.js
         | 
| 26 | 
            -
              #    - contains code for requiring all callbacks of all folders
         | 
| 27 | 
            -
              #    - always updated when new folders and callback.js files are created
         | 
| 28 | 
            -
              #
         | 
| 29 | 
            -
              #  paloma.js
         | 
| 30 | 
            -
              #    - declaration of namespace used in all callbacks
         | 
| 31 | 
            -
              #
         | 
| 32 | 
            -
              #  <controller_name>/callbacks.js
         | 
| 33 | 
            -
              #    - contains code for requiring all callbacks under the same folder <controller_name> 
         | 
| 34 | 
            -
              #
         | 
| 35 | 
            -
              #  <controller_name>/<action_name>.js
         | 
| 36 | 
            -
              #    - actual code to be executed when callback is called
         | 
| 37 | 
            -
              #
         | 
| 38 | 
            -
                
         | 
| 39 | 
            -
              PARENT  = 'app/assets/javascripts/paloma/'
         | 
| 40 | 
            -
              INDEX = PARENT + 'index.js'
         | 
| 41 | 
            -
              PALOMA = PARENT + 'paloma.js'
         | 
| 42 | 
            -
              
         | 
| 43 | 
            -
              class SetupGenerator < ::Rails::Generators::Base
         | 
| 44 | 
            -
                source_root File.expand_path('../templates', __FILE__)
         | 
| 45 | 
            -
                
         | 
| 46 | 
            -
                def setup_paloma
         | 
| 47 | 
            -
                  #index.js on callbacks folder
         | 
| 48 | 
            -
                  has_index = File.exists? INDEX
         | 
| 49 | 
            -
                  copy_file 'index.js', INDEX unless has_index  
         | 
| 50 | 
            -
                  
         | 
| 51 | 
            -
                  has_paloma = File.exists? PALOMA
         | 
| 52 | 
            -
                  copy_file 'paloma.js', PALOMA unless has_paloma
         | 
| 53 | 
            -
                end
         | 
| 54 | 
            -
                
         | 
| 55 | 
            -
              end
         | 
| 56 | 
            -
              
         | 
| 57 | 
            -
              
         | 
| 58 | 
            -
              class AddGenerator < ::Rails::Generators::NamedBase
         | 
| 59 | 
            -
                source_root File.expand_path('../templates', __FILE__)
         | 
| 60 | 
            -
                
         | 
| 61 | 
            -
                def create_callback_file
         | 
| 62 | 
            -
                  file = file_path.split('/')
         | 
| 63 | 
            -
                  controller = file[0]
         | 
| 64 | 
            -
                  action = file[1]
         | 
| 65 | 
            -
                  
         | 
| 66 | 
            -
                  callbacks = PARENT + "#{controller}/_callbacks.js"
         | 
| 67 | 
            -
                  templates = "#{Paloma.root}/lib/paloma/templates/"
         | 
| 68 | 
            -
                  local = PARENT + "#{controller}/_local.js"
         | 
| 69 | 
            -
                  action_file = PARENT + "#{controller}/#{action}.js"
         | 
| 70 | 
            -
                  
         | 
| 71 | 
            -
                  #_callbacks.js per folder(controller)
         | 
| 72 | 
            -
                  has_callbacks = File.exists? callbacks
         | 
| 73 | 
            -
                  unless has_callbacks
         | 
| 74 | 
            -
                    Dir.mkdir(PARENT + "#{controller}")
         | 
| 75 | 
            -
                    content = File.read(templates + '_callbacks.js').gsub('controller', "#{controller}")
         | 
| 76 | 
            -
                    File.open(callbacks, 'w'){ |f| f.write(content) }
         | 
| 77 | 
            -
                    File.open(INDEX, 'a+'){ |f| f << "\n//= require ./" + controller + '/_callbacks' }
         | 
| 78 | 
            -
                  end
         | 
| 79 | 
            -
                  
         | 
| 80 | 
            -
                  #_local.js per folder(controller)
         | 
| 81 | 
            -
                  has_local =File.exists? local
         | 
| 82 | 
            -
                  unless has_local
         | 
| 83 | 
            -
                    content = File.read(templates + '_local.js').gsub('controller', "#{controller}")
         | 
| 84 | 
            -
                    File.open(local, 'w'){ |f| f.write(content) }
         | 
| 85 | 
            -
                  end
         | 
| 86 | 
            -
                  
         | 
| 87 | 
            -
                  #<action>.js on folder(controller) - code for callback
         | 
| 88 | 
            -
                  has_action = File.exists? action_file
         | 
| 89 | 
            -
                  unless (action.nil? || has_action)
         | 
| 90 | 
            -
                    content = File.read(templates + 'action.js').gsub('controller/action', "#{controller}/#{action}")
         | 
| 91 | 
            -
                    File.open(action_file, 'w'){ |f| f.write(content) }
         | 
| 92 | 
            -
                  end
         | 
| 93 | 
            -
                end    
         | 
| 94 | 
            -
              end
         | 
| 95 | 
            -
            end
         |