forked from mattmccray/comatose
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* More updates in preparation for use as a GemPlugin
* A start on the CLI support
- Loading branch information
1 parent
8adaa15
commit a650d61
Showing
6 changed files
with
121 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,109 @@ | ||
#!/usr/bin/env ruby | ||
# Command line | ||
|
||
puts "It's still early, so this doesn't really do anything -- yet." | ||
puts | ||
puts "Soon, you will be able to initialize comatose support in your app by running:" | ||
puts | ||
puts " $> comatose --rails ." | ||
puts | ||
puts "Or, upgrade you're current install:" | ||
puts | ||
puts " $> comatose --update ." | ||
puts | ||
puts "Or, freeze as plugin:" | ||
puts | ||
puts " $> comatose --freeze ." | ||
puts | ||
puts "And maybe other wacky things too... Not sure yet. :-)" | ||
puts | ||
require 'rubygems' | ||
require 'optparse' | ||
|
||
args = ARGV | ||
options = { | ||
:action => :gem | ||
} | ||
|
||
begin | ||
OptionParser.new do |opts| | ||
opts.banner = "Usage: comatose [options] RAILS_ROOT" | ||
|
||
opts.on("-g", "--gem", "Initialize to run from gem (DEFAULT)") do |s| | ||
options[:action] = :gem | ||
puts "GEM" | ||
end | ||
|
||
opts.on("-p", "--plugin", "Install as plugin") do |s| | ||
options[:action] = :plugin | ||
puts "PLUGIN" | ||
end | ||
|
||
opts.on("-u", "--update", "Update current installation (CURRENTLY UNIMPLEMENTED)") do |s| | ||
options[:action] = :update | ||
puts "UPDATE" | ||
end | ||
|
||
opts.separator "" | ||
opts.separator "Common options:" | ||
|
||
# No argument, shows at tail. This will print an options summary. | ||
# Try it and see! | ||
opts.on_tail("-h", "--help", "Show this message") do | ||
puts opts | ||
exit | ||
end | ||
|
||
# Another typical switch to print the version. | ||
opts.on_tail("--version", "Show version") do | ||
require 'comatose/version' | ||
puts Comatose::VERSION_STRING | ||
exit | ||
end | ||
|
||
end.parse!(args) | ||
rescue OptionParser::ParseError => e | ||
puts e | ||
end | ||
|
||
if args.length == 0 | ||
puts "No action taken." | ||
exit | ||
end | ||
|
||
RAILS_ROOT = File.expand_path( args.last ) | ||
|
||
class String | ||
def /(string) | ||
File.join(self, string) | ||
end | ||
end | ||
|
||
unless File.directory?(RAILS_ROOT) and File.exists?( RAILS_ROOT / 'config'/ 'boot.rb' ) | ||
puts "Not a valid rails application path." | ||
exit | ||
end | ||
|
||
comatose_initializer_path = RAILS_ROOT / 'config' / 'initializers' / 'comatose.rb' | ||
|
||
unless File.exists?( comatose_initializer_path ) | ||
File.open(comatose_initializer_path, 'w') do |f| | ||
f.write <<-EOT | ||
require 'comatose' | ||
# 1.) You should add the following snippet to your environment.rb too, probably... | ||
# | ||
# gem 'comatose' | ||
# | ||
# 2.) Following is an example configuration block for Comatose: | ||
# | ||
Comatose.configure do |config| | ||
# Includes AuthenticationSystem in the ComatoseController | ||
#config.includes << :authenticated_system | ||
# admin | ||
#config.admin_title = "My Content" | ||
#config.admin_sub_title = "Content for the rest of us..." | ||
# Includes AuthenticationSystem in the ComatoseAdminController | ||
#config.admin_includes << :authenticated_system | ||
# Calls :login_required as a before_filter | ||
#config.admin_authorization = :login_required | ||
# Returns the author name (login, in this case) for the current user | ||
#config.admin_get_author do | ||
# current_user.login | ||
#end | ||
# See the getting started guide at http://comatose.rubyforge.org for more... | ||
end | ||
EOT | ||
end | ||
else | ||
puts "Comatose initializer already exists (at #{comatose_initializer_path})" | ||
end | ||
|
||
puts "Done." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,2 @@ | ||
require 'support/class_options' | ||
require 'acts_as_versioned' | ||
require 'redcloth' unless defined?(RedCloth) | ||
require 'liquid' unless defined?(Liquid) | ||
|
||
require 'comatose' | ||
require 'text_filters' | ||
|
||
require 'support/inline_rendering' | ||
require 'support/route_mapper' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module Comatose | ||
|
||
class ComatoseDrop < Liquid::Drop | ||
class ComatoseDrop < ::Liquid::Drop | ||
|
||
private :initialize | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,3 @@ | ||
# Init for gem version of Comatose | ||
|
||
require 'support/class_options' | ||
require 'acts_as_versioned' | ||
require 'redcloth' unless defined?(RedCloth) | ||
require 'liquid' unless defined?(Liquid) | ||
|
||
require 'comatose' | ||
require 'text_filters' | ||
|
||
require 'support/inline_rendering' | ||
require 'support/route_mapper' |