Cleanup trailing whitespace
Trailing whitespace isn't friendly to git or vim users.
This commit is contained in:
parent
9db9a8e9a6
commit
1174647779
|
@ -16,4 +16,4 @@
|
|||
* @widget.unique_impression_count now uses request_hash. This was incorrectly stated in the README, since it was using ip_address. The README is correct as a result of the method change.
|
||||
|
||||
== 0.2.4 (2011-02-17)
|
||||
* Fix issue #1 - action_name and controller_name were not being logged for impressionist method inside action
|
||||
* Fix issue #1 - action_name and controller_name were not being logged for impressionist method inside action
|
||||
|
|
|
@ -39,22 +39,22 @@ module ImpressionistController
|
|||
end
|
||||
|
||||
private
|
||||
|
||||
|
||||
def bypass
|
||||
Impressionist::Bots::WILD_CARDS.each do |wild_card|
|
||||
return true if request.user_agent and request.user_agent.downcase.include? wild_card
|
||||
end
|
||||
Impressionist::Bots::LIST.include? request.user_agent
|
||||
end
|
||||
|
||||
|
||||
def unique_instance?(impressionable, unique_opts)
|
||||
return unique_opts.blank? || !impressionable.impressions.where(unique_query(unique_opts)).exists?
|
||||
end
|
||||
|
||||
|
||||
def unique?(unique_opts)
|
||||
return unique_opts.blank? || !Impression.where(unique_query(unique_opts)).exists?
|
||||
end
|
||||
|
||||
|
||||
# creates the query to check for uniqueness
|
||||
def unique_query(unique_opts)
|
||||
full_statement = direct_create_statement
|
||||
|
@ -64,7 +64,7 @@ module ImpressionistController
|
|||
query
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# creates a statment hash that contains default values for creating an impression via an AR relation.
|
||||
def associative_create_statement(query_params={})
|
||||
query_params.reverse_merge!(
|
||||
|
@ -77,7 +77,7 @@ module ImpressionistController
|
|||
:referrer => request.referer
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
# creates a statment hash that contains default values for creating an impression.
|
||||
def direct_create_statement(query_params={})
|
||||
query_params.reverse_merge!(
|
||||
|
@ -86,7 +86,7 @@ module ImpressionistController
|
|||
)
|
||||
associative_create_statement(query_params)
|
||||
end
|
||||
|
||||
|
||||
def session_hash
|
||||
# # careful: request.session_options[:id] encoding in rspec test was ASCII-8BIT
|
||||
# # that broke the database query for uniqueness. not sure if this is a testing only issue.
|
||||
|
@ -95,7 +95,7 @@ module ImpressionistController
|
|||
# # request.session_options[:id].encode("ISO-8859-1")
|
||||
request.session_options[:id]
|
||||
end
|
||||
|
||||
|
||||
#use both @current_user and current_user helper
|
||||
def user_id
|
||||
user_id = @current_user ? @current_user.id : nil rescue nil
|
||||
|
@ -103,4 +103,4 @@ module ImpressionistController
|
|||
user_id
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,4 +13,4 @@ class Impression < ActiveRecord::Base
|
|||
resouce.try(:update_counter_cache)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
module Impressionist
|
||||
module Bots
|
||||
WILD_CARDS = ["bot","yahoo","slurp","google","msn","crawler"]
|
||||
|
||||
LIST = ["<a href='http://www.unchaos.com/'> UnChaos </a> From Chaos To Order Hybrid Web Search Engine.(vadim_gonchar@unchaos.com)",
|
||||
|
||||
LIST = ["<a href='http://www.unchaos.com/'> UnChaos </a> From Chaos To Order Hybrid Web Search Engine.(vadim_gonchar@unchaos.com)",
|
||||
"<a href='http://www.unchaos.com/'> UnChaos Bot Hybrid Web Search Engine. </a> (vadim_gonchar@unchaos.com)",
|
||||
"<b> UnChaosBot From Chaos To Order UnChaos Hybrid Web Search Engine at www.unchaos.com </b> (info@unchaos.com)",
|
||||
"<http://www.sygol.com/> http://www.sygol.com",
|
||||
|
@ -1459,4 +1459,4 @@ module Impressionist
|
|||
"zspider/0.9-dev http://feedback.redkolibri.com/",
|
||||
"ZyBorg/1.0 (ZyBorg@WISEnut.com; http://www.WISEnut.com)"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
Rails.application.routes.draw do
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'rails/generators'
|
||||
require 'rails/generators/migration'
|
||||
require 'rails/generators/migration'
|
||||
|
||||
class ImpressionistGenerator < Rails::Generators::Base
|
||||
include Rails::Generators::Migration
|
||||
|
@ -17,4 +17,4 @@ class ImpressionistGenerator < Rails::Generators::Base
|
|||
def create_migration_file
|
||||
migration_template 'create_impressions_table.rb', 'db/migrate/create_impressions_table.rb'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -34,4 +34,4 @@ class CreateImpressionsTable < ActiveRecord::Migration
|
|||
|
||||
drop_table :impressions
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,4 +15,4 @@ module Impressionist
|
|||
list
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,4 +14,4 @@ module Impressionist
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery
|
||||
before_filter :secondary_before_filter
|
||||
|
||||
|
||||
def secondary_before_filter
|
||||
@test_secondary_before_filter = "this is a test"
|
||||
end
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
class ArticlesController < ApplicationController
|
||||
before_filter :test_current_user_var
|
||||
|
||||
|
||||
def test_current_user_var
|
||||
if session[:user_id]
|
||||
@current_user = User.new
|
||||
@current_user.id = session[:user_id]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def index
|
||||
impressionist(Article.first,"this is a test article impression")
|
||||
end
|
||||
|
||||
|
||||
def show
|
||||
impressionist(Article.first)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,17 +2,17 @@ class PostsController < ApplicationController
|
|||
helper_method :current_user
|
||||
impressionist
|
||||
def index
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def show
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def edit
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def current_user
|
||||
if session[:user_id]
|
||||
user = User.new
|
||||
|
@ -20,4 +20,4 @@ class PostsController < ApplicationController
|
|||
@current_user ||= user
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
class WidgetsController < ApplicationController
|
||||
impressionist :actions=>[:show,:index], :unique => [:controller_name,:action_name,:impressionable_id]
|
||||
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
class Dummy < ActiveRecord::Base
|
||||
self.abstract_class = true # doesn't need to be backed by an actual table
|
||||
is_impressionable
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
class User
|
||||
attr_accessor :id
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1 +1 @@
|
|||
<%=@impressionist_hash==nil%>
|
||||
<%=@impressionist_hash==nil%>
|
||||
|
|
|
@ -1 +1 @@
|
|||
<%=link_to "Same Page", article_url(Article.first)%>
|
||||
<%=link_to "Same Page", article_url(Article.first)%>
|
||||
|
|
|
@ -16,7 +16,7 @@ test: &test
|
|||
# adapter: postgresql
|
||||
# database: impressionist_test
|
||||
# username: johnmcaliley
|
||||
# password:
|
||||
# password:
|
||||
# host: localhost
|
||||
# encoding: UTF8
|
||||
|
||||
|
@ -27,4 +27,4 @@ production:
|
|||
timeout: 5000
|
||||
|
||||
cucumber:
|
||||
<<: *test
|
||||
<<: *test
|
||||
|
|
|
@ -16,22 +16,22 @@ class CreateImpressionsTable < ActiveRecord::Migration
|
|||
end
|
||||
add_index :impressions, [:impressionable_type, :impressionable_id, :request_hash], :name => "poly_request_index", :unique => false
|
||||
add_index :impressions, [:impressionable_type, :impressionable_id, :ip_address], :name => "poly_ip_index", :unique => false
|
||||
add_index :impressions, [:impressionable_type, :impressionable_id, :session_hash], :name => "poly_session_index", :unique => false
|
||||
add_index :impressions, [:impressionable_type, :impressionable_id, :session_hash], :name => "poly_session_index", :unique => false
|
||||
add_index :impressions, [:controller_name,:action_name,:request_hash], :name => "controlleraction_request_index", :unique => false
|
||||
add_index :impressions, [:controller_name,:action_name,:ip_address], :name => "controlleraction_ip_index", :unique => false
|
||||
add_index :impressions, [:controller_name,:action_name,:session_hash], :name => "controlleraction_session_index", :unique => false
|
||||
add_index :impressions, [:controller_name,:action_name,:session_hash], :name => "controlleraction_session_index", :unique => false
|
||||
add_index :impressions, :user_id
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_index :impressions, :name => :poly_request_index
|
||||
remove_index :impressions, :name => :poly_ip_index
|
||||
remove_index :impressions, :name => :poly_session_index
|
||||
remove_index :impressions, :name => :poly_session_index
|
||||
remove_index :impressions, :name => :controlleraction_request_index
|
||||
remove_index :impressions, :name => :controlleraction_ip_index
|
||||
remove_index :impressions, :name => :controlleraction_session_index
|
||||
remove_index :impressions, :name => :controlleraction_session_index
|
||||
remove_index :impressions, :user_id
|
||||
|
||||
|
||||
drop_table :impressions
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
||||
# It is recommended to regenerate this file in the future when you upgrade to a
|
||||
# newer version of cucumber-rails. Consider adding your own code to a new file
|
||||
# It is recommended to regenerate this file in the future when you upgrade to a
|
||||
# newer version of cucumber-rails. Consider adding your own code to a new file
|
||||
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
||||
# files.
|
||||
|
||||
|
|
|
@ -962,4 +962,4 @@ Form.Element.DelayedObserver = Class.create({
|
|||
this.timer = null;
|
||||
this.callback(this.element, $F(this.element));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -971,4 +971,4 @@ Element.findChildren = function(element, only, recursive, tagName) {
|
|||
|
||||
Element.offsetSize = function (element, type) {
|
||||
return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')];
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1120,4 +1120,4 @@ $w('getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTex
|
|||
function(f) { Effect.Methods[f] = Element[f]; }
|
||||
);
|
||||
|
||||
Element.addMethods(Effect.Methods);
|
||||
Element.addMethods(Effect.Methods);
|
||||
|
|
|
@ -95,9 +95,9 @@ describe WidgetsController do
|
|||
get "show", :id=> 1
|
||||
Impression.all.size.should eq 11
|
||||
end
|
||||
|
||||
|
||||
describe "impressionist unique options" do
|
||||
|
||||
|
||||
it "should log unique impressions at the per action level" do
|
||||
get "show", :id=> 1
|
||||
Impression.all.size.should eq 12
|
||||
|
@ -108,7 +108,7 @@ describe WidgetsController do
|
|||
get "index"
|
||||
Impression.all.size.should eq 14
|
||||
end
|
||||
|
||||
|
||||
it "should log unique impressions only once per id" do
|
||||
get "show", :id=> 1
|
||||
Impression.all.size.should eq 12
|
||||
|
@ -119,7 +119,7 @@ describe WidgetsController do
|
|||
get "index"
|
||||
Impression.all.size.should eq 14
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
one:
|
||||
id: 1
|
||||
name: Test Article
|
||||
name: Test Article
|
||||
|
|
|
@ -16,7 +16,7 @@ impression8:
|
|||
session_hash: b1
|
||||
ip_address: 127.0.0.1
|
||||
created_at: 2010-01-01
|
||||
|
||||
|
||||
impression9:
|
||||
impressionable_type: Article
|
||||
impressionable_id: 1
|
||||
|
@ -24,20 +24,20 @@ impression9:
|
|||
session_hash: b2
|
||||
ip_address: 127.0.0.1
|
||||
created_at: 2011-01-03
|
||||
|
||||
|
||||
impression10:
|
||||
impressionable_type: Article
|
||||
impressionable_id: 1
|
||||
request_hash: a9
|
||||
session_hash: b3
|
||||
ip_address: 127.0.0.8
|
||||
created_at: 2010-01-01
|
||||
|
||||
created_at: 2010-01-01
|
||||
|
||||
impression11:
|
||||
impressionable_type: Article
|
||||
impressionable_id: 1
|
||||
request_hash: a10
|
||||
session_hash: b4
|
||||
session_hash: b4
|
||||
ip_address: 127.0.0.1
|
||||
created_at: 2010-01-01
|
||||
|
||||
created_at: 2010-01-01
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
one:
|
||||
id: 1
|
||||
name: Test Post
|
||||
name: Test Post
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
one:
|
||||
id: 1
|
||||
name: A Widget
|
||||
impressions_count: 0
|
||||
impressions_count: 0
|
||||
|
|
|
@ -5,14 +5,14 @@ describe Impressionist do
|
|||
method = RUBY_VERSION.match("1.8") ? "is_impressionable" : :is_impressionable
|
||||
ActiveRecord::Base.methods.include?(method).should be true
|
||||
end
|
||||
|
||||
|
||||
it "should include methods in ApplicationController" do
|
||||
method = RUBY_VERSION.match("1.8") ? "impressionist" : :impressionist
|
||||
ApplicationController.instance_methods.include?(method).should be true
|
||||
end
|
||||
|
||||
|
||||
it "should include the before_filter method in ApplicationController" do
|
||||
filters = ApplicationController._process_action_callbacks.select { |c| c.kind == :before }
|
||||
filters.collect{|filter|filter.filter}.include?(:impressionist_app_filter).should be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,4 +27,4 @@ describe Impression do
|
|||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,33 +2,33 @@ require 'spec_helper'
|
|||
|
||||
describe Impression do
|
||||
fixtures :articles,:impressions,:posts
|
||||
|
||||
|
||||
before(:each) do
|
||||
@article = Article.find(1)
|
||||
end
|
||||
|
||||
|
||||
it "should save a blank impression for an Article that has 10 impressions" do
|
||||
@article.impressions.create
|
||||
@article.impressions.size.should eq 12
|
||||
end
|
||||
|
||||
|
||||
it "should save an impression with a message" do
|
||||
@article.impressions.create(:message=>"test message")
|
||||
@article.impressions.last.message.should eq "test message"
|
||||
end
|
||||
|
||||
|
||||
it "should return the impression count for all with no date range specified" do
|
||||
@article.impressionist_count(:filter=>:all).should eq 11
|
||||
end
|
||||
|
||||
|
||||
it "should return unique impression count with no date range specified" do
|
||||
@article.impressionist_count.should eq 9
|
||||
end
|
||||
|
||||
|
||||
it "should return impression count with only start date specified" do
|
||||
@article.impressionist_count(:start_date=>"2011-01-01",:filter=>:all).should eq 8
|
||||
end
|
||||
|
||||
|
||||
it "should return impression count with whole date range specified" do
|
||||
@article.impressionist_count(:start_date=>"2011-01-01",:end_date=>"2011-01-02",:filter=>:all).should eq 7
|
||||
end
|
||||
|
@ -36,11 +36,11 @@ describe Impression do
|
|||
it "should return unique impression count with only start date specified" do
|
||||
@article.impressionist_count(:start_date=>"2011-01-01").should eq 7
|
||||
end
|
||||
|
||||
|
||||
it "should return unique impression count with date range specified" do
|
||||
@article.impressionist_count(:start_date=>"2011-01-01",:end_date=>"2011-01-02").should eq 7
|
||||
end
|
||||
|
||||
|
||||
it "should return unique impression count using ip address (which in turn eliminates duplicate request_hashes)" do
|
||||
@article.impressionist_count(:filter=>:ip_address).should eq 8
|
||||
end
|
||||
|
@ -48,7 +48,7 @@ describe Impression do
|
|||
it "should return unique impression count using session_hash (which in turn eliminates duplicate request_hashes)" do
|
||||
@article.impressionist_count(:filter=>:session_hash).should eq 7
|
||||
end
|
||||
|
||||
|
||||
# tests :dependent => :destroy
|
||||
it "should delete impressions on deletion of impressionable" do
|
||||
impressions_count = Impression.all.size
|
||||
|
@ -58,20 +58,20 @@ describe Impression do
|
|||
a.destroyed?.should be_true
|
||||
i.destroyed?.should be_true
|
||||
end
|
||||
|
||||
|
||||
#OLD COUNT METHODS. DEPRECATE SOON
|
||||
it "should return the impression count with no date range specified" do
|
||||
@article.impression_count.should eq 11
|
||||
end
|
||||
|
||||
|
||||
it "should return unique impression count with no date range specified" do
|
||||
@article.unique_impression_count.should eq 9
|
||||
end
|
||||
|
||||
|
||||
it "should return impression count with only start date specified" do
|
||||
@article.impression_count("2011-01-01").should eq 8
|
||||
end
|
||||
|
||||
|
||||
it "should return impression count with whole date range specified" do
|
||||
@article.impression_count("2011-01-01","2011-01-02").should eq 7
|
||||
end
|
||||
|
@ -79,11 +79,11 @@ describe Impression do
|
|||
it "should return unique impression count with only start date specified" do
|
||||
@article.unique_impression_count("2011-01-01").should eq 7
|
||||
end
|
||||
|
||||
|
||||
it "should return unique impression count with date range specified" do
|
||||
@article.unique_impression_count("2011-01-01","2011-01-02").should eq 7
|
||||
end
|
||||
|
||||
|
||||
it "should return unique impression count using ip address (which in turn eliminates duplicate request_hashes)" do
|
||||
@article.unique_impression_count_ip.should eq 8
|
||||
end
|
||||
|
@ -91,4 +91,4 @@ describe Impression do
|
|||
it "should return unique impression count using session_hash (which in turn eliminates duplicate request_hashes)" do
|
||||
@article.unique_impression_count_session.should eq 7
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,9 +13,9 @@ describe Impressionist do
|
|||
migration_name = generator_output.split("migrate/")[1].strip
|
||||
Dir.entries(migrations_dir).include?(migration_name).should be true
|
||||
end
|
||||
|
||||
|
||||
it "should run the migration created in the previous spec" do
|
||||
migrate_output = systemu("rake db:migrate RAILS_ENV=test")
|
||||
migrate_output[1].include?("CreateImpressionsTable: migrated").should be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,10 +24,10 @@ RSpec.configure do |config|
|
|||
# examples within a transaction, remove the following line or assign false
|
||||
# instead of true.
|
||||
config.use_transactional_fixtures = true
|
||||
|
||||
|
||||
# make the rails logger usable in the tests as logger.xxx "..."
|
||||
def logger
|
||||
Rails.logger
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
@ -5,23 +5,23 @@ class CreateImpressionsTable < ActiveRecord::Migration
|
|||
remove_index :impressions, :name => :controlleraction_index
|
||||
add_index :impressions, [:impressionable_type, :impressionable_id, :request_hash], :name => "poly_request_index", :unique => false
|
||||
add_index :impressions, [:impressionable_type, :impressionable_id, :ip_address], :name => "poly_ip_index", :unique => false
|
||||
add_index :impressions, [:impressionable_type, :impressionable_id, :session_hash], :name => "poly_session_index", :unique => false
|
||||
add_index :impressions, [:impressionable_type, :impressionable_id, :session_hash], :name => "poly_session_index", :unique => false
|
||||
add_index :impressions, [:controller_name,:action_name,:request_hash], :name => "controlleraction_request_index", :unique => false
|
||||
add_index :impressions, [:controller_name,:action_name,:ip_address], :name => "controlleraction_ip_index", :unique => false
|
||||
add_index :impressions, [:controller_name,:action_name,:session_hash], :name => "controlleraction_session_index", :unique => false
|
||||
|
||||
add_index :impressions, [:controller_name,:action_name,:session_hash], :name => "controlleraction_session_index", :unique => false
|
||||
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :impressions, :session_hash
|
||||
remove_index :impressions, :name => :poly_request_index
|
||||
remove_index :impressions, :name => :poly_ip_index
|
||||
remove_index :impressions, :name => :poly_session_index
|
||||
remove_index :impressions, :name => :poly_session_index
|
||||
remove_index :impressions, :name => :controlleraction_request_index
|
||||
remove_index :impressions, :name => :controlleraction_ip_index
|
||||
remove_index :impressions, :name => :controlleraction_session_index
|
||||
remove_index :impressions, :name => :controlleraction_session_index
|
||||
remove_index :impressions, :user_id
|
||||
add_index :impressions, [:impressionable_type, :impressionable_id, :request_hash, :ip_address], :name => "poly_index", :unique => false
|
||||
add_index :impressions, [:controller_name,:action_name,:request_hash,:ip_address], :name => "controlleraction_index", :unique => false
|
||||
add_index :impressions, [:controller_name,:action_name,:request_hash,:ip_address], :name => "controlleraction_index", :unique => false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
class Version04UpdateImpressionsTable < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column :impressions, :referrer, :string
|
||||
add_column :impressions, :referrer, :string
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :impressions, :referrer
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue