contentment 0.7.0 → 0.7.1
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/config/routes.rb +0 -15
- data/lib/contentment/engine.rb +4 -4
- data/lib/generators/contentment/contentment_views_templates/contents_helper.rb +1 -3
- data/lib/generators/contentment/templates/content_test.rb +5 -5
- data/lib/generators/contentment/templates/migration.rb +5 -9
- data/lib/generators/contentment_generator.rb +22 -23
- metadata +38 -42
data/config/routes.rb
CHANGED
@@ -1,18 +1,3 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
2
|
|
3
|
-
# We are adding full resources for bird and declaring which controller to use
|
4
|
-
# resources :contents
|
5
|
-
|
6
|
-
# If you had nests and wanted to nest your nests you would do:
|
7
|
-
|
8
|
-
# resources :birds, :controller => 'baby_dove/birds' do
|
9
|
-
# resources :nests, :controller => 'baby_dove/nests'
|
10
|
-
# end
|
11
|
-
|
12
|
-
# It's that simple. Run rake routes from your 'main app' and you will see
|
13
|
-
# the routes from the engine listed after any routes you define in the main
|
14
|
-
# app.
|
15
|
-
|
16
|
-
|
17
|
-
|
18
3
|
end
|
data/lib/contentment/engine.rb
CHANGED
@@ -5,8 +5,8 @@ require "rails"
|
|
5
5
|
# http://edgeapi.rubyonrails.org/classes/Rails/Engine.html
|
6
6
|
module Contentment
|
7
7
|
class Engine < Rails::Engine
|
8
|
-
|
9
|
-
|
8
|
+
# are these not used? engine_name, railtie_name
|
9
|
+
# engine_name "contentment"
|
10
10
|
|
11
11
|
# # We can add all of the public assets from our engine and make them
|
12
12
|
# # available to use. This allows us to use javascripts, images, stylesheets
|
@@ -14,6 +14,6 @@ module Contentment
|
|
14
14
|
# initializer "static assets" do |app|
|
15
15
|
# app.middleware.use ::ActionDispatch::Static, "#{root}/public"
|
16
16
|
# end
|
17
|
-
|
17
|
+
|
18
18
|
end
|
19
|
-
end
|
19
|
+
end
|
@@ -1,9 +1,7 @@
|
|
1
1
|
module ContentsHelper
|
2
2
|
|
3
|
-
# Is a helper really necessary? Apparently I thought so at some point.
|
4
|
-
# <%#= f.select :tipe, content_tipe_options %>
|
5
|
-
# When the helper is longer than what it replaces you've got a problem. :P
|
6
3
|
def content_tipe_options
|
7
4
|
Content.tipes
|
8
5
|
end
|
6
|
+
|
9
7
|
end
|
@@ -1,25 +1,25 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class ContentTest < ActiveSupport::TestCase
|
4
|
-
|
4
|
+
|
5
5
|
def setup
|
6
6
|
@a = Content.create(:app_id => 1, :position => 1, :title => 'a', :tipe => 'test')
|
7
7
|
@b = Content.create(:app_id => 1, :position => 2, :title => 'b', :tipe => 'test')
|
8
8
|
@c = Content.create(:app_id => 1, :position => 3, :title => 'c', :tipe => 'test')
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
test "content should fix position of other content with similar tipe on save" do
|
12
12
|
@c.position = 1
|
13
13
|
@c.save
|
14
|
-
|
14
|
+
|
15
15
|
assert(@c.reload.position == 1)
|
16
16
|
assert(@a.reload.position == 2)
|
17
17
|
assert(@b.reload.position == 3)
|
18
18
|
end
|
19
19
|
|
20
|
-
test "saving multiple pieces of content things kind of escalate out of control ... " do
|
20
|
+
test "saving multiple pieces of content things kind of escalate out of control ... " do
|
21
21
|
@a.position = 3
|
22
|
-
@a.save
|
22
|
+
@a.save
|
23
23
|
assert(3 == @a.reload.position)
|
24
24
|
assert(2 == @b.reload.position)
|
25
25
|
assert(4 == @c.reload.position)
|
@@ -1,24 +1,20 @@
|
|
1
|
-
# Everything listed in this migration will be added to a migration file
|
2
|
-
# inside of your main app.
|
3
1
|
class CreateContents < ActiveRecord::Migration
|
2
|
+
|
4
3
|
def self.up
|
5
|
-
|
6
|
-
# Birds Table
|
7
4
|
create_table :contents do |t|
|
8
5
|
t.string :title
|
9
6
|
t.text :body
|
10
7
|
t.string :tipe
|
11
8
|
t.string :dom_id
|
12
9
|
t.integer :position
|
13
|
-
t.boolean :visible
|
10
|
+
t.boolean :visible
|
14
11
|
t.string :link
|
15
12
|
t.timestamps
|
16
13
|
end
|
17
|
-
|
18
|
-
end # End of self.up
|
14
|
+
end
|
19
15
|
|
20
16
|
def self.down
|
21
17
|
drop_table :contents
|
22
|
-
|
23
|
-
|
18
|
+
end
|
19
|
+
|
24
20
|
end
|
@@ -2,11 +2,11 @@ require 'rails/generators'
|
|
2
2
|
require 'rails/generators/migration'
|
3
3
|
|
4
4
|
class ContentmentGenerator < Rails::Generators::Base
|
5
|
-
|
5
|
+
desc "This generator creates the contents model and table"
|
6
6
|
include Rails::Generators::Migration
|
7
7
|
|
8
8
|
def self.source_root
|
9
|
-
|
9
|
+
# This must be defined. It tells the generator where to find the template for your migration.
|
10
10
|
File.join(File.dirname(__FILE__), 'contentment/templates')
|
11
11
|
end
|
12
12
|
|
@@ -18,30 +18,29 @@ class ContentmentGenerator < Rails::Generators::Base
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
21
|
+
def install
|
22
|
+
content_model = "app/models/content.rb"
|
23
|
+
if File.exists?(content_model)
|
24
|
+
puts "Well, Fuck."
|
25
|
+
# Need to figure out how to ask the user if they would like to overwrite their model.
|
26
|
+
else
|
27
|
+
template 'content.rb', content_model
|
28
|
+
template 'content_test.rb', 'test/unit/content_test.rb'
|
29
|
+
end
|
30
|
+
|
31
|
+
contents_controller = 'app/controllers/contents_controller.rb'
|
32
|
+
if File.exists?(contents_controller)
|
33
|
+
puts "Damn, him too?"
|
34
|
+
# Again, figure out how to ask the user if they want to overwrite it.
|
35
|
+
else
|
36
|
+
template 'contents_controller.rb', contents_controller
|
37
|
+
end
|
38
|
+
end
|
39
39
|
|
40
40
|
# This method is pulling all of the migration data from the migration.rb template.
|
41
41
|
# After it pulls the migration date, it generates a migration in the main application
|
42
|
-
# called create_contents
|
43
|
-
# You can change the name of this if and when you make your own engine.
|
42
|
+
# called create_contents
|
44
43
|
def create_migration_file
|
45
44
|
migration_template 'migration.rb', 'db/migrate/create_contents.rb'
|
46
45
|
end
|
47
|
-
end
|
46
|
+
end
|
metadata
CHANGED
@@ -1,33 +1,40 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: contentment
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.7.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 7
|
9
|
-
- 0
|
10
|
-
version: 0.7.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Bob Larrick
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
12
|
+
date: 2012-09-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: jeweler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: Rails Engine for simple content management. See readme on github for
|
31
|
+
details.
|
23
32
|
email: larrick@gmail.com
|
24
33
|
executables: []
|
25
|
-
|
26
34
|
extensions: []
|
27
|
-
|
28
|
-
extra_rdoc_files:
|
35
|
+
extra_rdoc_files:
|
29
36
|
- README.rdoc
|
30
|
-
files:
|
37
|
+
files:
|
31
38
|
- config/routes.rb
|
32
39
|
- lib/contentment.rb
|
33
40
|
- lib/contentment/engine.rb
|
@@ -46,39 +53,28 @@ files:
|
|
46
53
|
- lib/generators/contentment_generator.rb
|
47
54
|
- lib/generators/contentment_views_generator.rb
|
48
55
|
- README.rdoc
|
49
|
-
has_rdoc: true
|
50
56
|
homepage: https://github.com/deathbob/Contentment
|
51
57
|
licenses: []
|
52
|
-
|
53
58
|
post_install_message:
|
54
59
|
rdoc_options: []
|
55
|
-
|
56
|
-
require_paths:
|
60
|
+
require_paths:
|
57
61
|
- lib
|
58
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
63
|
none: false
|
60
|
-
requirements:
|
61
|
-
- -
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
|
64
|
-
|
65
|
-
- 0
|
66
|
-
version: "0"
|
67
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
69
|
none: false
|
69
|
-
requirements:
|
70
|
-
- -
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
|
73
|
-
segments:
|
74
|
-
- 0
|
75
|
-
version: "0"
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
76
74
|
requirements: []
|
77
|
-
|
78
75
|
rubyforge_project: contentment
|
79
|
-
rubygems_version: 1.
|
76
|
+
rubygems_version: 1.8.24
|
80
77
|
signing_key:
|
81
78
|
specification_version: 3
|
82
79
|
summary: Rails Engine for simple content management.
|
83
80
|
test_files: []
|
84
|
-
|