seo_meta 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/license.md +21 -0
  2. data/readme.md +99 -0
  3. metadata +4 -2
data/license.md ADDED
@@ -0,0 +1,21 @@
1
+ # MIT License
2
+
3
+ Copyright (c) 2011 [Philip Arndt](http://philiparndt.name)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/readme.md ADDED
@@ -0,0 +1,99 @@
1
+ # SEO Meta tags plugin
2
+
3
+ ## Installation
4
+
5
+ Add to your project using your Bundler Gemfile:
6
+
7
+ gem 'seo_meta'
8
+
9
+ Include in your model by calling the method `is_seo_meta` in the class declaration,
10
+ for example with `Page`:
11
+
12
+ class Page < ActiveRecord::Base
13
+ is_seo_meta
14
+ end
15
+
16
+ Run the generator:
17
+
18
+ rails generate seo_meta
19
+
20
+ Migrate the database (unless you want to read 'Migrating existing data' below first):
21
+
22
+ rake db:migrate
23
+
24
+ ## Migrating existing data
25
+
26
+ This step is only if you already implemented SEO meta tag fields in your model.
27
+
28
+ At this point you could add to the migration that is generated in `db/migrate/`
29
+ logic to migrate across your existing data and remove the columns from your model
30
+ afterward, for example with `Page`:
31
+
32
+ class CreateSeoMeta < ActiveRecord::Migration
33
+
34
+ def self.up
35
+ # ... migration logic from the seo_meta generator ...
36
+
37
+ # Grab the attributes of the records that currently exist
38
+ existing_pages = ::Page.all.map(&:attributes)
39
+
40
+ # Remove columns
41
+ ::SeoMeta.attributes.each do |field|
42
+ if ::Page.column_names.map(&:to_sym).include?(field)
43
+ remove_column ::Page.table_name, field
44
+ end
45
+ end
46
+
47
+ # Reset column information because otherwise the old columns will still exist.
48
+ ::Page.reset_column_information
49
+
50
+ # Re-attach seo_meta
51
+ ::Page.module_eval do
52
+ is_seo_meta
53
+ end
54
+
55
+ # Migrate data
56
+ existing_pages.each do |page|
57
+ ::Page.find(page['id']).update_attributes({
58
+ ::SeoMeta.attributes.keys.inject({}) {|attributes, name|
59
+ attributes.merge(name => translation[name.to_s])
60
+ }
61
+ })
62
+ end
63
+ end
64
+
65
+ def self.down
66
+ # Grab the attributes of the records that currently exist
67
+ existing_pages = ::Page.all.map(&:attributes)
68
+
69
+ # Add columns back to your model
70
+ ::SeoMeta.attributes.each do |field, field_type|
71
+ unless ::Page.column_names.map(&:to_sym).include?(field)
72
+ add_column ::Page.table_name, field, field_type
73
+ end
74
+ end
75
+
76
+ # Reset column information because otherwise the new columns won't exist yet.
77
+ ::Page.reset_column_information
78
+
79
+ # Migrate data
80
+ existing_pages.each do |page|
81
+ ::Page.find(page['id']).update_attributes({
82
+ ::SeoMeta.attributes.keys.inject({}) {|attributes, name|
83
+ attributes.merge(name => translation[name.to_s])
84
+ }
85
+ })
86
+ end
87
+
88
+ # ... migration logic from the seo_meta generator ...
89
+ end
90
+
91
+ end
92
+
93
+ Now, run:
94
+
95
+ rake db:migrate
96
+
97
+ ## Anything else?
98
+
99
+ Nope, all done!
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: seo_meta
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.0
5
+ version: 1.0.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Philip Arndt
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-29 00:00:00 +13:00
13
+ date: 2011-03-30 00:00:00 +13:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -40,6 +40,8 @@ files:
40
40
  - lib/tasks/seo_meta.rake
41
41
  - db/migrate/1_create_seo_meta.rb
42
42
  - app/models/seo_metum.rb
43
+ - license.md
44
+ - readme.md
43
45
  has_rdoc: true
44
46
  homepage: http://philiparndt.name
45
47
  licenses: []