interest 0.0.1

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.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +26 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +329 -0
  7. data/Rakefile +2 -0
  8. data/interest.gemspec +29 -0
  9. data/lib/generators/interest_generator.rb +18 -0
  10. data/lib/generators/templates/migrations/blockings.rb +14 -0
  11. data/lib/generators/templates/migrations/followings.rb +15 -0
  12. data/lib/generators/templates/models/blocking.rb +3 -0
  13. data/lib/generators/templates/models/following.rb +4 -0
  14. data/lib/interest.rb +49 -0
  15. data/lib/interest/base.rb +49 -0
  16. data/lib/interest/blockable.rb +25 -0
  17. data/lib/interest/blockable/blockee.rb +40 -0
  18. data/lib/interest/blockable/blocker.rb +69 -0
  19. data/lib/interest/blockable/blocking.rb +48 -0
  20. data/lib/interest/blockable/exceptions.rb +12 -0
  21. data/lib/interest/definition.rb +45 -0
  22. data/lib/interest/exception.rb +10 -0
  23. data/lib/interest/follow_requestable.rb +25 -0
  24. data/lib/interest/follow_requestable/exceptions.rb +12 -0
  25. data/lib/interest/follow_requestable/follow_request.rb +45 -0
  26. data/lib/interest/follow_requestable/follow_requestee.rb +45 -0
  27. data/lib/interest/follow_requestable/follow_requester.rb +92 -0
  28. data/lib/interest/followable.rb +25 -0
  29. data/lib/interest/followable/exceptions.rb +12 -0
  30. data/lib/interest/followable/followee.rb +41 -0
  31. data/lib/interest/followable/follower.rb +68 -0
  32. data/lib/interest/followable/following.rb +62 -0
  33. data/lib/interest/utils.rb +29 -0
  34. data/lib/interest/version.rb +3 -0
  35. data/spec/blockable_spec.rb +127 -0
  36. data/spec/database.yml.example +3 -0
  37. data/spec/follow_requestable_spec.rb +126 -0
  38. data/spec/followable_spec.rb +171 -0
  39. data/spec/models/blocking_spec.rb +42 -0
  40. data/spec/models/following_spec.rb +120 -0
  41. data/spec/spec_helper.rb +103 -0
  42. data/spec/support/database.rb +10 -0
  43. data/spec/support/models/blockable_user.rb +8 -0
  44. data/spec/support/models/blocking.rb +4 -0
  45. data/spec/support/models/collection.rb +6 -0
  46. data/spec/support/models/follow_requestable_and_blockable_user.rb +8 -0
  47. data/spec/support/models/follow_requestable_user.rb +9 -0
  48. data/spec/support/models/followable_and_blockable_user.rb +9 -0
  49. data/spec/support/models/followable_user.rb +8 -0
  50. data/spec/support/models/following.rb +4 -0
  51. data/spec/support/models/stuff.rb +6 -0
  52. data/spec/support/schema.rb +26 -0
  53. metadata +211 -0
@@ -0,0 +1,103 @@
1
+ $:.unshift File.expand_path("../lib", File.dirname(__FILE__))
2
+
3
+ ENV['RAILS_ENV'] ||= 'test'
4
+
5
+ require "rspec/collection_matchers"
6
+ require "active_support/testing/assertions"
7
+ require "interest"
8
+
9
+ load File.expand_path("support/database.rb", File.dirname(__FILE__))
10
+ load File.expand_path("support/schema.rb", File.dirname(__FILE__))
11
+ Dir.glob File.expand_path("support/models/*.rb", File.dirname(__FILE__)), &method(:require)
12
+
13
+ # This file was generated by the `rspec --init` command. Conventionally, all
14
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
15
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
16
+ # file to always be loaded, without a need to explicitly require it in any files.
17
+ #
18
+ # Given that it is always loaded, you are encouraged to keep this file as
19
+ # light-weight as possible. Requiring heavyweight dependencies from this file
20
+ # will add to the boot time of your test suite on EVERY test run, even for an
21
+ # individual file that may not need all of that loaded. Instead, consider making
22
+ # a separate helper file that requires the additional dependencies and performs
23
+ # the additional setup, and require it from the spec files that actually need it.
24
+ #
25
+ # The `.rspec` file also contains a few flags that are not defaults but that
26
+ # users commonly want.
27
+ #
28
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
29
+ RSpec.configure do |config|
30
+ # rspec-expectations config goes here. You can use an alternate
31
+ # assertion/expectation library such as wrong or the stdlib/minitest
32
+ # assertions if you prefer.
33
+ config.expect_with :rspec do |expectations|
34
+ # This option will default to `true` in RSpec 4. It makes the `description`
35
+ # and `failure_message` of custom matchers include text for helper methods
36
+ # defined using `chain`, e.g.:
37
+ # be_bigger_than(2).and_smaller_than(4).description
38
+ # # => "be bigger than 2 and smaller than 4"
39
+ # ...rather than:
40
+ # # => "be bigger than 2"
41
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
42
+ end
43
+
44
+ # rspec-mocks config goes here. You can use an alternate test double
45
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
46
+ config.mock_with :rspec do |mocks|
47
+ # Prevents you from mocking or stubbing a method that does not exist on
48
+ # a real object. This is generally recommended, and will default to
49
+ # `true` in RSpec 4.
50
+ mocks.verify_partial_doubles = true
51
+ end
52
+
53
+ # The settings below are suggested to provide a good initial experience
54
+ # with RSpec, but feel free to customize to your heart's content.
55
+ =begin
56
+ # These two settings work together to allow you to limit a spec run
57
+ # to individual examples or groups you care about by tagging them with
58
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
59
+ # get run.
60
+ config.filter_run :focus
61
+ config.run_all_when_everything_filtered = true
62
+
63
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
64
+ # For more details, see:
65
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
66
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
67
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
68
+ config.disable_monkey_patching!
69
+
70
+ # This setting enables warnings. It's recommended, but in some cases may
71
+ # be too noisy due to issues in dependencies.
72
+ config.warnings = true
73
+
74
+ # Many RSpec users commonly either run the entire suite or an individual
75
+ # file, and it's useful to allow more verbose output when running an
76
+ # individual spec file.
77
+ if config.files_to_run.one?
78
+ # Use the documentation formatter for detailed output,
79
+ # unless a formatter has already been configured
80
+ # (e.g. via a command-line flag).
81
+ config.default_formatter = 'doc'
82
+ end
83
+
84
+ # Print the 10 slowest examples and example groups at the
85
+ # end of the spec run, to help surface which specs are running
86
+ # particularly slow.
87
+ config.profile_examples = 10
88
+
89
+ # Run specs in random order to surface order dependencies. If you find an
90
+ # order dependency and want to debug it, you can fix the order by providing
91
+ # the seed, which is printed after each run.
92
+ # --seed 1234
93
+ config.order = :random
94
+
95
+ # Seed global randomization in this process using the `--seed` CLI option.
96
+ # Setting this allows you to use `--seed` to deterministically reproduce
97
+ # test failures related to randomization by passing the same `--seed` value
98
+ # as the one that triggered the failure.
99
+ Kernel.srand config.seed
100
+ =end
101
+
102
+ config.include ActiveSupport::Testing::Assertions
103
+ end
@@ -0,0 +1,10 @@
1
+ require "active_record"
2
+
3
+ db_name = (ENV["DB"] || "sqlite3").to_sym
4
+ database_yml = File.expand_path("../database.yml", File.dirname(__FILE__))
5
+
6
+ raise "Please create #{database_yml} first to configure your database. Take a look at: #{database_yml}.sample" unless File.exists?(database_yml)
7
+
8
+ ActiveRecord::Base.configurations = YAML.load_file(database_yml)
9
+ ActiveRecord::Base.establish_connection(db_name)
10
+ ActiveRecord::Base.connection
@@ -0,0 +1,8 @@
1
+ require "active_record"
2
+ require "interest"
3
+
4
+ class BlockableUser < ActiveRecord::Base
5
+ self.table_name = :users
6
+
7
+ acts_as_blockable
8
+ end
@@ -0,0 +1,4 @@
1
+ require "active_record"
2
+ require "interest"
3
+
4
+ require File.expand_path("../../../lib/generators/templates/models/blocking", File.dirname(__FILE__))
@@ -0,0 +1,6 @@
1
+ require "active_record"
2
+ require "interest"
3
+
4
+ class Collection < ActiveRecord::Base
5
+ interest
6
+ end
@@ -0,0 +1,8 @@
1
+ require "active_record"
2
+ require "interest"
3
+
4
+ class FollowRequestableAndBlockableUser < ActiveRecord::Base
5
+ self.table_name = :users
6
+
7
+ interest
8
+ end
@@ -0,0 +1,9 @@
1
+ require "active_record"
2
+ require "interest"
3
+
4
+ class FollowRequestableUser < ActiveRecord::Base
5
+ self.table_name = :users
6
+
7
+ acts_as_followable
8
+ acts_as_follow_requestable
9
+ end
@@ -0,0 +1,9 @@
1
+ require "active_record"
2
+ require "interest"
3
+
4
+ class FollowableAndBlockableUser < ActiveRecord::Base
5
+ self.table_name = :users
6
+
7
+ acts_as_followable
8
+ acts_as_blockable
9
+ end
@@ -0,0 +1,8 @@
1
+ require "active_record"
2
+ require "interest"
3
+
4
+ class FollowableUser < ActiveRecord::Base
5
+ self.table_name = :users
6
+
7
+ acts_as_followable
8
+ end
@@ -0,0 +1,4 @@
1
+ require "active_record"
2
+ require "interest"
3
+
4
+ require File.expand_path("../../../lib/generators/templates/models/following", File.dirname(__FILE__))
@@ -0,0 +1,6 @@
1
+ require "active_record"
2
+ require "interest"
3
+
4
+ class Stuff < ActiveRecord::Base
5
+ acts_as_followee
6
+ end
@@ -0,0 +1,26 @@
1
+ require "active_support"
2
+ require "active_support/core_ext/string/inflections"
3
+ require "active_record"
4
+
5
+ ActiveRecord::Schema.define version: 0 do
6
+ create_table "users", force: true do |t|
7
+ t.datetime "created_at"
8
+ t.datetime "updated_at"
9
+ end
10
+
11
+ create_table "stuffs", force: true do |t|
12
+ t.datetime "created_at"
13
+ t.datetime "updated_at"
14
+ end
15
+
16
+ create_table "collections", force: true do |t|
17
+ t.datetime "created_at"
18
+ t.datetime "updated_at"
19
+ end
20
+ end
21
+
22
+ %w(followings blockings).each do |table_name|
23
+ ActiveRecord::Base.connection.drop_table table_name if ActiveRecord::Base.connection.table_exists?(table_name)
24
+ require File.expand_path("../../lib/generators/templates/migrations/#{table_name}", File.dirname(__FILE__))
25
+ "Interest#{table_name.camelize}Migration".constantize.migrate :up
26
+ end
metadata ADDED
@@ -0,0 +1,211 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: interest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - tatat
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activerecord
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sqlite3
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-collection_matchers
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1'
111
+ description: A gem to follow, follow request and block between any ActiveRecord models.
112
+ email:
113
+ - ioiioioloo@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - Gemfile
121
+ - LICENSE.txt
122
+ - README.md
123
+ - Rakefile
124
+ - interest.gemspec
125
+ - lib/generators/interest_generator.rb
126
+ - lib/generators/templates/migrations/blockings.rb
127
+ - lib/generators/templates/migrations/followings.rb
128
+ - lib/generators/templates/models/blocking.rb
129
+ - lib/generators/templates/models/following.rb
130
+ - lib/interest.rb
131
+ - lib/interest/base.rb
132
+ - lib/interest/blockable.rb
133
+ - lib/interest/blockable/blockee.rb
134
+ - lib/interest/blockable/blocker.rb
135
+ - lib/interest/blockable/blocking.rb
136
+ - lib/interest/blockable/exceptions.rb
137
+ - lib/interest/definition.rb
138
+ - lib/interest/exception.rb
139
+ - lib/interest/follow_requestable.rb
140
+ - lib/interest/follow_requestable/exceptions.rb
141
+ - lib/interest/follow_requestable/follow_request.rb
142
+ - lib/interest/follow_requestable/follow_requestee.rb
143
+ - lib/interest/follow_requestable/follow_requester.rb
144
+ - lib/interest/followable.rb
145
+ - lib/interest/followable/exceptions.rb
146
+ - lib/interest/followable/followee.rb
147
+ - lib/interest/followable/follower.rb
148
+ - lib/interest/followable/following.rb
149
+ - lib/interest/utils.rb
150
+ - lib/interest/version.rb
151
+ - spec/blockable_spec.rb
152
+ - spec/database.yml.example
153
+ - spec/follow_requestable_spec.rb
154
+ - spec/followable_spec.rb
155
+ - spec/models/blocking_spec.rb
156
+ - spec/models/following_spec.rb
157
+ - spec/spec_helper.rb
158
+ - spec/support/database.rb
159
+ - spec/support/models/blockable_user.rb
160
+ - spec/support/models/blocking.rb
161
+ - spec/support/models/collection.rb
162
+ - spec/support/models/follow_requestable_and_blockable_user.rb
163
+ - spec/support/models/follow_requestable_user.rb
164
+ - spec/support/models/followable_and_blockable_user.rb
165
+ - spec/support/models/followable_user.rb
166
+ - spec/support/models/following.rb
167
+ - spec/support/models/stuff.rb
168
+ - spec/support/schema.rb
169
+ homepage: https://github.com/conol/interest
170
+ licenses:
171
+ - MIT
172
+ metadata: {}
173
+ post_install_message:
174
+ rdoc_options: []
175
+ require_paths:
176
+ - lib
177
+ required_ruby_version: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ required_rubygems_version: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ requirements: []
188
+ rubyforge_project:
189
+ rubygems_version: 2.2.2
190
+ signing_key:
191
+ specification_version: 4
192
+ summary: Follow, follow request and block with ActiveRecord.
193
+ test_files:
194
+ - spec/blockable_spec.rb
195
+ - spec/database.yml.example
196
+ - spec/follow_requestable_spec.rb
197
+ - spec/followable_spec.rb
198
+ - spec/models/blocking_spec.rb
199
+ - spec/models/following_spec.rb
200
+ - spec/spec_helper.rb
201
+ - spec/support/database.rb
202
+ - spec/support/models/blockable_user.rb
203
+ - spec/support/models/blocking.rb
204
+ - spec/support/models/collection.rb
205
+ - spec/support/models/follow_requestable_and_blockable_user.rb
206
+ - spec/support/models/follow_requestable_user.rb
207
+ - spec/support/models/followable_and_blockable_user.rb
208
+ - spec/support/models/followable_user.rb
209
+ - spec/support/models/following.rb
210
+ - spec/support/models/stuff.rb
211
+ - spec/support/schema.rb