listable 0.1.7 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +5 -4
- data/Gemfile.lock +83 -45
- data/README.rdoc +9 -2
- data/VERSION +1 -1
- data/lib/listable.rb +12 -3
- data/lib/listable/querying.rb +1 -1
- data/lib/listable/railtie.rb +4 -0
- data/lib/tasks/listable.rake +20 -8
- data/listable.gemspec +21 -17
- data/test/helper.rb +2 -1
- data/test/models.rb +3 -3
- data/test/test_listable.rb +10 -8
- metadata +107 -67
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 603a187e1336468db573e761b02486180c76c02d
|
4
|
+
data.tar.gz: 5e8c3429f92a21fe1db7ea6d8c4df991e444295e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c453b509a740e4b74e5c1af2dd7bc6e7d12de76d9fa1fbfd763d05b2f60a364ca586ec07bea75c7429463b07b9f674721288720a6f1c89669cda7662e19d4b2b
|
7
|
+
data.tar.gz: 3e07b145a4b16af5d3119e3cd4f5d2e7aeb12648a157b94a529d9866e98146eb32a45c4bd032a1ed9908a8f206f80f4b9a1ad9e507b0ae9fb0f964fa63620445
|
data/Gemfile
CHANGED
@@ -3,15 +3,16 @@ source "http://rubygems.org"
|
|
3
3
|
# Example:
|
4
4
|
gem "activesupport", ">= 3.2"
|
5
5
|
gem "activerecord", ">= 3.2"
|
6
|
+
gem "composite_primary_keys", ">=5.0"
|
6
7
|
|
7
8
|
# Add dependencies to develop your gem here.
|
8
9
|
# Include everything needed to run rake, tests, features, etc.
|
9
10
|
group :development do
|
10
|
-
gem "test-unit", "~>
|
11
|
+
gem "test-unit", "~> 3.0.1"
|
11
12
|
gem "shoulda", ">= 0"
|
12
|
-
gem "rdoc", "~>
|
13
|
-
gem "bundler", "~> 1.2
|
14
|
-
gem "jeweler", "~>
|
13
|
+
gem "rdoc", "~> 4.1.1"
|
14
|
+
gem "bundler", "~> 1.7.2"
|
15
|
+
gem "jeweler", "~> 2.0.1"
|
15
16
|
gem "simplecov", ">= 0"
|
16
17
|
gem "sqlite3"
|
17
18
|
gem "pg"
|
data/Gemfile.lock
CHANGED
@@ -1,52 +1,89 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activemodel (
|
5
|
-
activesupport (=
|
6
|
-
builder (~> 3.
|
7
|
-
activerecord (
|
8
|
-
activemodel (=
|
9
|
-
activesupport (=
|
10
|
-
arel (~>
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
4
|
+
activemodel (4.1.5)
|
5
|
+
activesupport (= 4.1.5)
|
6
|
+
builder (~> 3.1)
|
7
|
+
activerecord (4.1.5)
|
8
|
+
activemodel (= 4.1.5)
|
9
|
+
activesupport (= 4.1.5)
|
10
|
+
arel (~> 5.0.0)
|
11
|
+
activesupport (4.1.5)
|
12
|
+
i18n (~> 0.6, >= 0.6.9)
|
13
|
+
json (~> 1.7, >= 1.7.7)
|
14
|
+
minitest (~> 5.1)
|
15
|
+
thread_safe (~> 0.1)
|
16
|
+
tzinfo (~> 1.1)
|
17
|
+
addressable (2.3.6)
|
18
|
+
arel (5.0.1.20140414130214)
|
19
|
+
builder (3.2.2)
|
20
|
+
composite_primary_keys (7.0.10)
|
21
|
+
activerecord (~> 4.1.4)
|
22
|
+
descendants_tracker (0.0.4)
|
23
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
24
|
+
docile (1.1.5)
|
25
|
+
faraday (0.9.0)
|
26
|
+
multipart-post (>= 1.2, < 3)
|
27
|
+
git (1.2.8)
|
28
|
+
github_api (0.12.1)
|
29
|
+
addressable (~> 2.3)
|
30
|
+
descendants_tracker (~> 0.0.4)
|
31
|
+
faraday (~> 0.8, < 0.10)
|
32
|
+
hashie (>= 3.2)
|
33
|
+
multi_json (>= 1.7.5, < 2.0)
|
34
|
+
nokogiri (~> 1.6.3)
|
35
|
+
oauth2
|
36
|
+
hashie (3.3.1)
|
37
|
+
highline (1.6.21)
|
38
|
+
i18n (0.6.11)
|
39
|
+
jeweler (2.0.1)
|
40
|
+
builder
|
41
|
+
bundler (>= 1.0)
|
23
42
|
git (>= 1.2.5)
|
43
|
+
github_api
|
44
|
+
highline (>= 1.6.15)
|
45
|
+
nokogiri (>= 1.5.10)
|
24
46
|
rake
|
25
47
|
rdoc
|
26
|
-
json (1.
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
multi_json (1.
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
48
|
+
json (1.8.1)
|
49
|
+
jwt (1.0.0)
|
50
|
+
mini_portile (0.6.0)
|
51
|
+
minitest (5.4.1)
|
52
|
+
multi_json (1.10.1)
|
53
|
+
multi_xml (0.5.5)
|
54
|
+
multipart-post (2.0.0)
|
55
|
+
mysql2 (0.3.16)
|
56
|
+
nokogiri (1.6.3.1)
|
57
|
+
mini_portile (= 0.6.0)
|
58
|
+
oauth2 (1.0.0)
|
59
|
+
faraday (>= 0.8, < 0.10)
|
60
|
+
jwt (~> 1.0)
|
61
|
+
multi_json (~> 1.3)
|
62
|
+
multi_xml (~> 0.5)
|
63
|
+
rack (~> 1.2)
|
64
|
+
pg (0.17.1)
|
65
|
+
power_assert (0.1.3)
|
66
|
+
rack (1.5.2)
|
67
|
+
rake (10.3.2)
|
68
|
+
rdoc (4.1.1)
|
35
69
|
json (~> 1.4)
|
36
|
-
shoulda (3.
|
37
|
-
shoulda-context (~> 1.0.1)
|
38
|
-
shoulda-matchers (
|
39
|
-
shoulda-context (1.
|
40
|
-
shoulda-matchers (
|
70
|
+
shoulda (3.5.0)
|
71
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
72
|
+
shoulda-matchers (>= 1.4.1, < 3.0)
|
73
|
+
shoulda-context (1.2.1)
|
74
|
+
shoulda-matchers (2.6.2)
|
41
75
|
activesupport (>= 3.0.0)
|
42
|
-
|
43
|
-
|
44
|
-
multi_json
|
45
|
-
simplecov-html (~> 0.
|
46
|
-
simplecov-html (0.
|
47
|
-
sqlite3 (1.3.
|
48
|
-
test-unit (
|
49
|
-
|
76
|
+
simplecov (0.9.0)
|
77
|
+
docile (~> 1.1.0)
|
78
|
+
multi_json
|
79
|
+
simplecov-html (~> 0.8.0)
|
80
|
+
simplecov-html (0.8.0)
|
81
|
+
sqlite3 (1.3.9)
|
82
|
+
test-unit (3.0.1)
|
83
|
+
power_assert
|
84
|
+
thread_safe (0.3.4)
|
85
|
+
tzinfo (1.2.2)
|
86
|
+
thread_safe (~> 0.1)
|
50
87
|
|
51
88
|
PLATFORMS
|
52
89
|
ruby
|
@@ -54,12 +91,13 @@ PLATFORMS
|
|
54
91
|
DEPENDENCIES
|
55
92
|
activerecord (>= 3.2)
|
56
93
|
activesupport (>= 3.2)
|
57
|
-
bundler (~> 1.2
|
58
|
-
|
94
|
+
bundler (~> 1.7.2)
|
95
|
+
composite_primary_keys (>= 5.0)
|
96
|
+
jeweler (~> 2.0.1)
|
59
97
|
mysql2
|
60
98
|
pg
|
61
|
-
rdoc (~>
|
99
|
+
rdoc (~> 4.1.1)
|
62
100
|
shoulda
|
63
101
|
simplecov
|
64
102
|
sqlite3
|
65
|
-
test-unit (~>
|
103
|
+
test-unit (~> 3.0.1)
|
data/README.rdoc
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
= listable
|
2
2
|
|
3
|
-
With listable you can consolidate fields from several models into one, backed up by a database view.
|
3
|
+
With listable you can consolidate fields from several ActiveRecord models into one, backed up by a database view.
|
4
4
|
It is perfect for e.g. a front page where you may want to display the most recent additions to your site in a joint list.
|
5
5
|
By providing scopes for each model you wish to include in a view, listable will automatically create the database view for you.
|
6
6
|
The view model and the models it lists will have a polymorphic association for convenience.
|
7
7
|
Listable currently supports the following connection adapters: SQLite, PostgreSQL and MySQL2.
|
8
8
|
|
9
|
+
== Requirements
|
10
|
+
* ActiveRecord >= 3.2
|
11
|
+
* Tested with Rails 4
|
12
|
+
|
9
13
|
== How to use
|
10
14
|
This chapter shows some basic examples of all the steps needed to get started.
|
11
15
|
|
@@ -40,10 +44,13 @@ Here is a basic example:
|
|
40
44
|
end
|
41
45
|
|
42
46
|
=== Creating the database views
|
43
|
-
You can create the database views by running the rake task <em>listable:
|
47
|
+
You can create the database views by running the rake task <em>listable:create</em>.
|
44
48
|
But you will hardly ever need to do that since all listable views are automatically (re)created when running
|
45
49
|
Rails' <em>db:migrate</em>.
|
46
50
|
|
51
|
+
The views created by listable will also conveniently be dropped and recreated when running <em>db:setup</em> or <em>db:reset</em>,
|
52
|
+
and dropped when running <em>db:drop</em>. If you need to drop the views manually, just run the rake task <em>listable:drop</em>
|
53
|
+
|
47
54
|
==== Why not generate Rails migrations to create the views?
|
48
55
|
I believe it is very awkward to create views through migrations for several reasons.
|
49
56
|
The basic role of a migration is to either add or remove columns where you can store data.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/listable.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'active_support/concern'
|
2
|
+
require 'composite_primary_keys'
|
2
3
|
|
3
4
|
require 'listable/view_manager'
|
4
5
|
require 'listable/connection_adapters'
|
@@ -10,13 +11,15 @@ module Listable
|
|
10
11
|
|
11
12
|
module ClassMethods
|
12
13
|
def listable_through(listable_view_name, scope_name)
|
13
|
-
has_one listable_view_name.to_s.singularize, as: :listable
|
14
|
+
has_one listable_view_name.to_s.singularize.to_sym, as: :listable
|
14
15
|
|
15
16
|
ViewManager.add_listable listable_view_name, self.name, scope_name
|
16
17
|
end
|
17
18
|
|
18
19
|
def acts_as_listable_view
|
19
20
|
self.table_name = ViewManager.prefixed_view_name(self.name)
|
21
|
+
self.primary_keys = :listable_id, :listable_type
|
22
|
+
|
20
23
|
belongs_to :listable, polymorphic: true
|
21
24
|
include ViewMethods
|
22
25
|
end
|
@@ -47,13 +50,19 @@ if defined?(Rails)
|
|
47
50
|
# Extending connection adapters when lazily loaded by Rails
|
48
51
|
require 'listable/railtie'
|
49
52
|
else
|
50
|
-
|
53
|
+
if ActiveRecord::VERSION::MAJOR < 4
|
54
|
+
require 'active_record/connection_adapters/sqlite_adapter'
|
55
|
+
ActiveRecord::ConnectionAdapters::SQLiteAdapter.send(:include, Listable::ConnectionAdapters::SQLiteExtensions)
|
56
|
+
else
|
57
|
+
require 'active_record/connection_adapters/sqlite3_adapter'
|
58
|
+
ActiveRecord::ConnectionAdapters::SQLite3Adapter.send(:include, Listable::ConnectionAdapters::SQLiteExtensions)
|
59
|
+
end
|
60
|
+
|
51
61
|
require 'active_record/connection_adapters/postgresql_adapter'
|
52
62
|
require 'active_record/connection_adapters/mysql2_adapter'
|
53
63
|
|
54
64
|
# Extending connection adapters
|
55
65
|
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send(:include, Listable::ConnectionAdapters::PostgreSQLExtensions)
|
56
|
-
ActiveRecord::ConnectionAdapters::SQLiteAdapter.send(:include, Listable::ConnectionAdapters::SQLiteExtensions)
|
57
66
|
ActiveRecord::ConnectionAdapters::Mysql2Adapter.send(:include, Listable::ConnectionAdapters::MySQLExtensions)
|
58
67
|
end
|
59
68
|
|
data/lib/listable/querying.rb
CHANGED
data/lib/listable/railtie.rb
CHANGED
@@ -11,6 +11,10 @@ module Listable
|
|
11
11
|
ActiveRecord::ConnectionAdapters::SQLiteAdapter.send(:include, Listable::ConnectionAdapters::SQLiteExtensions)
|
12
12
|
end
|
13
13
|
|
14
|
+
if ActiveRecord::ConnectionAdapters.const_defined?(:SQLite3Adapter)
|
15
|
+
ActiveRecord::ConnectionAdapters::SQLite3Adapter.send(:include, Listable::ConnectionAdapters::SQLiteExtensions)
|
16
|
+
end
|
17
|
+
|
14
18
|
if ActiveRecord::ConnectionAdapters.const_defined?(:Mysql2Adapter)
|
15
19
|
ActiveRecord::ConnectionAdapters::Mysql2Adapter.send(:include, Listable::ConnectionAdapters::MySQLExtensions)
|
16
20
|
end
|
data/lib/tasks/listable.rake
CHANGED
@@ -1,21 +1,33 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
|
1
3
|
namespace :listable do
|
2
4
|
desc "(Re)creates all listable views"
|
3
|
-
task :
|
4
|
-
puts "Creating Listable views..."
|
5
|
+
task :create => :environment do
|
5
6
|
Rails.application.eager_load!
|
6
|
-
|
7
|
+
|
8
|
+
ActiveRecord::Migration.say_with_time "Listable::ViewManager.create_views" do
|
9
|
+
Listable::ViewManager.create_views
|
10
|
+
end
|
7
11
|
end
|
8
12
|
|
9
|
-
task :
|
10
|
-
|
11
|
-
|
13
|
+
task :drop => :environment do
|
14
|
+
ActiveRecord::Migration.say_with_time "Listable::ViewManager.drop_view" do
|
15
|
+
Listable::ViewManager.drop_views
|
16
|
+
end
|
12
17
|
end
|
13
18
|
end
|
14
19
|
|
15
20
|
# Rebuild views after db:migrate
|
16
21
|
Rake::Task['db:migrate'].enhance do
|
17
|
-
Rake::Task['listable:
|
22
|
+
Rake::Task['listable:create'].invoke
|
23
|
+
end
|
24
|
+
|
25
|
+
# Rebuild views after db:setup
|
26
|
+
Rake::Task['db:setup'].prerequisites.unshift 'listable:drop'
|
27
|
+
Rake::Task['db:setup'].enhance do
|
28
|
+
Rake::Task['listable:create'].invoke
|
18
29
|
end
|
19
30
|
|
20
31
|
# Drop views before a rollback to prevent errors due to column dependency
|
21
|
-
Rake::Task['db:
|
32
|
+
Rake::Task['db:drop'].enhance ['listable:drop']
|
33
|
+
Rake::Task['db:rollback'].enhance ['listable:drop']
|
data/listable.gemspec
CHANGED
@@ -2,14 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: listable 0.2.0 ruby lib
|
5
6
|
|
6
7
|
Gem::Specification.new do |s|
|
7
8
|
s.name = "listable"
|
8
|
-
s.version = "0.
|
9
|
+
s.version = "0.2.0"
|
9
10
|
|
10
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
11
13
|
s.authors = ["Johannes Baldursson"]
|
12
|
-
s.date = "
|
14
|
+
s.date = "2014-09-02"
|
13
15
|
s.description = "With listable you can consolidate fields from several models into one, backed up by a database view.\n It is perfect for e.g. a front page where you may want to display the most recent additions to your site in a joint list.\n By providing scopes for each model you wish to include in a view, Listable will automatically create the database view for you."
|
14
16
|
s.email = "johannes.baldursson@gmail.com"
|
15
17
|
s.extra_rdoc_files = [
|
@@ -39,21 +41,21 @@ Gem::Specification.new do |s|
|
|
39
41
|
]
|
40
42
|
s.homepage = "http://github.com/baldursson/listable"
|
41
43
|
s.licenses = ["MIT"]
|
42
|
-
s.
|
43
|
-
s.rubygems_version = "1.8.10"
|
44
|
+
s.rubygems_version = "2.2.2"
|
44
45
|
s.summary = "ActiveRecord extension that makes it easy to list and query several models through a single view backed model."
|
45
46
|
|
46
47
|
if s.respond_to? :specification_version then
|
47
|
-
s.specification_version =
|
48
|
+
s.specification_version = 4
|
48
49
|
|
49
50
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
51
|
s.add_runtime_dependency(%q<activesupport>, [">= 3.2"])
|
51
52
|
s.add_runtime_dependency(%q<activerecord>, [">= 3.2"])
|
52
|
-
s.
|
53
|
+
s.add_runtime_dependency(%q<composite_primary_keys>, [">= 5.0"])
|
54
|
+
s.add_development_dependency(%q<test-unit>, ["~> 3.0.1"])
|
53
55
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
54
|
-
s.add_development_dependency(%q<rdoc>, ["~>
|
55
|
-
s.add_development_dependency(%q<bundler>, ["~> 1.2
|
56
|
-
s.add_development_dependency(%q<jeweler>, ["~>
|
56
|
+
s.add_development_dependency(%q<rdoc>, ["~> 4.1.1"])
|
57
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.7.2"])
|
58
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
|
57
59
|
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
58
60
|
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
59
61
|
s.add_development_dependency(%q<pg>, [">= 0"])
|
@@ -61,11 +63,12 @@ Gem::Specification.new do |s|
|
|
61
63
|
else
|
62
64
|
s.add_dependency(%q<activesupport>, [">= 3.2"])
|
63
65
|
s.add_dependency(%q<activerecord>, [">= 3.2"])
|
64
|
-
s.add_dependency(%q<
|
66
|
+
s.add_dependency(%q<composite_primary_keys>, [">= 5.0"])
|
67
|
+
s.add_dependency(%q<test-unit>, ["~> 3.0.1"])
|
65
68
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
66
|
-
s.add_dependency(%q<rdoc>, ["~>
|
67
|
-
s.add_dependency(%q<bundler>, ["~> 1.2
|
68
|
-
s.add_dependency(%q<jeweler>, ["~>
|
69
|
+
s.add_dependency(%q<rdoc>, ["~> 4.1.1"])
|
70
|
+
s.add_dependency(%q<bundler>, ["~> 1.7.2"])
|
71
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
69
72
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
70
73
|
s.add_dependency(%q<sqlite3>, [">= 0"])
|
71
74
|
s.add_dependency(%q<pg>, [">= 0"])
|
@@ -74,11 +77,12 @@ Gem::Specification.new do |s|
|
|
74
77
|
else
|
75
78
|
s.add_dependency(%q<activesupport>, [">= 3.2"])
|
76
79
|
s.add_dependency(%q<activerecord>, [">= 3.2"])
|
77
|
-
s.add_dependency(%q<
|
80
|
+
s.add_dependency(%q<composite_primary_keys>, [">= 5.0"])
|
81
|
+
s.add_dependency(%q<test-unit>, ["~> 3.0.1"])
|
78
82
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
79
|
-
s.add_dependency(%q<rdoc>, ["~>
|
80
|
-
s.add_dependency(%q<bundler>, ["~> 1.2
|
81
|
-
s.add_dependency(%q<jeweler>, ["~>
|
83
|
+
s.add_dependency(%q<rdoc>, ["~> 4.1.1"])
|
84
|
+
s.add_dependency(%q<bundler>, ["~> 1.7.2"])
|
85
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
|
82
86
|
s.add_dependency(%q<simplecov>, [">= 0"])
|
83
87
|
s.add_dependency(%q<sqlite3>, [">= 0"])
|
84
88
|
s.add_dependency(%q<pg>, [">= 0"])
|
data/test/helper.rb
CHANGED
@@ -11,6 +11,7 @@ rescue Bundler::BundlerError => e
|
|
11
11
|
$stderr.puts "Run `bundle install` to install missing gems"
|
12
12
|
exit e.status_code
|
13
13
|
end
|
14
|
+
|
14
15
|
require 'test/unit'
|
15
16
|
require 'shoulda'
|
16
17
|
require 'active_record'
|
@@ -18,8 +19,8 @@ require 'active_support'
|
|
18
19
|
|
19
20
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
20
21
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
21
|
-
require 'listable'
|
22
22
|
|
23
|
+
require 'listable'
|
23
24
|
|
24
25
|
class Test::Unit::TestCase
|
25
26
|
end
|
data/test/models.rb
CHANGED
@@ -4,17 +4,17 @@ end
|
|
4
4
|
|
5
5
|
class Page < ActiveRecord::Base
|
6
6
|
listable_through :topical_items, :listables
|
7
|
-
scope :listables, select([:title, :body])
|
7
|
+
scope :listables, -> { select([:title, :body]) }
|
8
8
|
end
|
9
9
|
|
10
10
|
class Employee < ActiveRecord::Base
|
11
11
|
listable_through :topical_items, :listables
|
12
|
-
scope :listables, concat_select([:first_name, ' ', :last_name], :title).select(:biography)
|
12
|
+
scope :listables, -> { concat_select([:first_name, ' ', :last_name], :title).select(:biography) }
|
13
13
|
end
|
14
14
|
|
15
15
|
class NewsArticle < ActiveRecord::Base
|
16
16
|
listable_through :topical_items, :listables
|
17
|
-
scope :listables, select_as(headline: 'title').select(:body)
|
17
|
+
scope :listables, -> { select_as(headline: 'title').select(:body) }
|
18
18
|
end
|
19
19
|
|
20
20
|
# Seeding pages
|
data/test/test_listable.rb
CHANGED
@@ -2,18 +2,20 @@ require 'helper'
|
|
2
2
|
|
3
3
|
class TestListable < Test::Unit::TestCase
|
4
4
|
|
5
|
-
|
6
|
-
def setup
|
5
|
+
def setup
|
7
6
|
Listable::ViewManager.create_views
|
8
7
|
end
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
def topical_items_count
|
10
|
+
TopicalItems.count(:all)
|
11
|
+
end
|
12
|
+
|
13
|
+
def listable_items_count
|
14
|
+
Page.listables.count(:all) + Employee.listables.count(:all) + NewsArticle.listables.count(:all)
|
15
|
+
end
|
16
|
+
|
17
|
+
context "a listable view model" do
|
13
18
|
|
14
|
-
def listable_items_count
|
15
|
-
Page.listables.count + Employee.listables.count + NewsArticle.listables.count
|
16
|
-
end
|
17
19
|
|
18
20
|
should "have as many rows as the models it lists" do
|
19
21
|
assert_equal listable_items_count, topical_items_count
|
metadata
CHANGED
@@ -1,143 +1,187 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: listable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Johannes Baldursson
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-09-02 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activesupport
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '3.2'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.2'
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: activerecord
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - ">="
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '3.2'
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: composite_primary_keys
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
36
55
|
- !ruby/object:Gem::Dependency
|
37
56
|
name: test-unit
|
38
|
-
requirement:
|
39
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
40
58
|
requirements:
|
41
|
-
- - ~>
|
59
|
+
- - "~>"
|
42
60
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
61
|
+
version: 3.0.1
|
44
62
|
type: :development
|
45
63
|
prerelease: false
|
46
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.0.1
|
47
69
|
- !ruby/object:Gem::Dependency
|
48
70
|
name: shoulda
|
49
|
-
requirement:
|
50
|
-
none: false
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
51
72
|
requirements:
|
52
|
-
- -
|
73
|
+
- - ">="
|
53
74
|
- !ruby/object:Gem::Version
|
54
75
|
version: '0'
|
55
76
|
type: :development
|
56
77
|
prerelease: false
|
57
|
-
version_requirements:
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
58
83
|
- !ruby/object:Gem::Dependency
|
59
84
|
name: rdoc
|
60
|
-
requirement:
|
61
|
-
none: false
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
62
86
|
requirements:
|
63
|
-
- - ~>
|
87
|
+
- - "~>"
|
64
88
|
- !ruby/object:Gem::Version
|
65
|
-
version:
|
89
|
+
version: 4.1.1
|
66
90
|
type: :development
|
67
91
|
prerelease: false
|
68
|
-
version_requirements:
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 4.1.1
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: bundler
|
71
|
-
requirement:
|
72
|
-
none: false
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
73
100
|
requirements:
|
74
|
-
- - ~>
|
101
|
+
- - "~>"
|
75
102
|
- !ruby/object:Gem::Version
|
76
|
-
version: 1.2
|
103
|
+
version: 1.7.2
|
77
104
|
type: :development
|
78
105
|
prerelease: false
|
79
|
-
version_requirements:
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.7.2
|
80
111
|
- !ruby/object:Gem::Dependency
|
81
112
|
name: jeweler
|
82
|
-
requirement:
|
83
|
-
none: false
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
84
114
|
requirements:
|
85
|
-
- - ~>
|
115
|
+
- - "~>"
|
86
116
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
117
|
+
version: 2.0.1
|
88
118
|
type: :development
|
89
119
|
prerelease: false
|
90
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 2.0.1
|
91
125
|
- !ruby/object:Gem::Dependency
|
92
126
|
name: simplecov
|
93
|
-
requirement:
|
94
|
-
none: false
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
95
128
|
requirements:
|
96
|
-
- -
|
129
|
+
- - ">="
|
97
130
|
- !ruby/object:Gem::Version
|
98
131
|
version: '0'
|
99
132
|
type: :development
|
100
133
|
prerelease: false
|
101
|
-
version_requirements:
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
102
139
|
- !ruby/object:Gem::Dependency
|
103
140
|
name: sqlite3
|
104
|
-
requirement:
|
105
|
-
none: false
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
106
142
|
requirements:
|
107
|
-
- -
|
143
|
+
- - ">="
|
108
144
|
- !ruby/object:Gem::Version
|
109
145
|
version: '0'
|
110
146
|
type: :development
|
111
147
|
prerelease: false
|
112
|
-
version_requirements:
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
113
153
|
- !ruby/object:Gem::Dependency
|
114
154
|
name: pg
|
115
|
-
requirement:
|
116
|
-
none: false
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
117
156
|
requirements:
|
118
|
-
- -
|
157
|
+
- - ">="
|
119
158
|
- !ruby/object:Gem::Version
|
120
159
|
version: '0'
|
121
160
|
type: :development
|
122
161
|
prerelease: false
|
123
|
-
version_requirements:
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
124
167
|
- !ruby/object:Gem::Dependency
|
125
168
|
name: mysql2
|
126
|
-
requirement:
|
127
|
-
none: false
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
128
170
|
requirements:
|
129
|
-
- -
|
171
|
+
- - ">="
|
130
172
|
- !ruby/object:Gem::Version
|
131
173
|
version: '0'
|
132
174
|
type: :development
|
133
175
|
prerelease: false
|
134
|
-
version_requirements:
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
description: |-
|
182
|
+
With listable you can consolidate fields from several models into one, backed up by a database view.
|
183
|
+
It is perfect for e.g. a front page where you may want to display the most recent additions to your site in a joint list.
|
184
|
+
By providing scopes for each model you wish to include in a view, Listable will automatically create the database view for you.
|
141
185
|
email: johannes.baldursson@gmail.com
|
142
186
|
executables: []
|
143
187
|
extensions: []
|
@@ -145,7 +189,7 @@ extra_rdoc_files:
|
|
145
189
|
- LICENSE.txt
|
146
190
|
- README.rdoc
|
147
191
|
files:
|
148
|
-
- .document
|
192
|
+
- ".document"
|
149
193
|
- Gemfile
|
150
194
|
- Gemfile.lock
|
151
195
|
- LICENSE.txt
|
@@ -167,30 +211,26 @@ files:
|
|
167
211
|
homepage: http://github.com/baldursson/listable
|
168
212
|
licenses:
|
169
213
|
- MIT
|
214
|
+
metadata: {}
|
170
215
|
post_install_message:
|
171
216
|
rdoc_options: []
|
172
217
|
require_paths:
|
173
218
|
- lib
|
174
219
|
required_ruby_version: !ruby/object:Gem::Requirement
|
175
|
-
none: false
|
176
220
|
requirements:
|
177
|
-
- -
|
221
|
+
- - ">="
|
178
222
|
- !ruby/object:Gem::Version
|
179
223
|
version: '0'
|
180
|
-
segments:
|
181
|
-
- 0
|
182
|
-
hash: 1407961267494115612
|
183
224
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
|
-
none: false
|
185
225
|
requirements:
|
186
|
-
- -
|
226
|
+
- - ">="
|
187
227
|
- !ruby/object:Gem::Version
|
188
228
|
version: '0'
|
189
229
|
requirements: []
|
190
230
|
rubyforge_project:
|
191
|
-
rubygems_version:
|
231
|
+
rubygems_version: 2.2.2
|
192
232
|
signing_key:
|
193
|
-
specification_version:
|
233
|
+
specification_version: 4
|
194
234
|
summary: ActiveRecord extension that makes it easy to list and query several models
|
195
235
|
through a single view backed model.
|
196
236
|
test_files: []
|