Class: OrmDev::Command::Create
- Inherits:
-
OrmDev::Command
- Object
- CLAide::Command
- OrmDev::Command
- OrmDev::Command::Create
- Defined in:
- lib/ormdev/command/create.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Create
constructor
A new instance of Create.
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Create
Returns a new instance of Create.
28 29 30 31 32 33 34 |
# File 'lib/ormdev/command/create.rb', line 28 def initialize(argv) @name = argv.shift_argument @template_url = argv.option('template-url') @fast = argv.flag?('fast', false) @skip = argv.flag?('skip', false) super end |
Class Method Details
.options ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/ormdev/command/create.rb', line 20 def self. [ ['--template-url=URL', 'Orm插件模板git地址,或者zip地址'], ['--fast', '通过Orm插件模板工程zip地址快速创建'], ['--skip', '跳过打开Orm插件模板工程'], ].concat(super) end |
Instance Method Details
#run ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/ormdev/command/create.rb', line 47 def run create = OrmDev::CreateHelper.new(@name, @fast, @template_url) create.setup(@skip) OrmDev::LogUtil.info '【创建插件工程】Success!!!,编写插件逻辑代码,添加版本控制' OrmDev::LogUtil.info " cd #{@name}".magenta OrmDev::LogUtil.info 'and' OrmDev::LogUtil.info " ormdev run".magenta end |
#validate! ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ormdev/command/create.rb', line 36 def validate! super help! 'A name for the Pod is required.' unless @name help! 'The Pod name cannot contain spaces.' if @name =~ /\s/ help! 'The Pod name cannot contain plusses.' if @name =~ /\+/ help! "The Pod name cannot begin with a '.'" if @name[0, 1] == '.' unless @template_url.nil? then help! '模板地址只能是以[git|zip]结尾的地址.' if !(@template_url.downcase.end_with?('.git') || @template_url.downcase.end_with?('.zip')) end end |