tagtical 1.5.7 → 1.5.8

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,8 +3,8 @@ source :gemcutter
3
3
  # Rails 3.0
4
4
 
5
5
  # Cannot require these as dependency until there the fix is released:
6
- #
7
- gem 'rails', '<=3.0.5'
6
+ #
7
+ gem 'rails', '<= 3.0.11'
8
8
  gem 'rspec'
9
9
  # http://rubyforge.org/tracker/?func=detail&atid=575&aid=29163&group_id=126
10
10
 
data/Gemfile.lock CHANGED
@@ -2,73 +2,77 @@ GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
4
  abstract (1.0.0)
5
- actionmailer (3.0.5)
6
- actionpack (= 3.0.5)
7
- mail (~> 2.2.15)
8
- actionpack (3.0.5)
9
- activemodel (= 3.0.5)
10
- activesupport (= 3.0.5)
5
+ actionmailer (3.0.11)
6
+ actionpack (= 3.0.11)
7
+ mail (~> 2.2.19)
8
+ actionpack (3.0.11)
9
+ activemodel (= 3.0.11)
10
+ activesupport (= 3.0.11)
11
11
  builder (~> 2.1.2)
12
12
  erubis (~> 2.6.6)
13
- i18n (~> 0.4)
13
+ i18n (~> 0.5.0)
14
14
  rack (~> 1.2.1)
15
- rack-mount (~> 0.6.13)
15
+ rack-mount (~> 0.6.14)
16
16
  rack-test (~> 0.5.7)
17
17
  tzinfo (~> 0.3.23)
18
- activemodel (3.0.5)
19
- activesupport (= 3.0.5)
18
+ activemodel (3.0.11)
19
+ activesupport (= 3.0.11)
20
20
  builder (~> 2.1.2)
21
- i18n (~> 0.4)
22
- activerecord (3.0.5)
23
- activemodel (= 3.0.5)
24
- activesupport (= 3.0.5)
25
- arel (~> 2.0.2)
21
+ i18n (~> 0.5.0)
22
+ activerecord (3.0.11)
23
+ activemodel (= 3.0.11)
24
+ activesupport (= 3.0.11)
25
+ arel (~> 2.0.10)
26
26
  tzinfo (~> 0.3.23)
27
- activeresource (3.0.5)
28
- activemodel (= 3.0.5)
29
- activesupport (= 3.0.5)
30
- activesupport (3.0.5)
27
+ activeresource (3.0.11)
28
+ activemodel (= 3.0.11)
29
+ activesupport (= 3.0.11)
30
+ activesupport (3.0.11)
31
31
  arel (2.0.10)
32
32
  builder (2.1.2)
33
33
  diff-lcs (1.1.3)
34
34
  erubis (2.6.6)
35
35
  abstract (>= 1.0.0)
36
36
  git (1.2.5)
37
- i18n (0.6.0)
37
+ i18n (0.5.0)
38
38
  jeweler (1.6.4)
39
39
  bundler (~> 1.0)
40
40
  git (>= 1.2.5)
41
41
  rake
42
+ json (1.6.5)
42
43
  mail (2.2.19)
43
44
  activesupport (>= 2.3.6)
44
45
  i18n (>= 0.4.0)
45
46
  mime-types (~> 1.16)
46
47
  treetop (~> 1.4.8)
47
48
  metaclass (0.0.1)
48
- mime-types (1.16)
49
+ mime-types (1.17.2)
49
50
  mocha (0.10.0)
50
51
  metaclass (~> 0.0.1)
51
52
  mysql (2.8.1)
52
- polyglot (0.3.2)
53
- rack (1.2.4)
53
+ polyglot (0.3.3)
54
+ rack (1.2.5)
54
55
  rack-mount (0.6.14)
55
56
  rack (>= 1.0.0)
56
57
  rack-test (0.5.7)
57
58
  rack (>= 1.0)
58
- rails (3.0.5)
59
- actionmailer (= 3.0.5)
60
- actionpack (= 3.0.5)
61
- activerecord (= 3.0.5)
62
- activeresource (= 3.0.5)
63
- activesupport (= 3.0.5)
59
+ rails (3.0.11)
60
+ actionmailer (= 3.0.11)
61
+ actionpack (= 3.0.11)
62
+ activerecord (= 3.0.11)
63
+ activeresource (= 3.0.11)
64
+ activesupport (= 3.0.11)
64
65
  bundler (~> 1.0)
65
- railties (= 3.0.5)
66
- railties (3.0.5)
67
- actionpack (= 3.0.5)
68
- activesupport (= 3.0.5)
66
+ railties (= 3.0.11)
67
+ railties (3.0.11)
68
+ actionpack (= 3.0.11)
69
+ activesupport (= 3.0.11)
69
70
  rake (>= 0.8.7)
71
+ rdoc (~> 3.4)
70
72
  thor (~> 0.14.4)
71
- rake (0.8.7)
73
+ rake (0.9.2.2)
74
+ rdoc (3.12)
75
+ json (~> 1.4)
72
76
  rspec (2.7.0)
73
77
  rspec-core (~> 2.7.0)
74
78
  rspec-expectations (~> 2.7.0)
@@ -93,6 +97,6 @@ DEPENDENCIES
93
97
  jeweler
94
98
  mocha
95
99
  mysql
96
- rails (<= 3.0.5)
100
+ rails (<= 3.0.11)
97
101
  rspec
98
102
  sqlite3-ruby
data/README.rdoc CHANGED
@@ -1,5 +1,7 @@
1
1
  = Tagtical
2
2
 
3
+ {<img src="https://secure.travis-ci.org/Mixbook/tagtical.png" />}[http://travis-ci.org/Mixbook/tagtical]
4
+
3
5
  This plugin was originally based on acts_as_taggable_on by Michael Bleigh (http://mbleigh.com/). That plugin
4
6
  was based on acts_as_taggable_on_steroids by Jonathan Viney.
5
7
 
data/Rakefile CHANGED
@@ -10,50 +10,50 @@ begin
10
10
 
11
11
  Spec::Rake::SpecTask.new('rcov') do |t|
12
12
  t.spec_files = FileList["spec/**/*_spec.rb"]
13
- t.rcov = true
14
- t.rcov_opts = ['--exclude', 'spec']
13
+ t.rcov = true
14
+ t.rcov_opts = ['--exclude', 'spec']
15
15
  end
16
-
16
+
17
17
  rescue LoadError
18
18
  # RSpec 2.0
19
19
  require 'rspec/core/rake_task'
20
20
 
21
21
  desc 'Default: run specs'
22
- task :default => :spec
22
+ task :default => :spec
23
23
  RSpec::Core::RakeTask.new do |t|
24
24
  t.pattern = "spec/**/*_spec.rb"
25
25
  end
26
-
26
+
27
27
  RSpec::Core::RakeTask.new('rcov') do |t|
28
- t.pattern = "spec/**/*_spec.rb"
29
- t.rcov = true
28
+ t.pattern = "spec/**/*_spec.rb"
29
+ t.rcov = true
30
30
  t.rcov_opts = ['--exclude', 'spec']
31
31
  end
32
32
 
33
33
  rescue LoadError
34
- puts "RSpec not available. Install it with: gem install rspec"
34
+ puts "RSpec not available. Install it with: gem install rspec"
35
35
  end
36
36
 
37
37
  namespace 'rails2.3' do
38
38
  task :spec do
39
39
  gemfile = File.join(File.dirname(__FILE__), 'lib', 'tagtical', 'compatibility', 'Gemfile')
40
40
  ENV['BUNDLE_GEMFILE'] = gemfile
41
- Rake::Task['spec'].invoke
41
+ Rake::Task['spec'].invoke
42
42
  end
43
43
  end
44
44
 
45
45
  begin
46
46
  require 'jeweler'
47
47
  Jeweler::Tasks.new do |gemspec|
48
- gemspec.name = "tagtical"
49
- gemspec.summary = "Tagtical is a tagging plugin for Rails that provides weighting, contexts, and inheritance for tags."
48
+ gemspec.name = "tagtical"
49
+ gemspec.summary = "Tagtical is a tagging plugin for Rails that provides weighting, contexts, and inheritance for tags."
50
50
  gemspec.description = "Tagtical allows you do create subclasses for Tag and add additional functionality in an STI fashion. For example. You could do Tag::Color.find_by_name('blue').to_rgb. It also supports storing weights or relevance on the taggings."
51
- gemspec.email = "aryk@mixbook.com"
52
- gemspec.homepage = "https://github.com/Mixbook/tagtical"
53
- gemspec.authors = ["Aryk Grosz"]
54
- gemspec.files = FileList["[A-Z]*", "{generators,lib,spec,rails}/**/*"] - FileList["**/*.log"]
51
+ gemspec.email = "aryk@mixbook.com"
52
+ gemspec.homepage = "https://github.com/Mixbook/tagtical"
53
+ gemspec.authors = ["Aryk Grosz"]
54
+ gemspec.files = FileList["[A-Z]*", "{generators,lib,spec,rails}/**/*"] - FileList["**/*.log"]
55
55
  end
56
56
  Jeweler::GemcutterTasks.new
57
57
  rescue LoadError
58
58
  puts "Jeweler not available. Install it with: gem install jeweler"
59
- end
59
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.7
1
+ 1.5.8
data/lib/tagtical/tag.rb CHANGED
@@ -50,19 +50,23 @@ module Tagtical
50
50
 
51
51
  # Method used to ensure list of tags for the given Tag class.
52
52
  # Returns a hash with the key being the value from the tag list and the value being the saved tag.
53
- def find_or_create_tags(*tag_list)
54
- find_or_build_or_create_tags(:create!, *tag_list)
53
+ def find_or_create_tags(tag_list, tag_types = [])
54
+ find_or_build_or_create_tags(:create!, tag_list, tag_types)
55
55
  end
56
56
 
57
- def find_or_build_tags(*tag_list)
58
- find_or_build_or_create_tags(:new, *tag_list)
57
+ def find_or_build_tags(tag_list, tag_types = [])
58
+ find_or_build_or_create_tags(:new, tag_list, tag_types)
59
59
  end
60
60
 
61
- def find_or_build_or_create_tags(operation, *tag_list)
61
+ def find_or_build_or_create_tags(operation, tag_list, tag_types)
62
62
  tag_list = [tag_list].flatten
63
63
  return {} if tag_list.empty?
64
64
 
65
- existing_tags = where_any_like(tag_list).all
65
+ existing_tags = where_any_like(tag_list)
66
+ if tag_types.present?
67
+ existing_tags = existing_tags.where(["type IS NULL OR type IN (?)", tag_types.map(&:klass).map(&:to_s)])
68
+ end
69
+ existing_tags = existing_tags.all
66
70
  tag_list.each_with_object({}) do |value, tag_lookup|
67
71
  tag_lookup[detect_comparable(existing_tags, value) || send(operation, :value => value)] = value
68
72
  end
@@ -296,7 +296,7 @@ module Tagtical::Taggable
296
296
  tag_list = tag_list.uniq
297
297
 
298
298
  # Find existing tags or create non-existing tags:
299
- tag_value_lookup = tag_type.klass.find_or_create_tags(tag_list)
299
+ tag_value_lookup = tag_type.klass.find_or_create_tags(tag_list, expanded_tag_types)
300
300
  tags = tag_value_lookup.keys
301
301
 
302
302
 
@@ -246,7 +246,7 @@ describe Tagtical::Tag do
246
246
 
247
247
  it "should find both tags" do
248
248
  lambda {
249
- @klass.find_or_create_tags("awesome", "epic")
249
+ @klass.find_or_create_tags(["awesome", "epic"])
250
250
  }.should change(@klass, :count).by(0)
251
251
  end
252
252
  end
@@ -310,7 +310,7 @@ describe Tagtical::Tag do
310
310
 
311
311
  it "should find or create by name" do
312
312
  lambda {
313
- @klass.find_or_create_tags("awesome", "epic").keys.map(&:value).should == ["awesome", "epic"]
313
+ @klass.find_or_create_tags(["awesome", "epic"]).keys.map(&:value).should == ["awesome", "epic"]
314
314
  }.should change(@klass, :count).by(1)
315
315
  end
316
316
 
@@ -7,6 +7,14 @@ describe Tagtical::Taggable do
7
7
  end
8
8
  subject { @taggable }
9
9
 
10
+ it "should not use not registered tags" do
11
+ Tag::Skill.create!(:value => "chess")
12
+ taggable = OtherTaggableModel.create!
13
+ taggable.tag_list = "chess, basketball"
14
+ taggable.save!
15
+ taggable.tags.any? { |t| t.is_a?(Tag::Skill) }.should be_false
16
+ end
17
+
10
18
  it "should have tag types" do
11
19
  TaggableModel.tag_types.should include("tag", "language", "skill", "craft", "need", "offering")
12
20
  @taggable.tag_types.should == TaggableModel.tag_types
@@ -696,7 +704,7 @@ describe Tagtical::Taggable do
696
704
  @taggable.tag_list_on(:skills).should == ["hello"]
697
705
  end
698
706
 
699
- #it "should be able to set a custom tag context list" do
707
+ #it "should be able to set a custom tag context list" do
700
708
  # bob = TaggableModel.create(:name => "Bob")
701
709
  # bob.set_tag_list_on(:rotors, "spinning, jumping")
702
710
  # bob.tag_list_on(:rotors).should == ["spinning","jumping"]
@@ -29,7 +29,7 @@ describe Tagtical::Tagging do
29
29
 
30
30
  it "should not be valid with a invalid tag" do
31
31
  @tagging.taggable = TaggableModel.create(:name => "Bob Jones")
32
- @tagging.tag = Tagtical::Tag.new(:value => "")
32
+ @tagging.tag = Tagtical::Tag.new(:value => "")
33
33
 
34
34
  @tagging.should_not be_valid
35
35
 
@@ -69,7 +69,7 @@ describe Tagtical::Tagging do
69
69
  it "should throw an error if the relevance is out of range" do
70
70
  @taggable.set_tag_list "car:11"
71
71
 
72
- expect { @taggable.save }.to raise_error
72
+ expect { @taggable.save! }.to raise_error
73
73
  end
74
74
  end
75
75
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tagtical
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.7
4
+ version: 1.5.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,23 +9,23 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-26 00:00:00.000000000 -08:00
12
+ date: 2012-02-23 00:00:00.000000000 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
17
- requirement: &2154015420 !ruby/object:Gem::Requirement
17
+ requirement: &2154054300 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - <=
21
21
  - !ruby/object:Gem::Version
22
- version: 3.0.5
22
+ version: 3.0.11
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2154015420
25
+ version_requirements: *2154054300
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rspec
28
- requirement: &2154014880 !ruby/object:Gem::Requirement
28
+ requirement: &2154053820 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *2154014880
36
+ version_requirements: *2154053820
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: sqlite3-ruby
39
- requirement: &2154014400 !ruby/object:Gem::Requirement
39
+ requirement: &2154053340 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *2154014400
47
+ version_requirements: *2154053340
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: mysql
50
- requirement: &2154013920 !ruby/object:Gem::Requirement
50
+ requirement: &2154052860 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *2154013920
58
+ version_requirements: *2154052860
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: jeweler
61
- requirement: &2154013440 !ruby/object:Gem::Requirement
61
+ requirement: &2154052380 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,7 +66,7 @@ dependencies:
66
66
  version: '0'
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *2154013440
69
+ version_requirements: *2154052380
70
70
  description: Tagtical allows you do create subclasses for Tag and add additional functionality
71
71
  in an STI fashion. For example. You could do Tag::Color.find_by_name('blue').to_rgb.
72
72
  It also supports storing weights or relevance on the taggings.