acts-as-taggable-on 2.0.6 → 2.3.0
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.
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +9 -0
- data/CHANGELOG +10 -0
- data/Gemfile +2 -9
- data/Guardfile +5 -0
- data/README.rdoc +89 -66
- data/Rakefile +9 -55
- data/acts-as-taggable-on.gemspec +28 -0
- data/lib/acts-as-taggable-on/version.rb +4 -0
- data/lib/acts-as-taggable-on.rb +33 -4
- data/lib/acts_as_taggable_on/acts_as_taggable_on/cache.rb +4 -4
- data/lib/acts_as_taggable_on/acts_as_taggable_on/collection.rb +38 -43
- data/lib/acts_as_taggable_on/acts_as_taggable_on/core.rb +146 -38
- data/lib/acts_as_taggable_on/acts_as_taggable_on/dirty.rb +37 -0
- data/lib/acts_as_taggable_on/acts_as_taggable_on/ownership.rb +36 -11
- data/lib/acts_as_taggable_on/acts_as_taggable_on/related.rb +23 -15
- data/lib/acts_as_taggable_on/tag.rb +16 -13
- data/lib/acts_as_taggable_on/tag_list.rb +13 -12
- data/lib/acts_as_taggable_on/taggable.rb +102 -0
- data/lib/acts_as_taggable_on/{acts_as_tagger.rb → tagger.rb} +3 -3
- data/lib/acts_as_taggable_on/tagging.rb +12 -2
- data/lib/acts_as_taggable_on/tags_helper.rb +2 -2
- data/lib/acts_as_taggable_on/utils.rb +34 -0
- data/lib/generators/acts_as_taggable_on/migration/migration_generator.rb +9 -2
- data/lib/generators/acts_as_taggable_on/migration/templates/active_record/migration.rb +3 -1
- data/spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb +300 -54
- data/spec/acts_as_taggable_on/tag_list_spec.rb +84 -61
- data/spec/acts_as_taggable_on/tag_spec.rb +51 -13
- data/spec/acts_as_taggable_on/taggable_spec.rb +261 -34
- data/spec/acts_as_taggable_on/tagger_spec.rb +36 -15
- data/spec/acts_as_taggable_on/tagging_spec.rb +2 -5
- data/spec/acts_as_taggable_on/tags_helper_spec.rb +16 -0
- data/spec/acts_as_taggable_on/utils_spec.rb +21 -0
- data/spec/database.yml.sample +4 -2
- data/spec/generators/acts_as_taggable_on/migration/migration_generator_spec.rb +22 -0
- data/spec/models.rb +19 -1
- data/spec/schema.rb +18 -0
- data/spec/spec_helper.rb +30 -7
- data/uninstall.rb +1 -0
- metadata +137 -51
- data/VERSION +0 -1
- data/generators/acts_as_taggable_on_migration/acts_as_taggable_on_migration_generator.rb +0 -7
- data/generators/acts_as_taggable_on_migration/templates/migration.rb +0 -29
- data/lib/acts_as_taggable_on/acts_as_taggable_on.rb +0 -53
- data/lib/acts_as_taggable_on/compatibility/Gemfile +0 -8
- data/lib/acts_as_taggable_on/compatibility/active_record_backports.rb +0 -17
- data/lib/acts_as_taggable_on/compatibility/postgresql.rb +0 -44
- data/spec/database.yml +0 -17
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe ActsAsTaggableOn::Utils do
|
4
|
+
describe "like_operator" do
|
5
|
+
before(:each) do
|
6
|
+
clean_database!
|
7
|
+
TaggableModel.acts_as_taggable_on(:tags, :languages, :skills, :needs, :offerings)
|
8
|
+
@taggable = TaggableModel.new(:name => "Bob Jones")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should return 'ILIKE' when the adapter is PostgreSQL" do
|
12
|
+
TaggableModel.connection.stub(:adapter_name).and_return("PostgreSQL")
|
13
|
+
TaggableModel.send(:like_operator).should == "ILIKE"
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return 'LIKE' when the adapter is not PostgreSQL" do
|
17
|
+
TaggableModel.connection.stub(:adapter_name).and_return("MySQL")
|
18
|
+
TaggableModel.send(:like_operator).should == "LIKE"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/database.yml.sample
CHANGED
@@ -3,15 +3,17 @@ sqlite3:
|
|
3
3
|
database: acts_as_taggable_on.sqlite3
|
4
4
|
|
5
5
|
mysql:
|
6
|
-
adapter:
|
6
|
+
adapter: mysql2
|
7
7
|
hostname: localhost
|
8
8
|
username: root
|
9
9
|
password:
|
10
10
|
database: acts_as_taggable_on
|
11
|
-
|
11
|
+
charset: utf8
|
12
|
+
|
12
13
|
postgresql:
|
13
14
|
adapter: postgresql
|
14
15
|
hostname: localhost
|
15
16
|
username: postgres
|
16
17
|
password:
|
17
18
|
database: acts_as_taggable_on
|
19
|
+
encoding: utf8
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# Generators are not automatically loaded by Rails
|
4
|
+
require 'generators/acts_as_taggable_on/migration/migration_generator'
|
5
|
+
|
6
|
+
describe ActsAsTaggableOn::MigrationGenerator do
|
7
|
+
# Tell the generator where to put its output (what it thinks of as Rails.root)
|
8
|
+
destination File.expand_path("../../../../../tmp", __FILE__)
|
9
|
+
|
10
|
+
before do
|
11
|
+
prepare_destination
|
12
|
+
Rails::Generators.options[:rails][:orm] = :active_record
|
13
|
+
end
|
14
|
+
describe 'no arguments' do
|
15
|
+
before { run_generator }
|
16
|
+
|
17
|
+
describe 'db/migrate/acts_as_taggable_on_migration.rb' do
|
18
|
+
subject { file('db/migrate/acts_as_taggable_on_migration.rb') }
|
19
|
+
it { should be_a_migration }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/spec/models.rb
CHANGED
@@ -10,6 +10,10 @@ class CachedModel < ActiveRecord::Base
|
|
10
10
|
acts_as_taggable
|
11
11
|
end
|
12
12
|
|
13
|
+
class OtherCachedModel < ActiveRecord::Base
|
14
|
+
acts_as_taggable_on :languages, :statuses, :glasses
|
15
|
+
end
|
16
|
+
|
13
17
|
class OtherTaggableModel < ActiveRecord::Base
|
14
18
|
acts_as_taggable_on :tags, :languages
|
15
19
|
acts_as_taggable_on :needs, :offerings
|
@@ -28,4 +32,18 @@ end
|
|
28
32
|
|
29
33
|
class UntaggableModel < ActiveRecord::Base
|
30
34
|
belongs_to :taggable_model
|
31
|
-
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class NonStandardIdTaggableModel < ActiveRecord::Base
|
38
|
+
set_primary_key "an_id"
|
39
|
+
acts_as_taggable
|
40
|
+
acts_as_taggable_on :languages
|
41
|
+
acts_as_taggable_on :skills
|
42
|
+
acts_as_taggable_on :needs, :offerings
|
43
|
+
has_many :untaggable_models
|
44
|
+
end
|
45
|
+
|
46
|
+
class OrderedTaggableModel < ActiveRecord::Base
|
47
|
+
acts_as_ordered_taggable
|
48
|
+
acts_as_ordered_taggable_on :colours
|
49
|
+
end
|
data/spec/schema.rb
CHANGED
@@ -21,6 +21,11 @@ ActiveRecord::Schema.define :version => 0 do
|
|
21
21
|
t.column :type, :string
|
22
22
|
end
|
23
23
|
|
24
|
+
create_table :non_standard_id_taggable_models, :primary_key => "an_id", :force => true do |t|
|
25
|
+
t.column :name, :string
|
26
|
+
t.column :type, :string
|
27
|
+
end
|
28
|
+
|
24
29
|
create_table :untaggable_models, :force => true do |t|
|
25
30
|
t.column :taggable_model_id, :integer
|
26
31
|
t.column :name, :string
|
@@ -32,6 +37,14 @@ ActiveRecord::Schema.define :version => 0 do
|
|
32
37
|
t.column :cached_tag_list, :string
|
33
38
|
end
|
34
39
|
|
40
|
+
create_table :other_cached_models, :force => true do |t|
|
41
|
+
t.column :name, :string
|
42
|
+
t.column :type, :string
|
43
|
+
t.column :cached_language_list, :string
|
44
|
+
t.column :cached_status_list, :string
|
45
|
+
t.column :cached_glass_list, :string
|
46
|
+
end
|
47
|
+
|
35
48
|
create_table :taggable_users, :force => true do |t|
|
36
49
|
t.column :name, :string
|
37
50
|
end
|
@@ -40,4 +53,9 @@ ActiveRecord::Schema.define :version => 0 do
|
|
40
53
|
t.column :name, :string
|
41
54
|
t.column :type, :string
|
42
55
|
end
|
56
|
+
|
57
|
+
create_table :ordered_taggable_models, :force => true do |t|
|
58
|
+
t.column :name, :string
|
59
|
+
t.column :type, :string
|
60
|
+
end
|
43
61
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
$LOAD_PATH << "." unless $LOAD_PATH.include?(".")
|
2
|
+
require 'logger'
|
2
3
|
|
3
4
|
begin
|
4
5
|
require "rubygems"
|
@@ -13,11 +14,12 @@ begin
|
|
13
14
|
Bundler.setup
|
14
15
|
rescue Bundler::GemNotFound
|
15
16
|
raise RuntimeError, "Bundler couldn't find some gems." +
|
16
|
-
"Did you run
|
17
|
+
"Did you run \`bundlee install\`?"
|
17
18
|
end
|
18
19
|
|
19
20
|
Bundler.require
|
20
21
|
require File.expand_path('../../lib/acts-as-taggable-on', __FILE__)
|
22
|
+
require 'ammeter/init'
|
21
23
|
|
22
24
|
unless [].respond_to?(:freq)
|
23
25
|
class Array
|
@@ -29,14 +31,35 @@ unless [].respond_to?(:freq)
|
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
+
# set adapter to use, default is sqlite3
|
35
|
+
# to use an alternative adapter run => rake spec DB='postgresql'
|
36
|
+
db_name = ENV['DB'] || 'sqlite3'
|
34
37
|
database_yml = File.expand_path('../database.yml', __FILE__)
|
38
|
+
|
35
39
|
if File.exists?(database_yml)
|
36
|
-
active_record_configuration = YAML.load_file(database_yml)
|
40
|
+
active_record_configuration = YAML.load_file(database_yml)
|
37
41
|
|
38
|
-
ActiveRecord::Base.
|
42
|
+
ActiveRecord::Base.configurations = active_record_configuration
|
43
|
+
config = ActiveRecord::Base.configurations[db_name]
|
44
|
+
|
45
|
+
begin
|
46
|
+
ActiveRecord::Base.establish_connection(db_name)
|
47
|
+
ActiveRecord::Base.connection
|
48
|
+
rescue
|
49
|
+
case db_name
|
50
|
+
when /mysql/
|
51
|
+
ActiveRecord::Base.establish_connection(config.merge('database' => nil))
|
52
|
+
ActiveRecord::Base.connection.create_database(config['database'], {:charset => 'utf8', :collation => 'utf8_unicode_ci'})
|
53
|
+
when 'postgresql'
|
54
|
+
ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
|
55
|
+
ActiveRecord::Base.connection.create_database(config['database'], config.merge('encoding' => 'utf8'))
|
56
|
+
end
|
57
|
+
|
58
|
+
ActiveRecord::Base.establish_connection(config)
|
59
|
+
end
|
60
|
+
|
39
61
|
ActiveRecord::Base.logger = Logger.new(File.join(File.dirname(__FILE__), "debug.log"))
|
62
|
+
ActiveRecord::Base.default_timezone = :utc
|
40
63
|
|
41
64
|
ActiveRecord::Base.silence do
|
42
65
|
ActiveRecord::Migration.verbose = false
|
@@ -51,10 +74,10 @@ end
|
|
51
74
|
|
52
75
|
def clean_database!
|
53
76
|
models = [ActsAsTaggableOn::Tag, ActsAsTaggableOn::Tagging, TaggableModel, OtherTaggableModel, InheritingTaggableModel,
|
54
|
-
AlteredInheritingTaggableModel, TaggableUser, UntaggableModel]
|
77
|
+
AlteredInheritingTaggableModel, TaggableUser, UntaggableModel, OrderedTaggableModel]
|
55
78
|
models.each do |model|
|
56
79
|
ActiveRecord::Base.connection.execute "DELETE FROM #{model.table_name}"
|
57
80
|
end
|
58
81
|
end
|
59
82
|
|
60
|
-
clean_database!
|
83
|
+
clean_database!
|
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
metadata
CHANGED
@@ -1,55 +1,136 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts-as-taggable-on
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 2
|
7
|
-
- 0
|
8
|
-
- 6
|
9
|
-
version: 2.0.6
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.3.0
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Michael Bleigh
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
date: 2012-01-06 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: &70275758086480 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70275758086480
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &70275758085980 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.6'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70275758085980
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: ammeter
|
38
|
+
requirement: &70275758085520 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.1.3
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70275758085520
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: sqlite3
|
49
|
+
requirement: &70275758103040 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70275758103040
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: mysql2
|
60
|
+
requirement: &70275758102400 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 0.3.7
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70275758102400
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pg
|
71
|
+
requirement: &70275758101640 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70275758101640
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: guard
|
82
|
+
requirement: &70275758100980 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *70275758100980
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: guard-rspec
|
93
|
+
requirement: &70275758100180 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
type: :development
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *70275758100180
|
102
|
+
description: With ActsAsTaggableOn, you can tag a single model on several contexts,
|
103
|
+
such as skills, interests, and awards. It also provides other advanced functionality.
|
22
104
|
email: michael@intridea.com
|
23
105
|
executables: []
|
24
|
-
|
25
106
|
extensions: []
|
26
|
-
|
27
|
-
|
28
|
-
-
|
29
|
-
|
107
|
+
extra_rdoc_files: []
|
108
|
+
files:
|
109
|
+
- .gitignore
|
110
|
+
- .rspec
|
111
|
+
- .travis.yml
|
30
112
|
- CHANGELOG
|
31
113
|
- Gemfile
|
114
|
+
- Guardfile
|
32
115
|
- MIT-LICENSE
|
33
116
|
- README.rdoc
|
34
117
|
- Rakefile
|
35
|
-
-
|
36
|
-
- generators/acts_as_taggable_on_migration/acts_as_taggable_on_migration_generator.rb
|
37
|
-
- generators/acts_as_taggable_on_migration/templates/migration.rb
|
118
|
+
- acts-as-taggable-on.gemspec
|
38
119
|
- lib/acts-as-taggable-on.rb
|
39
|
-
- lib/
|
120
|
+
- lib/acts-as-taggable-on/version.rb
|
40
121
|
- lib/acts_as_taggable_on/acts_as_taggable_on/cache.rb
|
41
122
|
- lib/acts_as_taggable_on/acts_as_taggable_on/collection.rb
|
42
123
|
- lib/acts_as_taggable_on/acts_as_taggable_on/core.rb
|
124
|
+
- lib/acts_as_taggable_on/acts_as_taggable_on/dirty.rb
|
43
125
|
- lib/acts_as_taggable_on/acts_as_taggable_on/ownership.rb
|
44
126
|
- lib/acts_as_taggable_on/acts_as_taggable_on/related.rb
|
45
|
-
- lib/acts_as_taggable_on/acts_as_tagger.rb
|
46
|
-
- lib/acts_as_taggable_on/compatibility/Gemfile
|
47
|
-
- lib/acts_as_taggable_on/compatibility/active_record_backports.rb
|
48
|
-
- lib/acts_as_taggable_on/compatibility/postgresql.rb
|
49
127
|
- lib/acts_as_taggable_on/tag.rb
|
50
128
|
- lib/acts_as_taggable_on/tag_list.rb
|
129
|
+
- lib/acts_as_taggable_on/taggable.rb
|
130
|
+
- lib/acts_as_taggable_on/tagger.rb
|
51
131
|
- lib/acts_as_taggable_on/tagging.rb
|
52
132
|
- lib/acts_as_taggable_on/tags_helper.rb
|
133
|
+
- lib/acts_as_taggable_on/utils.rb
|
53
134
|
- lib/generators/acts_as_taggable_on/migration/migration_generator.rb
|
54
135
|
- lib/generators/acts_as_taggable_on/migration/templates/active_record/migration.rb
|
55
136
|
- rails/init.rb
|
@@ -61,43 +142,45 @@ files:
|
|
61
142
|
- spec/acts_as_taggable_on/tagger_spec.rb
|
62
143
|
- spec/acts_as_taggable_on/tagging_spec.rb
|
63
144
|
- spec/acts_as_taggable_on/tags_helper_spec.rb
|
145
|
+
- spec/acts_as_taggable_on/utils_spec.rb
|
64
146
|
- spec/bm.rb
|
65
|
-
- spec/database.yml
|
66
147
|
- spec/database.yml.sample
|
148
|
+
- spec/generators/acts_as_taggable_on/migration/migration_generator_spec.rb
|
67
149
|
- spec/models.rb
|
68
150
|
- spec/schema.rb
|
69
151
|
- spec/spec_helper.rb
|
70
|
-
|
71
|
-
homepage:
|
152
|
+
- uninstall.rb
|
153
|
+
homepage: ''
|
72
154
|
licenses: []
|
73
|
-
|
74
155
|
post_install_message:
|
75
|
-
rdoc_options:
|
76
|
-
|
77
|
-
require_paths:
|
156
|
+
rdoc_options: []
|
157
|
+
require_paths:
|
78
158
|
- lib
|
79
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
159
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
160
|
+
none: false
|
161
|
+
requirements:
|
162
|
+
- - ! '>='
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
segments:
|
84
166
|
- 0
|
85
|
-
|
86
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
167
|
+
hash: 3587969812961176900
|
168
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
segments:
|
91
175
|
- 0
|
92
|
-
|
176
|
+
hash: 3587969812961176900
|
93
177
|
requirements: []
|
94
|
-
|
95
178
|
rubyforge_project:
|
96
|
-
rubygems_version: 1.
|
179
|
+
rubygems_version: 1.8.10
|
97
180
|
signing_key:
|
98
181
|
specification_version: 3
|
99
|
-
summary:
|
100
|
-
test_files:
|
182
|
+
summary: Advanced tagging for Rails.
|
183
|
+
test_files:
|
101
184
|
- spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb
|
102
185
|
- spec/acts_as_taggable_on/acts_as_tagger_spec.rb
|
103
186
|
- spec/acts_as_taggable_on/tag_list_spec.rb
|
@@ -106,7 +189,10 @@ test_files:
|
|
106
189
|
- spec/acts_as_taggable_on/tagger_spec.rb
|
107
190
|
- spec/acts_as_taggable_on/tagging_spec.rb
|
108
191
|
- spec/acts_as_taggable_on/tags_helper_spec.rb
|
192
|
+
- spec/acts_as_taggable_on/utils_spec.rb
|
109
193
|
- spec/bm.rb
|
194
|
+
- spec/database.yml.sample
|
195
|
+
- spec/generators/acts_as_taggable_on/migration/migration_generator_spec.rb
|
110
196
|
- spec/models.rb
|
111
197
|
- spec/schema.rb
|
112
198
|
- spec/spec_helper.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.0.6
|
@@ -1,29 +0,0 @@
|
|
1
|
-
class ActsAsTaggableOnMigration < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table :tags do |t|
|
4
|
-
t.column :name, :string
|
5
|
-
end
|
6
|
-
|
7
|
-
create_table :taggings do |t|
|
8
|
-
t.column :tag_id, :integer
|
9
|
-
t.column :taggable_id, :integer
|
10
|
-
t.column :tagger_id, :integer
|
11
|
-
t.column :tagger_type, :string
|
12
|
-
|
13
|
-
# You should make sure that the column created is
|
14
|
-
# long enough to store the required class names.
|
15
|
-
t.column :taggable_type, :string
|
16
|
-
t.column :context, :string
|
17
|
-
|
18
|
-
t.column :created_at, :datetime
|
19
|
-
end
|
20
|
-
|
21
|
-
add_index :taggings, :tag_id
|
22
|
-
add_index :taggings, [:taggable_id, :taggable_type, :context]
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.down
|
26
|
-
drop_table :taggings
|
27
|
-
drop_table :tags
|
28
|
-
end
|
29
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
module ActsAsTaggableOn
|
2
|
-
module Taggable
|
3
|
-
def taggable?
|
4
|
-
false
|
5
|
-
end
|
6
|
-
|
7
|
-
##
|
8
|
-
# This is an alias for calling <tt>acts_as_taggable_on :tags</tt>.
|
9
|
-
#
|
10
|
-
# Example:
|
11
|
-
# class Book < ActiveRecord::Base
|
12
|
-
# acts_as_taggable
|
13
|
-
# end
|
14
|
-
def acts_as_taggable
|
15
|
-
acts_as_taggable_on :tags
|
16
|
-
end
|
17
|
-
|
18
|
-
##
|
19
|
-
# Make a model taggable on specified contexts.
|
20
|
-
#
|
21
|
-
# @param [Array] tag_types An array of taggable contexts
|
22
|
-
#
|
23
|
-
# Example:
|
24
|
-
# class User < ActiveRecord::Base
|
25
|
-
# acts_as_taggable_on :languages, :skills
|
26
|
-
# end
|
27
|
-
def acts_as_taggable_on(*tag_types)
|
28
|
-
tag_types = tag_types.to_a.flatten.compact.map(&:to_sym)
|
29
|
-
|
30
|
-
if taggable?
|
31
|
-
write_inheritable_attribute(:tag_types, (self.tag_types + tag_types).uniq)
|
32
|
-
else
|
33
|
-
write_inheritable_attribute(:tag_types, tag_types)
|
34
|
-
class_inheritable_reader(:tag_types)
|
35
|
-
|
36
|
-
class_eval do
|
37
|
-
has_many :taggings, :as => :taggable, :dependent => :destroy, :include => :tag, :class_name => "ActsAsTaggableOn::Tagging"
|
38
|
-
has_many :base_tags, :through => :taggings, :source => :tag, :class_name => "ActsAsTaggableOn::Tag"
|
39
|
-
|
40
|
-
def self.taggable?
|
41
|
-
true
|
42
|
-
end
|
43
|
-
|
44
|
-
include ActsAsTaggableOn::Taggable::Core
|
45
|
-
include ActsAsTaggableOn::Taggable::Collection
|
46
|
-
include ActsAsTaggableOn::Taggable::Cache
|
47
|
-
include ActsAsTaggableOn::Taggable::Ownership
|
48
|
-
include ActsAsTaggableOn::Taggable::Related
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module ActsAsTaggableOn
|
2
|
-
module ActiveRecord
|
3
|
-
module Backports
|
4
|
-
def self.included(base)
|
5
|
-
base.class_eval do
|
6
|
-
named_scope :where, lambda { |conditions| { :conditions => conditions } }
|
7
|
-
named_scope :joins, lambda { |joins| { :joins => joins } }
|
8
|
-
named_scope :group, lambda { |group| { :group => group } }
|
9
|
-
named_scope :order, lambda { |order| { :order => order } }
|
10
|
-
named_scope :select, lambda { |select| { :select => select } }
|
11
|
-
named_scope :limit, lambda { |limit| { :limit => limit } }
|
12
|
-
named_scope :readonly, lambda { |readonly| { :readonly => readonly } }
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
module ActsAsTaggableOn
|
2
|
-
module Taggable
|
3
|
-
module PostgreSQL
|
4
|
-
def self.included(base)
|
5
|
-
base.send :include, ActsAsTaggableOn::Taggable::PostgreSQL::InstanceMethods
|
6
|
-
base.extend ActsAsTaggableOn::Taggable::PostgreSQL::ClassMethods
|
7
|
-
|
8
|
-
ActsAsTaggableOn::Tag.class_eval do
|
9
|
-
def self.named(name)
|
10
|
-
where(["name ILIKE ?", name])
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.named_any(list)
|
14
|
-
where(list.map { |tag| sanitize_sql(["name ILIKE ?", tag.to_s]) }.join(" OR "))
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.named_like(name)
|
18
|
-
where(["name ILIKE ?", "%#{name}%"])
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.named_like_any(list)
|
22
|
-
where(list.map { |tag| sanitize_sql(["name ILIKE ?", "%#{tag.to_s}%"]) }.join(" OR "))
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
module InstanceMethods
|
28
|
-
end
|
29
|
-
|
30
|
-
module ClassMethods
|
31
|
-
# all column names are necessary for PostgreSQL group clause
|
32
|
-
def grouped_column_names_for(*objects)
|
33
|
-
object = objects.shift
|
34
|
-
columns = object.column_names.map { |column| "#{object.table_name}.#{column}" }
|
35
|
-
columns << objects.map do |object|
|
36
|
-
"#{object.table_name}.created_at"
|
37
|
-
end.flatten
|
38
|
-
|
39
|
-
columns.flatten.join(", ")
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
data/spec/database.yml
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
sqlite3:
|
2
|
-
adapter: sqlite3
|
3
|
-
database: acts_as_taggable_on.sqlite3
|
4
|
-
|
5
|
-
mysql:
|
6
|
-
adapter: mysql
|
7
|
-
hostname: localhost
|
8
|
-
username: root
|
9
|
-
password:
|
10
|
-
database: acts_as_taggable_on
|
11
|
-
|
12
|
-
postgresql:
|
13
|
-
adapter: postgresql
|
14
|
-
hostname: localhost
|
15
|
-
username: postgres
|
16
|
-
password:
|
17
|
-
database: acts_as_taggable_on
|