like 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 747351a7296d5e1927d738f5a96b160c15e2c376
4
+ data.tar.gz: 90097bcf0a08a378a37c86ef12ab79d1e51a8f3f
5
+ SHA512:
6
+ metadata.gz: b20bc6c902121ff7e055677fd8b8abde771e6d542fc08fa767e72bdaf6892a7602a7f360772a4f56f864a8e80ca05f782e102e49be76345cd17659b3803d8497
7
+ data.tar.gz: 54012e5f2bee7f2f00669734059eac5d10b3cdd2b18bda50631bdb3645ae385586e7f1fa49b8cfb9ba4d0641bbfa56d11acb26e8771954b216d3d7a7a0c60908
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Inspire9
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Like
2
+
3
+ A simple Rails engine for liking ActiveRecord objects.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'like', '0.0.1'
10
+
11
+ Don't forget to bundle:
12
+
13
+ $ bundle
14
+
15
+ Then, add the migrations to your app and update your database accordingly:
16
+
17
+ $ rake like:install:migrations db:migrate
18
+
19
+ ### Contributing
20
+
21
+ 1. Fork it
22
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
23
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
24
+ 4. Push to the branch (`git push origin my-new-feature`)
25
+ 5. Create new Pull Request
26
+
27
+ ## Licence
28
+
29
+ Copyright (c) 2013, Like is developed and maintained by [Inspire9](http://inspire9.com), and is released under the open MIT Licence.
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,9 @@
1
+ class Like::Like < ActiveRecord::Base
2
+ self.table_name = 'like_likes'
3
+
4
+ belongs_to :liker, polymorphic: true
5
+ belongs_to :likeable, polymorphic: true
6
+
7
+ validates :liker, presence: true
8
+ validates :likeable, presence: true
9
+ end
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ Bundler.require :default, :development
5
+
6
+ Combustion.initialize!
7
+ run Combustion::Application
@@ -0,0 +1,13 @@
1
+ class CreateLikes < ActiveRecord::Migration
2
+ def change
3
+ create_table :like_likes do |t|
4
+ t.string :liker_type, null: false
5
+ t.integer :liker_id, null: false
6
+ t.string :likeable_type, null: false
7
+ t.integer :likeable_id, null: false
8
+ end
9
+
10
+ add_index :like_likes, [:liker_type, :liker_id, :likeable_type,
11
+ :likeable_id], name: :unique_like_likes, unique: true
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ module Like
2
+ def self.link(liker, likeable)
3
+ Like::Like.create liker: liker, likeable: likeable
4
+ end
5
+ end
6
+
7
+ require 'like/engine'
@@ -0,0 +1,3 @@
1
+ class Like::Engine < Rails::Engine
2
+ engine_name :like
3
+ end
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ Gem::Specification.new do |spec|
3
+ spec.name = 'like'
4
+ spec.version = '0.0.1'
5
+ spec.authors = ['Pat Allan']
6
+ spec.email = ['pat@freelancing-gods.com']
7
+ spec.summary = %q{Rails Engine for liking}
8
+ spec.description = %q{A simple Rails engine for liking ActiveRecord objects.}
9
+ spec.homepage = 'https://github.com/inspire9/like'
10
+ spec.license = 'MIT'
11
+
12
+ spec.files = `git ls-files`.split($/)
13
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ['lib']
16
+
17
+ spec.add_runtime_dependency 'rails', '>= 3.2'
18
+
19
+ spec.add_development_dependency 'combustion', '~> 0.5.1'
20
+ spec.add_development_dependency 'rspec-rails', '~> 2.14.0'
21
+ spec.add_development_dependency 'sqlite3', '~> 1.3.8'
22
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Liking an object' do
4
+ let(:user) { User.create! }
5
+ let(:article) { Article.create! }
6
+
7
+ it "saves the like" do
8
+ Like.link user, article
9
+
10
+ likes = Like::Like.where(
11
+ liker_type: 'User', liker_id: user.id,
12
+ likeable_type: 'Article', likeable_id: article.id
13
+ )
14
+
15
+ expect(likes.count).to eq(1)
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ class Article < ActiveRecord::Base
2
+ #
3
+ end
@@ -0,0 +1,3 @@
1
+ class User < ActiveRecord::Base
2
+ #
3
+ end
@@ -0,0 +1,3 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/combustion_test.sqlite
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ #
3
+ end
@@ -0,0 +1,9 @@
1
+ ActiveRecord::Schema.define do
2
+ create_table :articles, :force => true do |t|
3
+ t.timestamps
4
+ end
5
+
6
+ create_table :users, :force => true do |t|
7
+ t.timestamps
8
+ end
9
+ end
@@ -0,0 +1 @@
1
+ *.log
File without changes
@@ -0,0 +1,16 @@
1
+ require 'bundler'
2
+
3
+ Bundler.setup :default, :development
4
+
5
+ require 'combustion'
6
+ require 'like'
7
+
8
+ Combustion.initialize! :action_controller, :active_record
9
+
10
+ require 'rspec/rails'
11
+
12
+ Dir["./spec/support/**/*.rb"].each { |file| require file }
13
+
14
+ RSpec.configure do |config|
15
+ config.use_transactional_fixtures = true
16
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: like
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Pat Allan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '3.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: combustion
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.5.1
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.5.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 2.14.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 2.14.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: sqlite3
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.3.8
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 1.3.8
69
+ description: A simple Rails engine for liking ActiveRecord objects.
70
+ email:
71
+ - pat@freelancing-gods.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - app/models/like/like.rb
82
+ - config.ru
83
+ - db/migrate/1_create_likes.rb
84
+ - lib/like.rb
85
+ - lib/like/engine.rb
86
+ - like.gemspec
87
+ - spec/acceptance/liking_spec.rb
88
+ - spec/internal/app/models/article.rb
89
+ - spec/internal/app/models/user.rb
90
+ - spec/internal/config/database.yml
91
+ - spec/internal/config/routes.rb
92
+ - spec/internal/db/combustion_test.sqlite
93
+ - spec/internal/db/schema.rb
94
+ - spec/internal/log/.gitignore
95
+ - spec/internal/public/favicon.ico
96
+ - spec/spec_helper.rb
97
+ homepage: https://github.com/inspire9/like
98
+ licenses:
99
+ - MIT
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 2.1.11
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: Rails Engine for liking
121
+ test_files:
122
+ - spec/acceptance/liking_spec.rb
123
+ - spec/internal/app/models/article.rb
124
+ - spec/internal/app/models/user.rb
125
+ - spec/internal/config/database.yml
126
+ - spec/internal/config/routes.rb
127
+ - spec/internal/db/combustion_test.sqlite
128
+ - spec/internal/db/schema.rb
129
+ - spec/internal/log/.gitignore
130
+ - spec/internal/public/favicon.ico
131
+ - spec/spec_helper.rb