Sha256: fd27aa81eaffc76fa9200496a8015cea665cb6e8963fd09e380139a5d6b40281
Contents?: true
Size: 1.33 KB
Versions: 10
Compression:
Stored size: 1.33 KB
Contents
module Susanoo module Generators class NgModule < Thor::Group include Thor::Actions desc 'Create an AngularJS module.' argument :name, type: :string, desc: 'Name of AngularJS module' class_option :deps, type: :string, default: '', desc: 'Dependencies of Angularjs module, comma separated' def self.source_root File.join(File.dirname(__FILE__), '../templates/generators/ng_module') end def self.global_generator? false end def setup_directories empty_directory "src/views/#{directory_name}#{module_name}" mpath = 'src/assets/javascripts/modules/' empty_directory "#{mpath}#{directory_name}" unless directory_name.nil? end def install_js_module template 'module.js.erb', "src/assets/javascripts/modules/#{directory_name}#{module_name}.js" end def install_view template('index.html.erb', "src/views/#{directory_name}#{module_name}/index.html") end private def directory_name dir_name = name.split('/')[0..-2].join('/') return dir_name + '/' unless dir_name.empty? nil end def module_name name.split('/')[-1].underscore end def dependencies options[:deps].split(',') end end end end
Version data entries
10 entries across 10 versions & 1 rubygems