dm-taggings 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,9 @@
1
+ doc
2
+ .yardoc
3
+ pkg/*
4
+ coverage
5
+ .bundle
6
+ Gemfile.lock
7
+ Gemfile.local
8
+ Gemfile.local.lock
9
+
data/Gemfile ADDED
@@ -0,0 +1,142 @@
1
+ # If you're working on more than one datamapper gem at a time, then it's
2
+ # recommended to create a local Gemfile and use this instead of the git
3
+ # sources. This will make sure that you are developing against your
4
+ # other local datamapper sources that you currently work on. Gemfile.local
5
+ # will behave identically to the standard Gemfile apart from the fact that
6
+ # it fetches the datamapper gems from local paths. This means that you can use
7
+ # the same environment variables, like ADAPTER(S) or PLUGIN(S) when running
8
+ # bundle commands. Gemfile.local is added to .gitignore, so you don't need to
9
+ # worry about accidentally checking local development paths into git.
10
+ # In order to create a local Gemfile, all you need to do is run:
11
+ #
12
+ # bundle exec rake local_gemfile
13
+ #
14
+ # This will give you a Gemfile.local file that points to your local clones of
15
+ # the various datamapper gems. It's assumed that all datamapper repo clones
16
+ # reside in the same directory. You can use the Gemfile.local like so for
17
+ # running any bundle command:
18
+ #
19
+ # BUNDLE_GEMFILE=Gemfile.local bundle foo
20
+ #
21
+ # You can also specify which adapter(s) should be part of the bundle by setting
22
+ # an environment variable. This of course also works when using the Gemfile.local
23
+ #
24
+ # bundle foo # dm-sqlite-adapter
25
+ # ADAPTER=mysql bundle foo # dm-mysql-adapter
26
+ # ADAPTERS=sqlite,mysql bundle foo # dm-sqlite-adapter and dm-mysql-adapter
27
+ #
28
+ # Of course you can also use the ADAPTER(S) variable when using the Gemfile.local
29
+ # and running specs against selected adapters.
30
+ #
31
+ # For easily working with adapters supported on your machine, it's recommended
32
+ # that you first install all adapters that you are planning to use or work on
33
+ # by doing something like
34
+ #
35
+ # ADAPTERS=sqlite,mysql,postgres bundle install
36
+ #
37
+ # This will clone the various repositories and make them available to bundler.
38
+ # Once you have them installed you can easily switch between adapters for the
39
+ # various development tasks. Running something like
40
+ #
41
+ # ADAPTER=mysql bundle exec rake spec
42
+ #
43
+ # will make sure that the dm-mysql-adapter is part of the bundle, and will be used
44
+ # when running the specs.
45
+ #
46
+ # You can also specify which plugin(s) should be part of the bundle by setting
47
+ # an environment variable. This also works when using the Gemfile.local
48
+ #
49
+ # bundle foo # dm-migrations
50
+ # PLUGINS=dm-validations bundle foo # dm-migrations and dm-validations
51
+ # PLUGINS=dm-validations,dm-types bundle foo # dm-migrations, dm-validations and dm-types
52
+ #
53
+ # Of course you can combine the PLUGIN(S) and ADAPTER(S) env vars to run specs
54
+ # for certain adapter/plugin combinations.
55
+ #
56
+ # Finally, to speed up running specs and other tasks, it's recommended to run
57
+ #
58
+ # bundle lock
59
+ #
60
+ # after running 'bundle install' for the first time. This will make 'bundle exec' run
61
+ # a lot faster compared to the unlocked version. With an unlocked bundle you would
62
+ # typically just run 'bundle install' from time to time to fetch the latest sources from
63
+ # upstream. When you locked your bundle, you need to run
64
+ #
65
+ # bundle install --relock
66
+ #
67
+ # to make sure to fetch the latest updates and then lock the bundle again. Gemfile.lock
68
+ # is added to the .gitignore file, so you don't need to worry about accidentally checking
69
+ # it into version control.
70
+
71
+ source 'http://rubygems.org'
72
+
73
+ DATAMAPPER = 'git://github.com/datamapper'
74
+ DM_VERSION = '~> 1.0.2'
75
+
76
+ group :runtime do # Runtime dependencies (as in the gemspec)
77
+
78
+ if ENV['EXTLIB']
79
+ gem 'extlib', '~> 0.9.15', :git => "#{DATAMAPPER}/extlib.git"
80
+ else
81
+ gem 'activesupport', '~> 3.0.0', :git => 'git://github.com/rails/rails.git', :branch => '3-0-stable', :require => nil
82
+ end
83
+
84
+ gem 'dm-core', DM_VERSION, :git => "#{DATAMAPPER}/dm-core.git"
85
+ gem 'dm-constraints', DM_VERSION, :git => "#{DATAMAPPER}/dm-constraints.git"
86
+ gem 'dm-is-remixable', DM_VERSION, :git => "#{DATAMAPPER}/dm-is-remixable.git"
87
+
88
+ end
89
+
90
+ group(:development) do # Development dependencies (as in the gemspec)
91
+
92
+ gem 'rake', '~> 0.8.7'
93
+ gem 'rspec', '~> 1.3', :git => 'git://github.com/snusnu/rspec', :branch => 'heckle_fix_plus_gemfile'
94
+ gem 'jeweler', '~> 1.4'
95
+
96
+ end
97
+
98
+ group :quality do # These gems contain rake tasks that check the quality of the source code
99
+
100
+ gem 'metric_fu', '~> 1.3'
101
+ gem 'rcov', '~> 0.9.8'
102
+ gem 'reek', '~> 1.2.8'
103
+ gem 'roodi', '~> 2.1'
104
+ gem 'yard', '~> 0.5'
105
+ gem 'yardstick', '~> 0.1'
106
+
107
+ end
108
+
109
+ group :datamapper do # We need this because we want to pin these dependencies to their git master sources
110
+
111
+ adapters = ENV['ADAPTER'] || ENV['ADAPTERS']
112
+ adapters = adapters.to_s.tr(',', ' ').split.uniq - %w[ in_memory ]
113
+
114
+ DO_VERSION = '~> 0.10.2'
115
+ DM_DO_ADAPTERS = %w[ sqlite postgres mysql oracle sqlserver ]
116
+
117
+ if (do_adapters = DM_DO_ADAPTERS & adapters).any?
118
+ options = {}
119
+ options[:git] = "#{DATAMAPPER}/do.git" if ENV['DO_GIT'] == 'true'
120
+
121
+ gem 'data_objects', DO_VERSION, options.dup
122
+
123
+ do_adapters.each do |adapter|
124
+ adapter = 'sqlite3' if adapter == 'sqlite'
125
+ gem "do_#{adapter}", DO_VERSION, options.dup
126
+ end
127
+
128
+ gem 'dm-do-adapter', DM_VERSION, :git => "#{DATAMAPPER}/dm-do-adapter.git"
129
+ end
130
+
131
+ adapters.each do |adapter|
132
+ gem "dm-#{adapter}-adapter", DM_VERSION, :git => "#{DATAMAPPER}/dm-#{adapter}-adapter.git"
133
+ end
134
+
135
+ plugins = ENV['PLUGINS'] || ENV['PLUGIN']
136
+ plugins = plugins.to_s.tr(',', ' ').split.push('dm-migrations').uniq
137
+
138
+ plugins.each do |plugin|
139
+ gem plugin, DM_VERSION, :git => "#{DATAMAPPER}/#{plugin}.git"
140
+ end
141
+
142
+ end
@@ -0,0 +1 @@
1
+
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Piotr Solnica
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,18 @@
1
+ History.txt
2
+ LICENSE
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ TODO
7
+ lib/dm-taggings.rb
8
+ lib/dm-taggings/is/tag.rb
9
+ lib/dm-taggings/is/taggable.rb
10
+ lib/dm-taggings/is/tagger.rb
11
+ lib/dm-taggings/is/tagging.rb
12
+ lib/dm-taggings/is/version.rb
13
+ spec/classes.rb
14
+ spec/integration/tag_spec.rb
15
+ spec/integration/taggable_spec.rb
16
+ spec/spec.opts
17
+ spec/spec_helper.rb
18
+ tasks/hoe.rb
@@ -0,0 +1,155 @@
1
+ = dm-taggings
2
+
3
+ Tagging support for DataMapper
4
+
5
+ == Where to find help
6
+
7
+ * http://groups.google.com/group/datamapper
8
+ * #datamapper channel on IRC
9
+
10
+ == Dependencies
11
+
12
+ * dm-core
13
+ * dm-is-remixable
14
+ * dm-constraints
15
+
16
+ == Installation
17
+
18
+ System-wide:
19
+
20
+ gem install dm-taggings
21
+
22
+ Bundler:
23
+
24
+ gem "dm-taggings", "~> 0.11"
25
+
26
+ == Schema
27
+
28
+ The plugin differs from other typical implementations as it doesn't use
29
+ polymorphic associations, instead it creates explicit join models on-the-fly
30
+ via dm-is-remixable. For instance a <tt>Post</tt> model will have a
31
+ corresponding tagging model called <tt>PostTag</tt>, <tt>Book</tt> will have
32
+ <tt>BookTag</tt> etc.
33
+
34
+ <b>Important</b>: constraints are set to delete taggings of a corresponding
35
+ taggable resource when it gets deleted.
36
+
37
+ == Adapters support
38
+
39
+ Because of the usage of dm-constraints the pluging supports only the following
40
+ DataObject adapters:
41
+
42
+ * mysql
43
+ * oracle
44
+ * postgres
45
+ * sqlite
46
+ * sqlserver
47
+
48
+ == Basic usage
49
+
50
+ #############################################################################
51
+ # Taggings
52
+ #
53
+
54
+ class Post
55
+ include DataMapper::Resource
56
+
57
+ property :id, Serial
58
+ property :title, String
59
+ property :content, Text
60
+
61
+ is :taggable
62
+ end
63
+
64
+ # Create a post with tags
65
+ post = Post.create(
66
+ :title => "Hello World",
67
+ :content => "Lorem ipsum ...",
68
+ :tag_list => "foo, bar")
69
+
70
+ p post.tags
71
+ # => [#<Tag @id=1 @name="foo">, #<Tag @id=2 @name="bar">]
72
+
73
+ # Untag a post
74
+ post.untag!
75
+
76
+ p post.tags
77
+ # => []
78
+
79
+ # Tag a post again
80
+ post.tag! ["red", "green"]
81
+
82
+ p post.tags
83
+ # => [#<Tag @id=3 @name="red">, #<Tag @id=4 @name="green">]
84
+
85
+ # Find posts tagged with "green"
86
+ green_posts = Post.tagged_with("green")
87
+
88
+ p green_posts
89
+ # => [#<Post @id=1 @title="Hello World", @content => "Lorem ipsum ..."]
90
+
91
+ # tagged_with is chainable so you can combine it with other conditions
92
+ Post.tagged_with("green").all(:content => "foo")
93
+
94
+ #############################################################################
95
+ # Taggers
96
+ #
97
+
98
+ class User
99
+ include DataMapper::Resource
100
+
101
+ property :id, Serial
102
+ property :name, String
103
+ end
104
+
105
+ class Song
106
+ include DataMapper::Resource
107
+
108
+ property :id, Serial
109
+ property :title, String
110
+
111
+ is :taggable, :by => [ User ]
112
+ end
113
+
114
+ song = Song.create(:title => "Show must go on")
115
+ user = User.create(:name => "John")
116
+
117
+ # tagging via user
118
+ user.tag!(song, :with => "awesome, favourite")
119
+
120
+ p song.tags
121
+ # => [#<Tag @id=1 @name="awesome">, #<Tag @id=2 @name="favourite">]
122
+
123
+ p user.songs
124
+ # => [#<Song @id=1 @title="Show must go on">]
125
+
126
+ For detailed docs see project's RDoc[http://rdoc.info/github/solnic/dm-taggings/master/frames]
127
+
128
+ == Authors and contributors
129
+
130
+ * Martin Gamsjaeger (snusnu[http://github.com/snusnu])
131
+ * Maxime Guilbot (maxime[http://github.com/maxime]) (original author of dm-is-taggable)
132
+ * Piotr Solnica (solnic[http://github.com/solnic])
133
+
134
+ == Note on Patches/Pull Requests
135
+
136
+ * Fork the project.
137
+ * Make your feature addition or bug fix.
138
+ * Add tests for it. This is important so I don't break it in a
139
+ future version unintentionally.
140
+ * Commit, do not mess with rakefile, version, or history.
141
+ (if you want to have your own version, that is fine but bump version in a
142
+ commit by itself I can ignore when I pull)
143
+ * Send me a pull request. Bonus points for topic branches.
144
+
145
+ == TODO
146
+
147
+ * Support for custom tag_list separators and grouping, ie tag_list = '"a tag with spaces"; "another one"'
148
+ * Support for custom validation of Tag model
149
+ * Caching tag_list (custom TagList < String property would be nice probably)
150
+ * Support for more adapters!
151
+
152
+ == Copyright
153
+
154
+ Copyright (c) 2010 Piotr Solnica. See LICENSE for details.
155
+
@@ -0,0 +1,45 @@
1
+ begin
2
+ # Just in case the bundle was locked
3
+ # This shouldn't happen in a dev environment but lets be safe
4
+ require File.expand_path('../../.bundle/environment', __FILE__)
5
+ rescue LoadError
6
+ require 'rubygems'
7
+ require 'bundler'
8
+ Bundler.setup
9
+ end
10
+
11
+ Bundler.require(:default, :development)
12
+
13
+
14
+ begin
15
+
16
+ require 'rake'
17
+ require 'jeweler'
18
+
19
+ Jeweler::Tasks.new do |gem|
20
+
21
+ gem.name = 'dm-taggings'
22
+ gem.summary = 'Tagging plugin for DataMapper'
23
+ gem.description = 'DataMapper plugin that adds the possibility to tag models'
24
+ gem.email = 'piotr.solnica@gmail.com'
25
+ gem.homepage = 'http://github.com/solnic/dm-taggings'
26
+ gem.authors = [ 'Piotr Solnica' ]
27
+
28
+ gem.add_dependency 'dm-core', '~> 1.0.2'
29
+ gem.add_dependency 'dm-constraints', '~> 1.0.2'
30
+ gem.add_dependency 'dm-is-remixable', '~> 1.0.2'
31
+
32
+ gem.add_development_dependency 'rspec', '~> 1.3'
33
+ gem.add_development_dependency 'yard', '~> 0.5'
34
+
35
+ end
36
+
37
+ Jeweler::GemcutterTasks.new
38
+
39
+ FileList['tasks/**/*.rake'].each { |task| import task }
40
+
41
+ rescue LoadError => e
42
+ puts 'Jeweler (or a dependency) not available. Install it with: gem install jeweler'
43
+ puts e.message
44
+ puts e.backtrace
45
+ end
data/TODO ADDED
@@ -0,0 +1,5 @@
1
+ TODO
2
+ ====
3
+
4
+ - specs to be finished
5
+ - tagger support
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.11.0
@@ -0,0 +1,89 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{dm-taggings}
8
+ s.version = "0.11.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Piotr Solnica"]
12
+ s.date = %q{2010-10-14}
13
+ s.description = %q{DataMapper plugin that adds the possibility to tag models}
14
+ s.email = %q{piotr.solnica@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc",
18
+ "TODO"
19
+ ]
20
+ s.files = [
21
+ ".gitignore",
22
+ "Gemfile",
23
+ "History.txt",
24
+ "LICENSE",
25
+ "Manifest.txt",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "TODO",
29
+ "VERSION",
30
+ "dm-taggings.gemspec",
31
+ "lib/dm-taggings.rb",
32
+ "lib/dm-taggings/is/tag.rb",
33
+ "lib/dm-taggings/is/taggable.rb",
34
+ "lib/dm-taggings/is/tagger.rb",
35
+ "lib/dm-taggings/is/tagging.rb",
36
+ "lib/dm-taggings/is/version.rb",
37
+ "lib/dm-taggings/spec/taggable_shared_spec.rb",
38
+ "lib/dm-taggings/spec/tagger_shared_spec.rb",
39
+ "spec/fixtures/models.rb",
40
+ "spec/integration/post_spec.rb",
41
+ "spec/integration/tag_spec.rb",
42
+ "spec/integration/taggable_spec.rb",
43
+ "spec/integration/user_spec.rb",
44
+ "spec/spec.opts",
45
+ "spec/spec_helper.rb",
46
+ "tasks/hoe.rb",
47
+ "tasks/yard.rake",
48
+ "tasks/yardstick.rake"
49
+ ]
50
+ s.homepage = %q{http://github.com/solnic/dm-taggings}
51
+ s.rdoc_options = ["--charset=UTF-8"]
52
+ s.require_paths = ["lib"]
53
+ s.rubygems_version = %q{1.3.7}
54
+ s.summary = %q{Tagging plugin for DataMapper}
55
+ s.test_files = [
56
+ "spec/integration/taggable_spec.rb",
57
+ "spec/integration/post_spec.rb",
58
+ "spec/integration/tag_spec.rb",
59
+ "spec/integration/user_spec.rb",
60
+ "spec/fixtures/models.rb",
61
+ "spec/spec_helper.rb"
62
+ ]
63
+
64
+ if s.respond_to? :specification_version then
65
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
66
+ s.specification_version = 3
67
+
68
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
69
+ s.add_runtime_dependency(%q<dm-core>, ["~> 1.0.2"])
70
+ s.add_runtime_dependency(%q<dm-constraints>, ["~> 1.0.2"])
71
+ s.add_runtime_dependency(%q<dm-is-remixable>, ["~> 1.0.2"])
72
+ s.add_development_dependency(%q<rspec>, ["~> 1.3"])
73
+ s.add_development_dependency(%q<yard>, ["~> 0.5"])
74
+ else
75
+ s.add_dependency(%q<dm-core>, ["~> 1.0.2"])
76
+ s.add_dependency(%q<dm-constraints>, ["~> 1.0.2"])
77
+ s.add_dependency(%q<dm-is-remixable>, ["~> 1.0.2"])
78
+ s.add_dependency(%q<rspec>, ["~> 1.3"])
79
+ s.add_dependency(%q<yard>, ["~> 0.5"])
80
+ end
81
+ else
82
+ s.add_dependency(%q<dm-core>, ["~> 1.0.2"])
83
+ s.add_dependency(%q<dm-constraints>, ["~> 1.0.2"])
84
+ s.add_dependency(%q<dm-is-remixable>, ["~> 1.0.2"])
85
+ s.add_dependency(%q<rspec>, ["~> 1.3"])
86
+ s.add_dependency(%q<yard>, ["~> 0.5"])
87
+ end
88
+ end
89
+