etiqueta_rails 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/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,89 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ etiqueta_rails (0.0.1)
5
+ activerecord (>= 3.2.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (3.2.13)
11
+ activemodel (= 3.2.13)
12
+ activesupport (= 3.2.13)
13
+ builder (~> 3.0.0)
14
+ erubis (~> 2.7.0)
15
+ journey (~> 1.0.4)
16
+ rack (~> 1.4.5)
17
+ rack-cache (~> 1.2)
18
+ rack-test (~> 0.6.1)
19
+ sprockets (~> 2.2.1)
20
+ activemodel (3.2.13)
21
+ activesupport (= 3.2.13)
22
+ builder (~> 3.0.0)
23
+ activerecord (3.2.13)
24
+ activemodel (= 3.2.13)
25
+ activesupport (= 3.2.13)
26
+ arel (~> 3.0.2)
27
+ tzinfo (~> 0.3.29)
28
+ activesupport (3.2.13)
29
+ i18n (= 0.6.1)
30
+ multi_json (~> 1.0)
31
+ arel (3.0.2)
32
+ builder (3.0.4)
33
+ combustion (0.4.0)
34
+ activesupport (>= 3.0.0)
35
+ railties (>= 3.0.0)
36
+ thor (>= 0.14.6)
37
+ diff-lcs (1.2.4)
38
+ erubis (2.7.0)
39
+ hike (1.2.2)
40
+ i18n (0.6.1)
41
+ journey (1.0.4)
42
+ json (1.7.7)
43
+ multi_json (1.7.2)
44
+ rack (1.4.5)
45
+ rack-cache (1.2)
46
+ rack (>= 0.4)
47
+ rack-ssl (1.3.3)
48
+ rack
49
+ rack-test (0.6.2)
50
+ rack (>= 1.0)
51
+ railties (3.2.13)
52
+ actionpack (= 3.2.13)
53
+ activesupport (= 3.2.13)
54
+ rack-ssl (~> 1.3.2)
55
+ rake (>= 0.8.7)
56
+ rdoc (~> 3.4)
57
+ thor (>= 0.14.6, < 2.0)
58
+ rake (10.0.4)
59
+ rdoc (3.12.2)
60
+ json (~> 1.4)
61
+ rspec-core (2.13.1)
62
+ rspec-expectations (2.13.0)
63
+ diff-lcs (>= 1.1.3, < 2.0)
64
+ rspec-mocks (2.13.1)
65
+ rspec-rails (2.13.1)
66
+ actionpack (>= 3.0)
67
+ activesupport (>= 3.0)
68
+ railties (>= 3.0)
69
+ rspec-core (~> 2.13.0)
70
+ rspec-expectations (~> 2.13.0)
71
+ rspec-mocks (~> 2.13.0)
72
+ sprockets (2.2.2)
73
+ hike (~> 1.2)
74
+ multi_json (~> 1.0)
75
+ rack (~> 1.0)
76
+ tilt (~> 1.1, != 1.3.0)
77
+ sqlite3 (1.3.7)
78
+ thor (0.18.1)
79
+ tilt (1.4.0)
80
+ tzinfo (0.3.37)
81
+
82
+ PLATFORMS
83
+ ruby
84
+
85
+ DEPENDENCIES
86
+ combustion (~> 0.4.0)
87
+ etiqueta_rails!
88
+ rspec-rails (~> 2.13)
89
+ sqlite3 (~> 1.3.7)
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = 'etiqueta_rails'
4
- s.version = '0.0.1'
4
+ s.version = '0.0.2'
5
5
  s.authors = ['Heriberto Perez', 'Victor Velazquez']
6
6
  s.email = ['victorvelazquezgaspar@gmail.com', 'heriberto.perez@crowdint.com']
7
7
  s.homepage = 'https://github.com/heridev/etiqueta_rails'
@@ -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
+ 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'
14
18
  end
@@ -0,0 +1,8 @@
1
+ # Declare our top level module
2
+ module EtiquetaRails
3
+ #
4
+ end
5
+
6
+ # Require the rest of the gem's files
7
+ require 'etiqueta_rails/active_record'
8
+ require 'etiqueta_rails/engine'
@@ -0,0 +1,16 @@
1
+ module EtiquetaRails::ActiveRecord
2
+ def self.included(base)
3
+ # include our class methods
4
+ base.extend EtiquetaRails::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 => 'EtiquetaRails::Tagging',
11
+ :as => :taggable, :dependent => :destroy
12
+ has_many :tags, :class_name => 'EtiquetaRails::Tag',
13
+ :through => :taggings
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ require 'rails/engine'
2
+
3
+ class EtiquetaRails::Engine < Rails::Engine
4
+ # set our engine name
5
+ engine_name :etiqueta_rails
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 EtiquetaRails::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) { EtiquetaRails::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,6 @@
1
+ class EtiquetaRails::Tag < ActiveRecord::Base
2
+ has_many :taggings, :class_name => 'EtiquetaRails::Tagging',
3
+ :dependent => :destroy
4
+
5
+ validates :name, :presence => true, :uniqueness => true
6
+ end
@@ -0,0 +1,7 @@
1
+ class EtiquetaRails::Tagging < ActiveRecord::Base
2
+ belongs_to :taggable, :polymorphic => true
3
+ belongs_to :tag, :class_name => 'EtiquetaRails::Tag'
4
+
5
+ validates :taggable, :presence => true
6
+ validates :tag, :presence => true
7
+ end
@@ -0,0 +1,3 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/combustion_test.sqlite
@@ -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,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,3 @@
1
+ *.log
2
+ Gemfile.lock
3
+ spec/internal/db/*.sqlite
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: etiqueta_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,71 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
  date: 2013-05-01 00:00:00.000000000 Z
14
- dependencies: []
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: activerecord
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 3.2.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: 3.2.0
31
+ - !ruby/object:Gem::Dependency
32
+ name: combustion
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: 0.4.0
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: 0.4.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec-rails
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.13'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: '2.13'
63
+ - !ruby/object:Gem::Dependency
64
+ name: sqlite3
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
70
+ version: 1.3.7
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: 1.3.7
15
79
  description: This friendly etiqueta rails gem give you tags in your Rails app.
16
80
  email:
17
81
  - victorvelazquezgaspar@gmail.com
@@ -20,8 +84,22 @@ executables: []
20
84
  extensions: []
21
85
  extra_rdoc_files: []
22
86
  files:
87
+ - Gemfile
88
+ - Gemfile.lock
23
89
  - etiqueta_rails.gemspec
24
90
  - lib/etiqueta_rails.rb
91
+ - lib/etiqueta_rails/active_record.rb
92
+ - lib/etiqueta_rails/engine.rb
93
+ - spec/acceptance/etiqueta_rails_spec.rb
94
+ - spec/internal/app/models/article.rb
95
+ - spec/internal/app/models/etiqueta_rails/tag.rb
96
+ - spec/internal/app/models/etiqueta_rails/tagging.rb
97
+ - spec/internal/config/database.yml
98
+ - spec/internal/db/combustion_test.sqlite
99
+ - spec/internal/db/migrate/1_tag_tables.rb
100
+ - spec/internal/db/schema.rb
101
+ - spec/internal/log/.gitignore
102
+ - spec/spec_helper.rb
25
103
  homepage: https://github.com/heridev/etiqueta_rails
26
104
  licenses: []
27
105
  post_install_message: