class EmbeddedJs::Commands::Init

Constants

CONFIG_OUTPUT_PATH
TEMPLATES_DIR

Attributes

package_manager[R]

Public Class Methods

call(package_manager: 'npm') click to toggle source
# File lib/embedded_js/commands/init.rb, line 12
def call(package_manager: 'npm')
  new.call(package_manager: package_manager)
end

Public Instance Methods

call(package_manager: 'npm') click to toggle source
# File lib/embedded_js/commands/init.rb, line 17
def call(package_manager: 'npm')
  @package_manager = package_manager

  generate_config_file
  instructions
end

Private Instance Methods

config_template() click to toggle source
# File lib/embedded_js/commands/init.rb, line 38
def config_template
  File.read(config_template_path)
end
config_template_path() click to toggle source
# File lib/embedded_js/commands/init.rb, line 42
def config_template_path
  "#{TEMPLATES_DIR}/.embeddedjs.erb"
end
generate_config_file() click to toggle source
# File lib/embedded_js/commands/init.rb, line 28
def generate_config_file
  File.write(CONFIG_OUTPUT_PATH, render_config)
end
instructions() click to toggle source
# File lib/embedded_js/commands/init.rb, line 32
def instructions
  post_install_msg = File.read("#{TEMPLATES_DIR}/post_install.txt")

  puts post_install_msg
end
render_config() click to toggle source
# File lib/embedded_js/commands/init.rb, line 46
def render_config
  ERB.new(config_template).result(binding)
end