Class: Iota::CLI::Create
- Inherits:
-
Object
- Object
- Iota::CLI::Create
- Defined in:
- lib/iota/cli/create.rb
Instance Attribute Summary collapse
-
#function_name ⇒ Object
readonly
Returns the value of attribute function_name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#runtime ⇒ Object
readonly
Returns the value of attribute runtime.
-
#thor ⇒ Object
readonly
Returns the value of attribute thor.
Instance Method Summary collapse
-
#initialize(options, function_name, thor) ⇒ Create
constructor
A new instance of Create.
- #run ⇒ Object
Constructor Details
#initialize(options, function_name, thor) ⇒ Create
Returns a new instance of Create.
5 6 7 8 9 10 11 |
# File 'lib/iota/cli/create.rb', line 5 def initialize(, function_name, thor) = @function_name = function_name @thor = thor @path = [:path] || File.join('.', function_name) @runtime = [:runtime] end |
Instance Attribute Details
#function_name ⇒ Object (readonly)
Returns the value of attribute function_name.
3 4 5 |
# File 'lib/iota/cli/create.rb', line 3 def function_name @function_name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/iota/cli/create.rb', line 3 def end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/iota/cli/create.rb', line 3 def path @path end |
#runtime ⇒ Object (readonly)
Returns the value of attribute runtime.
3 4 5 |
# File 'lib/iota/cli/create.rb', line 3 def runtime @runtime end |
#thor ⇒ Object (readonly)
Returns the value of attribute thor.
3 4 5 |
# File 'lib/iota/cli/create.rb', line 3 def thor @thor end |
Instance Method Details
#run ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/iota/cli/create.rb', line 13 def run if Dir.exist?(path) thor.say("Directory '#{path}' already exists.", :red) return end unless Iota::Function::DEFAULT_HANDLER.has_key?(runtime) thor.say("Please specify valid runtime. (%s)" % Iota::Function::DEFAULT_HANDLER.keys.to_s) return end function = Iota::Function.new(function_name, path) thor.say("Creating function at directory #{path}.", :yellow) function.create_local(runtime) thor.say("Done.", :blue) if function.exists? thor.say("Note: Function #{function_name} already exists in remote. \\ Please be careful to deploy it to remote.", :yellow) end end |