has_machine_tags 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/{gemspec → .gemspec} +5 -3
- data/CHANGELOG.rdoc +3 -0
- data/README.rdoc +5 -2
- data/Rakefile +3 -3
- data/lib/has_machine_tags/tag.rb +9 -2
- data/lib/has_machine_tags/tag_console.rb +8 -7
- data/lib/has_machine_tags/version.rb +1 -1
- data/lib/has_machine_tags.rb +8 -5
- data/test/deps.rip +1 -0
- data/test/test_helper.rb +8 -3
- metadata +16 -9
data/{gemspec → .gemspec}
RENAMED
@@ -12,7 +12,9 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.description = "This gem implements Flickr's machine tags while still maintaining standard tagging behavior. This allows for more precise tagging as tags can have unlimited contexts provided by combinations of namespaces and predicates. These unlimited contexts also make machine tags ripe for modeling relationships between objects."
|
13
13
|
s.required_rubygems_version = ">= 1.3.6"
|
14
14
|
s.rubyforge_project = 'tagaholic'
|
15
|
-
s.add_development_dependency 'bacon'
|
16
|
-
s.files = Dir.glob(%w[{lib,test
|
15
|
+
s.add_development_dependency 'bacon', '>= 1.1.0'
|
16
|
+
s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
|
17
|
+
s.files += Dir.glob('generators/**/*.rb') + ['init.rb']
|
17
18
|
s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
|
18
|
-
|
19
|
+
s.license = 'MIT'
|
20
|
+
end
|
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -21,7 +21,10 @@ Install as a gem
|
|
21
21
|
|
22
22
|
bash> gem install has_machine_tags
|
23
23
|
|
24
|
-
# add in
|
24
|
+
# with bundler: add in Gemfile
|
25
|
+
gem 'has_machine_tags'
|
26
|
+
|
27
|
+
# without bundler: add in config/environment.rb
|
25
28
|
config.gem "has_machine_tags"
|
26
29
|
|
27
30
|
Or as a plugin
|
@@ -133,7 +136,7 @@ these characters are off limit unless used in the machine tag context:
|
|
133
136
|
* Possible add support for other ORM's ie DataMapper.
|
134
137
|
* Play friendly with other tagging plugins as needed.
|
135
138
|
|
136
|
-
== Issues
|
139
|
+
== Bugs/Issues
|
137
140
|
Please report them {on github}[http://github.com/cldwalker/has_machine_tags/issues].
|
138
141
|
|
139
142
|
== Credits
|
data/Rakefile
CHANGED
@@ -2,12 +2,12 @@ require 'rake'
|
|
2
2
|
require 'fileutils'
|
3
3
|
|
4
4
|
def gemspec
|
5
|
-
@gemspec ||= eval(File.read('gemspec'), binding, 'gemspec')
|
5
|
+
@gemspec ||= eval(File.read('.gemspec'), binding, '.gemspec')
|
6
6
|
end
|
7
7
|
|
8
8
|
desc "Build the gem"
|
9
9
|
task :gem=>:gemspec do
|
10
|
-
sh "gem build gemspec"
|
10
|
+
sh "gem build .gemspec"
|
11
11
|
FileUtils.mkdir_p 'pkg'
|
12
12
|
FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
|
13
13
|
end
|
@@ -32,4 +32,4 @@ task :test do |t|
|
|
32
32
|
sh 'bacon -q -Ilib -I. test/*_test.rb'
|
33
33
|
end
|
34
34
|
|
35
|
-
task :default => :test
|
35
|
+
task :default => :test
|
data/lib/has_machine_tags/tag.rb
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'has_machine_tags/tag_methods'
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'app/models/tag'
|
5
|
+
rescue LoadError
|
6
|
+
class ::Tag < ActiveRecord::Base #:nodoc:
|
7
|
+
end
|
3
8
|
end
|
9
|
+
|
10
|
+
::Tag.send :include, HasMachineTags::TagMethods
|
@@ -6,13 +6,14 @@ module HasMachineTags
|
|
6
6
|
# end
|
7
7
|
module TagConsole
|
8
8
|
def self.included(base) #:nodoc:
|
9
|
+
scope = Rails.version >= '3.0' ? 'scope' : 'named_scope'
|
9
10
|
base.class_eval %[
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
self.#{scope} :namespace_counts, :select=>'*, namespace as counter, count(namespace) as count', :group=>"namespace HAVING count(namespace)>=1"
|
12
|
+
self.#{scope} :predicate_counts, :select=>'*, predicate as counter, count(predicate) as count', :group=>"predicate HAVING count(predicate)>=1"
|
13
|
+
self.#{scope} :value_counts, :select=>'*, value as counter, count(value) as count', :group=>"value HAVING count(value)>=1"
|
14
|
+
self.#{scope} :distinct_namespaces, :select=>"distinct namespace"
|
15
|
+
self.#{scope} :distinct_predicates, :select=>"distinct predicate"
|
16
|
+
self.#{scope} :distinct_values, :select=>"distinct value"
|
16
17
|
]
|
17
18
|
base.extend ClassMethods
|
18
19
|
end
|
@@ -26,4 +27,4 @@ module HasMachineTags
|
|
26
27
|
def values; distinct_values.map(&:value).compact; end
|
27
28
|
end
|
28
29
|
end
|
29
|
-
end
|
30
|
+
end
|
data/lib/has_machine_tags.rb
CHANGED
@@ -2,6 +2,8 @@ require 'has_machine_tags/finder'
|
|
2
2
|
require 'has_machine_tags/tag_list'
|
3
3
|
require 'has_machine_tags/console'
|
4
4
|
require 'has_machine_tags/version'
|
5
|
+
require 'has_machine_tags/tag'
|
6
|
+
require 'has_machine_tags/tagging'
|
5
7
|
|
6
8
|
module HasMachineTags
|
7
9
|
def self.included(base) #:nodoc:
|
@@ -25,11 +27,10 @@ module HasMachineTags
|
|
25
27
|
extend HasMachineTags::Finder
|
26
28
|
include HasMachineTags::Console::InstanceMethods if options[:console]
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
30
|
+
scope_word = Rails.version >= '3.0' ? 'scope' : 'named_scope'
|
31
|
+
send scope_word, :tagged_with, lambda { |*args|
|
32
|
+
find_options_for_tagged_with(*args)
|
33
|
+
}
|
33
34
|
end
|
34
35
|
if options[:reverse_has_many]
|
35
36
|
model = self.to_s
|
@@ -83,3 +84,5 @@ module HasMachineTags
|
|
83
84
|
end
|
84
85
|
|
85
86
|
end
|
87
|
+
|
88
|
+
ActiveRecord::Base.send :include, HasMachineTags if defined?(ActiveRecord::Base)
|
data/test/deps.rip
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
bacon >=1.1.0
|
data/test/test_helper.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
|
-
require '
|
2
|
-
|
1
|
+
require 'active_record'
|
2
|
+
begin
|
3
|
+
# for rip
|
4
|
+
require 'initializer'
|
5
|
+
rescue LoadError
|
6
|
+
require 'rails'
|
7
|
+
end
|
3
8
|
require 'bacon'
|
4
9
|
require 'has_machine_tags'
|
5
10
|
require File.join(File.dirname(__FILE__), '..', 'init')
|
@@ -23,4 +28,4 @@ end
|
|
23
28
|
class Bacon::Context
|
24
29
|
def after_all; yield; end
|
25
30
|
def before_all; yield; end
|
26
|
-
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_machine_tags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 11
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
9
|
+
- 8
|
10
|
+
version: 0.1.8
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Gabriel Horner
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-09-30 00:00:00 -04:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
@@ -25,9 +26,12 @@ dependencies:
|
|
25
26
|
requirements:
|
26
27
|
- - ">="
|
27
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 19
|
28
30
|
segments:
|
31
|
+
- 1
|
32
|
+
- 1
|
29
33
|
- 0
|
30
|
-
version:
|
34
|
+
version: 1.1.0
|
31
35
|
type: :development
|
32
36
|
version_requirements: *id001
|
33
37
|
description: This gem implements Flickr's machine tags while still maintaining standard tagging behavior. This allows for more precise tagging as tags can have unlimited contexts provided by combinations of namespaces and predicates. These unlimited contexts also make machine tags ripe for modeling relationships between objects.
|
@@ -54,18 +58,19 @@ files:
|
|
54
58
|
- test/schema.rb
|
55
59
|
- test/tag_methods_test.rb
|
56
60
|
- test/test_helper.rb
|
57
|
-
- generators/has_machine_tags_migration/has_machine_tags_migration_generator.rb
|
58
|
-
- generators/has_machine_tags_migration/templates/migration.rb
|
59
61
|
- LICENSE.txt
|
60
62
|
- CHANGELOG.rdoc
|
61
63
|
- README.rdoc
|
64
|
+
- test/deps.rip
|
62
65
|
- Rakefile
|
63
|
-
- gemspec
|
66
|
+
- .gemspec
|
67
|
+
- generators/has_machine_tags_migration/has_machine_tags_migration_generator.rb
|
68
|
+
- generators/has_machine_tags_migration/templates/migration.rb
|
64
69
|
- init.rb
|
65
70
|
has_rdoc: true
|
66
71
|
homepage: http://tagaholic.me/has_machine_tags/
|
67
|
-
licenses:
|
68
|
-
|
72
|
+
licenses:
|
73
|
+
- MIT
|
69
74
|
post_install_message:
|
70
75
|
rdoc_options: []
|
71
76
|
|
@@ -76,6 +81,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
81
|
requirements:
|
77
82
|
- - ">="
|
78
83
|
- !ruby/object:Gem::Version
|
84
|
+
hash: 3
|
79
85
|
segments:
|
80
86
|
- 0
|
81
87
|
version: "0"
|
@@ -84,6 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
90
|
requirements:
|
85
91
|
- - ">="
|
86
92
|
- !ruby/object:Gem::Version
|
93
|
+
hash: 23
|
87
94
|
segments:
|
88
95
|
- 1
|
89
96
|
- 3
|