jskit_rails 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8be4087240bb5bcfabd77ccd006bbdde23ae5f4e
4
- data.tar.gz: 9c9217a2ae99809335411531b3f2186b36bfccdb
3
+ metadata.gz: bcd9fbda4dcb8214247e55f4b44a5cc97e9b5d83
4
+ data.tar.gz: 645875d832923ce32348206255e18f544df2f486
5
5
  SHA512:
6
- metadata.gz: 7f8df0a2ddbde6b3b458a5412589143d4491681901ffed69c453fb716450fa59f870a59234f2d49ec2f282ab5827263135eb712dccd991913452c702e60a28da
7
- data.tar.gz: 9ca356034d993e0ff3a4a058e5aeb369507f4cbf9304100bcb1d62e24ae0b160043ff54bff0b5c9d641c9802354dc4355795d0b53b982eb38e237c2e7a1340aa
6
+ metadata.gz: 0f0ce3d5b2cf5f534c142a53db851957cd1f7025853106e4266e854d026cb89f993df5097c13b6512601dc901e56cc1d7d697e83ec30c6dbcfac8b7285892d17
7
+ data.tar.gz: 00f8b09e5ec97a0ebe0f40406be07e20a33969cd4dfd81366586b9aa8eca0d3a0f7d5c1267b2f90c7b0976920b7eceeb010f28d5a55100a4d99ddd6445f29243
@@ -23,7 +23,7 @@ ApplicationController.class_eval do
23
23
  [
24
24
  JskitRails.configuration.app_namespace,
25
25
  "Dispatcher",
26
- event_trigger(event_name(controller_name, action_name), JSKit.action_payload)
26
+ %Q(trigger("#{[event_namespace, "controller", controller_name, action_name].compact.join(":")}"#{JSKit.action_payload});)
27
27
  ].join(".")
28
28
  end
29
29
 
@@ -31,7 +31,7 @@ ApplicationController.class_eval do
31
31
  [
32
32
  JskitRails.configuration.app_namespace,
33
33
  "Dispatcher",
34
- event_trigger(event_name(controller_name, "all"), JSKit.controller_payload)
34
+ %Q(trigger("#{[event_namespace, "controller", controller_name, "all"].compact.join(":")}"#{JSKit.controller_payload});)
35
35
  ].join(".")
36
36
  end
37
37
 
@@ -40,18 +40,10 @@ ApplicationController.class_eval do
40
40
  [
41
41
  JskitRails.configuration.app_namespace,
42
42
  "Dispatcher",
43
- event_trigger(event_name("application", "all"), JSKit.app_payload)
43
+ %Q(trigger("#{[event_namespace, "controller", "application", "all"].compact.join(":")}"#{JSKit.app_payload});)
44
44
  ].join(".")
45
45
  end
46
46
 
47
- def event_name(controller, action)
48
- [event_namespace, "controller", controller, action].compact.join(":")
49
- end
50
-
51
- def event_trigger(event, payload)
52
- %Q(trigger("#{event}"#{JSKit.controller_payload});)
53
- end
54
-
55
47
  def payload_js(payload)
56
48
  payload.empty? ? "" : ", #{payload.map(&:to_json).join(', ')}"
57
49
  end
@@ -63,8 +55,6 @@ ApplicationController.class_eval do
63
55
  :payload_js,
64
56
  :application_event,
65
57
  :action_event,
66
- :event_name,
67
- :event_trigger,
68
58
  :controller_event)
69
59
  end
70
60
 
@@ -28,19 +28,6 @@ describe ApplicationController, type: :controller do
28
28
  end
29
29
  end
30
30
 
31
- describe "#event_name" do
32
- it "returns the event name" do
33
- expect(ApplicationController::JSKit.send(:event_name, "test_controller", "test_action")).to eq("controller:test_controller:test_action")
34
- end
35
-
36
- context "with namespace" do
37
- it "returns the controller event name prefixed with the namespace" do
38
- allow(ApplicationController::JSKit).to receive(:event_namespace) { "test" }
39
- expect(ApplicationController::JSKit.send(:event_name, "test_controller", "test_action")).to eq("test:controller:test_controller:test_action")
40
- end
41
- end
42
- end
43
-
44
31
  describe "#jskit" do
45
32
  it "returns a script tag with the global event and the controller event" do
46
33
  subject = ApplicationController.new
@@ -49,6 +36,7 @@ describe ApplicationController, type: :controller do
49
36
  application_event = ApplicationController::JSKit.send(:application_event)
50
37
  controller_event = ApplicationController::JSKit.send(:controller_event)
51
38
  action_event = ApplicationController::JSKit.send(:action_event)
39
+
52
40
  expect(subject.jskit).to eq(subject.view_context.javascript_tag([application_event, controller_event, action_event].join("\n")))
53
41
  end
54
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jskit_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dayton Nolan