jsimple 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aaaf5d43fd079729c12049ccdaafa7d9cb7414eb
4
- data.tar.gz: 5e9d3ba9b23689659bea277d80776d6983def460
3
+ metadata.gz: 043e7f12d06d338ad9427266465716b82c88a9c9
4
+ data.tar.gz: 5771c6a61a7a60561c37b1992e87f586fe7716aa
5
5
  SHA512:
6
- metadata.gz: 412e807c898b56f721fe856f291a546c7f0f62ccc88a2f4a0cbc1b1a05b06e449bb72a330f098d1f2a3ec3e700188eb343c88b9f1a7d0924c9124322c527531c
7
- data.tar.gz: 6ea3f24087320e54bbd9f0a1c746b37a802033b2d6e27c6032c7336678b7096e16e219349f3c7366b40d2b76b7f992540f47258ab199ce9db0fbce8705345914
6
+ metadata.gz: 910b428605fef1fa5716a4a03f0e471cf4ae9b3287fdbc0e96ec1aa5b0644f9fb38221ff231dc0ee23dd503f4ce224d25aabd0e54b730b4c7dd7e74e79695a5d
7
+ data.tar.gz: a5d57d6fc5bf693b7ee9a80c4fb8f7979fd1064bf31e4b47b3f1cb3c8eff82c383d2287f9672444b18f25a6814ae10d9db56ac1eb230b98ed9c137a8d607dcdd
data/README.md CHANGED
@@ -18,10 +18,33 @@ Or install it yourself as:
18
18
 
19
19
  $ gem install jsimple
20
20
 
21
+ ## Configure
22
+
23
+ In order to have this make sense with your current setup you probably want to configure some of the defaults.
24
+
25
+ __Host__: `Jsimple.host = 'localhost'`
26
+ Server host for the JS client (usually Node) in development mode. Default is localhost.
27
+
28
+ __Port__: `Jsimple.port = '3100'`
29
+ Server port for the JS client (usually Node) in development mode. Default is 3100.
30
+
31
+ __Development__: `Jsimple.development = false`
32
+ Whether to start Jsimple in development mode. Default is `Rails.env.development?` otherwise false.
33
+
34
+ __Js_start_command__: `Jsimple.js_start_command = 'start'`
35
+ JS function name the legacy app will call to initialize the JS app.
36
+
21
37
  ## Usage
22
38
 
23
39
  ```ruby
24
- app = Jsimple.app('ContactList', props: [{name: 'Alice'}, {name: 'Bob'}], id: nil)
40
+ data = {name: 'Alice', age: 26}
41
+ app = Jsimple.app('ContactList', props: data, id: 'contact-list-id')
42
+ app.path
43
+ # => jsimple/test_app.min.js
44
+ app.init
45
+ # => <script>
46
+ # test_app.start(document.getElementById('contact-list-id'), JSON.parse('{"name": "Alice", "age": 26}'));
47
+ # </script>
25
48
  ```
26
49
 
27
50
  ## Development
@@ -1,6 +1,7 @@
1
1
  require 'jsimple/version'
2
2
 
3
3
  require 'jsimple/builder'
4
+ require 'jsimple/railtie' if defined?(Rails)
4
5
 
5
6
  require 'hot_reload_proxy'
6
7
 
@@ -20,12 +21,12 @@ module Jsimple
20
21
  @js_start_command = DEFAULT_JS_START_COMMAND
21
22
 
22
23
  def self.host=(host)
23
- HotReloadProxy::Proxy.foreign_host = host
24
+ HotReloadProxy::Proxy.host = host
24
25
  @host = host
25
26
  end
26
27
 
27
28
  def self.port=(port)
28
- HotReloadProxy::Proxy.foreign_port = port
29
+ HotReloadProxy::Proxy.port = port
29
30
  @port = port
30
31
  end
31
32
 
@@ -0,0 +1,10 @@
1
+ module Jsimple
2
+ module RailsViewHelper
3
+ def jsimple_app(name, props: {}, id: nil)
4
+ js_app = Jsimple.app(name, props: {}, id: nil)
5
+ js_app.path = js_app.path.html_safe
6
+ js_app.init = js_app.init.html_safe
7
+ js_app
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ require 'jsimple/rails_view_helper'
2
+
3
+ module Jsimple
4
+ class JsimpleRailtie < ::Rails::Railtie
5
+ initializer 'jsimple.view_helpers' do
6
+ ActionView::Base.send :include, RailsViewHelper
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Jsimple
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsimple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Burenstam
@@ -103,9 +103,9 @@ files:
103
103
  - jsimple.gemspec
104
104
  - lib/jsimple.rb
105
105
  - lib/jsimple/builder.rb
106
+ - lib/jsimple/rails_view_helper.rb
107
+ - lib/jsimple/railtie.rb
106
108
  - lib/jsimple/version.rb
107
- - lib/jsimple/view_helper.rb
108
- - lib/railtie.rb
109
109
  homepage: https://github.com/buren/jsimple
110
110
  licenses:
111
111
  - MIT
@@ -1,7 +0,0 @@
1
- module Jsimple
2
- module ViewHelper
3
- def jsimple_app(name, props: {}, id: nil)
4
- Jsimple.app(name, props: {}, id: nil)
5
- end
6
- end
7
- end
@@ -1,9 +0,0 @@
1
- require 'jsimple/view_helper'
2
-
3
- module Jsimple
4
- class JsimpleRailtie < Rails::Railtie
5
- initializer 'jsimple.view_helpers' do
6
- ActionView::Base.send :include, ViewHelper
7
- end
8
- end
9
- end