devape_cms 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +37 -0
- data/lib/devape_cms/engine.rb +6 -0
- data/lib/devape_cms.rb +4 -0
- data/lib/rails/generators/devape_cms/devape_cms_generator.rb +75 -0
- data/lib/rails/generators/devape_cms/templates/initializer.rb +8 -0
- data/lib/rails/generators/devape_cms/templates/migration.rb +9 -0
- data/lib/rails/generators/devape_cms/templates/schema.rb +11 -0
- data/lib/rails/railties/tasks.rake +8 -0
- data/lib/tasks/devape_cms_tasks.rake +4 -0
- metadata +64 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2011 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
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
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 = 'DevapeCms'
|
18
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
require 'rake/testtask'
|
27
|
+
|
28
|
+
Rake::TestTask.new(:test) do |t|
|
29
|
+
t.libs << 'lib'
|
30
|
+
t.libs << 'test'
|
31
|
+
t.pattern = 'test/**/*_test.rb'
|
32
|
+
t.verbose = false
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
task :default => :test
|
37
|
+
gem.add_dependency "acts_as_tree"
|
data/lib/devape_cms.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
class DevapeCmsGenerator < Rails::Generators::Base
|
5
|
+
include Rails::Generators::Migration
|
6
|
+
|
7
|
+
def self.source_root
|
8
|
+
File.join(File.dirname(__FILE__), 'templates')
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.next_migration_number(dirname) #:nodoc:
|
12
|
+
if ActiveRecord::Base.timestamped_migrations
|
13
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
14
|
+
else
|
15
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
# Every method that is declared below will be automatically executed when the generator is run
|
21
|
+
|
22
|
+
def create_migration_file
|
23
|
+
f = File.open File.join(File.dirname(__FILE__), 'templates', 'schema.rb')
|
24
|
+
schema = f.read; f.close
|
25
|
+
|
26
|
+
schema.gsub!(/ActiveRecord::Schema.*\n/, '')
|
27
|
+
schema.gsub!(/^end\n*$/, '')
|
28
|
+
|
29
|
+
f = File.open File.join(File.dirname(__FILE__), 'templates', 'migration.rb')
|
30
|
+
migration = f.read; f.close
|
31
|
+
migration.gsub!(/SCHEMA_AUTO_INSERTED_HERE/, schema)
|
32
|
+
|
33
|
+
tmp = File.open "~/migration_ready.rb", "w"
|
34
|
+
tmp.write migration
|
35
|
+
tmp.close
|
36
|
+
|
37
|
+
migration_template '../../../tmp/~migration_ready.rb',
|
38
|
+
'db/migrate/create_cheese_tables.rb'
|
39
|
+
remove_file 'tmp/~migration_ready.rb'
|
40
|
+
end
|
41
|
+
|
42
|
+
def copy_initializer_file
|
43
|
+
copy_file 'initializer.rb', 'config/initializers/cheese.rb'
|
44
|
+
end
|
45
|
+
|
46
|
+
def update_application_template
|
47
|
+
f = File.open "app/views/layouts/application.html.erb"
|
48
|
+
layout = f.read; f.close
|
49
|
+
|
50
|
+
if layout =~ /<%=[ ]+yield[ ]+%>/
|
51
|
+
print " \e[1m\e[34mquestion\e[0m Your layouts/application.html.erb layout currently has the line <%= yield %>. This gem needs to change this line to <%= content_for?(:content) ? yield(:content) : yield %> to support its nested layouts. This change should not affect any of your existing layouts or views. Is this okay? [y/n] "
|
52
|
+
begin
|
53
|
+
answer = gets.chomp
|
54
|
+
end while not answer =~ /[yn]/i
|
55
|
+
|
56
|
+
if answer =~ /y/i
|
57
|
+
|
58
|
+
layout.gsub!(/<%=[ ]+yield[ ]+%>/, '<%= content_for?(:content) ? yield(:content) : yield %>')
|
59
|
+
|
60
|
+
tmp = File.open "tmp/~application.html.erb", "w"
|
61
|
+
tmp.write layout; tmp.close
|
62
|
+
|
63
|
+
remove_file 'app/views/layouts/application.html.erb'
|
64
|
+
copy_file '../../../tmp/~application.html.erb',
|
65
|
+
'app/views/layouts/application.html.erb'
|
66
|
+
remove_file 'tmp/~application.html.erb'
|
67
|
+
end
|
68
|
+
elsif layout =~ /<%=[ ]+content_for\?\(:content\) \? yield\(:content\) : yield[ ]+%>/
|
69
|
+
puts " \e[1m\e[33mskipping\e[0m layouts/application.html.erb modification is already done."
|
70
|
+
else
|
71
|
+
puts " \e[1m\e[31mconflict\e[0m The gem is confused by your layouts/application.html.erb. It does not contain the default line <%= yield %>, you may need to make manual changes to get this gem's nested layouts working. Visit ###### for details."
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: devape_cms
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- John Kealy
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-07-23 00:00:00 Z
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Insert DevapeCms description.
|
17
|
+
email:
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/tasks/devape_cms_tasks.rake
|
26
|
+
- lib/devape_cms.rb
|
27
|
+
- lib/rails/railties/tasks.rake
|
28
|
+
- lib/rails/generators/devape_cms/devape_cms_generator.rb
|
29
|
+
- lib/rails/generators/devape_cms/templates/schema.rb
|
30
|
+
- lib/rails/generators/devape_cms/templates/initializer.rb
|
31
|
+
- lib/rails/generators/devape_cms/templates/migration.rb
|
32
|
+
- lib/devape_cms/engine.rb
|
33
|
+
- MIT-LICENSE
|
34
|
+
- Rakefile
|
35
|
+
- README.rdoc
|
36
|
+
homepage:
|
37
|
+
licenses: []
|
38
|
+
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
requirements: []
|
57
|
+
|
58
|
+
rubyforge_project:
|
59
|
+
rubygems_version: 1.8.5
|
60
|
+
signing_key:
|
61
|
+
specification_version: 3
|
62
|
+
summary: Insert DevapeCms summary.
|
63
|
+
test_files: []
|
64
|
+
|