acts_as_featureable 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +4 -0
  3. data/CHANGELOG.md +8 -0
  4. data/README.md +83 -9
  5. data/Rakefile +20 -3
  6. data/acts_as_featureable.gemspec +20 -20
  7. data/app/controllers/.keep +0 -0
  8. data/app/controllers/features_controller.rb +90 -0
  9. data/app/helpers/.keep +0 -0
  10. data/app/helpers/features_helper.rb +9 -0
  11. data/app/models/.keep +0 -0
  12. data/{lib/acts_as_featureable → app/models}/feature.rb +17 -3
  13. data/app/views/.keep +0 -0
  14. data/app/views/features/_feature.html.erb +5 -0
  15. data/app/views/features/_features.html.erb +3 -0
  16. data/app/views/features/_form.html.erb +19 -0
  17. data/app/views/features/edit.html.erb +1 -0
  18. data/app/views/features/index.html.erb +3 -0
  19. data/app/views/features/new.html.erb +1 -0
  20. data/app/views/features/show.html.erb +1 -0
  21. data/bin/rails +8 -0
  22. data/lib/acts_as_featureable/config.rb +30 -0
  23. data/lib/acts_as_featureable/engine.rb +9 -0
  24. data/lib/acts_as_featureable/feature_methods.rb +11 -0
  25. data/lib/acts_as_featureable/version.rb +1 -1
  26. data/lib/acts_as_featureable.rb +5 -19
  27. data/lib/generators/templates/create_features.rb +1 -0
  28. data/lib/generators/templates/initializer.rb +5 -0
  29. data/spec/controllers/features_controller_spec.rb +158 -0
  30. data/spec/dummy/README.rdoc +28 -0
  31. data/spec/dummy/Rakefile +6 -0
  32. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  33. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  34. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  35. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  36. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  37. data/spec/dummy/app/mailers/.keep +0 -0
  38. data/spec/dummy/app/models/.keep +0 -0
  39. data/spec/dummy/app/models/concerns/.keep +0 -0
  40. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  41. data/spec/dummy/bin/bundle +3 -0
  42. data/spec/dummy/bin/rails +4 -0
  43. data/spec/dummy/bin/rake +4 -0
  44. data/spec/dummy/config/application.rb +23 -0
  45. data/spec/dummy/config/boot.rb +5 -0
  46. data/spec/dummy/config/database.yml +25 -0
  47. data/spec/dummy/config/environment.rb +5 -0
  48. data/spec/dummy/config/environments/development.rb +29 -0
  49. data/spec/dummy/config/environments/production.rb +80 -0
  50. data/spec/dummy/config/environments/test.rb +36 -0
  51. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  52. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  53. data/spec/dummy/config/initializers/inflections.rb +16 -0
  54. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  55. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  56. data/spec/dummy/config/initializers/session_store.rb +3 -0
  57. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  58. data/spec/dummy/config/locales/en.yml +23 -0
  59. data/spec/dummy/config/routes.rb +5 -0
  60. data/spec/dummy/config.ru +4 -0
  61. data/spec/dummy/lib/assets/.keep +0 -0
  62. data/spec/dummy/log/.keep +0 -0
  63. data/spec/dummy/log/test.log +34618 -0
  64. data/spec/dummy/public/404.html +58 -0
  65. data/spec/dummy/public/422.html +58 -0
  66. data/spec/dummy/public/500.html +57 -0
  67. data/spec/dummy/public/favicon.ico +0 -0
  68. data/spec/extra/schema.rb +1 -0
  69. data/spec/factories/topics.rb +6 -0
  70. data/spec/helpers/features_helper_spec.rb +24 -0
  71. data/spec/models/feature_spec.rb +131 -0
  72. data/spec/spec_helper.rb +17 -2
  73. metadata +136 -58
  74. data/spec/feature_spec.rb +0 -71
  75. /data/spec/{featureable_spec.rb → models/featureable_spec.rb} +0 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7fd7ae3319ca73121825929c08ffed994ed1da4d
4
+ data.tar.gz: 1b0d23f470a30c8f5a4b56f9e78064c9dec180c2
5
+ SHA512:
6
+ metadata.gz: 6da70932bd2a8635194ddefa226dd36086f2a788d3c532bf94a02eabff9905b1093ec4d7216a39a6c73547babcbddbd739e5d03dd1edaee27dba2e90bd75b93c
7
+ data.tar.gz: 9ad74f02e91c5a73c5196e88f80b6be92250dd31b2b4981e1f2804eccebba15bd7a9fc3677b3a2f55c407130ba0b56fd6ebb8c52878cde9ffba92af51bf618ec
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.3"
4
+ - "2.0.0"
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## v0.0.2
2
+
3
+ * enhancements
4
+ * Added categories
5
+ * Added validations
6
+ * Turned into Rails::Engine with controller (with CanCan support) and basic views
7
+ * Added 2 helper methods 'feature_form_for' and 'features_for' for creating a quick form and a list of features for a given featureable
8
+
1
9
  ## v0.0.1
2
10
 
3
11
  * initial release
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Acts As Featureable
2
2
 
3
+ [![Build Status](https://travis-ci.org/kainage/acts_as_featureable.png)](https://travis-ci.org/kainage/acts_as_featureable)
4
+
5
+ Requires ruby *1.9.3* or later
6
+
3
7
  Add a polymorphic resource to your rails app for pulling content to a main/features page.
4
8
 
5
9
  ## Installation
@@ -44,6 +48,19 @@ class Topic
44
48
  end
45
49
  ```
46
50
 
51
+ Add the routes to your _routes_ config file for the resource(s) you wish to make featureable
52
+
53
+ ```ruby
54
+ resources :topics do
55
+ resources :features
56
+ end
57
+ ```
58
+
59
+ ### CanCan integration
60
+
61
+ If you are using CanCan for authorization, the _features controller_ will automatically add authorization
62
+ to each action.
63
+
47
64
  ### Creating Features
48
65
 
49
66
  Add a feature to a model. The _title_ and _summary_ (or whichever methods you add in the initializer file) will be assigned:
@@ -51,7 +68,7 @@ Add a feature to a model. The _title_ and _summary_ (or whichever methods you ad
51
68
  ```ruby
52
69
  featureable = Topic.create(title: 'Title', summary: 'Summary')
53
70
  featureable.features.create
54
- #<Feature title: "Title", summary: "Summary">
71
+ # => <Feature title: "Title", summary: "Summary">
55
72
  ```
56
73
 
57
74
  You can also override them directly:
@@ -59,7 +76,7 @@ You can also override them directly:
59
76
  ```ruby
60
77
  featureable = Topic.create(title: 'Title', summary: 'Summary')
61
78
  featureable.features.create(title: 'My New Title', summary 'My New Summary')
62
- #<Feature title: "My New Title", summary: "My New Summary">
79
+ # => <Feature title: "My New Title", summary: "My New Summary">
63
80
  ```
64
81
 
65
82
  The _position_ of the features can be specified:
@@ -67,7 +84,7 @@ The _position_ of the features can be specified:
67
84
  ```ruby
68
85
  featureable = Topic.create
69
86
  featureable.features.create(position: 3)
70
- #<Feature position: 3>
87
+ # => <Feature position: 3>
71
88
  ```
72
89
 
73
90
  If it is not specified, it will automatically be assigned the next, lowest _position_:
@@ -75,10 +92,10 @@ If it is not specified, it will automatically be assigned the next, lowest _posi
75
92
  ```ruby
76
93
  featureable = Topic.create
77
94
  featureable.features.create
78
- #<Feature position: 1>
95
+ # => <Feature position: 1>
79
96
 
80
97
  featureable.features.create
81
- #<Feature position: 2>
98
+ # => <Feature position: 2>
82
99
  ```
83
100
 
84
101
  If you try and assign a position which has already been taken, it will find the next, lowest available _position_:
@@ -86,15 +103,50 @@ If you try and assign a position which has already been taken, it will find the
86
103
  ```ruby
87
104
  featureable = Topic.create
88
105
  featureable.features.create
89
- #<Feature position: 1>
106
+ # => <Feature position: 1>
90
107
 
91
108
  featureable.features.create(position: 1)
92
- #<Feature position: 2>
109
+ # => <Feature position: 2>
93
110
 
94
111
  featureable.features.create(position: 1)
95
- #<Feature position: 3>
112
+ # => <Feature position: 3>
113
+ ```
114
+
115
+ ### Categories
116
+
117
+ You can specify categories when creating features:
118
+
119
+ ```ruby
120
+ featureable = Topic.create
121
+ featureable.features.create(category: :mains)
122
+ # => <Feature category: "mains">
123
+ ```
124
+
125
+ You can specify any category and as many as you like to pull to different parts of your site.
126
+
127
+ ```ruby
128
+ featureable = Topic.create
129
+ featureable.features.create(category: :mains)
130
+ # => <Feature category: "mains">
131
+ featureable.features.create(category: :hot_topics)
132
+ # => <Feature category: "hot_topics">
133
+
134
+ featureable.features.count
135
+ # => 2
136
+
137
+ featureable.features.where(category: :hot_topics).count
138
+ # => 1
139
+ ```
140
+
141
+ This is the default behaviour. If you specify categories in your ```acts_as_featureable.rb``` initilaizer file:
142
+
143
+ ```ruby
144
+ config.categories = [:mains, :hot_topics]
96
145
  ```
97
146
 
147
+ then these are the only allowable categories for your application. You also get the side benefit of
148
+ having a scope created for each of these categories on the Feature class. See the next section for more details.
149
+
98
150
  ### Feature scope
99
151
 
100
152
  Get all features ordered by thier _position_ ascending:
@@ -103,7 +155,29 @@ Get all features ordered by thier _position_ ascending:
103
155
  Feature.ordered
104
156
  ```
105
157
 
106
- Implementing the forms and views is left up to the developer.
158
+ If you have specified strict categories in your initializer (see previous section) then you can use those as scopes
159
+ on the Feature class:
160
+
161
+ ```ruby
162
+ Feature.hot_topics
163
+ # => <Feature category: "hot_topics" ... >
164
+ ```
165
+
166
+ ## View Helpers
167
+
168
+ Adds two helper methods to your views:
169
+
170
+ ```ruby
171
+ <%= feature_form_for(featureable) %>
172
+ ```
173
+
174
+ Which renders a basic form for creating features from a featureable object.
175
+
176
+ ```ruby
177
+ <%= features_for(featureable) %>
178
+ ```
179
+
180
+ Which simiply lists the features' position and category with a delete link
107
181
 
108
182
  ## Contributing
109
183
 
data/Rakefile CHANGED
@@ -1,6 +1,23 @@
1
- require "bundler/gem_tasks"
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
+
8
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
9
+
10
+ load 'rails/tasks/engine.rake'
11
+
12
+ Bundler::GemHelper.install_tasks
13
+
14
+ Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
15
+
16
+ require 'rspec/core'
2
17
  require 'rspec/core/rake_task'
3
18
 
4
- RSpec::Core::RakeTask.new(:spec)
19
+ desc "Run all specs in spec directory (excluding plugin specs)"
20
+
21
+ RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
5
22
 
6
- task default: :spec
23
+ task :default => :spec
@@ -4,26 +4,26 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'acts_as_featureable/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "acts_as_featureable"
8
- spec.version = ActsAsFeatureable::VERSION
9
- spec.authors = ["Kainage"]
10
- spec.email = ["kainage@gmail.com"]
11
- spec.description = %q{Add a feature resource to a rails app}
12
- spec.summary = %q{Creates a new polymorphic resrouce, Feature, for pulling content to a main/features page}
13
- spec.homepage = "https://github.com/kainage/acts_as_featureable"
14
- spec.license = "MIT"
7
+ spec.name = "acts_as_featureable"
8
+ spec.version = ActsAsFeatureable::VERSION
9
+ spec.authors = ["Kainage"]
10
+ spec.email = ["kainage@gmail.com"]
11
+ spec.description = %q{Add a feature resource to a rails app}
12
+ spec.summary = %q{Creates a new polymorphic resrouce, Feature, for pulling content to a main/features page}
13
+ spec.homepage = "https://github.com/kainage/acts_as_featureable"
14
+ spec.license = "MIT"
15
15
 
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec"
24
- spec.add_development_dependency "activerecord"
25
- spec.add_development_dependency "sqlite3"
26
- spec.add_development_dependency "shoulda-matchers"
27
-
28
- spec.add_runtime_dependency "activerecord"
21
+ spec.add_dependency "rails", "~> 4.0.0.rc1"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "sqlite3"
27
+ spec.add_development_dependency "shoulda-matchers"
28
+ spec.add_development_dependency "rspec-rails"
29
29
  end
File without changes
@@ -0,0 +1,90 @@
1
+ class FeaturesController < ApplicationController
2
+ authorize_resource if defined?(CanCan::Ability)
3
+
4
+ before_filter :find_featureable
5
+
6
+ def index
7
+ @features = Feature.all
8
+
9
+ respond_to do |format|
10
+ format.html
11
+ format.json { render json: @features }
12
+ end
13
+ end
14
+
15
+ def show
16
+ @feature = Feature.find(params[:id])
17
+
18
+ respond_to do |format|
19
+ format.html
20
+ format.json { render json: @feature }
21
+ end
22
+ end
23
+
24
+ def new
25
+ @feature = @featureable.features.build
26
+
27
+ respond_to do |format|
28
+ format.html
29
+ format.json { render json: @feature }
30
+ end
31
+ end
32
+
33
+ def edit
34
+ @feature = Feature.find(params[:id])
35
+
36
+ respond_to do |format|
37
+ format.html
38
+ format.json { render json: @feature }
39
+ end
40
+ end
41
+
42
+ def create
43
+ @feature = @featureable.features.build(feature_params)
44
+
45
+ respond_to do |format|
46
+ if @feature.save
47
+ format.html { redirect_to @featureable, notice: 'Feature was successfully created.' }
48
+ format.json { render json: @feature, status: :created, location: @feature }
49
+ else
50
+ format.html { redirect_to @featureable, alert: @feature.errors.full_messages.join(',') }
51
+ format.json { render json: @feature.errors, status: :unprocessable_entity }
52
+ end
53
+ end
54
+ end
55
+
56
+ def update
57
+ @feature = Feature.find(params[:id])
58
+
59
+ respond_to do |format|
60
+ if @feature.update(feature_params)
61
+ format.html { redirect_to @featureable, notice: 'Feature was successfully updated.' }
62
+ format.json { head :no_content }
63
+ else
64
+ format.html { redirect_to @featureable, alert: @feature.errors.full_messages.join(',') }
65
+ format.json { render json: @feature.errors, status: :unprocessable_entity }
66
+ end
67
+ end
68
+ end
69
+
70
+ def destroy
71
+ @feature = Feature.find(params[:id])
72
+ @feature.destroy
73
+
74
+ respond_to do |format|
75
+ format.html { redirect_to @featureable, notice: 'Feature was successfully removed.' }
76
+ format.json { head :no_content }
77
+ end
78
+ end
79
+
80
+ private
81
+
82
+ def feature_params
83
+ params.require(:feature).permit(:position, :category)
84
+ end
85
+
86
+ def find_featureable
87
+ resource, id = request.path.split('/')[1, 2]
88
+ @featureable = resource.singularize.classify.constantize.find(id)
89
+ end
90
+ end
data/app/helpers/.keep ADDED
File without changes
@@ -0,0 +1,9 @@
1
+ module FeaturesHelper
2
+ def feature_form_for(featureable)
3
+ render 'features/form', :featureable => featureable
4
+ end
5
+
6
+ def features_for(featureable)
7
+ render 'features/features', :featureable => featureable
8
+ end
9
+ end
data/app/models/.keep ADDED
File without changes
@@ -3,18 +3,28 @@ class Feature < ActiveRecord::Base
3
3
 
4
4
  before_validation :assign_title, :assign_summary, :assign_position
5
5
 
6
- validate :feature_limit_not_reached
6
+ validate :feature_limit_not_reached, :ensure_categories
7
+
8
+ validates_presence_of :featureable_id, :featureable_type
7
9
 
8
10
  validates_numericality_of :position
9
11
 
10
12
  private
11
13
 
14
+ def ensure_categories
15
+ cats = ::ActsAsFeatureable::categories
16
+ # Allow all categories if set to false
17
+ if cats && self.category && !cats.include?(self.category.to_sym)
18
+ errors.add(:category, " is not in the list [#{cats.join(',')}]")
19
+ end
20
+ end
21
+
12
22
  def feature_limit_not_reached
13
23
  limit = ActsAsFeatureable.feature_limit
14
24
  errors.add(:base,
15
25
  "The feature limit of #{limit} has been reached. \
16
26
  Please delete or change an existing feature."
17
- ) if Feature.count >= limit
27
+ ) if ActsAsFeatureable.categories ? Feature.where(category: self.category).count >= limit : Feature.count >= limit
18
28
  end
19
29
 
20
30
  def assign_title
@@ -48,7 +58,11 @@ class Feature < ActiveRecord::Base
48
58
  def assign_position
49
59
  # If there is no position given, or the position given is already taken,
50
60
  # assign the lowest open position. Otherwise assign it.
51
- all_positions = Feature.select('features.position').map(&:position).sort
61
+ all_positions = if ActsAsFeatureable.categories
62
+ Feature.select('features.position, features.category').where(category: self.category).map(&:position).sort
63
+ else
64
+ Feature.select('features.position').map(&:position).sort
65
+ end
52
66
 
53
67
  if !self.position || (self.position && all_positions.include?(self.position))
54
68
  # Find lowest, non-taken position
data/app/views/.keep ADDED
File without changes
@@ -0,0 +1,5 @@
1
+ <div class="feature">
2
+ <%= content_tag :span, feature.position, :class => 'position' %>
3
+ <%= content_tag :span, feature.category, :class => 'category' %>
4
+ <%= link_to 'Remove', [feature.featureable, feature], :method => :delete, :data => { :confirm => 'Are you sure?' } %>
5
+ </div>
@@ -0,0 +1,3 @@
1
+ <% featureable.features.each do |feature| %>
2
+ <%= render feature %>
3
+ <% end unless featureable.features.empty? %>
@@ -0,0 +1,19 @@
1
+ <% cats = ActsAsFeatureable.categories %>
2
+
3
+ <%= form_for [featureable, Feature.new] do |f| %>
4
+ <div class="field">
5
+ <%= f.label :position %>
6
+ <%= f.select :position, (1..ActsAsFeatureable.feature_limit) %>
7
+ </div>
8
+
9
+ <div class="field">
10
+ <%= f.label :category%>
11
+ <% if cats %>
12
+ <%= f.select :category, cats %>
13
+ <% else %>
14
+ <%= f.text_field :category %>
15
+ <% end %>
16
+ </div>
17
+
18
+ <%= f.submit %>
19
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= render 'form' %>
@@ -0,0 +1,3 @@
1
+ <% @features.each do |feature| %>
2
+ <%= render feature %>
3
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= render 'form' %>
@@ -0,0 +1 @@
1
+ <%= render @feature %>
data/bin/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/cts_as_featureable/engine', __FILE__)
6
+
7
+ require 'rails/all'
8
+ require 'rails/engine/commands'
@@ -0,0 +1,30 @@
1
+ module ActsAsFeatureable
2
+ # Set the maximum limit of features availible.
3
+ mattr_accessor :feature_limit
4
+ @@feature_limit = 10
5
+
6
+ # Set the order of auto title assign
7
+ mattr_accessor :auto_title_assign_list
8
+ @@auto_title_assign_list = [:title, :name]
9
+
10
+ # Set the order of auto summary assigning
11
+ mattr_accessor :auto_summary_assign_list
12
+ @@auto_summary_assign_list = [:summary, :caption, :tldr, :content, :text]
13
+
14
+ # Limit the categories you wish to use.
15
+ # This should be an array of symbols
16
+ # [:main, :articles, :images]
17
+ #
18
+ # false allows unlimited categories.
19
+ #
20
+ # The benefit of using this is gaining the scopes for which categories you include.
21
+ #
22
+ # Feature.articles
23
+ # => [<# Feature > ,<# Feature>]
24
+ mattr_accessor :categories
25
+ @@categories = false
26
+
27
+ def self.setup
28
+ yield self
29
+ end
30
+ end
@@ -0,0 +1,9 @@
1
+ module ActsAsFeatureable
2
+ class Engine < ::Rails::Engine
3
+ config.generators do |g|
4
+ g.test_framework :rspec, :fixture => false
5
+ g.assets false
6
+ g.helper false
7
+ end
8
+ end
9
+ end
@@ -4,6 +4,17 @@ module ActsAsFeatureable
4
4
  feature_model.belongs_to :featureable, polymorphic: true
5
5
 
6
6
  feature_model.scope :ordered, ->{ feature_model.order('position ASC') }
7
+
8
+ def feature_model.method_missing(meth, *args, &block)
9
+ if ::ActsAsFeatureable.categories.include?(meth)
10
+ self.scope meth, -> { self.where(category: meth) }
11
+ self.send(meth)
12
+ else
13
+ super
14
+ end
15
+ end
16
+
17
+ feature_model.send(:private, :method_missing)
7
18
  end
8
19
  end
9
20
  end
@@ -1,3 +1,3 @@
1
1
  module ActsAsFeatureable
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,22 +1,8 @@
1
+ require 'acts_as_featureable/engine'
2
+
3
+ require 'active_support/core_ext/module/attribute_accessors'
4
+ require 'acts_as_featureable/config'
5
+
1
6
  require 'acts_as_featureable/version'
2
7
  require 'acts_as_featureable/featureable_methods'
3
8
  require 'acts_as_featureable/feature_methods'
4
- require 'acts_as_featureable/feature'
5
-
6
- module ActsAsFeatureable
7
- # Set the maximum limit of features availible.
8
- mattr_accessor :feature_limit
9
- @@feature_limit = 10
10
-
11
- # Set the order of auto title assign
12
- mattr_accessor :auto_title_assign_list
13
- @@auto_title_assign_list = [:title, :name]
14
-
15
- # Set the order of auto summary assigning
16
- mattr_accessor :auto_summary_assign_list
17
- @@auto_summary_assign_list = [:summary, :caption, :tldr, :content, :text]
18
-
19
- def self.setup
20
- yield self
21
- end
22
- end
@@ -5,6 +5,7 @@ class CreateFeatures < ActiveRecord::Migration
5
5
  t.string :title
6
6
  t.text :summary
7
7
  t.integer :position, :null => false
8
+ t.string :category
8
9
  t.timestamps
9
10
  end
10
11
 
@@ -7,4 +7,9 @@ ActsAsFeatureable.setup do |config|
7
7
 
8
8
  # Set the order of auto summary assigning.
9
9
  config.auto_summary_assign_list = [:summary, :caption, :tldr, :content, :text]
10
+
11
+ # Limit the categories you wish to use.
12
+ # => [:main, :articles, :images]
13
+ # false allows unlimited categories.
14
+ config.categories = false
10
15
  end