prusswan-forem 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/.gitignore +7 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +17 -0
  4. data/Gemfile.lock +135 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.rdoc +3 -0
  7. data/Rakefile +33 -0
  8. data/app/assets/images/forem/.gitkeep +0 -0
  9. data/app/assets/javascripts/forem/application.js +15 -0
  10. data/app/assets/javascripts/forem/forem/topics.js +2 -0
  11. data/app/assets/javascripts/forem/posts.js +2 -0
  12. data/app/assets/javascripts/forem/topics.js +2 -0
  13. data/app/assets/stylesheets/forem/application.css +13 -0
  14. data/app/assets/stylesheets/forem/forem/topics.css +4 -0
  15. data/app/assets/stylesheets/forem/posts.css +4 -0
  16. data/app/assets/stylesheets/forem/topics.css +4 -0
  17. data/app/controllers/forem/application_controller.rb +11 -0
  18. data/app/controllers/forem/posts_controller.rb +24 -0
  19. data/app/controllers/forem/topics_controller.rb +27 -0
  20. data/app/helpers/forem/application_helper.rb +4 -0
  21. data/app/helpers/forem/posts_helper.rb +4 -0
  22. data/app/helpers/forem/topics_helper.rb +4 -0
  23. data/app/models/forem/post.rb +8 -0
  24. data/app/models/forem/topic.rb +17 -0
  25. data/app/views/forem/posts/_form.html.erb +4 -0
  26. data/app/views/forem/posts/_post.html.erb +6 -0
  27. data/app/views/forem/posts/new.html.erb +5 -0
  28. data/app/views/forem/topics/_form.html.erb +11 -0
  29. data/app/views/forem/topics/index.html.erb +28 -0
  30. data/app/views/forem/topics/new.html.erb +2 -0
  31. data/app/views/forem/topics/show.html.erb +6 -0
  32. data/app/views/layouts/forem/application.html.erb +15 -0
  33. data/config/routes.rb +7 -0
  34. data/db/migrate/20120727035001_create_forem_topics.rb +10 -0
  35. data/db/migrate/20120727083000_create_forem_posts.rb +11 -0
  36. data/db/migrate/20120727091721_add_posts_count_to_forem_topics.rb +5 -0
  37. data/lib/forem/engine.rb +19 -0
  38. data/lib/forem/version.rb +3 -0
  39. data/lib/forem.rb +6 -0
  40. data/lib/tasks/forem_tasks.rake +4 -0
  41. data/prusswan-forem.gemspec +25 -0
  42. data/script/rails +8 -0
  43. data/spec/configuration_spec.rb +14 -0
  44. data/spec/controllers/forem/posts_controller_spec.rb +5 -0
  45. data/spec/controllers/forem/topics_controller_spec.rb +5 -0
  46. data/spec/dummy/README.rdoc +261 -0
  47. data/spec/dummy/Rakefile +7 -0
  48. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  49. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  50. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  51. data/spec/dummy/app/controllers/fake_controller.rb +5 -0
  52. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  53. data/spec/dummy/app/mailers/.gitkeep +0 -0
  54. data/spec/dummy/app/models/.gitkeep +0 -0
  55. data/spec/dummy/app/models/user.rb +7 -0
  56. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  57. data/spec/dummy/config/application.rb +59 -0
  58. data/spec/dummy/config/boot.rb +10 -0
  59. data/spec/dummy/config/database.yml +25 -0
  60. data/spec/dummy/config/environment.rb +5 -0
  61. data/spec/dummy/config/environments/development.rb +37 -0
  62. data/spec/dummy/config/environments/production.rb +67 -0
  63. data/spec/dummy/config/environments/test.rb +37 -0
  64. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  65. data/spec/dummy/config/initializers/forem.rb +1 -0
  66. data/spec/dummy/config/initializers/inflections.rb +15 -0
  67. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  68. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  69. data/spec/dummy/config/initializers/session_store.rb +8 -0
  70. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  71. data/spec/dummy/config/locales/en.yml +5 -0
  72. data/spec/dummy/config/routes.rb +7 -0
  73. data/spec/dummy/config.ru +4 -0
  74. data/spec/dummy/db/migrate/20120727122700_create_users.rb +9 -0
  75. data/spec/dummy/db/schema.rb +38 -0
  76. data/spec/dummy/lib/assets/.gitkeep +0 -0
  77. data/spec/dummy/log/.gitkeep +0 -0
  78. data/spec/dummy/public/404.html +26 -0
  79. data/spec/dummy/public/422.html +26 -0
  80. data/spec/dummy/public/500.html +25 -0
  81. data/spec/dummy/public/favicon.ico +0 -0
  82. data/spec/dummy/script/rails +6 -0
  83. data/spec/requests/posts_spec.rb +62 -0
  84. data/spec/requests/topics_spec.rb +46 -0
  85. data/spec/spec_helper.rb +12 -0
  86. data/spec/support/capybara.rb +8 -0
  87. data/spec/support/dummy_login.rb +19 -0
  88. data/spec/support/load_routes.rb +5 -0
  89. metadata +203 -0
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ spec/dummy/db/*.sqlite3
5
+ spec/dummy/log/*.log
6
+ spec/dummy/tmp/
7
+ spec/dummy/.sass-cache
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source :rubygems
2
+
3
+ # Declare your gem's dependencies in forem.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ # jquery-rails is used by the dummy application
9
+ gem "jquery-rails"
10
+
11
+ # Declare any dependencies that are still in development here instead of in
12
+ # your gemspec. These might include edge Rails or gems from your path or
13
+ # Git. Remember to move these dependencies to your gemspec before releasing
14
+ # your gem to rubygems.org.
15
+
16
+ # To use debugger
17
+ # gem 'debugger'
data/Gemfile.lock ADDED
@@ -0,0 +1,135 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ prusswan-forem (0.0.2)
5
+ rails (~> 3.2.7)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ actionmailer (3.2.7)
11
+ actionpack (= 3.2.7)
12
+ mail (~> 2.4.4)
13
+ actionpack (3.2.7)
14
+ activemodel (= 3.2.7)
15
+ activesupport (= 3.2.7)
16
+ builder (~> 3.0.0)
17
+ erubis (~> 2.7.0)
18
+ journey (~> 1.0.4)
19
+ rack (~> 1.4.0)
20
+ rack-cache (~> 1.2)
21
+ rack-test (~> 0.6.1)
22
+ sprockets (~> 2.1.3)
23
+ activemodel (3.2.7)
24
+ activesupport (= 3.2.7)
25
+ builder (~> 3.0.0)
26
+ activerecord (3.2.7)
27
+ activemodel (= 3.2.7)
28
+ activesupport (= 3.2.7)
29
+ arel (~> 3.0.2)
30
+ tzinfo (~> 0.3.29)
31
+ activeresource (3.2.7)
32
+ activemodel (= 3.2.7)
33
+ activesupport (= 3.2.7)
34
+ activesupport (3.2.7)
35
+ i18n (~> 0.6)
36
+ multi_json (~> 1.0)
37
+ addressable (2.3.1)
38
+ arel (3.0.2)
39
+ builder (3.0.0)
40
+ capybara (1.1.2)
41
+ mime-types (>= 1.16)
42
+ nokogiri (>= 1.3.3)
43
+ rack (>= 1.0.0)
44
+ rack-test (>= 0.5.4)
45
+ selenium-webdriver (~> 2.0)
46
+ xpath (~> 0.1.4)
47
+ childprocess (0.3.4)
48
+ ffi (~> 1.0, >= 1.0.6)
49
+ diff-lcs (1.1.3)
50
+ erubis (2.7.0)
51
+ ffi (1.1.0)
52
+ hike (1.2.1)
53
+ i18n (0.6.0)
54
+ journey (1.0.4)
55
+ jquery-rails (2.0.2)
56
+ railties (>= 3.2.0, < 5.0)
57
+ thor (~> 0.14)
58
+ json (1.7.4)
59
+ libwebsocket (0.1.4)
60
+ addressable
61
+ mail (2.4.4)
62
+ i18n (>= 0.4.0)
63
+ mime-types (~> 1.16)
64
+ treetop (~> 1.4.8)
65
+ mime-types (1.19)
66
+ multi_json (1.3.6)
67
+ nokogiri (1.5.5)
68
+ polyglot (0.3.3)
69
+ rack (1.4.1)
70
+ rack-cache (1.2)
71
+ rack (>= 0.4)
72
+ rack-ssl (1.3.2)
73
+ rack
74
+ rack-test (0.6.1)
75
+ rack (>= 1.0)
76
+ rails (3.2.7)
77
+ actionmailer (= 3.2.7)
78
+ actionpack (= 3.2.7)
79
+ activerecord (= 3.2.7)
80
+ activeresource (= 3.2.7)
81
+ activesupport (= 3.2.7)
82
+ bundler (~> 1.0)
83
+ railties (= 3.2.7)
84
+ railties (3.2.7)
85
+ actionpack (= 3.2.7)
86
+ activesupport (= 3.2.7)
87
+ rack-ssl (~> 1.3.2)
88
+ rake (>= 0.8.7)
89
+ rdoc (~> 3.4)
90
+ thor (>= 0.14.6, < 2.0)
91
+ rake (0.9.2.2)
92
+ rdoc (3.12)
93
+ json (~> 1.4)
94
+ rspec (2.11.0)
95
+ rspec-core (~> 2.11.0)
96
+ rspec-expectations (~> 2.11.0)
97
+ rspec-mocks (~> 2.11.0)
98
+ rspec-core (2.11.1)
99
+ rspec-expectations (2.11.1)
100
+ diff-lcs (~> 1.1.3)
101
+ rspec-mocks (2.11.1)
102
+ rspec-rails (2.11.0)
103
+ actionpack (>= 3.0)
104
+ activesupport (>= 3.0)
105
+ railties (>= 3.0)
106
+ rspec (~> 2.11.0)
107
+ rubyzip (0.9.9)
108
+ selenium-webdriver (2.25.0)
109
+ childprocess (>= 0.2.5)
110
+ libwebsocket (~> 0.1.3)
111
+ multi_json (~> 1.0)
112
+ rubyzip
113
+ sprockets (2.1.3)
114
+ hike (~> 1.2)
115
+ rack (~> 1.0)
116
+ tilt (~> 1.1, != 1.3.0)
117
+ sqlite3 (1.3.6)
118
+ thor (0.15.4)
119
+ tilt (1.3.3)
120
+ treetop (1.4.10)
121
+ polyglot
122
+ polyglot (>= 0.3.1)
123
+ tzinfo (0.3.33)
124
+ xpath (0.1.4)
125
+ nokogiri (~> 1.3)
126
+
127
+ PLATFORMS
128
+ ruby
129
+
130
+ DEPENDENCIES
131
+ capybara
132
+ jquery-rails
133
+ prusswan-forem!
134
+ rspec-rails (~> 2.5)
135
+ sqlite3
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = Forem
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'Forem'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+
28
+ Bundler::GemHelper.install_tasks
29
+
30
+ require 'rspec/core/rake_task'
31
+ RSpec::Core::RakeTask.new(:spec)
32
+
33
+ task :default => :spec
File without changes
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,11 @@
1
+ module Forem
2
+ class ApplicationController < ::ApplicationController
3
+ private
4
+ def authenticate_forem_user!
5
+ if !current_user
6
+ flash[:notice] = "You must be authenticated before you can do that."
7
+ redirect_to main_app.sign_in_url
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,24 @@
1
+ require_dependency "forem/application_controller"
2
+
3
+ module Forem
4
+ class PostsController < ApplicationController
5
+ before_filter :find_topic
6
+ before_filter :authenticate_forem_user!, :only => [:new, :create]
7
+
8
+ def new
9
+ @post = @topic.posts.build
10
+ end
11
+
12
+ def create
13
+ params[:post].merge!(:user => current_user)
14
+ @post = @topic.posts.create(params[:post])
15
+ flash[:notice] = "Post has been created!"
16
+ redirect_to topic_path(@topic)
17
+ end
18
+
19
+ private
20
+ def find_topic
21
+ @topic = Forem::Topic.find(params[:topic_id])
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,27 @@
1
+ require_dependency "forem/application_controller"
2
+
3
+ module Forem
4
+ class TopicsController < ApplicationController
5
+ before_filter :authenticate_forem_user!, :only => [:new, :create]
6
+
7
+ def index
8
+ @topics = Forem::Topic.all
9
+ end
10
+
11
+ def new
12
+ @topic = Forem::Topic.new
13
+ @topic.posts.build
14
+ end
15
+
16
+ def create
17
+ params[:topic].merge!(:user => current_user)
18
+ @topic = Forem::Topic.create(params[:topic])
19
+ flash[:notice] = "Topic has been created!"
20
+ redirect_to @topic
21
+ end
22
+
23
+ def show
24
+ @topic = Forem::Topic.find(params[:id])
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,4 @@
1
+ module Forem
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Forem
2
+ module PostsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Forem
2
+ module TopicsHelper
3
+ end
4
+ end
@@ -0,0 +1,8 @@
1
+ module Forem
2
+ class Post < ActiveRecord::Base
3
+ attr_accessible :text, :topic_id, :user
4
+
5
+ belongs_to :topic, :counter_cache => true
6
+ belongs_to :user, :class_name => Forem::Engine.user_class.to_s
7
+ end
8
+ end
@@ -0,0 +1,17 @@
1
+ module Forem
2
+ class Topic < ActiveRecord::Base
3
+ attr_accessible :subject, :user, :posts_attributes
4
+
5
+ belongs_to :user, :class_name => Forem::Engine.user_class.to_s
6
+ has_many :posts, :order => "created_at ASC"
7
+ accepts_nested_attributes_for :posts
8
+ has_one :last_post, :class_name => "Forem::Post", :order => "created_at DESC"
9
+
10
+ before_save :set_post_user
11
+
12
+ private
13
+ def set_post_user
14
+ self.posts.first.user = self.user
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,4 @@
1
+ <p>
2
+ <%= post.label :text %><br>
3
+ <%= post.text_area :text %>
4
+ </p>
@@ -0,0 +1,6 @@
1
+ <%= div_for(post, class: 'forem_post') do %>
2
+ <small>Written at <%= post.created_at %></small>
3
+ <small class='user'>By <%= post.user %></small>
4
+ <%= simple_format(post.text) %>
5
+ <%= link_to "Reply", new_topic_post_path(@topic) %>
6
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <h2>New Post</h2>
2
+ <%= form_for [@topic, @post] do |post| %>
3
+ <%= render :partial => "form", :locals => { :post => post } %>
4
+ <%= post.submit %>
5
+ <% end %>
@@ -0,0 +1,11 @@
1
+ <%= form_for @topic do |f| %>
2
+ <p>
3
+ <%= f.label :subject %>
4
+ <%= f.text_field :subject %>
5
+ </p>
6
+
7
+ <%= f.fields_for :posts do |post| %>
8
+ <%= render :partial => "forem/posts/form", :locals => { :post => post} %>
9
+ <% end %>
10
+ <%= f.submit %>
11
+ <% end %>
@@ -0,0 +1,28 @@
1
+ <h1>Topics</h1>
2
+ <% if current_user %>
3
+ <%= link_to "New Topic", new_topic_path %>
4
+ <% end %>
5
+ <% if @topics.empty? %>
6
+ There are currently no topics.
7
+ <% else %>
8
+ <table id='topics'>
9
+ <thead>
10
+ <tr>
11
+ <td>Subject</td>
12
+ <td>Posts count</td>
13
+ <td>Last post at</td>
14
+ </tr>
15
+ </thead>
16
+ <tbody>
17
+ <% @topics.each do |topic| %>
18
+ <tr>
19
+ <td id='topic_subject'><%= link_to topic.subject, topic %></td>
20
+ <td id='posts_count'><%= topic.posts_count %></td>
21
+ <td id='last_post'>
22
+ last post was <%= time_ago_in_words(topic.last_post.created_at) %> ago by <%= topic.last_post.user %>
23
+ </td>
24
+ </tr>
25
+ <% end %>
26
+ </tbody>
27
+ </table>
28
+ <% end %>
@@ -0,0 +1,2 @@
1
+ <h1>New Topic</h1>
2
+ <%= render "form" %>
@@ -0,0 +1,6 @@
1
+ <%= div_for @topic, class: 'forem_topic' do %>
2
+ <h1><%= @topic.subject %></h1>
3
+ <div id='posts'>
4
+ <%= render :partial => "forem/posts/post", :collection => @topic.posts %>
5
+ </div>
6
+ <% end %>
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Forem</title>
5
+ <%= stylesheet_link_tag "forem/application", :media => "all" %>
6
+ <%= javascript_include_tag "forem/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+ <% flash.each do |key, message| %>
11
+ <div id='flash_<%= key %>'><%= message %></div>
12
+ <% end %>
13
+ <%= yield %>
14
+ </body>
15
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,7 @@
1
+ Forem::Engine.routes.draw do
2
+ resources :topics do
3
+ resources :posts
4
+ end
5
+
6
+ root :to => "topics#index"
7
+ end
@@ -0,0 +1,10 @@
1
+ class CreateForemTopics < ActiveRecord::Migration
2
+ def change
3
+ create_table :forem_topics do |t|
4
+ t.text :subject
5
+ t.integer :user_id
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ class CreateForemPosts < ActiveRecord::Migration
2
+ def change
3
+ create_table :forem_posts do |t|
4
+ t.integer :topic_id
5
+ t.text :text
6
+ t.integer :user_id
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ class AddPostsCountToForemTopics < ActiveRecord::Migration
2
+ def change
3
+ add_column :forem_topics, :posts_count, :integer, :default => 0
4
+ end
5
+ end
@@ -0,0 +1,19 @@
1
+ module Forem
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Forem
4
+
5
+ config.generators.integration_tool :rspec
6
+ config.generators.test_framework :rspec
7
+
8
+ class << self
9
+ attr_accessor :user_class
10
+ end
11
+
12
+ def self.user_class
13
+ error = "Please define Forem::Engine.user_class" +
14
+ " in config/initializers/forem.rb"
15
+
16
+ @user_class || raise(ConfigurationNotSet, error)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module Forem
2
+ VERSION = "0.0.2"
3
+ end
data/lib/forem.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "forem/engine"
2
+
3
+ module Forem
4
+ class ConfigurationNotSet < StandardError
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :forem do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,25 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require "forem/version"
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ s.name = "prusswan-forem"
9
+ s.version = Forem::VERSION
10
+ s.authors = ["prusswan"]
11
+ s.email = ["prusswan@gmail.com"]
12
+ s.homepage = "https://github.com/prusswan/forem"
13
+ s.summary = "prusswan's forem gem"
14
+ s.description = "prusswan's forem gem"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+
18
+ s.add_dependency "rails", "~> 3.2.7"
19
+ # s.add_dependency "jquery-rails"
20
+
21
+ s.add_development_dependency "sqlite3"
22
+
23
+ s.add_development_dependency "rspec-rails", "~> 2.5"
24
+ s.add_development_dependency "capybara"
25
+ end
data/script/rails ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/forem/engine', __FILE__)
6
+
7
+ require 'rails/all'
8
+ require 'rails/engine/commands'
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Configuration' do
4
+ before { Forem::Engine.user_class = nil }
5
+
6
+ it "user_class must be set" do
7
+ config = lambda { Forem::Engine.user_class }
8
+ error = "Please define Forem::Engine.user_class" +
9
+ " in config/initializers/forem.rb"
10
+ config.should raise_error(Forem::ConfigurationNotSet, error)
11
+ Forem::Engine.user_class = User
12
+ config.should_not raise_error(Forem::ConfigurationNotSet)
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe Forem::PostsController do
4
+
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe Forem::TopicsController do
4
+
5
+ end