Sha256: bf62a5569cfba0fae6f84a0bddfec5b22553e539be5968f4e9d33a67f68ab443

Contents?: true

Size: 823 Bytes

Versions: 3

Compression:

Stored size: 823 Bytes

Contents

class ModuleGenerator < Rails::Generators::NamedBase
	#source_root File.expand_path('../templates', __FILE__)
	
	def create_module_file
		
		name = file_name.downcase.gsub(/\s|-/, '_')
		param = class_path
		param.map! {|item| item.downcase.gsub(/\s|-/, '_')}
		
		path = File.join('app/modules', *param)
		
		scope = []
		text = ""
		param.map! {|item|
			item = item.camelcase
			scope << item
			text += "module #{scope.join('::')}; end\n"
			item
		}
		param << name.camelcase
		scope = param.join('::')
		
		
		create_file File.join(path, "#{name}.rb") do
			type = ask("What type of module (device, service, logic) will this be?")
			
			text += <<-FILE


class #{scope} < AutomateEm::#{type.downcase.camelcase}
	def on_load
	end
	
	def on_unload
	end
	
	def on_update
	end
end

			FILE
			
			text
		end
		
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
automate-em-0.0.4 lib/generators/module/module_generator.rb
automate-em-0.0.3 lib/generators/module/module_generator.rb
automate-em-0.0.2 lib/generators/module/module_generator.rb