tag_ocelot 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +5 -0
- data/Gemfile +3 -0
- data/app/models/tag_ocelot/tag.rb +6 -0
- data/app/models/tag_ocelot/tagging.rb +7 -0
- data/db/migrate/1_tag_tables.rb +27 -0
- data/lib/tag_ocelot/active_record.rb +16 -0
- data/lib/tag_ocelot/engine.rb +12 -0
- data/lib/tag_ocelot/tag_names.rb +0 -0
- data/lib/tag_ocelot.rb +8 -0
- data/spec/acceptance/tag_names_spec.rb +0 -0
- data/spec/acceptance/tags_spec.rb +20 -0
- data/spec/internal/app/models/article.rb +3 -0
- data/spec/internal/config/database.yml +3 -0
- data/spec/internal/db/schema.rb +6 -0
- data/spec/spec_helper.rb +11 -0
- data/tag_ocelot.gemspec +6 -2
- metadata +97 -39
data/.gitignore
ADDED
data/Gemfile
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
class TagTables < ActiveRecord::Migration
|
|
2
|
+
def up
|
|
3
|
+
create_table :taggings do |t|
|
|
4
|
+
t.integer :tag_id, :null => false
|
|
5
|
+
t.integer :taggable_id, :null => false
|
|
6
|
+
t.string :taggable_type, :null => false
|
|
7
|
+
t.timestamps
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
add_index :taggings, :tag_id
|
|
11
|
+
add_index :taggings, [:taggable_type, :taggable_id]
|
|
12
|
+
add_index :taggings, [:taggable_type, :taggable_id, :tag_id],
|
|
13
|
+
:unique => true, :name => 'unique_taggings'
|
|
14
|
+
|
|
15
|
+
create_table :tags do |t|
|
|
16
|
+
t.string :name, :null => false
|
|
17
|
+
t.timestamps
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
add_index :tags, :name, :unique => true
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def down
|
|
24
|
+
drop_table :tags
|
|
25
|
+
drop_table :taggings
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module TagOcelot::ActiveRecord
|
|
2
|
+
def self.included(base)
|
|
3
|
+
# include our class methods
|
|
4
|
+
base.extend TagOcelot::ActiveRecord::ClassMethods
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
module ClassMethods
|
|
8
|
+
# Set up the underlying tag associations in the model
|
|
9
|
+
def has_many_tags
|
|
10
|
+
has_many :taggings, :class_name => 'TagOcelot::Tagging',
|
|
11
|
+
:as => :taggable, :dependent => :destroy
|
|
12
|
+
has_many :tags, :class_name => 'TagOcelot::Tag',
|
|
13
|
+
:through => :taggings
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require 'rails/engine'
|
|
2
|
+
|
|
3
|
+
class TagOcelot::Engine < Rails::Engine
|
|
4
|
+
# set our engine name
|
|
5
|
+
engine_name :tag_echidna
|
|
6
|
+
|
|
7
|
+
ActiveSupport.on_load :active_record do
|
|
8
|
+
# this is run when Rails loads ActiveRecord, and is
|
|
9
|
+
# within the context of ActiveRecord::Base.
|
|
10
|
+
include TagOcelot::ActiveRecord
|
|
11
|
+
end
|
|
12
|
+
end
|
|
File without changes
|
data/lib/tag_ocelot.rb
CHANGED
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe 'Adding and removing tags' do
|
|
4
|
+
let(:article) { Article.create }
|
|
5
|
+
let(:pancakes) { TagOcelot::Tag.create :name => 'pancakes' }
|
|
6
|
+
|
|
7
|
+
it "stores new tags" do
|
|
8
|
+
article.tags << pancakes
|
|
9
|
+
|
|
10
|
+
article.tags.reload.should == [pancakes]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "removes existing tags" do
|
|
14
|
+
article.tags << pancakes
|
|
15
|
+
|
|
16
|
+
article.tags.delete pancakes
|
|
17
|
+
|
|
18
|
+
article.tags.reload.should == []
|
|
19
|
+
end
|
|
20
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/tag_ocelot.gemspec
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
2
|
Gem::Specification.new do |s|
|
|
3
3
|
s.name = 'tag_ocelot'
|
|
4
|
-
s.version = '0.0.
|
|
4
|
+
s.version = '0.0.2'
|
|
5
5
|
s.authors = ['Brian Case']
|
|
6
6
|
s.email = ['brian@curvo.com']
|
|
7
7
|
s.homepage = 'https://github.com/curvo/tag_ocelot'
|
|
@@ -11,4 +11,8 @@ Gem::Specification.new do |s|
|
|
|
11
11
|
s.files = `git ls-files`.split("\n")
|
|
12
12
|
s.test_files = `git ls-files -- {spec}/*`.split("\n")
|
|
13
13
|
s.require_paths = ['lib']
|
|
14
|
-
|
|
14
|
+
s.add_runtime_dependency 'activerecord', '>= 3.2.0'
|
|
15
|
+
s.add_development_dependency 'combustion', '~> 0.4.0'
|
|
16
|
+
s.add_development_dependency 'rspec-rails', '~> 2.13'
|
|
17
|
+
s.add_development_dependency 'sqlite3', '~> 1.3.7'
|
|
18
|
+
end
|
metadata
CHANGED
|
@@ -1,67 +1,125 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tag_ocelot
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.2
|
|
5
5
|
prerelease:
|
|
6
|
-
segments:
|
|
7
|
-
- 0
|
|
8
|
-
- 0
|
|
9
|
-
- 1
|
|
10
|
-
version: 0.0.1
|
|
11
6
|
platform: ruby
|
|
12
|
-
authors:
|
|
7
|
+
authors:
|
|
13
8
|
- Brian Case
|
|
14
9
|
autorequire:
|
|
15
10
|
bindir: bin
|
|
16
11
|
cert_chain: []
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
date: 2013-05-01 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: activerecord
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: 3.2.0
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ! '>='
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: 3.2.0
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
31
|
+
name: combustion
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
none: false
|
|
34
|
+
requirements:
|
|
35
|
+
- - ~>
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: 0.4.0
|
|
38
|
+
type: :development
|
|
39
|
+
prerelease: false
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ~>
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: 0.4.0
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: rspec-rails
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
none: false
|
|
50
|
+
requirements:
|
|
51
|
+
- - ~>
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '2.13'
|
|
54
|
+
type: :development
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
none: false
|
|
58
|
+
requirements:
|
|
59
|
+
- - ~>
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '2.13'
|
|
62
|
+
- !ruby/object:Gem::Dependency
|
|
63
|
+
name: sqlite3
|
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
|
65
|
+
none: false
|
|
66
|
+
requirements:
|
|
67
|
+
- - ~>
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: 1.3.7
|
|
70
|
+
type: :development
|
|
71
|
+
prerelease: false
|
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
73
|
+
none: false
|
|
74
|
+
requirements:
|
|
75
|
+
- - ~>
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
version: 1.3.7
|
|
21
78
|
description: This friendly ocelot gives you tags in your Rails app.
|
|
22
|
-
email:
|
|
79
|
+
email:
|
|
23
80
|
- brian@curvo.com
|
|
24
81
|
executables: []
|
|
25
|
-
|
|
26
82
|
extensions: []
|
|
27
|
-
|
|
28
83
|
extra_rdoc_files: []
|
|
29
|
-
|
|
30
|
-
|
|
84
|
+
files:
|
|
85
|
+
- .gitignore
|
|
86
|
+
- Gemfile
|
|
87
|
+
- app/models/tag_ocelot/tag.rb
|
|
88
|
+
- app/models/tag_ocelot/tagging.rb
|
|
89
|
+
- db/migrate/1_tag_tables.rb
|
|
31
90
|
- lib/tag_ocelot.rb
|
|
91
|
+
- lib/tag_ocelot/active_record.rb
|
|
92
|
+
- lib/tag_ocelot/engine.rb
|
|
93
|
+
- lib/tag_ocelot/tag_names.rb
|
|
94
|
+
- spec/acceptance/tag_names_spec.rb
|
|
95
|
+
- spec/acceptance/tags_spec.rb
|
|
96
|
+
- spec/internal/app/models/article.rb
|
|
97
|
+
- spec/internal/config/database.yml
|
|
98
|
+
- spec/internal/db/schema.rb
|
|
99
|
+
- spec/spec_helper.rb
|
|
32
100
|
- tag_ocelot.gemspec
|
|
33
101
|
homepage: https://github.com/curvo/tag_ocelot
|
|
34
102
|
licenses: []
|
|
35
|
-
|
|
36
103
|
post_install_message:
|
|
37
104
|
rdoc_options: []
|
|
38
|
-
|
|
39
|
-
require_paths:
|
|
105
|
+
require_paths:
|
|
40
106
|
- lib
|
|
41
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
42
108
|
none: false
|
|
43
|
-
requirements:
|
|
44
|
-
- -
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
- 0
|
|
49
|
-
version: "0"
|
|
50
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
|
+
requirements:
|
|
110
|
+
- - ! '>='
|
|
111
|
+
- !ruby/object:Gem::Version
|
|
112
|
+
version: '0'
|
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
114
|
none: false
|
|
52
|
-
requirements:
|
|
53
|
-
- -
|
|
54
|
-
- !ruby/object:Gem::Version
|
|
55
|
-
|
|
56
|
-
segments:
|
|
57
|
-
- 0
|
|
58
|
-
version: "0"
|
|
115
|
+
requirements:
|
|
116
|
+
- - ! '>='
|
|
117
|
+
- !ruby/object:Gem::Version
|
|
118
|
+
version: '0'
|
|
59
119
|
requirements: []
|
|
60
|
-
|
|
61
120
|
rubyforge_project:
|
|
62
121
|
rubygems_version: 1.8.24
|
|
63
122
|
signing_key:
|
|
64
123
|
specification_version: 3
|
|
65
124
|
summary: The Tag Ocelot
|
|
66
125
|
test_files: []
|
|
67
|
-
|