tag_mio 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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTIwYTExMWNiNzE2NDcxNmQ1ZGNjMmI4ODJjOWVkZjk4ZmU5OWM1NQ==
4
+ ZWE0ODViYjU2NWE5MDY1YTgxMTUzMGEyMzRhOGZkM2Q0ZWZjM2I4Mg==
5
5
  data.tar.gz: !binary |-
6
- MTM2ODc4MWJlNGNjNjY1Yzk1MDZmMWNmOTI5NTI5NDcxMjU1MDVlMw==
6
+ YzNiNjljNTgwOWNjMTUzNzI2NjRhZTQxYTFiNTNmNWY2MWNlMjA4Ng==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MDFiMDBiNzA2MmU1NDVlZjRmYmQ2Nzc5ZmM5ZWI4NGI1OTk4ODVmZTg3NTVj
10
- MmI0MDJiMzMxMjlkM2E1YjViNmJjM2E0NTQ4ODM4NjE3OWViMTRiNmRiNWRh
11
- NTZkMGExZjFiODcwODUwZDA2ZTRmOTEyM2YzNGY5ODEwYWE4NjQ=
9
+ ZWNlMDViOTNkMTQyOTVlMGYxOTljN2M1NmQ3MzZjNzExZWNlZjVmMjM0NmM0
10
+ M2I4ODgzNGIzY2E5NjE1ZTM4NGZhYTViY2UxM2IwM2UzYWMzOGE2ZDMzMTVl
11
+ MDZiYTU5YjVkMTRmOWNiYTA0MDcwNDQzMmY1ZGRmYTk2ZDRiMGE=
12
12
  data.tar.gz: !binary |-
13
- YWI4NjVjODIyYzZkZDg2ZmE5OTg0M2Q2YWJmZDViMzhlZTRkNGYzYzJlZWMz
14
- YTEyODNhNDg4NmZhNjg0YzM2ZDA3MzFlYTAxOWZiZGNmNjEwODhlYTI5MGM3
15
- ZWJjMWJkNmQ4ODJhMjBlZDMzOWRmMjE5MjY3ZmM4N2JlYWRlYmQ=
13
+ NWM2YjQwNWZlN2QzY2MzMTc0NDkzNzFlZmI3NDg5NTkyY2U5NTU3NmExNDYz
14
+ YzgwYTJjMzUxZWUwNjdkNDYxNTIyYzEwYzA4N2E5ZWE0YWQyZTIzNTZjZDA0
15
+ ZWQ3ZGFkM2I5YTI2OGI3ZWNlZjE0OGYwNWQ0YmYwMWQzZWUzMTA=
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ spec/internal/db/*.sqlite
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,6 @@
1
+ class TagMio::Tag < ActiveRecord::Base
2
+ has_many :taggings, :class_name => 'TagMio::Tagging',
3
+ :dependent => :destroy
4
+
5
+ validates :name, :presence => true, :uniqueness => true
6
+ end
@@ -0,0 +1,7 @@
1
+ class TagMio::Tagging < ActiveRecord::Base
2
+ belongs_to :taggable, :polymorphic => true
3
+ belongs_to :tag, :class_name => 'TagMio::Tag'
4
+
5
+ validates :taggable, :presence => true
6
+ validates :tag, :presence => true
7
+ end
@@ -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
data/lib/tag_mio.rb CHANGED
@@ -0,0 +1,8 @@
1
+ # Declare our top level module
2
+ module TagMio
3
+ #
4
+ end
5
+
6
+ # Require the rest of the gem's files
7
+ require 'tag_mio/active_record'
8
+ require 'tag_mio/engine'
@@ -0,0 +1,16 @@
1
+ module TagMio::ActiveRecord
2
+ def self.included(base)
3
+ # include our class methods
4
+ base.extend TagMio::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 => 'TagMio::Tagging',
11
+ :as => :taggable, :dependent => :destroy
12
+ has_many :tags, :class_name => 'TagMio::Tag',
13
+ :through => :taggings
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ require 'rails/engine'
2
+
3
+ class TagMio::Engine < Rails::Engine
4
+ # set our engine name
5
+ engine_name :tag_mio
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 TagMio::ActiveRecord
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Adding and removing tags' do
4
+ let(:article) { Article.create }
5
+ let(:pancakes) { TagMio::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
@@ -0,0 +1,3 @@
1
+ class Article < ActiveRecord::Base
2
+ has_many_tags
3
+ end
@@ -0,0 +1,3 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/combustion_test.sqlite
@@ -0,0 +1,6 @@
1
+ ActiveRecord::Schema.define do
2
+ create_table :articles, :force => true do |t|
3
+ t.string :title
4
+ t.timestamps
5
+ end
6
+ end
@@ -0,0 +1 @@
1
+ *.log
@@ -0,0 +1,11 @@
1
+ require 'bundler'
2
+
3
+ Bundler.require :default, :development
4
+
5
+ Combustion.initialize! :active_record
6
+
7
+ require 'rspec/rails'
8
+
9
+ RSpec.configure do |config|
10
+ config.use_transactional_fixtures = true
11
+ end
data/tag_mio.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'tag_mio'
3
- s.version = '0.0.1'
3
+ s.version = '0.0.2'
4
4
  s.authors = ['Gianluigi Pignatari']
5
5
  s.email = ['gianluigi@ggpdev.com']
6
6
  s.homepage = 'https://github.com/pignatarig/tag_mio'
@@ -10,4 +10,9 @@ Gem::Specification.new do |s|
10
10
  s.files = `git ls-files`.split("\n")
11
11
  s.test_files = `git ls-files -- {spec}/*`.split("\n")
12
12
  s.require_paths = ['lib']
13
+
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'
13
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tag_mio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gianluigi Pignatari
@@ -9,7 +9,63 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2013-05-01 00:00:00.000000000 Z
12
- dependencies: []
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 3.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: combustion
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.4.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.4.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '2.13'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.13'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sqlite3
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.3.7
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 1.3.7
13
69
  description: This friendly mio gives you tags in your Rails app. Also my first gem.
14
70
  email:
15
71
  - gianluigi@ggpdev.com
@@ -17,7 +73,20 @@ executables: []
17
73
  extensions: []
18
74
  extra_rdoc_files: []
19
75
  files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - app/models/tag_mio/tag.rb
79
+ - app/models/tag_mio/tagging.rb
80
+ - db/migrate/1_tag_tables.rb
20
81
  - lib/tag_mio.rb
82
+ - lib/tag_mio/active_record.rb
83
+ - lib/tag_mio/engine.rb
84
+ - spec/acceptance/tags_spec.rb
85
+ - spec/internal/app/models/article.rb
86
+ - spec/internal/config/database.yml
87
+ - spec/internal/db/schema.rb
88
+ - spec/internal/log/.gitignore
89
+ - spec/spec_helper.rb
21
90
  - tag_mio.gemspec
22
91
  homepage: https://github.com/pignatarig/tag_mio
23
92
  licenses: []