forked from tcocca/acts_as_follower
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from aredotna/scouting/rebase-origin-master
Scouting/rebase origin master
- Loading branch information
Showing
47 changed files
with
609 additions
and
334 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
inherit_from: .rubocop_todo.yml | ||
|
||
AllCops: | ||
Exclude: | ||
- 'Gemfile' | ||
- 'acts_as_follower.gemspec' | ||
- 'test/dummy30/**/*' | ||
UseCache: true | ||
SuggestExtensions: false | ||
NewCops: enable | ||
|
||
# | ||
# *** Layout | ||
# | ||
Layout/LineLength: | ||
Max: 120 | ||
|
||
Layout/SpaceBeforeBlockBraces: | ||
EnforcedStyle: space | ||
EnforcedStyleForEmptyBraces: space | ||
|
||
# | ||
# *** Metrics | ||
# | ||
Metrics/AbcSize: | ||
Max: 27 | ||
|
||
Metrics/BlockLength: | ||
Max: 35 | ||
Exclude: | ||
- 'test/**/*' | ||
|
||
Metrics/ClassLength: | ||
Max: 200 | ||
Exclude: | ||
- 'test/**/*' | ||
|
||
Metrics/CyclomaticComplexity: | ||
Max: 8 | ||
|
||
Metrics/MethodLength: | ||
Max: 20 | ||
|
||
Metrics/ModuleLength: | ||
Max: 150 | ||
|
||
Metrics/ParameterLists: | ||
Max: 4 | ||
|
||
Metrics/PerceivedComplexity: | ||
Max: 10 | ||
|
||
# | ||
# *** Naming | ||
# | ||
Naming/VariableNumber: | ||
EnforcedStyle: snake_case | ||
|
||
Naming/MethodParameterName: | ||
Enabled: false | ||
# | ||
# *** Style | ||
# | ||
Style/AsciiComments: | ||
Enabled: false | ||
|
||
Style/ClassAndModuleChildren: | ||
EnforcedStyle: nested | ||
|
||
Style/Documentation: | ||
Enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# This configuration was generated by | ||
# `rubocop --auto-gen-config` | ||
# on 2021-01-21 22:14:46 UTC using RuboCop version 1.8.1. | ||
# The point is for the user to remove these configuration records | ||
# one by one as the offenses are removed from the code base. | ||
# Note that changes in the inspected code, or installation of new | ||
# versions of RuboCop, may require this file to be generated again. | ||
|
||
# Offense count: 2 | ||
Lint/UselessAssignment: | ||
Exclude: | ||
- 'lib/acts_as_follower/follower.rb' | ||
|
||
# Offense count: 2 | ||
# Configuration parameters: MinBodyLength. | ||
Style/GuardClause: | ||
Exclude: | ||
- 'lib/acts_as_follower/follower.rb' | ||
|
||
# Offense count: 3 | ||
Style/MissingRespondToMissing: | ||
Exclude: | ||
- 'lib/acts_as_follower.rb' | ||
- 'lib/acts_as_follower/followable.rb' | ||
- 'lib/acts_as_follower/follower.rb' | ||
|
||
# Offense count: 2 | ||
# Configuration parameters: AllowedMethods. | ||
# AllowedMethods: respond_to_missing? | ||
Style/OptionalBooleanParameter: | ||
Exclude: | ||
- 'lib/acts_as_follower/followable.rb' | ||
- 'lib/acts_as_follower/follower.rb' | ||
|
||
Layout/LineLength: | ||
Exclude: | ||
- 'test/acts_as_follower_test.rb' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'acts_as_follower' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,31 @@ | ||
require "acts_as_follower/version" | ||
# frozen_string_literal: true | ||
|
||
require 'acts_as_follower/version' | ||
|
||
module ActsAsFollower | ||
autoload :Follower, 'acts_as_follower/follower' | ||
autoload :Followable, 'acts_as_follower/followable' | ||
autoload :FollowerLib, 'acts_as_follower/follower_lib' | ||
autoload :FollowScopes, 'acts_as_follower/follow_scopes' | ||
|
||
def self.setup | ||
@configuration ||= Configuration.new | ||
yield @configuration if block_given? | ||
end | ||
|
||
def self.method_missing(method_name, *args, &block) | ||
@configuration.respond_to?(method_name) ? @configuration.send(method_name, *args, &block) : super | ||
end | ||
|
||
class Configuration | ||
attr_accessor :custom_parent_classes | ||
|
||
def initialize | ||
@custom_parent_classes = [] | ||
end | ||
end | ||
|
||
setup | ||
|
||
require 'acts_as_follower/railtie' if defined?(Rails) && Rails::VERSION::MAJOR >= 3 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,45 @@ | ||
# frozen_string_literal: true | ||
|
||
module ActsAsFollower #:nodoc: | ||
module FollowScopes | ||
|
||
# returns Follow records where follower is the record passed in. | ||
def for_follower(follower) | ||
where(:follower_id => follower.id, | ||
:follower_type => parent_class_name(follower)) | ||
where(follower_id: follower.id, follower_type: parent_class_name(follower)) | ||
end | ||
|
||
# returns Follow records where followable is the record passed in. | ||
def for_followable(followable) | ||
where(:followable_id => followable.id, :followable_type => parent_class_name(followable)) | ||
where(followable_id: followable.id, followable_type: parent_class_name(followable)) | ||
end | ||
|
||
# returns Follow records where follower_type is the record passed in. | ||
def for_follower_type(follower_type) | ||
where(:follower_type => follower_type) | ||
where(follower_type: follower_type) | ||
end | ||
|
||
# returns Follow records where followeable_type is the record passed in. | ||
def for_followable_type(followable_type) | ||
where(:followable_type => followable_type) | ||
where(followable_type: followable_type) | ||
end | ||
|
||
# returns Follow records from past 2 weeks with default parameter. | ||
def recent(from) | ||
where(["created_at > ?", (from || 2.weeks.ago).to_s(:db)]) | ||
where(['created_at > ?', (from || 2.weeks.ago).to_s(:db)]) | ||
end | ||
|
||
# returns Follow records in descending order. | ||
def descending | ||
order("follows.created_at DESC") | ||
order('follows.created_at DESC') | ||
end | ||
|
||
# returns unblocked Follow records. | ||
def unblocked | ||
where(:blocked => false) | ||
where(blocked: false) | ||
end | ||
|
||
# returns blocked Follow records. | ||
def blocked | ||
where(:blocked => true) | ||
where(blocked: true) | ||
end | ||
|
||
end | ||
end |
Oops, something went wrong.