Class: Roby::CLI::GenMain
- Includes:
- Thor::Actions
- Defined in:
- lib/roby/cli/gen_main.rb
Overview
Scaffolding CLI (roby gen)
Instance Method Summary collapse
- #actions(name) ⇒ Object
- #app(dir = nil, init_path: "roby_app", robot_path: "roby_app") ⇒ Object
- #klass(name) ⇒ Object
- #module(name) ⇒ Object
- #robot(name, robot_path: "roby_app") ⇒ Object
- #task(name) ⇒ Object
- #task_srv(name) ⇒ Object
Instance Method Details
#actions(name) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/roby/cli/gen_main.rb', line 67 def actions(name) Roby.app.require_app_dir(needs_current: true) Roby.app.load_base_config file_name, class_name = Gen.resolve_name( "actions", name, [:robot], %w[models actions], %w[Actions] ) template File.join("actions", "class.rb"), "#{File.join('models', 'actions', *file_name)}.rb", context: Gen.make_context("class_name" => class_name) context = Gen.make_context( "class_name" => class_name, "require_path" => File.join("models", "actions", *file_name) ) template File.join("actions", "test.rb"), File.join("test", "actions", *file_name[0..-2], "test_#{file_name[-1]}.rb"), context: context end |
#app(dir = nil, init_path: "roby_app", robot_path: "roby_app") ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/roby/cli/gen_main.rb', line 27 def app(dir = nil, init_path: "roby_app", robot_path: "roby_app") if dir raise CLIInvalidArguments, "#{dir} already exists" if File.exist?(dir) else dir = Dir.pwd end directory "app/", dir, verbose: ![:quiet] copy_file File.join(init_path, "config", "init.rb"), File.join(dir, "config", "init.rb"), verbose: ![:quiet] template File.join(robot_path, "config", "robots", "robot.rb"), File.join(dir, "config", "robots", "default.rb"), context: Gen.make_context("robot_name" => "default"), verbose: ![:quiet] template File.join(robot_path, "config", "robots", "test.rb"), File.join(dir, "test", "robots", "test_default.rb"), context: Gen.make_context("robot_name" => "default"), verbose: ![:quiet] dir end |
#klass(name) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/roby/cli/gen_main.rb', line 91 def klass(name) Roby.app.require_app_dir(needs_current: true) Roby.app.load_base_config file_name, class_name = Gen.resolve_name( "class", name, nil, ["lib", Roby.app.app_name], [] ) template File.join("class", "class.rb"), "#{File.join('lib', Roby.app.app_name, *file_name)}.rb", context: Gen.make_context("class_name" => class_name) context = Gen.make_context( "class_name" => class_name, "require_path" => File.join(Roby.app.app_name, *file_name) ) template File.join("class", "test.rb"), File.join("test", "lib", *file_name[0..-2], "test_#{file_name[-1]}.rb"), context: context end |
#module(name) ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/roby/cli/gen_main.rb', line 114 def module(name) Roby.app.require_app_dir(needs_current: true) Roby.app.load_base_config file_name, class_name = Gen.resolve_name( "module", name, nil, ["lib", Roby.app.app_name], [] ) template File.join("module", "module.rb"), "#{File.join('lib', Roby.app.app_name, *file_name)}.rb", context: Gen.make_context("module_name" => class_name) context = Gen.make_context( "module_name" => class_name, "require_path" => File.join(Roby.app.app_name, *file_name) ) template File.join("module", "test.rb"), File.join("test", "lib", *file_name[0..-2], "test_#{file_name[-1]}.rb"), context: context end |
#robot(name, robot_path: "roby_app") ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/roby/cli/gen_main.rb', line 50 def robot(name, robot_path: "roby_app") Roby.app.require_app_dir(needs_current: true) Roby.app.load_base_config template File.join(robot_path, "config", "robots", "robot.rb"), File.join("config", "robots", "#{name}.rb"), context: Gen.make_context("robot_name" => name) template File.join(robot_path, "config", "robots", "test.rb"), File.join("test", "robots", "test_#{name}.rb"), context: Gen.make_context("robot_name" => name) end |
#task(name) ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/roby/cli/gen_main.rb', line 139 def task(name) Roby.app.require_app_dir(needs_current: true) Roby.app.load_base_config file_name, class_name = Gen.resolve_name( "tasks", name, [:robot], %w[models tasks], %w[Tasks] ) template File.join("task", "class.rb"), "#{File.join('models', 'tasks', *file_name)}.rb", context: Gen.make_context("class_name" => class_name) template File.join("task", "test.rb"), File.join("test", "tasks", *file_name[0..-2], "test_#{file_name[-1]}.rb"), context: Gen.make_context( "class_name" => class_name, "require_path" => File.join("models", "tasks", *file_name) ) end |
#task_srv(name) ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/roby/cli/gen_main.rb', line 163 def task_srv(name) Roby.app.require_app_dir(needs_current: true) Roby.app.load_base_config file_name, class_name = Gen.resolve_name( "services", name, [:robot], %w[models services], %w[Services] ) template File.join("task_srv", "class.rb"), "#{File.join('models', 'services', *file_name)}.rb", context: Gen.make_context("class_name" => class_name) end |