bbenezech-acts-as-taggable-on 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +23 -0
- data/MIT-LICENSE +22 -0
- data/README.rdoc +219 -0
- data/Rakefile +30 -0
- data/VERSION +1 -0
- data/lib/acts-as-taggable-on.rb +17 -0
- data/lib/acts_as_taggable_on/acts_as_taggable_on.rb +405 -0
- data/lib/acts_as_taggable_on/acts_as_tagger.rb +52 -0
- data/lib/acts_as_taggable_on/group_helper.rb +12 -0
- data/lib/acts_as_taggable_on/tag.rb +27 -0
- data/lib/acts_as_taggable_on/tag_list.rb +95 -0
- data/lib/acts_as_taggable_on/tagging.rb +11 -0
- data/lib/acts_as_taggable_on/tags_helper.rb +13 -0
- data/rails/init.rb +5 -0
- data/spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb +207 -0
- data/spec/acts_as_taggable_on/acts_as_tagger_spec.rb +72 -0
- data/spec/acts_as_taggable_on/group_helper_spec.rb +18 -0
- data/spec/acts_as_taggable_on/tag_list_spec.rb +64 -0
- data/spec/acts_as_taggable_on/tag_spec.rb +73 -0
- data/spec/acts_as_taggable_on/taggable_spec.rb +252 -0
- data/spec/acts_as_taggable_on/tagger_spec.rb +23 -0
- data/spec/acts_as_taggable_on/tagging_spec.rb +25 -0
- data/spec/acts_as_taggable_on/tags_helper_spec.rb +30 -0
- data/spec/schema.rb +33 -0
- data/spec/spec.opts +3 -0
- data/spec/spec_helper.rb +56 -0
- metadata +99 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe TagsHelper do
|
4
|
+
before(:each) do
|
5
|
+
[TaggableModel, Tag, Tagging].each(&:delete_all)
|
6
|
+
|
7
|
+
@bob = TaggableModel.create(:name => "Bob Jones", :language_list => "ruby, php")
|
8
|
+
@tom = TaggableModel.create(:name => "Tom Marley", :language_list => "ruby, java")
|
9
|
+
@eve = TaggableModel.create(:name => "Eve Nodd", :language_list => "ruby, c++")
|
10
|
+
|
11
|
+
@helper = class Helper
|
12
|
+
include TagsHelper
|
13
|
+
end.new
|
14
|
+
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should yield the proper css classes" do
|
19
|
+
tags = { }
|
20
|
+
|
21
|
+
@helper.tag_cloud(TaggableModel.tag_counts_on(:languages), ["sucky", "awesome"]) do |tag, css_class|
|
22
|
+
tags[tag.name] = css_class
|
23
|
+
end
|
24
|
+
|
25
|
+
tags["ruby"].should == "awesome"
|
26
|
+
tags["java"].should == "sucky"
|
27
|
+
tags["c++"].should == "sucky"
|
28
|
+
tags["php"].should == "sucky"
|
29
|
+
end
|
30
|
+
end
|
data/spec/schema.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
ActiveRecord::Schema.define :version => 0 do
|
2
|
+
create_table "v2_taggings", :force => true do |t|
|
3
|
+
t.integer "tag_id", :limit => 11
|
4
|
+
t.integer "taggable_id", :limit => 11
|
5
|
+
t.string "taggable_type"
|
6
|
+
t.string "context"
|
7
|
+
t.integer "position"
|
8
|
+
t.datetime "created_at"
|
9
|
+
t.integer "tagger_id", :limit => 11
|
10
|
+
t.string "tagger_type"
|
11
|
+
end
|
12
|
+
|
13
|
+
add_index "v2_taggings", ["tag_id"], :name => "index_taggings_on_tag_id"
|
14
|
+
add_index "v2_taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context"
|
15
|
+
|
16
|
+
create_table "v2_tags", :force => true do |t|
|
17
|
+
t.string "name"
|
18
|
+
end
|
19
|
+
|
20
|
+
create_table :taggable_models, :force => true do |t|
|
21
|
+
t.column :name, :string
|
22
|
+
t.column :type, :string
|
23
|
+
#t.column :cached_tag_list, :string
|
24
|
+
end
|
25
|
+
create_table :taggable_users, :force => true do |t|
|
26
|
+
t.column :name, :string
|
27
|
+
end
|
28
|
+
create_table :other_taggable_models, :force => true do |t|
|
29
|
+
t.column :name, :string
|
30
|
+
t.column :type, :string
|
31
|
+
#t.column :cached_tag_list, :string
|
32
|
+
end
|
33
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# require File.dirname(__FILE__) + '/../../../../spec/spec_helper'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'activerecord'
|
4
|
+
require 'spec'
|
5
|
+
|
6
|
+
module Spec::Example::ExampleGroupMethods
|
7
|
+
alias :context :describe
|
8
|
+
end
|
9
|
+
|
10
|
+
class Array
|
11
|
+
def freq
|
12
|
+
k=Hash.new(0)
|
13
|
+
each {|e| k[e]+=1}
|
14
|
+
k
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
TEST_DATABASE_FILE = File.join(File.dirname(__FILE__), '..', 'test.sqlite3')
|
19
|
+
|
20
|
+
File.unlink(TEST_DATABASE_FILE) if File.exist?(TEST_DATABASE_FILE)
|
21
|
+
ActiveRecord::Base.establish_connection(
|
22
|
+
"adapter" => "sqlite3", "database" => TEST_DATABASE_FILE
|
23
|
+
)
|
24
|
+
|
25
|
+
RAILS_DEFAULT_LOGGER = Logger.new(File.join(File.dirname(__FILE__), "debug.log"))
|
26
|
+
|
27
|
+
load(File.dirname(__FILE__) + '/schema.rb')
|
28
|
+
|
29
|
+
$: << File.join(File.dirname(__FILE__), '..', 'lib')
|
30
|
+
require File.join(File.dirname(__FILE__), '..', 'init')
|
31
|
+
|
32
|
+
class TaggableModel < ActiveRecord::Base
|
33
|
+
acts_as_taggable
|
34
|
+
acts_as_taggable_on :languages
|
35
|
+
acts_as_taggable_on :skills
|
36
|
+
acts_as_taggable_on :needs, :offerings
|
37
|
+
end
|
38
|
+
|
39
|
+
class OtherTaggableModel < ActiveRecord::Base
|
40
|
+
acts_as_taggable_on :tags, :languages
|
41
|
+
acts_as_taggable_on :needs, :offerings
|
42
|
+
end
|
43
|
+
|
44
|
+
class InheritingTaggableModel < TaggableModel
|
45
|
+
end
|
46
|
+
|
47
|
+
class AlteredInheritingTaggableModel < TaggableModel
|
48
|
+
acts_as_taggable_on :parts
|
49
|
+
end
|
50
|
+
|
51
|
+
class TaggableUser < ActiveRecord::Base
|
52
|
+
acts_as_tagger
|
53
|
+
end
|
54
|
+
|
55
|
+
class UntaggableModel < ActiveRecord::Base
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bbenezech-acts-as-taggable-on
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "Benoit B\xC3\xA9n\xC3\xA9zech"
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-01-04 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: acts_as_list
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description: Based on ActsAsTaggableOn
|
26
|
+
email: benoit.benezech@gmail.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README.rdoc
|
33
|
+
files:
|
34
|
+
- CHANGELOG
|
35
|
+
- MIT-LICENSE
|
36
|
+
- README.rdoc
|
37
|
+
- Rakefile
|
38
|
+
- VERSION
|
39
|
+
- lib/acts-as-taggable-on.rb
|
40
|
+
- lib/acts_as_taggable_on/acts_as_taggable_on.rb
|
41
|
+
- lib/acts_as_taggable_on/acts_as_tagger.rb
|
42
|
+
- lib/acts_as_taggable_on/group_helper.rb
|
43
|
+
- lib/acts_as_taggable_on/tag.rb
|
44
|
+
- lib/acts_as_taggable_on/tag_list.rb
|
45
|
+
- lib/acts_as_taggable_on/tagging.rb
|
46
|
+
- lib/acts_as_taggable_on/tags_helper.rb
|
47
|
+
- rails/init.rb
|
48
|
+
- spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb
|
49
|
+
- spec/acts_as_taggable_on/acts_as_tagger_spec.rb
|
50
|
+
- spec/acts_as_taggable_on/group_helper_spec.rb
|
51
|
+
- spec/acts_as_taggable_on/tag_list_spec.rb
|
52
|
+
- spec/acts_as_taggable_on/tag_spec.rb
|
53
|
+
- spec/acts_as_taggable_on/taggable_spec.rb
|
54
|
+
- spec/acts_as_taggable_on/tagger_spec.rb
|
55
|
+
- spec/acts_as_taggable_on/tagging_spec.rb
|
56
|
+
- spec/acts_as_taggable_on/tags_helper_spec.rb
|
57
|
+
- spec/schema.rb
|
58
|
+
- spec/spec.opts
|
59
|
+
- spec/spec_helper.rb
|
60
|
+
has_rdoc: true
|
61
|
+
homepage: http://github.com/bbenezech/acts-as-taggable-on
|
62
|
+
licenses: []
|
63
|
+
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options:
|
66
|
+
- --charset=UTF-8
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
74
|
+
version:
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: "0"
|
80
|
+
version:
|
81
|
+
requirements: []
|
82
|
+
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 1.3.5
|
85
|
+
signing_key:
|
86
|
+
specification_version: 3
|
87
|
+
summary: Based on ActsAsTaggableOn
|
88
|
+
test_files:
|
89
|
+
- spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb
|
90
|
+
- spec/acts_as_taggable_on/acts_as_tagger_spec.rb
|
91
|
+
- spec/acts_as_taggable_on/group_helper_spec.rb
|
92
|
+
- spec/acts_as_taggable_on/tag_list_spec.rb
|
93
|
+
- spec/acts_as_taggable_on/tag_spec.rb
|
94
|
+
- spec/acts_as_taggable_on/taggable_spec.rb
|
95
|
+
- spec/acts_as_taggable_on/tagger_spec.rb
|
96
|
+
- spec/acts_as_taggable_on/tagging_spec.rb
|
97
|
+
- spec/acts_as_taggable_on/tags_helper_spec.rb
|
98
|
+
- spec/schema.rb
|
99
|
+
- spec/spec_helper.rb
|