Class: Drupal
- Inherits:
-
Object
- Object
- Drupal
- Defined in:
- lib/drupal.rb,
lib/drupal/install.rb,
lib/drupal/todo_list.rb,
lib/drupal/create_module.rb
Defined Under Namespace
Classes: Create_Module, Install, Todo_List
Constant Summary collapse
Instance Method Summary collapse
-
#determine_handler ⇒ Object
Determine handler based on the current arguments.
-
#execute_handler ⇒ Object
Execute the handler if it was found.
-
#is_handler(klass) ⇒ Object
Check existance of a handler.
-
#output_help ⇒ Object
Output help information.
-
#output_version ⇒ Object
Output version information.
-
#parse_options ⇒ Object
Parse stdin for options.
-
#run(arguments) ⇒ Object
Run the drupal development tool.
Instance Method Details
#determine_handler ⇒ Object
Determine handler based on the current arguments.
81 82 83 84 85 86 |
# File 'lib/drupal.rb', line 81 def determine_handler @handler = @arguments.shift.capitalize while !@arguments.empty? && !is_handler(@handler) do @handler << '_' + @arguments.shift.capitalize end end |
#execute_handler ⇒ Object
Execute the handler if it was found.
89 90 91 92 |
# File 'lib/drupal.rb', line 89 def execute_handler abort 'Invalid command.' if !is_handler(@handler) eval("Drupal::#{@handler}.new.run(@arguments)") end |
#is_handler(klass) ⇒ Object
Check existance of a handler.
95 96 97 |
# File 'lib/drupal.rb', line 95 def is_handler(klass) Drupal.const_defined?(klass) end |
#output_help ⇒ Object
Output help information.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/drupal.rb', line 100 def output_help # TODO: utilize RDoc puts <<-USAGE SYNOPSIS: drupal [options] [arguments] ARGUMENTS: create module <module_name> [dir] Generates a module skeleton from an interactive wizard. Current directory unless [dir] is specified. todo list [total] Displays list of todo items or a total. install <core | project> [dir] [5.x|6.x|7.x] Install a Drupal project or core itself to [dir] (defaults to curent dir) for version (defaults to 6.x) EXAMPLES: Create a new module in the current directory. drupal create module my_module Create a new module in a specific directory. drupal create module my_module ./sites/all/modules View todo list for current directory. drupal todo list View todo list for multiple files or directories. drupal todo list ./sites/all/modules/mymodule View total todo items only. drupal todo list total ./sites/all/modules Install drupal core to the current directory. drupal install core Install a 5.x module when in the 'modules directory drupal install devel . 5.x Install a module to the modules folder in my new installation (from drupal root) drupal install devel ./sites/all/modules Install a module when in the 'modules directory drupal install devel USAGE exit end |
#output_version ⇒ Object
Output version information.
149 150 151 152 |
# File 'lib/drupal.rb', line 149 def output_version puts "Version #{Drupal::VERSION}" exit end |
#parse_options ⇒ Object
Parse stdin for options.
73 74 75 76 77 78 |
# File 'lib/drupal.rb', line 73 def opts = OptionParser.new opts.on('-h', '--help') { output_help } opts.on('-V', '--version') { output_version } opts.parse!(@arguments) end |
#run(arguments) ⇒ Object
Run the drupal development tool.
63 64 65 66 67 68 69 70 |
# File 'lib/drupal.rb', line 63 def run(arguments) @arguments = arguments || [] @options = OpenStruct.new abort 'Arguments required. Use --help for additional information.' if @arguments.empty? determine_handler execute_handler end |