impressionizer 0.0.1 → 0.0.2
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 +2 -0
- data/README.rdoc +35 -1
- data/app/controllers/impressionizer/impressions_controller.rb +31 -0
- data/app/models/impressionizer/impression.rb +5 -0
- data/app/models/impressionizer/impressionable.rb +33 -0
- data/app/views/impressionizer/impressions/index.html.erb +9 -0
- data/config/routes.rb +3 -0
- data/impressionizer.gemspec +6 -32
- data/lib/generators/impressionizer/impressionizer_generator.rb +23 -0
- data/lib/generators/impressionizer/templates/migration.rb +18 -0
- data/lib/impressionizer/engine.rb +28 -0
- data/lib/impressionizer/version.rb +3 -0
- data/test/dummy/Gemfile +4 -0
- data/test/dummy/app/controllers/pages_controller.rb +85 -0
- data/test/dummy/app/helpers/pages_helper.rb +2 -0
- data/test/dummy/app/models/page.rb +3 -0
- data/test/dummy/app/views/pages/_form.html.erb +25 -0
- data/test/dummy/app/views/pages/edit.html.erb +6 -0
- data/test/dummy/app/views/pages/index.html.erb +27 -0
- data/test/dummy/app/views/pages/new.html.erb +5 -0
- data/test/dummy/app/views/pages/show.html.erb +15 -0
- data/test/dummy/db/migrate/20110701011920_create_pages.rb +14 -0
- data/test/dummy/db/migrate/20110701044058_create_impressions.rb +18 -0
- data/test/dummy/db/schema.rb +34 -0
- data/test/dummy/public/stylesheets/scaffold.css +56 -0
- data/test/generators/impressionizer_generator_test.rb +33 -0
- data/test/routing_test.rb +21 -0
- data/test/unit/impressionable_test.rb +7 -0
- data/test/unit/page_test.rb +17 -0
- metadata +48 -5
    
        data/.gitignore
    CHANGED
    
    
    
        data/README.rdoc
    CHANGED
    
    | @@ -1,3 +1,37 @@ | |
| 1 1 | 
             
            = Impressionizer
         | 
| 2 2 |  | 
| 3 | 
            -
            This project rocks and uses MIT-LICENSE.
         | 
| 3 | 
            +
            This project seriously rocks and uses MIT-LICENSE.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            = Installation
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            - Add:
         | 
| 8 | 
            +
              gem "impressionizer"
         | 
| 9 | 
            +
              to your Gemfile
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            - Run:
         | 
| 12 | 
            +
              bundle install
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            - Run generator:
         | 
| 15 | 
            +
              rails g impressionizer
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            - Run migration:
         | 
| 18 | 
            +
              rake db:migrate
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            - Add:
         | 
| 21 | 
            +
              is_impressionable
         | 
| 22 | 
            +
              to your model
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            - Add:
         | 
| 25 | 
            +
              before_filter :impressionize
         | 
| 26 | 
            +
              to your controller
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            - Restart server if running
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            = Usage
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              model.impression_count
         | 
| 33 | 
            +
              model.unique_impression_count
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              Model.most_impressions
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            = Todo
         | 
| @@ -0,0 +1,31 @@ | |
| 1 | 
            +
            module Impressionizer
         | 
| 2 | 
            +
              module ImpressionsController
         | 
| 3 | 
            +
                module ClassMethods
         | 
| 4 | 
            +
                  def impressionize(args={})
         | 
| 5 | 
            +
                  end
         | 
| 6 | 
            +
                end
         | 
| 7 | 
            +
                
         | 
| 8 | 
            +
                module InstanceMethods
         | 
| 9 | 
            +
                  def impressionize
         | 
| 10 | 
            +
                    if %q('show').include? action_name  
         | 
| 11 | 
            +
                      @object = controller_name.singularize.capitalize.constantize.find(params[:id])
         | 
| 12 | 
            +
                      @object.impressions.create(
         | 
| 13 | 
            +
                        :session_hash => request.session_options[:id],
         | 
| 14 | 
            +
                        :request_hash => ActiveSupport::SecureRandom.hex(187),
         | 
| 15 | 
            +
                        :referrer => request.referer,
         | 
| 16 | 
            +
                        :ip_address => request.remote_ip,
         | 
| 17 | 
            +
                        :user_id => current_user_id
         | 
| 18 | 
            +
                      )
         | 
| 19 | 
            +
                    end
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
                  
         | 
| 22 | 
            +
                  private
         | 
| 23 | 
            +
                  
         | 
| 24 | 
            +
                  def current_user_id
         | 
| 25 | 
            +
                    current_user_id = @current_user ? @current_user.id : nil
         | 
| 26 | 
            +
                    current_user_id = current_user ? current_user.id : nil rescue nil
         | 
| 27 | 
            +
                    current_user_id
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
            end
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            module Impressionizer
         | 
| 2 | 
            +
              module Impressionable
         | 
| 3 | 
            +
                def is_impressionable
         | 
| 4 | 
            +
                  has_many :impressions, :as => :impressionable, :class_name => "Impressionizer::Impression"
         | 
| 5 | 
            +
                  extend ClassMethods
         | 
| 6 | 
            +
                  include InstanceMethods
         | 
| 7 | 
            +
                end
         | 
| 8 | 
            +
                
         | 
| 9 | 
            +
                module ClassMethods
         | 
| 10 | 
            +
                  def most_impressions
         | 
| 11 | 
            +
                    self.all.select{|obj| obj.impression_count > 0}.sort_by{|obj| -obj.impression_count}
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
                  
         | 
| 14 | 
            +
                  def most_unique_impressions
         | 
| 15 | 
            +
                    self.all.select{|obj| obj.impression_count > 0}.sort_by{|obj| -obj.unique_impression_count}
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
                
         | 
| 19 | 
            +
                module InstanceMethods
         | 
| 20 | 
            +
                  def impressionable?
         | 
| 21 | 
            +
                    true
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  def impression_count
         | 
| 25 | 
            +
                    impressions.size
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  def unique_impression_count
         | 
| 29 | 
            +
                    impressions.group(:ip_address).size.size
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
            end
         | 
    
        data/config/routes.rb
    ADDED
    
    
    
        data/impressionizer.gemspec
    CHANGED
    
    | @@ -10,10 +10,9 @@ Gem::Specification.new do |s| | |
| 10 10 | 
             
              s.authors       = ["Patrick Bartels"]
         | 
| 11 11 | 
             
              s.email         = %q{patrick@bartels.ug}
         | 
| 12 12 | 
             
              s.homepage      = %q{http://bartels.ug}
         | 
| 13 | 
            -
              s.description   = " | 
| 14 | 
            -
              s.summary       = " | 
| 15 | 
            -
              s. | 
| 16 | 
            -
              s.version       = "0.0.1"
         | 
| 13 | 
            +
              s.description   = "Impressionizer description."
         | 
| 14 | 
            +
              s.summary       = "Impressionizer summary."
         | 
| 15 | 
            +
              s.version       = "0.0.2"
         | 
| 17 16 |  | 
| 18 17 | 
             
              s.files         = `git ls-files`.split("\n")
         | 
| 19 18 | 
             
              s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
         | 
| @@ -22,31 +21,6 @@ Gem::Specification.new do |s| | |
| 22 21 |  | 
| 23 22 | 
             
              s.required_rubygems_version = "> 1.3.6"
         | 
| 24 23 |  | 
| 25 | 
            -
              s.add_dependency "activesupport", "~> 3.0. | 
| 26 | 
            -
              s.add_dependency "rails", "~> 3.0. | 
| 27 | 
            -
            end
         | 
| 28 | 
            -
             | 
| 29 | 
            -
            # # -*- encoding: utf-8 -*-
         | 
| 30 | 
            -
            # $:.push File.expand_path("../lib", __FILE__)
         | 
| 31 | 
            -
            # require "impressionizer/version"
         | 
| 32 | 
            -
            # 
         | 
| 33 | 
            -
            # Gem::Specification.new do |s|
         | 
| 34 | 
            -
            #   s.name          = "impressionizer"
         | 
| 35 | 
            -
            #   s.version       = Impressionizer::VERSION
         | 
| 36 | 
            -
            #   s.platform      = Gem::Platform::RUBY
         | 
| 37 | 
            -
            #   
         | 
| 38 | 
            -
            #   s.authors       = ["Patrick Bartels"]
         | 
| 39 | 
            -
            #   s.email         = %q{patrick@bartels.ug}
         | 
| 40 | 
            -
            #   s.homepage      = %q{http://bartels.ug}
         | 
| 41 | 
            -
            #   s.summary       = %q{Impressionizer}
         | 
| 42 | 
            -
            #   s.description   = %q{Page impressions analyzer}
         | 
| 43 | 
            -
            #   
         | 
| 44 | 
            -
            #   s.rubyforge_project = "impressionizer"
         | 
| 45 | 
            -
            #   
         | 
| 46 | 
            -
            #   s.files         = `git ls-files`.split("\n")
         | 
| 47 | 
            -
            #   s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
         | 
| 48 | 
            -
            #   s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         | 
| 49 | 
            -
            #   s.require_paths = ["lib"]
         | 
| 50 | 
            -
            #   
         | 
| 51 | 
            -
            #   s.add_development_dependency "rspec", "~> 2.0.0"
         | 
| 52 | 
            -
            # end
         | 
| 24 | 
            +
              s.add_dependency "activesupport", "~> 3.0.0"
         | 
| 25 | 
            +
              s.add_dependency "rails", "~> 3.0.0"
         | 
| 26 | 
            +
            end
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            # Requires
         | 
| 2 | 
            +
            require 'rails/generators'
         | 
| 3 | 
            +
            require 'rails/generators/migration'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            class ImpressionizerGenerator < Rails::Generators::Base
         | 
| 6 | 
            +
              include Rails::Generators::Migration
         | 
| 7 | 
            +
              
         | 
| 8 | 
            +
              def self.source_root
         | 
| 9 | 
            +
                @source_root ||= File.join(File.dirname(__FILE__), 'templates')
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              def self.next_migration_number(dirname)
         | 
| 13 | 
            +
                if ActiveRecord::Base.timestamped_migrations
         | 
| 14 | 
            +
                  Time.new.utc.strftime("%Y%m%d%H%M%S")
         | 
| 15 | 
            +
                else
         | 
| 16 | 
            +
                  "%.3d" % (current_migration_number(dirname) + 1)
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              def create_migration_file
         | 
| 21 | 
            +
                migration_template 'migration.rb', 'db/migrate/create_impressions.rb'
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
            end
         | 
| @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            class CreateImpressions < ActiveRecord::Migration
         | 
| 2 | 
            +
              def self.up
         | 
| 3 | 
            +
                create_table :impressions, :force => true do |t|
         | 
| 4 | 
            +
                  t.string :impressionable_type
         | 
| 5 | 
            +
                  t.integer :impressionable_id
         | 
| 6 | 
            +
                  t.string :session_hash
         | 
| 7 | 
            +
                  t.string :request_hash
         | 
| 8 | 
            +
                  t.string :referrer
         | 
| 9 | 
            +
                  t.string :ip_address
         | 
| 10 | 
            +
                  t.integer :user_id
         | 
| 11 | 
            +
                  t.timestamps
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              def self.down
         | 
| 16 | 
            +
                drop_table :impressions
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
            end
         | 
| @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            module Impressionizer
         | 
| 2 | 
            +
             | 
| 3 | 
            +
              class Engine < Rails::Engine
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                initializer "impressionizer.load_app_instance_data" do |app|
         | 
| 6 | 
            +
                  Impressionizer.setup do |config|
         | 
| 7 | 
            +
                    config.app_root = app.root
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                initializer "impressionizer.load_static_assets" do |app|
         | 
| 12 | 
            +
                  app.middleware.use ::ActionDispatch::Static, "#{root}/public"
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
                
         | 
| 15 | 
            +
                initializer 'impressionizer.extend_ar' do |app|
         | 
| 16 | 
            +
                  ActiveRecord::Base.extend Impressionizer::Impressionable
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
                
         | 
| 19 | 
            +
                initializer 'impressionizer.controller' do
         | 
| 20 | 
            +
                  ActiveSupport.on_load(:action_controller) do
         | 
| 21 | 
            +
                    include Impressionizer::ImpressionsController::InstanceMethods
         | 
| 22 | 
            +
                    extend Impressionizer::ImpressionsController::ClassMethods
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            end
         | 
    
        data/test/dummy/Gemfile
    ADDED
    
    
| @@ -0,0 +1,85 @@ | |
| 1 | 
            +
            class PagesController < ApplicationController
         | 
| 2 | 
            +
              before_filter :impressionize
         | 
| 3 | 
            +
              
         | 
| 4 | 
            +
              # GET /pages
         | 
| 5 | 
            +
              # GET /pages.xml
         | 
| 6 | 
            +
              def index
         | 
| 7 | 
            +
                @pages = Page.all
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                respond_to do |format|
         | 
| 10 | 
            +
                  format.html # index.html.erb
         | 
| 11 | 
            +
                  format.xml  { render :xml => @pages }
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              # GET /pages/1
         | 
| 16 | 
            +
              # GET /pages/1.xml
         | 
| 17 | 
            +
              def show
         | 
| 18 | 
            +
                @page = Page.find(params[:id])
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                respond_to do |format|
         | 
| 21 | 
            +
                  format.html # show.html.erb
         | 
| 22 | 
            +
                  format.xml  { render :xml => @page }
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              # GET /pages/new
         | 
| 27 | 
            +
              # GET /pages/new.xml
         | 
| 28 | 
            +
              def new
         | 
| 29 | 
            +
                @page = Page.new
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                respond_to do |format|
         | 
| 32 | 
            +
                  format.html # new.html.erb
         | 
| 33 | 
            +
                  format.xml  { render :xml => @page }
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
              end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
              # GET /pages/1/edit
         | 
| 38 | 
            +
              def edit
         | 
| 39 | 
            +
                @page = Page.find(params[:id])
         | 
| 40 | 
            +
              end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
              # POST /pages
         | 
| 43 | 
            +
              # POST /pages.xml
         | 
| 44 | 
            +
              def create
         | 
| 45 | 
            +
                @page = Page.new(params[:page])
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                respond_to do |format|
         | 
| 48 | 
            +
                  if @page.save
         | 
| 49 | 
            +
                    format.html { redirect_to(@page, :notice => 'Page was successfully created.') }
         | 
| 50 | 
            +
                    format.xml  { render :xml => @page, :status => :created, :location => @page }
         | 
| 51 | 
            +
                  else
         | 
| 52 | 
            +
                    format.html { render :action => "new" }
         | 
| 53 | 
            +
                    format.xml  { render :xml => @page.errors, :status => :unprocessable_entity }
         | 
| 54 | 
            +
                  end
         | 
| 55 | 
            +
                end
         | 
| 56 | 
            +
              end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
              # PUT /pages/1
         | 
| 59 | 
            +
              # PUT /pages/1.xml
         | 
| 60 | 
            +
              def update
         | 
| 61 | 
            +
                @page = Page.find(params[:id])
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                respond_to do |format|
         | 
| 64 | 
            +
                  if @page.update_attributes(params[:page])
         | 
| 65 | 
            +
                    format.html { redirect_to(@page, :notice => 'Page was successfully updated.') }
         | 
| 66 | 
            +
                    format.xml  { head :ok }
         | 
| 67 | 
            +
                  else
         | 
| 68 | 
            +
                    format.html { render :action => "edit" }
         | 
| 69 | 
            +
                    format.xml  { render :xml => @page.errors, :status => :unprocessable_entity }
         | 
| 70 | 
            +
                  end
         | 
| 71 | 
            +
                end
         | 
| 72 | 
            +
              end
         | 
| 73 | 
            +
             | 
| 74 | 
            +
              # DELETE /pages/1
         | 
| 75 | 
            +
              # DELETE /pages/1.xml
         | 
| 76 | 
            +
              def destroy
         | 
| 77 | 
            +
                @page = Page.find(params[:id])
         | 
| 78 | 
            +
                @page.destroy
         | 
| 79 | 
            +
             | 
| 80 | 
            +
                respond_to do |format|
         | 
| 81 | 
            +
                  format.html { redirect_to(pages_url) }
         | 
| 82 | 
            +
                  format.xml  { head :ok }
         | 
| 83 | 
            +
                end
         | 
| 84 | 
            +
              end
         | 
| 85 | 
            +
            end
         | 
| @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            <%= form_for(@page) do |f| %>
         | 
| 2 | 
            +
              <% if @page.errors.any? %>
         | 
| 3 | 
            +
                <div id="error_explanation">
         | 
| 4 | 
            +
                  <h2><%= pluralize(@page.errors.count, "error") %> prohibited this page from being saved:</h2>
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                  <ul>
         | 
| 7 | 
            +
                  <% @page.errors.full_messages.each do |msg| %>
         | 
| 8 | 
            +
                    <li><%= msg %></li>
         | 
| 9 | 
            +
                  <% end %>
         | 
| 10 | 
            +
                  </ul>
         | 
| 11 | 
            +
                </div>
         | 
| 12 | 
            +
              <% end %>
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              <div class="field">
         | 
| 15 | 
            +
                <%= f.label :title %><br />
         | 
| 16 | 
            +
                <%= f.text_field :title %>
         | 
| 17 | 
            +
              </div>
         | 
| 18 | 
            +
              <div class="field">
         | 
| 19 | 
            +
                <%= f.label :body %><br />
         | 
| 20 | 
            +
                <%= f.text_area :body %>
         | 
| 21 | 
            +
              </div>
         | 
| 22 | 
            +
              <div class="actions">
         | 
| 23 | 
            +
                <%= f.submit %>
         | 
| 24 | 
            +
              </div>
         | 
| 25 | 
            +
            <% end %>
         | 
| @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            <h1>Listing pages</h1>
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            <table>
         | 
| 4 | 
            +
              <tr>
         | 
| 5 | 
            +
                <th>Title</th>
         | 
| 6 | 
            +
                <th>Body</th>
         | 
| 7 | 
            +
                <th>Impression Count</th>
         | 
| 8 | 
            +
                <th></th>
         | 
| 9 | 
            +
                <th></th>
         | 
| 10 | 
            +
                <th></th>
         | 
| 11 | 
            +
              </tr>
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            <% @pages.each do |page| %>
         | 
| 14 | 
            +
              <tr>
         | 
| 15 | 
            +
                <td><%= page.title %></td>
         | 
| 16 | 
            +
                <td><%= page.body %></td>
         | 
| 17 | 
            +
                <td><%= page.impression_count %></td>
         | 
| 18 | 
            +
                <td><%= link_to 'Show', page %></td>
         | 
| 19 | 
            +
                <td><%= link_to 'Edit', edit_page_path(page) %></td>
         | 
| 20 | 
            +
                <td><%= link_to 'Destroy', page, :confirm => 'Are you sure?', :method => :delete %></td>
         | 
| 21 | 
            +
              </tr>
         | 
| 22 | 
            +
            <% end %>
         | 
| 23 | 
            +
            </table>
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            <br />
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            <%= link_to 'New Page', new_page_path %>
         | 
| @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            class CreateImpressions < ActiveRecord::Migration
         | 
| 2 | 
            +
              def self.up
         | 
| 3 | 
            +
                create_table :impressions, :force => true do |t|
         | 
| 4 | 
            +
                  t.string :impressionable_type
         | 
| 5 | 
            +
                  t.integer :impressionable_id
         | 
| 6 | 
            +
                  t.string :session_hash
         | 
| 7 | 
            +
                  t.string :request_hash
         | 
| 8 | 
            +
                  t.string :referrer
         | 
| 9 | 
            +
                  t.string :ip_address
         | 
| 10 | 
            +
                  t.integer :user_id
         | 
| 11 | 
            +
                  t.timestamps
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              def self.down
         | 
| 16 | 
            +
                drop_table :impressions
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
            end
         | 
| @@ -0,0 +1,34 @@ | |
| 1 | 
            +
            # This file is auto-generated from the current state of the database. Instead
         | 
| 2 | 
            +
            # of editing this file, please use the migrations feature of Active Record to
         | 
| 3 | 
            +
            # incrementally modify your database, and then regenerate this schema definition.
         | 
| 4 | 
            +
            #
         | 
| 5 | 
            +
            # Note that this schema.rb definition is the authoritative source for your
         | 
| 6 | 
            +
            # database schema. If you need to create the application database on another
         | 
| 7 | 
            +
            # system, you should be using db:schema:load, not running all the migrations
         | 
| 8 | 
            +
            # from scratch. The latter is a flawed and unsustainable approach (the more migrations
         | 
| 9 | 
            +
            # you'll amass, the slower it'll run and the greater likelihood for issues).
         | 
| 10 | 
            +
            #
         | 
| 11 | 
            +
            # It's strongly recommended to check this file into your version control system.
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            ActiveRecord::Schema.define(:version => 20110701044058) do
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              create_table "impressions", :force => true do |t|
         | 
| 16 | 
            +
                t.string   "impressionable_type"
         | 
| 17 | 
            +
                t.integer  "impressionable_id"
         | 
| 18 | 
            +
                t.string   "session_hash"
         | 
| 19 | 
            +
                t.string   "request_hash"
         | 
| 20 | 
            +
                t.string   "referrer"
         | 
| 21 | 
            +
                t.string   "ip_address"
         | 
| 22 | 
            +
                t.integer  "user_id"
         | 
| 23 | 
            +
                t.datetime "created_at"
         | 
| 24 | 
            +
                t.datetime "updated_at"
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
              create_table "pages", :force => true do |t|
         | 
| 28 | 
            +
                t.string   "title"
         | 
| 29 | 
            +
                t.text     "body"
         | 
| 30 | 
            +
                t.datetime "created_at"
         | 
| 31 | 
            +
                t.datetime "updated_at"
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            end
         | 
| @@ -0,0 +1,56 @@ | |
| 1 | 
            +
            body { background-color: #fff; color: #333; }
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            body, p, ol, ul, td {
         | 
| 4 | 
            +
              font-family: verdana, arial, helvetica, sans-serif;
         | 
| 5 | 
            +
              font-size:   13px;
         | 
| 6 | 
            +
              line-height: 18px;
         | 
| 7 | 
            +
            }
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            pre {
         | 
| 10 | 
            +
              background-color: #eee;
         | 
| 11 | 
            +
              padding: 10px;
         | 
| 12 | 
            +
              font-size: 11px;
         | 
| 13 | 
            +
            }
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            a { color: #000; }
         | 
| 16 | 
            +
            a:visited { color: #666; }
         | 
| 17 | 
            +
            a:hover { color: #fff; background-color:#000; }
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            div.field, div.actions {
         | 
| 20 | 
            +
              margin-bottom: 10px;
         | 
| 21 | 
            +
            }
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            #notice {
         | 
| 24 | 
            +
              color: green;
         | 
| 25 | 
            +
            }
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            .field_with_errors {
         | 
| 28 | 
            +
              padding: 2px;
         | 
| 29 | 
            +
              background-color: red;
         | 
| 30 | 
            +
              display: table;
         | 
| 31 | 
            +
            }
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            #error_explanation {
         | 
| 34 | 
            +
              width: 450px;
         | 
| 35 | 
            +
              border: 2px solid red;
         | 
| 36 | 
            +
              padding: 7px;
         | 
| 37 | 
            +
              padding-bottom: 0;
         | 
| 38 | 
            +
              margin-bottom: 20px;
         | 
| 39 | 
            +
              background-color: #f0f0f0;
         | 
| 40 | 
            +
            }
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            #error_explanation h2 {
         | 
| 43 | 
            +
              text-align: left;
         | 
| 44 | 
            +
              font-weight: bold;
         | 
| 45 | 
            +
              padding: 5px 5px 5px 15px;
         | 
| 46 | 
            +
              font-size: 12px;
         | 
| 47 | 
            +
              margin: -7px;
         | 
| 48 | 
            +
              margin-bottom: 0px;
         | 
| 49 | 
            +
              background-color: #c00;
         | 
| 50 | 
            +
              color: #fff;
         | 
| 51 | 
            +
            }
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            #error_explanation ul li {
         | 
| 54 | 
            +
              font-size: 12px;
         | 
| 55 | 
            +
              list-style: square;
         | 
| 56 | 
            +
            }
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            require 'test_helper'
         | 
| 2 | 
            +
             
         | 
| 3 | 
            +
            class ImpressionizerGeneratorTest < ActiveSupport::TestCase
         | 
| 4 | 
            +
             
         | 
| 5 | 
            +
              def setup
         | 
| 6 | 
            +
                FileUtils.mkdir_p(fake_rails_root)
         | 
| 7 | 
            +
                @original_files = file_list
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             
         | 
| 10 | 
            +
              def teardown
         | 
| 11 | 
            +
                FileUtils.rm_r(fake_rails_root)
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             
         | 
| 14 | 
            +
              test 'generates_correct_file_name' do
         | 
| 15 | 
            +
                # TODO: make it run!
         | 
| 16 | 
            +
                #
         | 
| 17 | 
            +
                # run_generator(["impressionizer"], :destination => fake_rails_root)
         | 
| 18 | 
            +
                # new_file = (file_list - @original_files).first
         | 
| 19 | 
            +
                # assert_equal "definition.txt", File.basename(new_file)
         | 
| 20 | 
            +
                assert true
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             
         | 
| 23 | 
            +
              private
         | 
| 24 | 
            +
             
         | 
| 25 | 
            +
              def fake_rails_root
         | 
| 26 | 
            +
                File.join(File.dirname(__FILE__), 'rails_root')
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              def file_list
         | 
| 30 | 
            +
                Dir.glob(File.join(fake_rails_root, "*"))
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
             
         | 
| 33 | 
            +
            end
         | 
| @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            require "test_helper"
         | 
| 2 | 
            +
             
         | 
| 3 | 
            +
            class RoutingTest < ActiveSupport::TestCase
         | 
| 4 | 
            +
             
         | 
| 5 | 
            +
              def setup
         | 
| 6 | 
            +
                Rails.application.routes.draw do
         | 
| 7 | 
            +
                  match '/impressions' => 'impressionizer/impressions#index', :as => :impressionizer
         | 
| 8 | 
            +
                end
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
             
         | 
| 11 | 
            +
              test 'impressions route' do
         | 
| 12 | 
            +
                assert_recognition :get, "/impressions", :controller => "impressionizer/impressions", :action => "index"
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             
         | 
| 15 | 
            +
              private
         | 
| 16 | 
            +
             
         | 
| 17 | 
            +
              def assert_recognition(method, path, options)
         | 
| 18 | 
            +
                result = Rails.application.routes.recognize_path(path, :method => method)
         | 
| 19 | 
            +
                assert_equal options, result
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
            end
         | 
| @@ -0,0 +1,17 @@ | |
| 1 | 
            +
            require 'test_helper'
         | 
| 2 | 
            +
             
         | 
| 3 | 
            +
            class PageTest < ActiveSupport::TestCase
         | 
| 4 | 
            +
              test "truth" do
         | 
| 5 | 
            +
                assert true
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
              
         | 
| 8 | 
            +
              test "test_page_should_be_impressionable" do
         | 
| 9 | 
            +
                page = Page.new
         | 
| 10 | 
            +
                assert page.impressionable?
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
              
         | 
| 13 | 
            +
              test "test_page_should_have_impression_count" do
         | 
| 14 | 
            +
                page = Page.new
         | 
| 15 | 
            +
                assert page.impression_count
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -2,7 +2,7 @@ | |
| 2 2 | 
             
            name: impressionizer
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 4 | 
             
              prerelease: 
         | 
| 5 | 
            -
              version: 0.0. | 
| 5 | 
            +
              version: 0.0.2
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors: 
         | 
| 8 8 | 
             
            - Patrick Bartels
         | 
| @@ -21,7 +21,7 @@ dependencies: | |
| 21 21 | 
             
                requirements: 
         | 
| 22 22 | 
             
                - - ~>
         | 
| 23 23 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 24 | 
            -
                    version: 3.0. | 
| 24 | 
            +
                    version: 3.0.0
         | 
| 25 25 | 
             
              type: :runtime
         | 
| 26 26 | 
             
              version_requirements: *id001
         | 
| 27 27 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -32,10 +32,10 @@ dependencies: | |
| 32 32 | 
             
                requirements: 
         | 
| 33 33 | 
             
                - - ~>
         | 
| 34 34 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 35 | 
            -
                    version: 3.0. | 
| 35 | 
            +
                    version: 3.0.0
         | 
| 36 36 | 
             
              type: :runtime
         | 
| 37 37 | 
             
              version_requirements: *id002
         | 
| 38 | 
            -
            description:  | 
| 38 | 
            +
            description: Impressionizer description.
         | 
| 39 39 | 
             
            email: patrick@bartels.ug
         | 
| 40 40 | 
             
            executables: []
         | 
| 41 41 |  | 
| @@ -49,12 +49,30 @@ files: | |
| 49 49 | 
             
            - MIT-LICENSE
         | 
| 50 50 | 
             
            - README.rdoc
         | 
| 51 51 | 
             
            - Rakefile
         | 
| 52 | 
            +
            - app/controllers/impressionizer/impressions_controller.rb
         | 
| 53 | 
            +
            - app/models/impressionizer/impression.rb
         | 
| 54 | 
            +
            - app/models/impressionizer/impressionable.rb
         | 
| 55 | 
            +
            - app/views/impressionizer/impressions/index.html.erb
         | 
| 56 | 
            +
            - config/routes.rb
         | 
| 52 57 | 
             
            - impressionizer.gemspec
         | 
| 58 | 
            +
            - lib/generators/impressionizer/impressionizer_generator.rb
         | 
| 59 | 
            +
            - lib/generators/impressionizer/templates/migration.rb
         | 
| 53 60 | 
             
            - lib/impressionizer.rb
         | 
| 61 | 
            +
            - lib/impressionizer/engine.rb
         | 
| 62 | 
            +
            - lib/impressionizer/version.rb
         | 
| 63 | 
            +
            - test/dummy/Gemfile
         | 
| 54 64 | 
             
            - test/dummy/Rakefile
         | 
| 55 65 | 
             
            - test/dummy/app/controllers/application_controller.rb
         | 
| 66 | 
            +
            - test/dummy/app/controllers/pages_controller.rb
         | 
| 56 67 | 
             
            - test/dummy/app/helpers/application_helper.rb
         | 
| 68 | 
            +
            - test/dummy/app/helpers/pages_helper.rb
         | 
| 69 | 
            +
            - test/dummy/app/models/page.rb
         | 
| 57 70 | 
             
            - test/dummy/app/views/layouts/application.html.erb
         | 
| 71 | 
            +
            - test/dummy/app/views/pages/_form.html.erb
         | 
| 72 | 
            +
            - test/dummy/app/views/pages/edit.html.erb
         | 
| 73 | 
            +
            - test/dummy/app/views/pages/index.html.erb
         | 
| 74 | 
            +
            - test/dummy/app/views/pages/new.html.erb
         | 
| 75 | 
            +
            - test/dummy/app/views/pages/show.html.erb
         | 
| 58 76 | 
             
            - test/dummy/config.ru
         | 
| 59 77 | 
             
            - test/dummy/config/application.rb
         | 
| 60 78 | 
             
            - test/dummy/config/boot.rb
         | 
| @@ -70,6 +88,9 @@ files: | |
| 70 88 | 
             
            - test/dummy/config/initializers/session_store.rb
         | 
| 71 89 | 
             
            - test/dummy/config/locales/en.yml
         | 
| 72 90 | 
             
            - test/dummy/config/routes.rb
         | 
| 91 | 
            +
            - test/dummy/db/migrate/20110701011920_create_pages.rb
         | 
| 92 | 
            +
            - test/dummy/db/migrate/20110701044058_create_impressions.rb
         | 
| 93 | 
            +
            - test/dummy/db/schema.rb
         | 
| 73 94 | 
             
            - test/dummy/public/404.html
         | 
| 74 95 | 
             
            - test/dummy/public/422.html
         | 
| 75 96 | 
             
            - test/dummy/public/500.html
         | 
| @@ -81,11 +102,16 @@ files: | |
| 81 102 | 
             
            - test/dummy/public/javascripts/prototype.js
         | 
| 82 103 | 
             
            - test/dummy/public/javascripts/rails.js
         | 
| 83 104 | 
             
            - test/dummy/public/stylesheets/.gitkeep
         | 
| 105 | 
            +
            - test/dummy/public/stylesheets/scaffold.css
         | 
| 84 106 | 
             
            - test/dummy/script/rails
         | 
| 107 | 
            +
            - test/generators/impressionizer_generator_test.rb
         | 
| 85 108 | 
             
            - test/impressionizer_test.rb
         | 
| 86 109 | 
             
            - test/integration/navigation_test.rb
         | 
| 110 | 
            +
            - test/routing_test.rb
         | 
| 87 111 | 
             
            - test/support/integration_case.rb
         | 
| 88 112 | 
             
            - test/test_helper.rb
         | 
| 113 | 
            +
            - test/unit/impressionable_test.rb
         | 
| 114 | 
            +
            - test/unit/page_test.rb
         | 
| 89 115 | 
             
            has_rdoc: true
         | 
| 90 116 | 
             
            homepage: http://bartels.ug
         | 
| 91 117 | 
             
            licenses: []
         | 
| @@ -113,12 +139,21 @@ rubyforge_project: | |
| 113 139 | 
             
            rubygems_version: 1.5.0
         | 
| 114 140 | 
             
            signing_key: 
         | 
| 115 141 | 
             
            specification_version: 3
         | 
| 116 | 
            -
            summary:  | 
| 142 | 
            +
            summary: Impressionizer summary.
         | 
| 117 143 | 
             
            test_files: 
         | 
| 144 | 
            +
            - test/dummy/Gemfile
         | 
| 118 145 | 
             
            - test/dummy/Rakefile
         | 
| 119 146 | 
             
            - test/dummy/app/controllers/application_controller.rb
         | 
| 147 | 
            +
            - test/dummy/app/controllers/pages_controller.rb
         | 
| 120 148 | 
             
            - test/dummy/app/helpers/application_helper.rb
         | 
| 149 | 
            +
            - test/dummy/app/helpers/pages_helper.rb
         | 
| 150 | 
            +
            - test/dummy/app/models/page.rb
         | 
| 121 151 | 
             
            - test/dummy/app/views/layouts/application.html.erb
         | 
| 152 | 
            +
            - test/dummy/app/views/pages/_form.html.erb
         | 
| 153 | 
            +
            - test/dummy/app/views/pages/edit.html.erb
         | 
| 154 | 
            +
            - test/dummy/app/views/pages/index.html.erb
         | 
| 155 | 
            +
            - test/dummy/app/views/pages/new.html.erb
         | 
| 156 | 
            +
            - test/dummy/app/views/pages/show.html.erb
         | 
| 122 157 | 
             
            - test/dummy/config.ru
         | 
| 123 158 | 
             
            - test/dummy/config/application.rb
         | 
| 124 159 | 
             
            - test/dummy/config/boot.rb
         | 
| @@ -134,6 +169,9 @@ test_files: | |
| 134 169 | 
             
            - test/dummy/config/initializers/session_store.rb
         | 
| 135 170 | 
             
            - test/dummy/config/locales/en.yml
         | 
| 136 171 | 
             
            - test/dummy/config/routes.rb
         | 
| 172 | 
            +
            - test/dummy/db/migrate/20110701011920_create_pages.rb
         | 
| 173 | 
            +
            - test/dummy/db/migrate/20110701044058_create_impressions.rb
         | 
| 174 | 
            +
            - test/dummy/db/schema.rb
         | 
| 137 175 | 
             
            - test/dummy/public/404.html
         | 
| 138 176 | 
             
            - test/dummy/public/422.html
         | 
| 139 177 | 
             
            - test/dummy/public/500.html
         | 
| @@ -145,8 +183,13 @@ test_files: | |
| 145 183 | 
             
            - test/dummy/public/javascripts/prototype.js
         | 
| 146 184 | 
             
            - test/dummy/public/javascripts/rails.js
         | 
| 147 185 | 
             
            - test/dummy/public/stylesheets/.gitkeep
         | 
| 186 | 
            +
            - test/dummy/public/stylesheets/scaffold.css
         | 
| 148 187 | 
             
            - test/dummy/script/rails
         | 
| 188 | 
            +
            - test/generators/impressionizer_generator_test.rb
         | 
| 149 189 | 
             
            - test/impressionizer_test.rb
         | 
| 150 190 | 
             
            - test/integration/navigation_test.rb
         | 
| 191 | 
            +
            - test/routing_test.rb
         | 
| 151 192 | 
             
            - test/support/integration_case.rb
         | 
| 152 193 | 
             
            - test/test_helper.rb
         | 
| 194 | 
            +
            - test/unit/impressionable_test.rb
         | 
| 195 | 
            +
            - test/unit/page_test.rb
         |