Class: Lambit::Commands::Build::PackageTemplatesCommand
- Inherits:
-
Common::Base
- Object
- Common::Base
- Lambit::Commands::Build::PackageTemplatesCommand
- Defined in:
- lib/lambit/commands/build.rb
Instance Attribute Summary collapse
-
#project_path ⇒ Object
readonly
Returns the value of attribute project_path.
-
#tmpl_config ⇒ Object
readonly
Returns the value of attribute tmpl_config.
-
#tmpl_name ⇒ Object
readonly
Returns the value of attribute tmpl_name.
-
#workspace ⇒ Object
readonly
Returns the value of attribute workspace.
Attributes inherited from Common::Base
Instance Method Summary collapse
- #command ⇒ Object
-
#initialize(opts, args) ⇒ PackageTemplatesCommand
constructor
A new instance of PackageTemplatesCommand.
Methods inherited from Common::Base
Constructor Details
#initialize(opts, args) ⇒ PackageTemplatesCommand
Returns a new instance of PackageTemplatesCommand.
49 50 51 52 53 54 55 |
# File 'lib/lambit/commands/build.rb', line 49 def initialize(opts, args) super @workspace = opts['workspace'] @project_path = opts['project_path'] @tmpl_name = args[0] @tmpl_config = args[1] end |
Instance Attribute Details
#project_path ⇒ Object (readonly)
Returns the value of attribute project_path.
45 46 47 |
# File 'lib/lambit/commands/build.rb', line 45 def project_path @project_path end |
#tmpl_config ⇒ Object (readonly)
Returns the value of attribute tmpl_config.
47 48 49 |
# File 'lib/lambit/commands/build.rb', line 47 def tmpl_config @tmpl_config end |
#tmpl_name ⇒ Object (readonly)
Returns the value of attribute tmpl_name.
46 47 48 |
# File 'lib/lambit/commands/build.rb', line 46 def tmpl_name @tmpl_name end |
#workspace ⇒ Object (readonly)
Returns the value of attribute workspace.
44 45 46 |
# File 'lib/lambit/commands/build.rb', line 44 def workspace @workspace end |
Instance Method Details
#command ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/lambit/commands/build.rb', line 57 def command tmpl = JSON.parse(File.read("#{self.project_path}/templates/#{self.tmpl_name}")) tmpl.merge!(self.tmpl_config) unless self.tmpl_config.nil? begin File.open("#{self.workspace}/#{self.tmpl_name}",'w') do |f| f.write(tmpl.to_json) end @exitstatus = 0 rescue Exception => e if Lambit.is_debug? Lambit.logger.error e else Lambit.logger.error e. end @exitstatus = 1 end return '', self.exitstatus end |