styxie 0.0.3 → 0.0.4

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: 14c9639dd180e61ebfdb9c6198a231d6c8f26be3
4
- data.tar.gz: 2cdac238d96f91ad6fb12529b2bdb25076d56065
3
+ metadata.gz: d6544120d5ab6bae640de6ea3daa9c084aca872d
4
+ data.tar.gz: b2dc50ecec73907c0b77e01dcb5c1e40ac69da4c
5
5
  SHA512:
6
- metadata.gz: f0d4d5bbe87cfa4e0afd563338a59eebb5eb2994be014761a9870c183876b513f259adfe54a2d338ae6bee57b8857b34437c8146480105e22be6528acd35b591
7
- data.tar.gz: cd6352842b249f96d965f9b544b1b41a4b12e8ed08172e061ea91d5be4a54e9f6f8637f4a57c7d8bb3a1b02fc9bedb5006d1b36e7cec1ef1ff7dcb4920f5c64d
6
+ metadata.gz: ef3ce1b35d08cc70bca59dba9a89147bcf1ce53c8b24073b4f5a832a552de55c3c24ef04a988d6117ee969240737cb074061367a190ad141e2444a6a210a7e5f
7
+ data.tar.gz: cc17cab622ae5ccd74ff07853770f5e639d9880895a7ccad7d586fdbfa5717706996b9a3ce20fa8b5a8ef67ba981ba81b4291b57f8cc21155b7f435908a93b2c
data/README.md CHANGED
@@ -21,6 +21,7 @@ In your assets application.js include appropriate libs:
21
21
  # app/controllers/foos_controller.rb
22
22
  class FoosController < ApplicationController
23
23
  include Styxie::Initializer
24
+ helper_method :styxie_initialize # in case of Rails
24
25
  end
25
26
  ```
26
27
 
@@ -33,7 +34,7 @@ In common each controller in Rails comes with *app/assets/javascripts/controller
33
34
  **Styxie.Initializer** allows you to define bootstrap logic for each Rails action separately and
34
35
  pass some data from server right into it.
35
36
 
36
- To enable initializers bootstrap, add *styx_initialize* call into your layout:
37
+ To enable initializers bootstrap, add *styxie_initialize* call into your layout:
37
38
 
38
39
  ```erb
39
40
  <head>
@@ -1,22 +1,3 @@
1
1
  @Styxie = {
2
2
  Initializers: {}
3
3
  }
4
-
5
- @Styxie.URL =
6
- go: (url, force=false) ->
7
- # 'Force' required if you want to reload same page with another anchor
8
- url = this.build(url, "reloadthispagepls=#{Math.random()}") if force
9
- window.location.href = url
10
-
11
- build: (url, params) ->
12
- hash = url.match(/\#.*$/)
13
- hash = if hash then hash[0] else false
14
-
15
- url = url.replace(hash, '') if hash
16
- url = url + "?" if url.indexOf("?") == -1
17
-
18
- url = "#{url}&#{params}"
19
-
20
- url = url + hash if hash
21
-
22
- return url
@@ -5,19 +5,23 @@ module Styxie
5
5
  cfg.merge! data
6
6
  end
7
7
 
8
- def styxie_initialize(klass: styxie_class, method: action_name, data: styxie_configuration)
8
+ def styxie_initialize(klass: styxie_class, method: action_name, data: styxie_configuration, autorun: true)
9
9
  json = data.to_json
10
+ init_call = autorun ? 'initStyxie();' : ''
10
11
  result = <<-CODE
11
12
  <script type="text/javascript">
12
13
  //<![CDATA[
13
- if (Styxie.Initializers.#{klass} && Styxie.Initializers.#{klass}.initialize)
14
- {
15
- Styxie.Initializers.#{klass}.initialize(#{json});
16
- }
17
- if (Styxie.Initializers.#{klass} && Styxie.Initializers.#{klass}['#{method}'])
18
- {
19
- Styxie.Initializers.#{klass}['#{method}'](#{json});
20
- }
14
+ function initStyxie() {
15
+ if (Styxie.Initializers.#{klass} && Styxie.Initializers.#{klass}.initialize)
16
+ {
17
+ Styxie.Initializers.#{klass}.initialize(#{json});
18
+ }
19
+ if (Styxie.Initializers.#{klass} && Styxie.Initializers.#{klass}['#{method}'])
20
+ {
21
+ Styxie.Initializers.#{klass}['#{method}'](#{json});
22
+ }
23
+ };
24
+ #{init_call}
21
25
  //]]>
22
26
  </script>
23
27
  CODE
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Styxie
4
- VERSION = '0.0.3'.freeze
4
+ VERSION = '0.0.4'.freeze
5
5
  end
@@ -22,6 +22,7 @@ describe Styxie::Initializer do
22
22
  controller.stub(action_name: 'index')
23
23
  result = controller.styxie_initialize
24
24
  expect(result).to include "Styxie.Initializers.ModuleTests['index']({});"
25
+ expect(result).to include "initStyxie();"
25
26
  expect(result.html_safe?).to be_truthy
26
27
  end
27
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: styxie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yury Kotov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-09-03 00:00:00.000000000 Z
12
+ date: 2016-10-20 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Set of helpers to maintain bridge between Server side and Client (JS)
15
15
  side