jcnetdev / comatose forked from darthapo/comatose

Comatose is a micro CMS, implemented as a Rails plugin, that is designed to be easy to embed and extend.

This URL has Read+Write access

jcnetdev (author)
Wed Sep 17 03:53:53 -0700 2008
commit  45f38e26d7b44b33263956363bbe9eee1feccf71
tree    f5c19bb8e1fe07bf163be444b7b7f349cca81fb2
parent  c7d982ed59e72cd07cc759627d371019555ad15b
comatose / Rakefile
100644 123 lines (102 sloc) 3.684 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
require 'rake'
require 'rake/tasklib'
require 'rake/testtask'
require 'rake/rdoctask'
require 'test/behaviors'
 
desc 'Default: run unit tests.'
task :default => :test
 
desc 'Test the Comatose plugin.'
Rake::TestTask.new(:test) do |t|
  t.libs << 'lib'
  t.pattern = 'test/**/*_test.rb'
  t.verbose = false
end
 
Behaviors::ReportTask.new :specs do |t|
  t.pattern = 'test/**/*_test.rb'
end
 
desc 'Generate documentation for Comatose.'
Rake::RDocTask.new(:rdoc) do |rdoc|
  rdoc.rdoc_dir = 'rdoc'
  rdoc.title = 'Comatose'
  rdoc.options << '--line-numbers' << '--inline-source'
  rdoc.rdoc_files.include('README')
  rdoc.rdoc_files.include('lib/**/*.rb')
end
 
def manifest_files
  Dir.glob("**/*").delete_if do |item|
    item.include?(".git") or item =~ /gem(?:spec)?$/ or File.directory?(item)
  end
end
 
desc "Generate a MANIFEST files"
task :manifest do
  File.open('MANIFEST', 'w') do |f|
    f.write manifest_files.join("\n")
  end
  puts 'Created MANIFEST'
end
 
 
desc "Update GEMSPEC"
task :gemspec=>:manifest do
  $: << 'lib'
  require 'comatose/version'
  
  gemspec_src =<<-EOGS
# Generated on #{ Time.now.to_s }
Gem::Specification.new do |s|
s.name = "comatose"
s.version = "#{ Comatose::VERSION }"
s.date = "#{ Time.now.strftime('%Y-%m-%d') }" # 2008-05-20
s.summary = "Micro CMS designed for being embedded into existing Rails applications"
s.email = "matt@elucidata.net"
s.rubyforge_project = 'comatose'
s.homepage = "http://comatose.rubyforge.org"
s.description = "Comatose is a micro CMS designed for being embedded into existing Rails applications."
s.has_rdoc = true
s.authors = ["M@ McCray"]
s.bindir = 'bin'
s.executables = ['comatose']
s.files = ["#{ manifest_files.join('", "') }"]
s.test_files = ["#{ manifest_files.delete_if{ |f| !f.include?('test/') }.join('", "') }"]
s.rdoc_options = ["--main", "README.rdoc"]
s.extra_rdoc_files = %w(README.rdoc CHANGELOG SPECS LICENSE)
#s.add_dependency("mime-types", ["> 0.0.0"])
end
EOGS
  
  File.open("comatose.gemspec", 'w') do |f|
    f.write gemspec_src
  end
  
  puts "Update GEMSPEC"
end
 
desc "Builds the admin costumizable layout, the embedded layout have the JS and CSS inlined"
task :build do
  require 'erb'
 
  # Javascript
  script_path = File.join('resources', 'public', 'javascripts', 'comatose_admin.js')
  script_contents = ''
  # Stylesheet
  style_path = File.join('resources', 'public', 'stylesheets', 'comatose_admin.css')
  style_contents = ''
  # Layout Template
  tmpl_path = File.join('resources', 'layouts', 'comatose_admin_template.html.erb')
  tmpl_contents = ''
  # Layout Target
  layout_path = File.join('views', 'layouts', 'comatose_admin.html.erb')
  layout_contents = ''
  # Customizable Target
  customizable_path = File.join('views', 'layouts', 'comatose_admin_customize.html.erb')
  
  # Read the file contents...
  File.open(script_path, 'r') {|f| script_contents = "<script>\n#{f.read}\n</script>" }
  File.open(style_path, 'r') {|f| style_contents = "<style>\n#{f.read}\n</style>" }
  File.open(tmpl_path, 'r') {|f| tmpl_contents = f.read }
 
  # Create the final layout...
  layout_contents = ERB.new( tmpl_contents ).result(binding)
  
  # Write it out...
  File.open(layout_path, 'w') {|f| f.write layout_contents }
  
  # Now let's create the customizable one...
  style_contents = "<%= stylesheet_link_tag 'comatose_admin' %>"
  script_contents = "<%= javascript_include_tag 'comatose_admin' %>"
  
  # Create the final layout...
  layout_contents = ERB.new( tmpl_contents ).result(binding)
  
  # Write it out...
  File.open(customizable_path, 'w') {|f| f.write layout_contents }
  
  # That's it -- we're done.
  puts "Finished."
end