Module: Upgrow::Generators::Helper
- Included in:
- TestUnit::Generators::InputGenerator, TestUnit::Generators::InstallGenerator, TestUnit::Generators::RecordGenerator, TestUnit::Generators::RepositoryGenerator, ActionGenerator, InputGenerator, InstallGenerator, ModelGenerator, RecordGenerator, RepositoryGenerator
- Defined in:
- lib/generators/upgrow.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #class_name ⇒ Object
- #module_namespacing(&block) ⇒ Object
- #move_file(origin, destination) ⇒ Object
- #namespace_content(namespaces, content) ⇒ Object
Class Method Details
.included(base) ⇒ Object
12 13 14 |
# File 'lib/generators/upgrow.rb', line 12 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#class_name ⇒ Object
30 31 32 |
# File 'lib/generators/upgrow.rb', line 30 def class_name file_name.camelize end |
#module_namespacing(&block) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/generators/upgrow.rb', line 34 def module_namespacing(&block) super do content = capture(&block) concat(namespace_content(class_path, content)) end end |
#move_file(origin, destination) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/generators/upgrow.rb', line 16 def move_file(origin, destination) origin = File.(origin, destination_root) destination = File.(destination, destination_root) say_status( :move, "#{relative_to_original_destination_root(origin)} -> " + relative_to_original_destination_root(destination) ) FileUtils.mkdir_p(File.dirname(destination)) FileUtils.mv(origin, destination) end |
#namespace_content(namespaces, content) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/generators/upgrow.rb', line 41 def namespace_content(namespaces, content) namespace = namespaces.shift content = namespace_content(namespaces, content) if namespaces.any? if namespace "module #{namespace.camelize}\n#{indent(content).chomp}\nend\n" else content end end |