Class: Omnitest::Command::Generate::Documentation
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Omnitest::Command::Generate::Documentation
- Includes:
- Omnitest::Core::FileSystem, Psychic::Code2Doc::CodeHelper, Psychic::Code2Doc::SnippetHelper, Thor::Actions
- Defined in:
- lib/omnitest/command/generators/documentation.rb
Constant Summary collapse
- BUILTIN_GENERATORS =
Dir["#{Omnitest::Reporters::GENERATORS_DIR}/*"].select { |f| File.directory? f }
Instance Attribute Summary collapse
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#project_basedir ⇒ Object
readonly
Returns the value of attribute project_basedir.
-
#project_name ⇒ Object
readonly
Returns the value of attribute project_name.
-
#projects ⇒ Object
readonly
Returns the value of attribute projects.
Class Method Summary collapse
- .generator_names ⇒ Object
- .generator_not_found(generator) ⇒ Object
- .generators ⇒ Object
- .source_root ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#project ⇒ Object (readonly)
Returns the value of attribute project.
15 16 17 |
# File 'lib/omnitest/command/generators/documentation.rb', line 15 def project @project end |
#project_basedir ⇒ Object (readonly)
Returns the value of attribute project_basedir.
15 16 17 |
# File 'lib/omnitest/command/generators/documentation.rb', line 15 def project_basedir @project_basedir end |
#project_name ⇒ Object (readonly)
Returns the value of attribute project_name.
15 16 17 |
# File 'lib/omnitest/command/generators/documentation.rb', line 15 def project_name @project_name end |
#projects ⇒ Object (readonly)
Returns the value of attribute projects.
15 16 17 |
# File 'lib/omnitest/command/generators/documentation.rb', line 15 def projects @projects end |
Class Method Details
.generator_names ⇒ Object
22 23 24 |
# File 'lib/omnitest/command/generators/documentation.rb', line 22 def generator_names generators.map { |d| File.basename d } end |
.generator_not_found(generator) ⇒ Object
26 27 28 29 |
# File 'lib/omnitest/command/generators/documentation.rb', line 26 def generator_not_found(generator) s = "ERROR: No generator named #{generator}, available generators: " s << generator_names.join(', ') end |
.generators ⇒ Object
18 19 20 |
# File 'lib/omnitest/command/generators/documentation.rb', line 18 def generators BUILTIN_GENERATORS + Dir['tests/omnitest/generators/*'].select { |f| File.directory? f } end |
.source_root ⇒ Object
31 32 33 |
# File 'lib/omnitest/command/generators/documentation.rb', line 31 def source_root Omnitest::RESOURCES_DIR end |
Instance Method Details
#apply_template ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/omnitest/command/generators/documentation.rb', line 68 def apply_template if [:template] generator_script = "#{options[:template]}_template.rb" apply(generator_script) else case [:scope] when 'global' @projects = Omnitest.filter_projects(project_regexp) process_directory when 'project' Omnitest.filter_projects(project_regexp).each do | project | bind_project_variables(project) process_directory end when 'scenario' Omnitest.scenarios(project_regexp, scenario_regexp).each do | scenario | bind_scenario_variables(scenario) process_directory end end end end |
#set_source_and_destination ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/omnitest/command/generators/documentation.rb', line 52 def set_source_and_destination unless [:template] || File.exist?([:source]) abort 'Either the --source directory must exist, or --template must be specified' end if [:template] generator = self.class.generators.find { |d| File.basename(d) == [:template] } abort self.class.generator_not_found(generator) if generator.nil? source_paths << generator else source_paths << Pathname([:source]). end self.destination_root = [:destination] end |
#setup ⇒ Object
47 48 49 50 |
# File 'lib/omnitest/command/generators/documentation.rb', line 47 def setup Omnitest.update_config!() Omnitest.setup end |