Sha256: 513350b7ba602b61e7e76c584c12f5c8748fd0f93a1404761159a77608305edf

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 KB

Contents

require 'jsimple/version'

require 'jsimple/builder'
require 'jsimple/railtie' if defined?(Rails)

require 'hot_reload_proxy'

module Jsimple
  def self.app(name, props: {}, id: nil)
    Builder.app_factory(name, props, id)
  end

  def self.path(*args)
    app(*args).path
  end

  def self.init(*args)
    app(*args).init
  end

  # Config
  DEFAULT_HOST = 'localhost'
  DEFAULT_PORT = '3100'
  DEFAULT_DEVELOPMENT = defined?(Rails) ? Rails.env.development? : false
  DEFAULT_JS_START_COMMAND = 'start'
  DEFAULT_JS_PATH_PREFIX = 'jsimple'
  DEFAULT_JS_DEV_PATH_PREFIX = ''
  @host = DEFAULT_HOST
  @port = DEFAULT_PORT
  @development = DEFAULT_DEVELOPMENT
  @js_start_command = DEFAULT_JS_START_COMMAND
  @js_path_prefix = DEFAULT_JS_PATH_PREFIX
  @js_dev_path_prefix = DEFAULT_JS_DEV_PATH_PREFIX

  def self.host=(host)
    HotReloadProxy::Config.host = host
    @host = host
  end

  def self.port=(port)
    HotReloadProxy::Config.port = port
    @port = port
  end

  def self.development=(development)
    @development = development
  end

  def self.js_start_command=(js_start_command)
    @js_start_command = js_start_command
  end

  def self.js_path_prefix=(js_path_prefix)
    @js_path_prefix = js_path_prefix
  end

  def self.js_dev_path_prefix=(js_dev_path_prefix)
    @js_dev_path_prefix = js_dev_path_prefix
  end

  def self.host
    @host
  end

  def self.port
    @port
  end

  def self.development
    @development
  end

  def self.js_start_command
    @js_start_command
  end

  def self.js_path_prefix
    @js_path_prefix
  end

  def self.js_dev_path_prefix
    @js_dev_path_prefix
  end

  def self.reset!
    @host = DEFAULT_HOST
    @port = DEFAULT_PORT
    @development = DEFAULT_DEVELOPMENT
    @js_start_command = DEFAULT_JS_START_COMMAND
    @js_path_prefix = DEFAULT_JS_PATH_PREFIX
    @js_dev_path_prefix = DEFAULT_JS_DEV_PATH_PREFIX
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jsimple-0.5.0 lib/jsimple.rb