acts-as-taggable-on-padrino 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == 2011-06-30
2
+
3
+ * Simplified code, should now work as described in te docs.
4
+
1
5
  == 2011-06-20
2
6
 
3
7
  * Converted to Padrino compatible Gem
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{acts-as-taggable-on-padrino}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Bleigh", "John Knott"]
12
- s.date = %q{2011-06-29}
12
+ s.date = %q{2011-06-30}
13
13
  s.description = %q{Padrino version of the popular Rails tagging plugin. With ActsAsTaggableOnPadrino, you could tag a single model on several contexts, such as skills, interests, and awards. It also provides other advanced functionality.}
14
14
  s.email = %q{john.knott@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -47,7 +47,6 @@ Gem::Specification.new do |s|
47
47
  "spec/acts_as_taggable_on_padrino/tagging_spec.rb",
48
48
  "spec/acts_as_taggable_on_padrino/tags_helper_spec.rb",
49
49
  "spec/bm.rb",
50
- "spec/database.yml.sample",
51
50
  "spec/models.rb",
52
51
  "spec/schema.rb",
53
52
  "spec/spec_helper.rb",
@@ -18,16 +18,14 @@ require "acts_as_taggable_on_padrino/tagging"
18
18
 
19
19
  $LOAD_PATH.shift
20
20
 
21
- ActiveRecord::Base.extend ActsAsTaggableOn::Taggable
22
- ActiveRecord::Base.extend ActsAsTaggableOn::Tagger
23
- ActiveRecord::Base.extend ActsAsTaggableOn::Tag
24
- ActiveRecord::Base.extend ActsAsTaggableOn::Tagging
21
+ ActiveRecord::Base.extend ActsAsTaggableOnPadrino::Taggable
22
+ ActiveRecord::Base.extend ActsAsTaggableOnPadrino::Tagger
25
23
 
26
24
  if defined?(Padrino::Helpers::TagHelpers)
27
- Padrino::Helpers::TagHelpers.send :include, ActsAsTaggableOn::TagsHelper
25
+ Padrino::Helpers::TagHelpers.send :include, ActsAsTaggableOnPadrino::TagsHelper
28
26
  end
29
27
 
30
- module ActsAsTaggableOn
28
+ module ActsAsTaggableOnPadrino
31
29
  def like_operator
32
30
  @like_operator ||= (ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' ? 'ILIKE' : 'LIKE')
33
31
  end
@@ -1,32 +1,32 @@
1
- module ActsAsTaggableOn
2
- module Tag
3
- def acts_as_tag(opts = {})
4
- opts.assert_valid_keys :tagging
5
- tagging_class_name = opts[:tagging] || 'Tagging'
1
+ module ActsAsTaggableOnPadrino
2
+ class Tag < ::ActiveRecord::Base
3
+ attr_accessible :name
6
4
 
7
- class_eval do
8
- attr_accessible :name
5
+ ### ASSOCIATIONS:
9
6
 
10
- ### ASSOCIATIONS:
7
+ has_many :taggings, :dependent => :destroy, :class_name => 'ActsAsTaggableOnPadrino::Tagging'
11
8
 
12
- has_many :taggings, :dependent => :destroy, :class_name => tagging_class_name
9
+ ### VALIDATIONS:
10
+ validates_presence_of :name
11
+ validates_uniqueness_of :name
13
12
 
14
- ### VALIDATIONS:
15
- validates_presence_of :name
16
- validates_uniqueness_of :name
13
+ ### SCOPES:
14
+ # Override this with 'ILIKE' for case-insensitive operation on postgres
15
+ cattr_accessor :like_operator
16
+ self.like_operator = 'LIKE'
17
17
 
18
- ### SCOPES:
19
- scope :named, lambda {|name| where(["name #{ActsAsTaggableOn.like_operator} ?", name]) }
20
- scope :named_any, lambda {|list| where(list.map { |tag| sanitize_sql(["name #{ActsAsTaggableOn.like_operator} ?", tag.to_s]) }.join(" OR ")) }
21
- scope :named_like, lambda {|name| where(["name #{ActsAsTaggableOn.like_operator} ?", "%#{name}%"]) }
22
- scope :named_like_any, lambda {|list| where(list.map { |tag| sanitize_sql(["name #{ActsAsTaggableOn.like_operator} ?", "%#{tag.to_s}%"]) }.join(" OR ")) }
23
- end
18
+ scope :named, lambda {|name| where(["name #{like_operator} ?", name]) }
19
+ scope :named_any, lambda {|list| where(list.map { |tag| sanitize_sql(["name #{like_operator} ?", tag.to_s]) }.join(" OR ")) }
20
+ scope :named_like, lambda {|name| where(["name #{like_operator} ?", "%#{name}%"]) }
21
+ scope :named_like_any, lambda {|list| where(list.map { |tag| sanitize_sql(["name #{like_operator} ?", "%#{tag.to_s}%"]) }.join(" OR ")) }
24
22
 
25
- include ActsAsTaggableOn::Tag::InstanceMethods
26
- extend ActsAsTaggableOn::Tag::ClassMethods
27
- end
23
+ ### CLASS METHODS:
24
+
25
+ class << self
26
+ def using_postgresql?
27
+ connection.adapter_name == 'PostgreSQL'
28
+ end
28
29
 
29
- module ClassMethods
30
30
  def find_or_create_with_like_by_name(name)
31
31
  named_like(name).first || create(:name => name)
32
32
  end
@@ -35,12 +35,12 @@ module ActsAsTaggableOn
35
35
  list = list.flatten
36
36
  return [] if list.empty?
37
37
 
38
- existing_tags = named_any(list)
38
+ existing_tags = Tag.named_any(list)
39
39
  new_tag_names = list.reject do |name|
40
40
  name = comparable_name(name)
41
41
  existing_tags.any? { |tag| comparable_name(tag.name) == name }
42
42
  end
43
- created_tags = new_tag_names.map { |name| create(:name => name) }
43
+ created_tags = new_tag_names.map { |name| Tag.create(:name => name) }
44
44
 
45
45
  existing_tags + created_tags
46
46
  end
@@ -55,18 +55,18 @@ module ActsAsTaggableOn
55
55
  end
56
56
  end
57
57
 
58
- module InstanceMethods
59
- def ==(object)
60
- super || (object.is_a?(self.class) && name == object.name)
61
- end
58
+ ### INSTANCE METHODS:
62
59
 
63
- def to_s
64
- name
65
- end
60
+ def ==(object)
61
+ super || (object.is_a?(Tag) && name == object.name)
62
+ end
66
63
 
67
- def count
68
- read_attribute(:count).to_i
69
- end
64
+ def to_s
65
+ name
66
+ end
67
+
68
+ def count
69
+ read_attribute(:count).to_i
70
70
  end
71
71
  end
72
- end
72
+ end
@@ -1,18 +1,18 @@
1
- module ActsAsTaggableOn
1
+ module ActsAsTaggableOnPadrino
2
2
  module Taggable
3
3
  def taggable?
4
4
  false
5
5
  end
6
6
 
7
7
  ##
8
- # This is an alias for calling <tt>acts_as_taggable_on_padrino :tags</tt>.
8
+ # This is an alias for calling <tt>acts_as_taggable_on :tags</tt>.
9
9
  #
10
10
  # Example:
11
11
  # class Book < ActiveRecord::Base
12
12
  # acts_as_taggable
13
13
  # end
14
- def acts_as_taggable(opts = {})
15
- acts_as_taggable_on :tags, opts
14
+ def acts_as_taggable
15
+ acts_as_taggable_on :tags
16
16
  end
17
17
 
18
18
  ##
@@ -22,41 +22,34 @@ module ActsAsTaggableOn
22
22
  #
23
23
  # Example:
24
24
  # class User < ActiveRecord::Base
25
- # acts_as_taggable_on_padrino :languages, :skills
25
+ # acts_as_taggable_on :languages, :skills
26
26
  # end
27
27
  def acts_as_taggable_on(*tag_types)
28
- opts = tag_types.extract_options!
29
- opts.assert_valid_keys :tag, :tagging
30
-
31
28
  tag_types = tag_types.to_a.flatten.compact.map {|type| type.to_sym }
32
29
 
33
30
  if taggable?
34
31
  write_inheritable_attribute(:tag_types, (self.tag_types + tag_types).uniq)
35
32
  else
36
- opts.reverse_merge!(:tag => 'Tag', :tagging => 'Tagging')
37
- tag_class_name = opts[:tag]
38
- tagging_class_name = opts[:tagging]
39
- tag = tag_class_name.constantize
40
- tagging = tagging_class_name.constantize
41
-
42
33
  write_inheritable_attribute(:tag_types, tag_types)
43
- write_inheritable_attribute(:acts_as_taggable_on_tag_model, tag)
44
- write_inheritable_attribute(:acts_as_taggable_on_tagging_model, tagging)
45
- class_inheritable_reader(:tag_types, :acts_as_taggable_on_tagging_model, :acts_as_taggable_on_tag_model)
34
+ write_inheritable_attribute(:tag_table_name, ActsAsTaggableOnPadrino::Tag.table_name)
35
+ write_inheritable_attribute(:tagging_table_name, ActsAsTaggableOnPadrino::Tagging.table_name)
36
+ class_inheritable_reader(:tag_types, :tag_table_name, :tagging_table_name)
37
+
38
+ Tag.like_operator = 'ILIKE' if Tag.using_postgresql?
46
39
 
47
40
  class_eval do
48
- has_many :taggings, :as => :taggable, :dependent => :destroy, :include => :tag, :class_name => tagging_class_name
49
- has_many :base_tags, :through => :taggings, :source => :tag, :class_name => tag_class_name
41
+ has_many :taggings, :as => :taggable, :dependent => :destroy, :include => :tag, :class_name => "ActsAsTaggableOnPadrino::Tagging"
42
+ has_many :base_tags, :through => :taggings, :source => :tag, :class_name => "ActsAsTaggableOnPadrino::Tag"
50
43
 
51
44
  def self.taggable?
52
45
  true
53
46
  end
54
47
 
55
- include ActsAsTaggableOn::Taggable::Core
56
- include ActsAsTaggableOn::Taggable::Collection
57
- include ActsAsTaggableOn::Taggable::Cache
58
- include ActsAsTaggableOn::Taggable::Ownership
59
- include ActsAsTaggableOn::Taggable::Related
48
+ include ActsAsTaggableOnPadrino::Taggable::Core
49
+ include ActsAsTaggableOnPadrino::Taggable::Collection
50
+ include ActsAsTaggableOnPadrino::Taggable::Cache
51
+ include ActsAsTaggableOnPadrino::Taggable::Ownership
52
+ include ActsAsTaggableOnPadrino::Taggable::Related
60
53
  end
61
54
  end
62
55
  end
@@ -1,11 +1,11 @@
1
- module ActsAsTaggableOn::Taggable
1
+ module ActsAsTaggableOnPadrino::Taggable
2
2
  module Cache
3
3
  def self.included(base)
4
4
  # Skip adding caching capabilities if table not exists or no cache columns exist
5
5
  return unless base.table_exists? && base.tag_types.any? { |context| base.column_names.include?("cached_#{context.to_s.singularize}_list") }
6
6
 
7
- base.send :include, ActsAsTaggableOn::Taggable::Cache::InstanceMethods
8
- base.extend ActsAsTaggableOn::Taggable::Cache::ClassMethods
7
+ base.send :include, ActsAsTaggableOnPadrino::Taggable::Cache::InstanceMethods
8
+ base.extend ActsAsTaggableOnPadrino::Taggable::Cache::ClassMethods
9
9
 
10
10
  base.class_eval do
11
11
  before_save :save_cached_tag_list
@@ -1,8 +1,8 @@
1
- module ActsAsTaggableOn::Taggable
1
+ module ActsAsTaggableOnPadrino::Taggable
2
2
  module Collection
3
3
  def self.included(base)
4
- base.send :include, ActsAsTaggableOn::Taggable::Collection::InstanceMethods
5
- base.extend ActsAsTaggableOn::Taggable::Collection::ClassMethods
4
+ base.send :include, ActsAsTaggableOnPadrino::Taggable::Collection::InstanceMethods
5
+ base.extend ActsAsTaggableOnPadrino::Taggable::Collection::ClassMethods
6
6
  base.initialize_acts_as_taggable_on_collection
7
7
  end
8
8
 
@@ -55,26 +55,26 @@ module ActsAsTaggableOn::Taggable
55
55
  options.assert_valid_keys :start_at, :end_at, :conditions, :at_least, :at_most, :order, :limit, :on, :id
56
56
 
57
57
  ## Generate scope:
58
- tagging_scope = acts_as_taggable_on_tagging_model.select("#{acts_as_taggable_on_tagging_model.table_name}.tag_id, COUNT(#{acts_as_taggable_on_tagging_model.table_name}.tag_id) AS tags_count").
59
- joins("INNER JOIN #{table_name} ON #{table_name}.#{primary_key} = #{acts_as_taggable_on_tagging_model.table_name}.taggable_id").
58
+ tagging_scope = ActsAsTaggableOnPadrino::Tagging.select("#{tagging_table_name}.tag_id, COUNT(#{tagging_table_name}.tag_id) AS tags_count").
59
+ joins("INNER JOIN #{table_name} ON #{table_name}.#{primary_key} = #{tagging_table_name}.taggable_id").
60
60
  where(:taggable_type => base_class.name)
61
61
  tagging_scope = tagging_scope.where(table_name => {inheritance_column => name}) unless descends_from_active_record? # Current model is STI descendant, so add type checking to the join condition
62
62
  tagging_scope = tagging_scope.where(:taggable_id => options.delete(:id)) if options[:id]
63
63
  tagging_scope = tagging_scope.where(:context => options.delete(:on).to_s) if options[:on]
64
- tagging_scope = tagging_scope.where(["#{acts_as_taggable_on_tagging_model.table_name}.created_at >= ?", options.delete(:start_at)]) if options[:start_at]
65
- tagging_scope = tagging_scope.where(["#{acts_as_taggable_on_tagging_model.table_name}.created_at <= ?", options.delete(:end_at)]) if options[:end_at]
64
+ tagging_scope = tagging_scope.where(["#{tagging_table_name}.created_at >= ?", options.delete(:start_at)]) if options[:start_at]
65
+ tagging_scope = tagging_scope.where(["#{tagging_table_name}.created_at <= ?", options.delete(:end_at)]) if options[:end_at]
66
66
 
67
- tag_scope = acts_as_taggable_on_tag_model.select("#{acts_as_taggable_on_tag_model.table_name}.*, #{acts_as_taggable_on_tagging_model.table_name}.tags_count AS count").order(options[:order]).limit(options[:limit])
67
+ tag_scope = ActsAsTaggableOnPadrino::Tag.select("#{tag_table_name}.*, #{tagging_table_name}.tags_count AS count").order(options[:order]).limit(options[:limit])
68
68
  tag_scope.where(options[:conditions]) if options[:conditions]
69
69
 
70
70
  # GROUP BY and HAVING clauses:
71
71
  at_least = sanitize_sql(['tags_count >= ?', options.delete(:at_least)]) if options[:at_least]
72
72
  at_most = sanitize_sql(['tags_count <= ?', options.delete(:at_most)]) if options[:at_most]
73
- having = ["COUNT(#{acts_as_taggable_on_tagging_model.table_name}.tag_id) > 0", at_least, at_most].compact.join(' AND ')
73
+ having = ["COUNT(#{tagging_table_name}.tag_id) > 0", at_least, at_most].compact.join(' AND ')
74
74
 
75
75
  # Append the current scope to the scope, because we can't use scope(:find) in RoR 3.0 anymore:
76
76
  tagging_scope = tagging_scope.where(:taggable_id => select("#{table_name}.#{primary_key}")).
77
- group("#{acts_as_taggable_on_tagging_model.table_name}.tag_id").
77
+ group("#{tagging_table_name}.tag_id").
78
78
  having(having)
79
79
 
80
80
  tag_scope = tag_scope.joins("JOIN (#{tagging_scope.to_sql}) AS taggings ON taggings.tag_id = tags.id")
@@ -1,8 +1,8 @@
1
- module ActsAsTaggableOn::Taggable
1
+ module ActsAsTaggableOnPadrino::Taggable
2
2
  module Core
3
3
  def self.included(base)
4
- base.send :include, ActsAsTaggableOn::Taggable::Core::InstanceMethods
5
- base.extend ActsAsTaggableOn::Taggable::Core::ClassMethods
4
+ base.send :include, ActsAsTaggableOnPadrino::Taggable::Core::InstanceMethods
5
+ base.extend ActsAsTaggableOnPadrino::Taggable::Core::ClassMethods
6
6
 
7
7
  base.class_eval do
8
8
  attr_writer :custom_contexts
@@ -20,9 +20,9 @@ module ActsAsTaggableOn::Taggable
20
20
  context_tags = tags_type.to_sym
21
21
 
22
22
  class_eval do
23
- has_many context_taggings, :as => :taggable, :dependent => :destroy, :include => :tag, :class_name => acts_as_taggable_on_tagging_model.name,
24
- :conditions => ["#{acts_as_taggable_on_tagging_model.table_name}.tag_id = #{acts_as_taggable_on_tag_model.table_name}.id AND #{acts_as_taggable_on_tagging_model.table_name}.context = ?", tags_type]
25
- has_many context_tags, :through => context_taggings, :source => :tag, :class_name => acts_as_taggable_on_tag_model.name
23
+ has_many context_taggings, :as => :taggable, :dependent => :destroy, :include => :tag, :class_name => "ActsAsTaggableOnPadrino::Tagging",
24
+ :conditions => ["#{tagging_table_name}.tag_id = #{tag_table_name}.id AND #{tagging_table_name}.context = ?", tags_type]
25
+ has_many context_tags, :through => context_taggings, :source => :tag, :class_name => "ActsAsTaggableOnPadrino::Tag"
26
26
  end
27
27
 
28
28
  class_eval %(
@@ -48,7 +48,7 @@ module ActsAsTaggableOn::Taggable
48
48
 
49
49
  # all column names are necessary for PostgreSQL group clause
50
50
  def grouped_column_names_for(object)
51
- if object.connection.adapter_name == 'PostgreSQL'
51
+ if ActsAsTaggableOnPadrino::Tag.using_postgresql?
52
52
  object.column_names.map { |column| "#{object.table_name}.#{column}" }.join(", ")
53
53
  else
54
54
  "#{object.table_name}.#{object.primary_key}"
@@ -70,7 +70,7 @@ module ActsAsTaggableOn::Taggable
70
70
  # User.tagged_with("awesome", "cool", :any => true) # Users that are tagged with awesome or cool
71
71
  # User.tagged_with("awesome", "cool", :match_all => true) # Users that are tagged with just awesome and cool
72
72
  def tagged_with(tags, options = {})
73
- tag_list = ActsAsTaggableOn::Taggable::TagList.from(tags)
73
+ tag_list = ActsAsTaggableOnPadrino::Taggable::TagList.from(tags)
74
74
 
75
75
  return {} if tag_list.empty?
76
76
 
@@ -80,15 +80,15 @@ module ActsAsTaggableOn::Taggable
80
80
  context = options.delete(:on)
81
81
 
82
82
  if options.delete(:exclude)
83
- tags_conditions = tag_list.map { |t| sanitize_sql(["#{acts_as_taggable_on_tag_model.table_name}.name #{ActsAsTaggableOn.like_operator} ?", t]) }.join(" OR ")
84
- conditions << "#{table_name}.#{primary_key} NOT IN (SELECT #{acts_as_taggable_on_tagging_model.table_name}.taggable_id FROM #{acts_as_taggable_on_tagging_model.table_name} JOIN #{acts_as_taggable_on_tag_model.table_name} ON #{acts_as_taggable_on_tagging_model.table_name}.tag_id = #{acts_as_taggable_on_tag_model.table_name}.id AND (#{tags_conditions}) WHERE #{acts_as_taggable_on_tagging_model.table_name}.taggable_type = #{quote_value(base_class.name)})"
83
+ tags_conditions = tag_list.map { |t| sanitize_sql(["#{tag_table_name}.name #{ActsAsTaggableOnPadrino::Tag.like_operator} ?", t]) }.join(" OR ")
84
+ conditions << "#{table_name}.#{primary_key} NOT IN (SELECT #{tagging_table_name}.taggable_id FROM #{tagging_table_name} JOIN #{tag_table_name} ON #{tagging_table_name}.tag_id = #{tag_table_name}.id AND (#{tags_conditions}) WHERE #{tagging_table_name}.taggable_type = #{quote_value(base_class.name)})"
85
85
 
86
86
  elsif options.delete(:any)
87
- tags_conditions = tag_list.map { |t| sanitize_sql(["#{acts_as_taggable_on_tag_model.table_name}.name #{ActsAsTaggableOn.like_operator} ?", t]) }.join(" OR ")
88
- conditions << "#{table_name}.#{primary_key} IN (SELECT #{acts_as_taggable_on_tagging_model.table_name}.taggable_id FROM #{acts_as_taggable_on_tagging_model.table_name} JOIN #{acts_as_taggable_on_tag_model.table_name} ON #{acts_as_taggable_on_tagging_model.table_name}.tag_id = #{acts_as_taggable_on_tag_model.table_name}.id AND (#{tags_conditions}) WHERE #{acts_as_taggable_on_tagging_model.table_name}.taggable_type = #{quote_value(base_class.name)})"
87
+ tags_conditions = tag_list.map { |t| sanitize_sql(["#{tag_table_name}.name #{ActsAsTaggableOnPadrino::Tag.like_operator} ?", t]) }.join(" OR ")
88
+ conditions << "#{table_name}.#{primary_key} IN (SELECT #{tagging_table_name}.taggable_id FROM #{tagging_table_name} JOIN #{tag_table_name} ON #{tagging_table_name}.tag_id = #{tag_table_name}.id AND (#{tags_conditions}) WHERE #{tagging_table_name}.taggable_type = #{quote_value(base_class.name)})"
89
89
 
90
90
  else
91
- tags = acts_as_taggable_on_tag_model.named_any(tag_list)
91
+ tags = ActsAsTaggableOnPadrino::Tag.named_any(tag_list)
92
92
  return where("1 = 0") unless tags.length == tag_list.length
93
93
 
94
94
  tags.each do |tag|
@@ -97,7 +97,7 @@ module ActsAsTaggableOn::Taggable
97
97
 
98
98
  taggings_alias = "#{undecorated_table_name}_taggings_#{prefix}"
99
99
 
100
- tagging_join = "JOIN #{acts_as_taggable_on_tagging_model.table_name} #{taggings_alias}" +
100
+ tagging_join = "JOIN #{tagging_table_name} #{taggings_alias}" +
101
101
  " ON #{taggings_alias}.taggable_id = #{table_name}.#{primary_key}" +
102
102
  " AND #{taggings_alias}.taggable_type = #{quote_value(base_class.name)}" +
103
103
  " AND #{taggings_alias}.tag_id = #{tag.id}"
@@ -110,7 +110,7 @@ module ActsAsTaggableOn::Taggable
110
110
  taggings_alias, tags_alias = "#{undecorated_table_name}_taggings_group", "#{undecorated_table_name}_tags_group"
111
111
 
112
112
  if options.delete(:match_all)
113
- joins << "LEFT OUTER JOIN #{acts_as_taggable_on_tagging_model.table_name} #{taggings_alias}" +
113
+ joins << "LEFT OUTER JOIN #{tagging_table_name} #{taggings_alias}" +
114
114
  " ON #{taggings_alias}.taggable_id = #{table_name}.#{primary_key}" +
115
115
  " AND #{taggings_alias}.taggable_type = #{quote_value(base_class.name)}"
116
116
 
@@ -160,7 +160,7 @@ module ActsAsTaggableOn::Taggable
160
160
 
161
161
  def tag_list_cache_on(context)
162
162
  variable_name = "@#{context.to_s.singularize}_list"
163
- instance_variable_get(variable_name) || instance_variable_set(variable_name, ActsAsTaggableOn::Taggable::TagList.new(tags_on(context).names))
163
+ instance_variable_get(variable_name) || instance_variable_set(variable_name, ActsAsTaggableOnPadrino::Taggable::TagList.new(tags_on(context).names))
164
164
  end
165
165
 
166
166
  def tag_list_on(context)
@@ -172,28 +172,28 @@ module ActsAsTaggableOn::Taggable
172
172
  variable_name = "@all_#{context.to_s.singularize}_list"
173
173
  return instance_variable_get(variable_name) if instance_variable_get(variable_name)
174
174
 
175
- instance_variable_set(variable_name, ActsAsTaggableOn::Taggable::TagList.new(all_tags_on(context).names).freeze)
175
+ instance_variable_set(variable_name, ActsAsTaggableOnPadrino::Taggable::TagList.new(all_tags_on(context).names).freeze)
176
176
  end
177
177
 
178
178
  ##
179
179
  # Returns all tags of a given context
180
180
  def all_tags_on(context)
181
181
  base_tags.where(:taggings => {:context => context.to_s}).
182
- group(grouped_column_names_for(acts_as_taggable_on_tag_model)).
183
- order("max(#{acts_as_taggable_on_tagging_model.table_name}.created_at)")
182
+ group(grouped_column_names_for(ActsAsTaggableOnPadrino::Tag)).
183
+ order("max(#{tagging_table_name}.created_at)")
184
184
  end
185
185
 
186
186
  ##
187
187
  # Returns all tags that are not owned of a given context
188
188
  def tags_on(context)
189
- base_tags.where(["#{acts_as_taggable_on_tagging_model.table_name}.context = ? AND #{acts_as_taggable_on_tagging_model.table_name}.tagger_id IS NULL", context.to_s])
189
+ base_tags.where(["#{tagging_table_name}.context = ? AND #{tagging_table_name}.tagger_id IS NULL", context.to_s])
190
190
  end
191
191
 
192
192
  def set_tag_list_on(context, new_list)
193
193
  add_custom_context(context)
194
194
 
195
195
  variable_name = "@#{context.to_s.singularize}_list"
196
- instance_variable_set(variable_name, ActsAsTaggableOn::Taggable::TagList.from(new_list))
196
+ instance_variable_set(variable_name, ActsAsTaggableOnPadrino::Taggable::TagList.from(new_list))
197
197
  end
198
198
 
199
199
  def tagging_contexts
@@ -216,7 +216,7 @@ module ActsAsTaggableOn::Taggable
216
216
  tag_list = tag_list_cache_on(context).uniq
217
217
 
218
218
  # Find existing tags or create non-existing tags:
219
- tag_list = acts_as_taggable_on_tag_model.find_or_create_all_with_like_by_name(tag_list)
219
+ tag_list = ActsAsTaggableOnPadrino::Tag.find_or_create_all_with_like_by_name(tag_list)
220
220
 
221
221
  current_tags = tags_on(context)
222
222
  old_tags = current_tags - tag_list
@@ -228,7 +228,7 @@ module ActsAsTaggableOn::Taggable
228
228
 
229
229
  if old_taggings.present?
230
230
  # Destroy old taggings:
231
- acts_as_taggable_on_tagging_model.destroy_all :id => old_taggings.map {|tagging| tagging.id }
231
+ ActsAsTaggableOnPadrino::Tagging.destroy_all :id => old_taggings.map {|tagging| tagging.id }
232
232
  end
233
233
 
234
234
  # Create new taggings:
@@ -1,8 +1,8 @@
1
- module ActsAsTaggableOn::Taggable
1
+ module ActsAsTaggableOnPadrino::Taggable
2
2
  module Ownership
3
3
  def self.included(base)
4
- base.send :include, ActsAsTaggableOn::Taggable::Ownership::InstanceMethods
5
- base.extend ActsAsTaggableOn::Taggable::Ownership::ClassMethods
4
+ base.send :include, ActsAsTaggableOnPadrino::Taggable::Ownership::InstanceMethods
5
+ base.extend ActsAsTaggableOnPadrino::Taggable::Ownership::ClassMethods
6
6
 
7
7
  base.class_eval do
8
8
  after_save :save_owned_tags
@@ -48,7 +48,7 @@ module ActsAsTaggableOn::Taggable
48
48
  cache = cached_owned_tag_list_on(context)
49
49
  cache.delete_if { |key, value| key.id == owner.id && key.class == owner.class }
50
50
 
51
- cache[owner] ||= ActsAsTaggableOn::Taggable::TagList.new(*owner_tags_on(owner, context).names)
51
+ cache[owner] ||= ActsAsTaggableOnPadrino::Taggable::TagList.new(*owner_tags_on(owner, context).names)
52
52
  end
53
53
 
54
54
  def set_owner_tag_list_on(owner, context, new_list)
@@ -57,7 +57,7 @@ module ActsAsTaggableOn::Taggable
57
57
  cache = cached_owned_tag_list_on(context)
58
58
  cache.delete_if { |key, value| key.id == owner.id && key.class == owner.class }
59
59
 
60
- cache[owner] = ActsAsTaggableOn::Taggable::TagList.from(new_list)
60
+ cache[owner] = ActsAsTaggableOnPadrino::Taggable::TagList.from(new_list)
61
61
  end
62
62
 
63
63
  def reload(*args)
@@ -72,7 +72,7 @@ module ActsAsTaggableOn::Taggable
72
72
  tagging_contexts.each do |context|
73
73
  cached_owned_tag_list_on(context).each do |owner, tag_list|
74
74
  # Find existing tags or create non-existing tags:
75
- tag_list = acts_as_taggable_on_tag_model.find_or_create_all_with_like_by_name(tag_list.uniq)
75
+ tag_list = ActsAsTaggableOnPadrino::Tag.find_or_create_all_with_like_by_name(tag_list.uniq)
76
76
 
77
77
  owned_tags = owner_tags_on(owner, context)
78
78
  old_tags = owned_tags - tag_list
@@ -80,14 +80,13 @@ module ActsAsTaggableOn::Taggable
80
80
 
81
81
  # Find all taggings that belong to the taggable (self), are owned by the owner,
82
82
  # have the correct context, and are removed from the list.
83
- old_taggings = acts_as_taggable_on_tagging_model.where(
84
- :taggable_id => id, :taggable_type => self.class.base_class.to_s,
85
- :tagger_type => owner.class.to_s, :tagger_id => owner.id,
86
- :tag_id => old_tags, :context => context)
83
+ old_taggings = ActsAsTaggableOnPadrino::Tagging.where(:taggable_id => id, :taggable_type => self.class.base_class.to_s,
84
+ :tagger_type => owner.class.to_s, :tagger_id => owner.id,
85
+ :tag_id => old_tags, :context => context)
87
86
 
88
87
  if old_taggings.present?
89
88
  # Destroy old taggings:
90
- acts_as_taggable_on_tagging_model.destroy_all(:id => old_taggings.map {|tagging| tagging.id })
89
+ ActsAsTaggableOnPadrino::Tagging.destroy_all(:id => old_taggings.map {|tagging| tagging.id })
91
90
  end
92
91
 
93
92
  # Create new taggings:
@@ -1,8 +1,8 @@
1
- module ActsAsTaggableOn::Taggable
1
+ module ActsAsTaggableOnPadrino::Taggable
2
2
  module Related
3
3
  def self.included(base)
4
- base.send :include, ActsAsTaggableOn::Taggable::Related::InstanceMethods
5
- base.extend ActsAsTaggableOn::Taggable::Related::ClassMethods
4
+ base.send :include, ActsAsTaggableOnPadrino::Taggable::Related::InstanceMethods
5
+ base.extend ActsAsTaggableOnPadrino::Taggable::Related::ClassMethods
6
6
  base.initialize_acts_as_taggable_on_related
7
7
  end
8
8
 
@@ -38,7 +38,7 @@ module ActsAsTaggableOn::Taggable
38
38
 
39
39
  module InstanceMethods
40
40
  def matching_contexts_for(search_context, result_context, klass)
41
- related_tags_for(search_context, klass).where("#{acts_as_taggable_on_tagging_model.table_name}.context = ?", result_context)
41
+ related_tags_for(search_context, klass).where("#{tagging_table_name}.context = ?", result_context)
42
42
  end
43
43
 
44
44
  def related_tags_for(context, klass)
@@ -46,12 +46,12 @@ module ActsAsTaggableOn::Taggable
46
46
 
47
47
  scope = klass.scoped
48
48
  scope = scope.where("#{klass.table_name}.id != ?", id) if self.class == klass # exclude self
49
- scope.select("#{klass.table_name}.*, COUNT(#{acts_as_taggable_on_tag_model.table_name}.id) AS count").
50
- from("#{klass.table_name}, #{acts_as_taggable_on_tag_model.table_name}, #{acts_as_taggable_on_tagging_model.table_name}").
51
- where("#{klass.table_name}.id = #{acts_as_taggable_on_tagging_model.table_name}.taggable_id").
52
- where("#{acts_as_taggable_on_tagging_model.table_name}.taggable_type = ?", klass.to_s).
53
- where("#{acts_as_taggable_on_tagging_model.table_name}.tag_id = #{acts_as_taggable_on_tag_model.table_name}.id").
54
- where("#{acts_as_taggable_on_tag_model.table_name}.name IN (?)", tags_to_find).
49
+ scope.select("#{klass.table_name}.*, COUNT(#{tag_table_name}.id) AS count").
50
+ from("#{klass.table_name}, #{tag_table_name}, #{tagging_table_name}").
51
+ where("#{klass.table_name}.id = #{tagging_table_name}.taggable_id").
52
+ where("#{tagging_table_name}.taggable_type = ?", klass.to_s).
53
+ where("#{tagging_table_name}.tag_id = #{tag_table_name}.id").
54
+ where("#{tag_table_name}.name IN (?)", tags_to_find).
55
55
  group(grouped_column_names_for(klass)).
56
56
  order("count DESC")
57
57
  end
@@ -1,4 +1,4 @@
1
- module ActsAsTaggableOn::Taggable
1
+ module ActsAsTaggableOnPadrino::Taggable
2
2
  class TagList < Array
3
3
  cattr_accessor :delimiter
4
4
  self.delimiter = ','
@@ -1,4 +1,4 @@
1
- module ActsAsTaggableOn
1
+ module ActsAsTaggableOnPadrino
2
2
  module Tagger
3
3
  ##
4
4
  # Make a model a tagger. This allows an instance of a model to claim ownership
@@ -9,18 +9,14 @@ module ActsAsTaggableOn
9
9
  # acts_as_tagger
10
10
  # end
11
11
  def acts_as_tagger(opts={})
12
- opts.assert_valid_keys :tagging, :tag
13
- tagging_class_name = opts[:tagging] || 'Tagging'
14
- tag_class_name = opts[:tag] || 'Tag'
15
-
16
12
  class_eval do
17
13
  has_many :owned_taggings, opts.merge(:as => :tagger, :dependent => :destroy,
18
- :include => :tag, :class_name => tagging_class_name)
19
- has_many :owned_tags, :through => :owned_taggings, :source => :tag, :uniq => true, :class_name => tag_class_name
14
+ :include => :tag, :class_name => "ActsAsTaggableOnPadrino::Tagging")
15
+ has_many :owned_tags, :through => :owned_taggings, :source => :tag, :uniq => true, :class_name => "ActsAsTaggableOnPadrino::Tag"
20
16
  end
21
17
 
22
- include ActsAsTaggableOn::Tagger::InstanceMethods
23
- extend ActsAsTaggableOn::Tagger::ClassMethods
18
+ include ActsAsTaggableOnPadrino::Tagger::InstanceMethods
19
+ extend ActsAsTaggableOnPadrino::Tagger::ClassMethods
24
20
  end
25
21
 
26
22
  def is_tagger?
@@ -1,29 +1,22 @@
1
- module ActsAsTaggableOn
2
- module Tagging
3
- def acts_as_tagging(opts = {})
4
- opts.assert_valid_keys :tag
5
- tag_class_name = opts[:tag] || 'Tag'
1
+ module ActsAsTaggableOnPadrino
2
+ class Tagging < ::ActiveRecord::Base #:nodoc:
3
+ attr_accessible :tag,
4
+ :tag_id,
5
+ :context,
6
+ :taggable,
7
+ :taggable_type,
8
+ :taggable_id,
9
+ :tagger,
10
+ :tagger_type,
11
+ :tagger_id
6
12
 
7
- class_eval do
8
- attr_accessible :tag,
9
- :tag_id,
10
- :context,
11
- :taggable,
12
- :taggable_type,
13
- :taggable_id,
14
- :tagger,
15
- :tagger_type,
16
- :tagger_id
13
+ belongs_to :tag, :class_name => 'ActsAsTaggableOnPadrino::Tag'
14
+ belongs_to :taggable, :polymorphic => true
15
+ belongs_to :tagger, :polymorphic => true
17
16
 
18
- belongs_to :tag, :class_name => tag_class_name
19
- belongs_to :taggable, :polymorphic => true
20
- belongs_to :tagger, :polymorphic => true
17
+ validates_presence_of :context
18
+ validates_presence_of :tag_id
21
19
 
22
- validates_presence_of :context
23
- validates_presence_of :tag_id
24
-
25
- validates_uniqueness_of :tag_id, :scope => [ :taggable_type, :taggable_id, :context, :tagger_id, :tagger_type ]
26
- end
27
- end
20
+ validates_uniqueness_of :tag_id, :scope => [ :taggable_type, :taggable_id, :context, :tagger_id, :tagger_type ]
28
21
  end
29
- end
22
+ end
@@ -1,4 +1,4 @@
1
- module ActsAsTaggableOn
1
+ module ActsAsTaggableOnPadrino
2
2
  module TagsHelper
3
3
  # See the README for an example using tag_cloud.
4
4
  def tag_cloud(tags, classes)
@@ -1,8 +1,8 @@
1
1
  require File.expand_path('../../spec_helper', __FILE__)
2
2
 
3
- describe ActsAsTaggableOn::Taggable::TagList do
3
+ describe ActsAsTaggableOnPadrino::Taggable::TagList do
4
4
  before(:each) do
5
- @tag_list = ActsAsTaggableOn::Taggable::TagList.new("awesome","radical")
5
+ @tag_list = ActsAsTaggableOnPadrino::Taggable::TagList.new("awesome","radical")
6
6
  end
7
7
 
8
8
  it "should be an array" do
@@ -1,19 +1,19 @@
1
1
  require File.expand_path('../../spec_helper', __FILE__)
2
2
 
3
- describe ActsAsTaggableOn::Tag do
3
+ describe ActsAsTaggableOnPadrino::Tag do
4
4
  before(:each) do
5
- @tag = TestTag.new
5
+ @tag = ActsAsTaggableOnPadrino::Tag.new
6
6
  @user = TaggableModel.create(:name => "Pablo")
7
7
  end
8
8
 
9
9
  describe "named like any" do
10
10
  before(:each) do
11
- TestTag.create(:name => "awesome")
12
- TestTag.create(:name => "epic")
11
+ ActsAsTaggableOnPadrino::Tag.create(:name => "awesome")
12
+ ActsAsTaggableOnPadrino::Tag.create(:name => "epic")
13
13
  end
14
14
 
15
15
  it "should find both tags" do
16
- TestTag.named_like_any(["awesome", "epic"]).should have(2).items
16
+ ActsAsTaggableOnPadrino::Tag.named_like_any(["awesome", "epic"]).should have(2).items
17
17
  end
18
18
  end
19
19
 
@@ -24,17 +24,17 @@ describe ActsAsTaggableOn::Tag do
24
24
  end
25
25
 
26
26
  it "should find by name" do
27
- TestTag.find_or_create_with_like_by_name("awesome").should == @tag
27
+ ActsAsTaggableOnPadrino::Tag.find_or_create_with_like_by_name("awesome").should == @tag
28
28
  end
29
29
 
30
30
  it "should find by name case insensitive" do
31
- TestTag.find_or_create_with_like_by_name("AWESOME").should == @tag
31
+ ActsAsTaggableOnPadrino::Tag.find_or_create_with_like_by_name("AWESOME").should == @tag
32
32
  end
33
33
 
34
34
  it "should create by name" do
35
35
  lambda {
36
- TestTag.find_or_create_with_like_by_name("epic")
37
- }.should change(TestTag, :count).by(1)
36
+ ActsAsTaggableOnPadrino::Tag.find_or_create_with_like_by_name("epic")
37
+ }.should change(ActsAsTaggableOnPadrino::Tag, :count).by(1)
38
38
  end
39
39
  end
40
40
 
@@ -45,27 +45,27 @@ describe ActsAsTaggableOn::Tag do
45
45
  end
46
46
 
47
47
  it "should find by name" do
48
- TestTag.find_or_create_all_with_like_by_name("awesome").should == [@tag]
48
+ ActsAsTaggableOnPadrino::Tag.find_or_create_all_with_like_by_name("awesome").should == [@tag]
49
49
  end
50
50
 
51
51
  it "should find by name case insensitive" do
52
- TestTag.find_or_create_all_with_like_by_name("AWESOME").should == [@tag]
52
+ ActsAsTaggableOnPadrino::Tag.find_or_create_all_with_like_by_name("AWESOME").should == [@tag]
53
53
  end
54
54
 
55
55
  it "should create by name" do
56
56
  lambda {
57
- TestTag.find_or_create_all_with_like_by_name("epic")
58
- }.should change(TestTag, :count).by(1)
57
+ ActsAsTaggableOnPadrino::Tag.find_or_create_all_with_like_by_name("epic")
58
+ }.should change(ActsAsTaggableOnPadrino::Tag, :count).by(1)
59
59
  end
60
60
 
61
61
  it "should find or create by name" do
62
62
  lambda {
63
- TestTag.find_or_create_all_with_like_by_name("awesome", "epic").map(&:name).should == ["awesome", "epic"]
64
- }.should change(TestTag, :count).by(1)
63
+ ActsAsTaggableOnPadrino::Tag.find_or_create_all_with_like_by_name("awesome", "epic").map(&:name).should == ["awesome", "epic"]
64
+ }.should change(ActsAsTaggableOnPadrino::Tag, :count).by(1)
65
65
  end
66
66
 
67
67
  it "should return an empty array if no tags are specified" do
68
- TestTag.find_or_create_all_with_like_by_name([]).should == []
68
+ ActsAsTaggableOnPadrino::Tag.find_or_create_all_with_like_by_name([]).should == []
69
69
  end
70
70
  end
71
71
 
@@ -81,7 +81,7 @@ describe ActsAsTaggableOn::Tag do
81
81
 
82
82
  it "should equal a tag with the same name" do
83
83
  @tag.name = "awesome"
84
- new_tag = TestTag.new(:name => "awesome")
84
+ new_tag = ActsAsTaggableOnPadrino::Tag.new(:name => "awesome")
85
85
  new_tag.should == @tag
86
86
  end
87
87
 
@@ -93,13 +93,13 @@ describe ActsAsTaggableOn::Tag do
93
93
  it "have named_scope named(something)" do
94
94
  @tag.name = "cool"
95
95
  @tag.save!
96
- TestTag.named('cool').should include(@tag)
96
+ ActsAsTaggableOnPadrino::Tag.named('cool').should include(@tag)
97
97
  end
98
98
 
99
99
  it "have named_scope named_like(something)" do
100
100
  @tag.name = "cool"
101
101
  @tag.save!
102
- @another_tag = TestTag.create!(:name => "coolip")
103
- TestTag.named_like('cool').should include(@tag, @another_tag)
102
+ @another_tag = ActsAsTaggableOnPadrino::Tag.create!(:name => "coolip")
103
+ ActsAsTaggableOnPadrino::Tag.named_like('cool').should include(@tag, @another_tag)
104
104
  end
105
105
  end
@@ -26,11 +26,11 @@ describe "Taggable" do
26
26
 
27
27
  it "should be able to create tags" do
28
28
  @taggable.skill_list = "ruby, rails, css"
29
- @taggable.instance_variable_get("@skill_list").instance_of?(ActsAsTaggableOn::Taggable::TagList).should be_true
29
+ @taggable.instance_variable_get("@skill_list").instance_of?(ActsAsTaggableOnPadrino::Taggable::TagList).should be_true
30
30
 
31
31
  lambda {
32
32
  @taggable.save
33
- }.should change(Tag, :count).by(3)
33
+ }.should change(ActsAsTaggableOnPadrino::Tag, :count).by(3)
34
34
 
35
35
  @taggable.reload
36
36
  @taggable.skill_list.sort.should == %w(ruby rails css).sort
@@ -106,7 +106,7 @@ describe "Taggable" do
106
106
  bob = TaggableModel.create(:name => "Bob", :tag_list => "ruby")
107
107
  frank = TaggableModel.create(:name => "Frank", :tag_list => "Ruby")
108
108
 
109
- Tag.find(:all).size.should == 1
109
+ ActsAsTaggableOnPadrino::Tag.find(:all).size.should == 1
110
110
  TaggableModel.tagged_with("ruby").to_a.should == TaggableModel.tagged_with("Ruby").to_a
111
111
  end
112
112
 
@@ -246,7 +246,7 @@ describe "Taggable" do
246
246
  bob.tag_list << "happier"
247
247
  bob.tag_list << "happier"
248
248
  bob.save
249
- }.should change(Tagging, :count).by(1)
249
+ }.should change(ActsAsTaggableOnPadrino::Tagging, :count).by(1)
250
250
  end
251
251
 
252
252
  describe "Associations" do
@@ -262,10 +262,10 @@ describe "Taggable" do
262
262
  end
263
263
 
264
264
  describe "grouped_column_names_for method" do
265
- if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
265
+ if ActsAsTaggableOnPadrino::Tag.using_postgresql?
266
266
  context "on postgres" do
267
267
  it "should return all column names joined for Tag" do
268
- @taggable.grouped_column_names_for(Tag).should == "tags.id, tags.name"
268
+ @taggable.grouped_column_names_for(ActsAsTaggableOnPadrino::Tag).should == "tags.id, tags.name"
269
269
  end
270
270
 
271
271
  it "should return all column names joined for TaggableModel" do
@@ -274,7 +274,7 @@ describe "Taggable" do
274
274
  end
275
275
  else
276
276
  it "should return the id column for Tag" do
277
- @taggable.grouped_column_names_for(Tag).should == "tags.id"
277
+ @taggable.grouped_column_names_for(ActsAsTaggableOnPadrino::Tag).should == "tags.id"
278
278
  end
279
279
 
280
280
  it "should return the id column for TaggableModel" do
@@ -21,7 +21,7 @@ describe "Tagger" do
21
21
  lambda{
22
22
  @user.tag(@taggable, :with => 'ruby, scheme', :on => :tags)
23
23
  @user2.tag(@taggable, :with => 'java, python, lisp, ruby', :on => :tags)
24
- }.should change(Tagging, :count).by(6)
24
+ }.should change(ActsAsTaggableOnPadrino::Tagging, :count).by(6)
25
25
 
26
26
  [@user, @user2, @taggable].each(&:reload)
27
27
 
@@ -42,7 +42,7 @@ describe "Tagger" do
42
42
 
43
43
  lambda {
44
44
  @user2.tag(@taggable, :with => 'java, python, lisp', :on => :tags)
45
- }.should change(Tagging, :count).by(-1)
45
+ }.should change(ActsAsTaggableOnPadrino::Tagging, :count).by(-1)
46
46
 
47
47
  [@user, @user2, @taggable].each(&:reload)
48
48
 
@@ -61,7 +61,7 @@ describe "Tagger" do
61
61
 
62
62
  lambda {
63
63
  @user2.tag(@taggable, :with => 'epic', :on => :tags)
64
- }.should change(Tagging, :count).by(-1)
64
+ }.should change(ActsAsTaggableOnPadrino::Tagging, :count).by(-1)
65
65
 
66
66
  @taggable.reload
67
67
  @taggable.all_tags_list.should include('awesome')
@@ -78,7 +78,7 @@ describe "Tagger" do
78
78
 
79
79
  lambda {
80
80
  @taggable.update_attributes(:tag_list => "")
81
- }.should change(Tagging, :count).by(-1)
81
+ }.should change(ActsAsTaggableOnPadrino::Tagging, :count).by(-1)
82
82
 
83
83
  @taggable.tag_list.should == []
84
84
  @taggable.all_tags_list.sort.should == %w(ruby scheme).sort
@@ -1,13 +1,13 @@
1
1
  require File.expand_path('../../spec_helper', __FILE__)
2
2
 
3
- describe ActsAsTaggableOn::Tagging do
3
+ describe ActsAsTaggableOnPadrino::Tagging do
4
4
  before(:each) do
5
- @tagging = TestTagging.new
5
+ @tagging = ActsAsTaggableOnPadrino::Tagging.new
6
6
  end
7
7
 
8
8
  it "should not be valid with a invalid tag" do
9
9
  @tagging.taggable = TaggableModel.create(:name => "Bob Jones")
10
- @tagging.tag = TestTag.new(:name => "")
10
+ @tagging.tag = ActsAsTaggableOnPadrino::Tag.new(:name => "")
11
11
  @tagging.context = "tags"
12
12
 
13
13
  @tagging.should_not be_valid
@@ -17,10 +17,10 @@ describe ActsAsTaggableOn::Tagging do
17
17
 
18
18
  it "should not create duplicate taggings" do
19
19
  @taggable = TaggableModel.create(:name => "Bob Jones")
20
- @tag = TestTag.create(:name => "awesome")
20
+ @tag = ActsAsTaggableOnPadrino::Tag.create(:name => "awesome")
21
21
 
22
22
  lambda {
23
- 2.times { TestTagging.create(:taggable => @taggable, :tag => @tag, :context => 'tags') }
24
- }.should change(TestTagging, :count).by(1)
23
+ 2.times { ActsAsTaggableOnPadrino::Tagging.create(:taggable => @taggable, :tag => @tag, :context => 'tags') }
24
+ }.should change(ActsAsTaggableOnPadrino::Tagging, :count).by(1)
25
25
  end
26
26
  end
@@ -1,13 +1,13 @@
1
1
  require File.expand_path('../../spec_helper', __FILE__)
2
2
 
3
- describe ActsAsTaggableOn::TagsHelper do
3
+ describe ActsAsTaggableOnPadrino::TagsHelper do
4
4
  before(:each) do
5
5
  @bob = TaggableModel.create(:name => "Bob Jones", :language_list => "ruby, php")
6
6
  @tom = TaggableModel.create(:name => "Tom Marley", :language_list => "ruby, java")
7
7
  @eve = TaggableModel.create(:name => "Eve Nodd", :language_list => "ruby, c++")
8
8
 
9
9
  @helper = class Helper
10
- include ActsAsTaggableOn::TagsHelper
10
+ include ActsAsTaggableOnPadrino::TagsHelper
11
11
  end.new
12
12
  end
13
13
 
@@ -1,19 +1,3 @@
1
- class Tag < ActiveRecord::Base
2
- acts_as_tag
3
- end
4
-
5
- class TestTag < ActiveRecord::Base
6
- acts_as_tag
7
- end
8
-
9
- class Tagging < ActiveRecord::Base
10
- acts_as_tagging
11
- end
12
-
13
- class TestTagging < ActiveRecord::Base
14
- acts_as_tagging :tag => 'TestTag'
15
- end
16
-
17
1
  class TaggableModel < ActiveRecord::Base
18
2
  acts_as_taggable
19
3
  acts_as_taggable_on :languages
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts-as-taggable-on-padrino
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,12 +10,12 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-06-29 00:00:00.000000000 +01:00
13
+ date: 2011-06-30 00:00:00.000000000 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activerecord
18
- requirement: &13175840 !ruby/object:Gem::Requirement
18
+ requirement: &20418920 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: 3.0.0
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *13175840
26
+ version_requirements: *20418920
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sqlite3-ruby
29
- requirement: &13175360 !ruby/object:Gem::Requirement
29
+ requirement: &20418440 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
- version_requirements: *13175360
37
+ version_requirements: *20418440
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: mysql
40
- requirement: &13174880 !ruby/object:Gem::Requirement
40
+ requirement: &20417960 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ! '>='
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: '0'
46
46
  type: :development
47
47
  prerelease: false
48
- version_requirements: *13174880
48
+ version_requirements: *20417960
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: pg
51
- requirement: &13169320 !ruby/object:Gem::Requirement
51
+ requirement: &20417480 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ! '>='
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: '0'
57
57
  type: :development
58
58
  prerelease: false
59
- version_requirements: *13169320
59
+ version_requirements: *20417480
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: jeweler
62
- requirement: &13168840 !ruby/object:Gem::Requirement
62
+ requirement: &20417000 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ! '>='
@@ -67,10 +67,10 @@ dependencies:
67
67
  version: '0'
68
68
  type: :development
69
69
  prerelease: false
70
- version_requirements: *13168840
70
+ version_requirements: *20417000
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: rspec
73
- requirement: &13168360 !ruby/object:Gem::Requirement
73
+ requirement: &20416520 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ! '>='
@@ -78,10 +78,10 @@ dependencies:
78
78
  version: 2.0.0
79
79
  type: :development
80
80
  prerelease: false
81
- version_requirements: *13168360
81
+ version_requirements: *20416520
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: rcov
84
- requirement: &13167880 !ruby/object:Gem::Requirement
84
+ requirement: &20416040 !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
87
87
  - - ! '>='
@@ -89,10 +89,10 @@ dependencies:
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
- version_requirements: *13167880
92
+ version_requirements: *20416040
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: database_cleaner
95
- requirement: &13167400 !ruby/object:Gem::Requirement
95
+ requirement: &20415560 !ruby/object:Gem::Requirement
96
96
  none: false
97
97
  requirements:
98
98
  - - ! '>='
@@ -100,7 +100,7 @@ dependencies:
100
100
  version: '0'
101
101
  type: :development
102
102
  prerelease: false
103
- version_requirements: *13167400
103
+ version_requirements: *20415560
104
104
  description: Padrino version of the popular Rails tagging plugin. With ActsAsTaggableOnPadrino,
105
105
  you could tag a single model on several contexts, such as skills, interests, and
106
106
  awards. It also provides other advanced functionality.
@@ -141,7 +141,6 @@ files:
141
141
  - spec/acts_as_taggable_on_padrino/tagging_spec.rb
142
142
  - spec/acts_as_taggable_on_padrino/tags_helper_spec.rb
143
143
  - spec/bm.rb
144
- - spec/database.yml.sample
145
144
  - spec/models.rb
146
145
  - spec/schema.rb
147
146
  - spec/spec_helper.rb
@@ -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