Skip to content
This repository
Browse code

Renamed seed and blog structure migration, removed name option from g…

…enerator, regenerated gemspec.
  • Loading branch information...
commit a058a24e90d46cb0efd0654c7d3385db23ef3ba3 1 parent 7ac190f
Philip Arndt authored March 04, 2011
54  db/migrate/1_create_blog_structure.rb
... ...
@@ -0,0 +1,54 @@
  1
+class CreateBlogStructure < ActiveRecord::Migration
  2
+
  3
+  def self.up
  4
+    create_table :blog_posts, :id => true do |t|
  5
+      t.string :title
  6
+      t.text :body
  7
+      t.boolean :draft
  8
+      t.datetime :published_at
  9
+      t.timestamps
  10
+    end
  11
+
  12
+    add_index :blog_posts, :id
  13
+
  14
+    create_table :blog_comments, :id => true do |t|
  15
+      t.integer :blog_post_id
  16
+      t.boolean :spam
  17
+      t.string :name
  18
+      t.string :email
  19
+      t.text :body
  20
+      t.string :state
  21
+      t.timestamps
  22
+    end
  23
+
  24
+    add_index :blog_comments, :id
  25
+
  26
+    create_table :blog_categories, :id => true do |t|
  27
+      t.string :title
  28
+      t.timestamps
  29
+    end
  30
+
  31
+    add_index :blog_categories, :id
  32
+
  33
+    create_table :blog_categories_blog_posts, :id => false do |t|
  34
+      t.integer :blog_category_id
  35
+      t.integer :blog_post_id
  36
+    end
  37
+
  38
+    add_index :blog_categories_blog_posts, [:blog_category_id, :blog_post_id], :name => 'index_blog_categories_blog_posts_on_bc_and_bp'
  39
+
  40
+    load(Rails.root.join('db', 'seeds', 'refinerycms_blog.rb').to_s)
  41
+  end
  42
+
  43
+  def self.down
  44
+    UserPlugin.destroy_all({:name => "refinerycms_blog"})
  45
+
  46
+    Page.delete_all({:link_url => "/blog"})
  47
+
  48
+    drop_table :blog_posts
  49
+    drop_table :blog_comments
  50
+    drop_table :blog_categories
  51
+    drop_table :blog_categories_blog_posts
  52
+  end
  53
+
  54
+end
57  db/migrate/1_create_singular_name.rb
... ...
@@ -1,57 +0,0 @@
1  
-@refinerycms_blog_tables = [{
2  
-  :table_name => 'blog_posts',
3  
-  :attributes => [
4  
-    Rails::Generators::GeneratedAttribute.new('title', 'string'),
5  
-    Rails::Generators::GeneratedAttribute.new('body', 'text'),
6  
-    Rails::Generators::GeneratedAttribute.new('draft', 'boolean'),
7  
-    Rails::Generators::GeneratedAttribute.new('published_at', 'datetime')
8  
-  ], :id => true
9  
-},{
10  
-  :table_name => 'blog_comments',
11  
-  :attributes => [
12  
-    Rails::Generators::GeneratedAttribute.new('blog_post_id', 'integer'),
13  
-    Rails::Generators::GeneratedAttribute.new('spam', 'boolean'),
14  
-    Rails::Generators::GeneratedAttribute.new('name', 'string'),
15  
-    Rails::Generators::GeneratedAttribute.new('email', 'string'),
16  
-    Rails::Generators::GeneratedAttribute.new('body', 'text'),
17  
-    Rails::Generators::GeneratedAttribute.new('state', 'string')
18  
-  ], :id => true
19  
-},{
20  
-  :table_name => 'blog_categories',
21  
-  :attributes => [
22  
-    Rails::Generators::GeneratedAttribute.new('title', 'string')
23  
-  ], :id => true
24  
-},{
25  
-  :table_name => 'blog_categories_blog_posts',
26  
-  :attributes => [
27  
-    Rails::Generators::GeneratedAttribute.new('blog_category_id', 'integer'),
28  
-    Rails::Generators::GeneratedAttribute.new('blog_post_id', 'integer')
29  
-  ], :id => false
30  
-}]
31  
-
32  
-class Create<%= singular_name.camelize %> < ActiveRecord::Migration
33  
-
34  
-  def self.up<% @refinerycms_blog_tables.each do |table| %>
35  
-    create_table :<%= table[:table_name] %>, :id => <%= table[:id].to_s %> do |t|
36  
-<% table[:attributes].each do |attribute| -%>
37  
-      t.<%= attribute.type %> :<%= attribute.name %>
38  
-<% end -%>
39  
-      <%= 't.timestamps' if table[:id] %>
40  
-    end
41  
-
42  
-    <%= "add_index :#{table[:table_name]}, :id" if table[:id] %>
43  
-<% end -%>
44  
-    load(Rails.root.join('db', 'seeds', 'refinerycms_blog.rb').to_s)
45  
-  end
46  
-
47  
-  def self.down
48  
-    UserPlugin.destroy_all({:name => "refinerycms_blog"})
49  
-
50  
-    Page.delete_all({:link_url => "/blog"})
51  
-
52  
-<% @refinerycms_blog_tables.each do |table| -%>
53  
-    drop_table :<%= table[:table_name] %>
54  
-<% end -%>
55  
-  end
56  
-
57  
-end
0  db/seeds/seed.rb → db/seeds/refinerycms_blog.rb
File renamed without changes
1  lib/generators/refinerycms_blog_generator.rb
@@ -3,7 +3,6 @@
3 3
 class RefinerycmsBlogGenerator < ::Refinery::Generators::EngineInstaller
4 4
 
5 5
   source_root File.expand_path('../../../', __FILE__)
6  
-  argument :name, :type => :string, :default => 'blog_structure', :banner => ''
7 6
   engine_name "refinerycms-blog"
8 7
 
9 8
 end
27  refinerycms-blog.gemspec
... ...
@@ -1,8 +1,8 @@
1 1
 Gem::Specification.new do |s|
2 2
   s.name              = %q{refinerycms-blog}
3  
-  s.version           = %q{1.2}
  3
+  s.version           = %q{1.3}
4 4
   s.description       = %q{A really straightforward open source Ruby on Rails blog engine designed for integration with RefineryCMS.}
5  
-  s.date              = %q{2011-03-02}
  5
+  s.date              = %q{2011-03-04}
6 6
   s.summary           = %q{Ruby on Rails blogging engine for RefineryCMS.}
7 7
   s.email             = %q{info@refinerycms.com}
8 8
   s.homepage          = %q{http://refinerycms.com}
@@ -97,6 +97,12 @@ Gem::Specification.new do |s|
97 97
     config/locales/pt-BR.yml
98 98
     config/locales/ru.yml
99 99
     config/routes.rb
  100
+    db
  101
+    db/migrate
  102
+    db/migrate/1_create_blog_structure.rb
  103
+    db/migrate/2_add_user_id_to_blog_posts.rb
  104
+    db/seeds
  105
+    db/seeds/refinerycms_blog.rb
100 106
     features
101 107
     features/authors.feature
102 108
     features/support
@@ -107,26 +113,11 @@ Gem::Specification.new do |s|
107 113
     features/support/paths.rb
108 114
     features/support/step_definitions
109 115
     features/support/step_definitions/authors_steps.rb
110  
-    generators
111  
-    generators/refinerycms_blog
112  
-    generators/refinerycms_blog/refinerycms_blog_generator.rb
113  
-    generators/refinerycms_blog/templates
114  
-    generators/refinerycms_blog/templates/db
115  
-    generators/refinerycms_blog/templates/db/migrate
116  
-    generators/refinerycms_blog/templates/db/migrate/migration.rb
117  
-    generators/refinerycms_blog/templates/db/seeds
118  
-    generators/refinerycms_blog/templates/db/seeds/seed.rb
119 116
     lib
120 117
     lib/gemspec.rb
121 118
     lib/generators
122 119
     lib/generators/refinerycms_blog
123 120
     lib/generators/refinerycms_blog/templates
124  
-    lib/generators/refinerycms_blog/templates/db
125  
-    lib/generators/refinerycms_blog/templates/db/migrate
126  
-    lib/generators/refinerycms_blog/templates/db/migrate/migration_number_add_user_id_to_blog_posts.rb
127  
-    lib/generators/refinerycms_blog/templates/db/migrate/migration_number_create_singular_name.rb
128  
-    lib/generators/refinerycms_blog/templates/db/seeds
129  
-    lib/generators/refinerycms_blog/templates/db/seeds/seed.rb
130 121
     lib/generators/refinerycms_blog_generator.rb
131 122
     lib/refinerycms-blog.rb
132 123
     public
@@ -155,8 +146,6 @@ Gem::Specification.new do |s|
155 146
     public/stylesheets/refinery
156 147
     public/stylesheets/refinery/refinerycms-blog.css
157 148
     public/stylesheets/refinerycms-blog.css
158  
-    rails
159  
-    rails/init.rb
160 149
     readme.md
161 150
     spec
162 151
     spec/models

0 notes on commit a058a24

Please sign in to comment.
Something went wrong with that request. Please try again.