stimulus_reflex 3.3.0 → 3.4.0.pre4
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 +4 -4
- data/CHANGELOG.md +113 -8
- data/Gemfile.lock +70 -69
- data/README.md +6 -3
- data/{lib → app/channels}/stimulus_reflex/channel.rb +36 -21
- data/lib/generators/stimulus_reflex/config_generator.rb +14 -0
- data/lib/generators/{stimulus_reflex_generator.rb → stimulus_reflex/stimulus_reflex_generator.rb} +0 -0
- data/lib/generators/{templates → stimulus_reflex/templates}/app/javascript/controllers/%file_name%_controller.js.tt +0 -0
- data/lib/generators/{templates → stimulus_reflex/templates}/app/javascript/controllers/application_controller.js.tt +0 -0
- data/lib/generators/{templates → stimulus_reflex/templates}/app/reflexes/%file_name%_reflex.rb.tt +0 -0
- data/lib/generators/{templates → stimulus_reflex/templates}/app/reflexes/application_reflex.rb.tt +0 -0
- data/lib/generators/stimulus_reflex/templates/config/initializers/stimulus_reflex.rb +20 -0
- data/lib/stimulus_reflex.rb +3 -2
- data/lib/stimulus_reflex/broadcasters/broadcaster.rb +12 -9
- data/lib/stimulus_reflex/broadcasters/nothing_broadcaster.rb +4 -0
- data/lib/stimulus_reflex/broadcasters/page_broadcaster.rb +8 -3
- data/lib/stimulus_reflex/broadcasters/selector_broadcaster.rb +12 -2
- data/lib/stimulus_reflex/configuration.rb +27 -0
- data/lib/stimulus_reflex/element.rb +8 -0
- data/lib/stimulus_reflex/logger.rb +106 -0
- data/lib/stimulus_reflex/reflex.rb +29 -22
- data/lib/stimulus_reflex/sanity_checker.rb +82 -22
- data/lib/stimulus_reflex/utils/colorize.rb +23 -0
- data/lib/stimulus_reflex/version.rb +1 -1
- data/lib/tasks/stimulus_reflex/install.rake +12 -8
- data/package.json +57 -0
- data/stimulus_reflex.gemspec +40 -0
- data/tags +98 -0
- data/test/broadcasters/broadcaster_test.rb +15 -0
- data/test/broadcasters/nothing_broadcaster_test.rb +34 -0
- data/test/broadcasters/page_broadcaster_test.rb +69 -0
- data/test/broadcasters/selector_broadcaster_test.rb +83 -0
- data/test/generators/stimulus_reflex_generator_test.rb +1 -0
- data/test/test_helper.rb +2 -0
- data/test/tmp/app/reflexes/application_reflex.rb +12 -0
- data/test/tmp/app/reflexes/posts_reflex.rb +24 -0
- data/yarn.lock +4685 -0
- metadata +42 -21
|
@@ -1,36 +1,53 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class StimulusReflex::SanityChecker
|
|
4
|
-
NODE_VERSION_FORMAT = /(\d+\.\d+\.\d+.*):/
|
|
5
4
|
JSON_VERSION_FORMAT = /(\d+\.\d+\.\d+.*)"/
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
class << self
|
|
7
|
+
def check!
|
|
8
|
+
return if StimulusReflex.config.on_failed_sanity_checks == :ignore
|
|
9
|
+
return if called_by_generate_config?
|
|
10
|
+
|
|
11
|
+
instance = new
|
|
12
|
+
instance.check_caching_enabled
|
|
13
|
+
instance.check_javascript_package_version
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def called_by_generate_config?
|
|
19
|
+
ARGV.include? "stimulus_reflex:config"
|
|
20
|
+
end
|
|
11
21
|
end
|
|
12
22
|
|
|
13
23
|
def check_caching_enabled
|
|
14
24
|
unless caching_enabled?
|
|
15
|
-
|
|
16
|
-
|
|
25
|
+
warn_and_exit <<~WARN
|
|
26
|
+
Stimulus Reflex requires caching to be enabled. Caching allows the session to be modified during ActionCable requests.
|
|
17
27
|
To enable caching in development, run:
|
|
18
28
|
rails dev:cache
|
|
19
29
|
WARN
|
|
20
30
|
end
|
|
31
|
+
|
|
32
|
+
unless not_null_store?
|
|
33
|
+
warn_and_exit <<~WARN
|
|
34
|
+
Stimulus Reflex requires caching to be enabled. Caching allows the session to be modified during ActionCable requests.
|
|
35
|
+
But your config.cache_store is set to :null_store, so it won't work.
|
|
36
|
+
WARN
|
|
37
|
+
end
|
|
21
38
|
end
|
|
22
39
|
|
|
23
40
|
def check_javascript_package_version
|
|
24
41
|
if javascript_package_version.nil?
|
|
25
|
-
|
|
26
|
-
|
|
42
|
+
warn_and_exit <<~WARN
|
|
43
|
+
Can't locate the stimulus_reflex NPM package.
|
|
27
44
|
Either add it to your package.json as a dependency or use "yarn link stimulus_reflex" if you are doing development.
|
|
28
45
|
WARN
|
|
29
46
|
end
|
|
30
47
|
|
|
31
48
|
unless javascript_version_matches?
|
|
32
|
-
|
|
33
|
-
|
|
49
|
+
warn_and_exit <<~WARN
|
|
50
|
+
The Stimulus Reflex javascript package version (#{javascript_package_version}) does not match the Rubygem version (#{gem_version}).
|
|
34
51
|
To update the Stimulus Reflex npm package:
|
|
35
52
|
yarn upgrade stimulus_reflex@#{gem_version}
|
|
36
53
|
WARN
|
|
@@ -40,8 +57,11 @@ class StimulusReflex::SanityChecker
|
|
|
40
57
|
private
|
|
41
58
|
|
|
42
59
|
def caching_enabled?
|
|
43
|
-
Rails.application.config.action_controller.perform_caching
|
|
44
|
-
|
|
60
|
+
Rails.application.config.action_controller.perform_caching
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def not_null_store?
|
|
64
|
+
Rails.application.config.cache_store != :null_store
|
|
45
65
|
end
|
|
46
66
|
|
|
47
67
|
def javascript_version_matches?
|
|
@@ -53,14 +73,11 @@ class StimulusReflex::SanityChecker
|
|
|
53
73
|
end
|
|
54
74
|
|
|
55
75
|
def javascript_package_version
|
|
56
|
-
|
|
57
|
-
@_js_version = find_javascript_package_version
|
|
76
|
+
@_js_version ||= find_javascript_package_version
|
|
58
77
|
end
|
|
59
78
|
|
|
60
79
|
def find_javascript_package_version
|
|
61
|
-
if (match = search_file(
|
|
62
|
-
match[NODE_VERSION_FORMAT, 1]
|
|
63
|
-
elsif (match = search_file(yarn_link_path, regex: /version/))
|
|
80
|
+
if (match = search_file(package_json_path, regex: /version/))
|
|
64
81
|
match[JSON_VERSION_FORMAT, 1]
|
|
65
82
|
end
|
|
66
83
|
end
|
|
@@ -70,11 +87,54 @@ class StimulusReflex::SanityChecker
|
|
|
70
87
|
File.foreach(path).grep(regex).first
|
|
71
88
|
end
|
|
72
89
|
|
|
73
|
-
def
|
|
74
|
-
Rails.root.join("
|
|
90
|
+
def package_json_path
|
|
91
|
+
Rails.root.join("node_modules", "stimulus_reflex", "package.json")
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def initializer_path
|
|
95
|
+
@_initializer_path ||= Rails.root.join("config", "initializers", "stimulus_reflex.rb")
|
|
75
96
|
end
|
|
76
97
|
|
|
77
|
-
def
|
|
78
|
-
|
|
98
|
+
def warn_and_exit(text)
|
|
99
|
+
puts "WARNING:"
|
|
100
|
+
puts text
|
|
101
|
+
exit_with_info if StimulusReflex.config.on_failed_sanity_checks == :exit
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def exit_with_info
|
|
105
|
+
puts
|
|
106
|
+
|
|
107
|
+
# bundle exec rails generate stimulus_reflex:config
|
|
108
|
+
if File.exist?(initializer_path)
|
|
109
|
+
puts <<~INFO
|
|
110
|
+
If you know what you are doing and you want to start the application anyway,
|
|
111
|
+
you can add the following directive to the StimulusReflex initializer,
|
|
112
|
+
which is located at #{initializer_path}
|
|
113
|
+
|
|
114
|
+
StimulusReflex.configure do |config|
|
|
115
|
+
config.on_failed_sanity_checks = :warn
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
INFO
|
|
119
|
+
else
|
|
120
|
+
puts <<~INFO
|
|
121
|
+
If you know what you are doing and you want to start the application anyway,
|
|
122
|
+
you can create a StimulusReflex initializer with the command:
|
|
123
|
+
|
|
124
|
+
bundle exec rails generate stimulus_reflex:config
|
|
125
|
+
|
|
126
|
+
Then open your initializer at
|
|
127
|
+
|
|
128
|
+
<RAILS_ROOT>/config/initializers/stimulus_reflex.rb
|
|
129
|
+
|
|
130
|
+
and then add the following directive:
|
|
131
|
+
|
|
132
|
+
StimulusReflex.configure do |config|
|
|
133
|
+
config.on_failed_sanity_checks = :warn
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
INFO
|
|
137
|
+
end
|
|
138
|
+
exit
|
|
79
139
|
end
|
|
80
140
|
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module StimulusReflex
|
|
4
|
+
module Utils
|
|
5
|
+
module Colorize
|
|
6
|
+
COLORS = {
|
|
7
|
+
red: "31",
|
|
8
|
+
green: "32",
|
|
9
|
+
yellow: "33",
|
|
10
|
+
blue: "34",
|
|
11
|
+
magenta: "35",
|
|
12
|
+
cyan: "36",
|
|
13
|
+
white: "37"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
refine String do
|
|
17
|
+
COLORS.each do |name, code|
|
|
18
|
+
define_method(name) { "\e[#{code}m#{self}\e[0m" }
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -9,15 +9,16 @@ namespace :stimulus_reflex do
|
|
|
9
9
|
system "bundle exec rails webpacker:install:stimulus"
|
|
10
10
|
gem_version = StimulusReflex::VERSION.gsub(".pre", "-pre")
|
|
11
11
|
system "yarn add stimulus_reflex@#{gem_version}"
|
|
12
|
+
main_folder = defined?(Webpacker) ? Webpacker.config.source_path.to_s.gsub("#{Rails.root}/", "") : "app/javascript"
|
|
12
13
|
|
|
13
|
-
FileUtils.mkdir_p Rails.root.join("
|
|
14
|
+
FileUtils.mkdir_p Rails.root.join("#{main_folder}/controllers"), verbose: true
|
|
14
15
|
FileUtils.mkdir_p Rails.root.join("app/reflexes"), verbose: true
|
|
15
16
|
|
|
16
|
-
filepath =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
filepath = [
|
|
18
|
+
"#{main_folder}/controllers/index.js",
|
|
19
|
+
"#{main_folder}/controllers/index.ts",
|
|
20
|
+
"#{main_folder}/packs/application.js",
|
|
21
|
+
"#{main_folder}/packs/application.ts"
|
|
21
22
|
]
|
|
22
23
|
.select { |path| File.exist?(path) }
|
|
23
24
|
.map { |path| Rails.root.join(path) }
|
|
@@ -42,7 +43,8 @@ namespace :stimulus_reflex do
|
|
|
42
43
|
end
|
|
43
44
|
|
|
44
45
|
initialize_line = lines.find { |line| line.start_with?("StimulusReflex.initialize") }
|
|
45
|
-
lines << "StimulusReflex.initialize(application, { consumer, controller,
|
|
46
|
+
lines << "StimulusReflex.initialize(application, { consumer, controller, isolate: true })\n" unless initialize_line
|
|
47
|
+
lines << "StimulusReflex.debug = process.env.RAILS_ENV === 'development'\n" unless initialize_line
|
|
46
48
|
File.open(filepath, "w") { |f| f.write lines.join }
|
|
47
49
|
|
|
48
50
|
filepath = Rails.root.join("config/environments/development.rb")
|
|
@@ -58,11 +60,13 @@ namespace :stimulus_reflex do
|
|
|
58
60
|
lines.delete_at 1
|
|
59
61
|
lines.insert 1, " adapter: redis\n"
|
|
60
62
|
lines.insert 2, " url: <%= ENV.fetch(\"REDIS_URL\") { \"redis://localhost:6379/1\" } %>\n"
|
|
61
|
-
lines.insert 3, " channel_prefix: " + Rails.
|
|
63
|
+
lines.insert 3, " channel_prefix: " + File.basename(Rails.root.to_s).underscore + "_development\n"
|
|
62
64
|
File.open(filepath, "w") { |f| f.write lines.join }
|
|
63
65
|
end
|
|
64
66
|
|
|
65
67
|
system "bundle exec rails generate stimulus_reflex example"
|
|
68
|
+
puts "Generating default StimulusReflex configuration file into your application config/initializers directory"
|
|
69
|
+
system "bundle exec rails generate stimulus_reflex:config"
|
|
66
70
|
system "rails dev:cache" unless Rails.root.join("tmp", "caching-dev.txt").exist?
|
|
67
71
|
end
|
|
68
72
|
end
|
data/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "stimulus_reflex",
|
|
3
|
+
"version": "3.4.0-pre3",
|
|
4
|
+
"description": "Build reactive applications with the Rails tooling you already know and love.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ruby",
|
|
7
|
+
"rails",
|
|
8
|
+
"websockets",
|
|
9
|
+
"actioncable",
|
|
10
|
+
"turbolinks",
|
|
11
|
+
"reactive",
|
|
12
|
+
"cable",
|
|
13
|
+
"ujs",
|
|
14
|
+
"ssr",
|
|
15
|
+
"stimulus",
|
|
16
|
+
"reflex",
|
|
17
|
+
"stimulus_reflex",
|
|
18
|
+
"dom",
|
|
19
|
+
"morphdom"
|
|
20
|
+
],
|
|
21
|
+
"homepage": "https://docs.stimulusreflex.com/",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/hopsoft/stimulus_reflex/issues"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com:hopsoft/stimulus_reflex.git"
|
|
28
|
+
},
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"author": "Nathan Hopkins <natehop@gmail.com>",
|
|
31
|
+
"main": "./javascript/stimulus_reflex.js",
|
|
32
|
+
"module": "./javascript/stimulus_reflex.js",
|
|
33
|
+
"scripts": {
|
|
34
|
+
"postinstall": "node javascript/scripts/post_install.js",
|
|
35
|
+
"prettier-standard:check": "yarn run prettier-standard --check *.js **/*.js",
|
|
36
|
+
"prettier-standard:format": "yarn run prettier-standard *.js **/*.js",
|
|
37
|
+
"test": "yarn run mocha --require @babel/register --require esm ./javascript/test"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"stimulus": ">= 1.1"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@rails/actioncable": ">= 6.0",
|
|
44
|
+
"cable_ready": ">= 4.3.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@babel/core": "^7.6.2",
|
|
48
|
+
"@babel/preset-env": "^7.6.2",
|
|
49
|
+
"@babel/register": "^7.6.2",
|
|
50
|
+
"assert": "^2.0.0",
|
|
51
|
+
"esm": "^3.2.25",
|
|
52
|
+
"jsdom": "^16.0.1",
|
|
53
|
+
"mocha": "^8.0.1",
|
|
54
|
+
"prettier-standard": "^16.1.0",
|
|
55
|
+
"stimulus": "^1.1.1"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require File.expand_path("../lib/stimulus_reflex/version", __FILE__)
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |gem|
|
|
4
|
+
gem.name = "stimulus_reflex"
|
|
5
|
+
gem.license = "MIT"
|
|
6
|
+
gem.version = StimulusReflex::VERSION
|
|
7
|
+
gem.authors = ["Nathan Hopkins"]
|
|
8
|
+
gem.email = ["natehop@gmail.com"]
|
|
9
|
+
gem.homepage = "https://github.com/hopsoft/stimulus_reflex"
|
|
10
|
+
gem.summary = "Build reactive applications with the Rails tooling you already know and love."
|
|
11
|
+
gem.post_install_message = <<~MESSAGE
|
|
12
|
+
Friendly reminder: When updating the stimulus_reflex gem,
|
|
13
|
+
don't forget to update your npm package as well.
|
|
14
|
+
|
|
15
|
+
See https://www.npmjs.com/package/stimulus_reflex
|
|
16
|
+
MESSAGE
|
|
17
|
+
|
|
18
|
+
gem.metadata = {
|
|
19
|
+
"bug_tracker_uri" => "https://github.com/hopsoft/stimulus_reflex/issues",
|
|
20
|
+
"changelog_uri" => "https://github.com/hopsoft/stimulus_reflex/CHANGELOG.md",
|
|
21
|
+
"documentation_uri" => "https://docs.stimulusreflex.com",
|
|
22
|
+
"homepage_uri" => gem.homepage,
|
|
23
|
+
"source_code_uri" => gem.homepage
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
gem.files = Dir["app/**/*", "lib/**/*", "bin/*", "[A-Z]*"]
|
|
27
|
+
gem.test_files = Dir["test/**/*.rb"]
|
|
28
|
+
|
|
29
|
+
gem.add_dependency "rack"
|
|
30
|
+
gem.add_dependency "nokogiri"
|
|
31
|
+
gem.add_dependency "rails", ">= 5.2"
|
|
32
|
+
gem.add_dependency "redis"
|
|
33
|
+
gem.add_dependency "cable_ready", ">= 4.3.0"
|
|
34
|
+
|
|
35
|
+
gem.add_development_dependency "bundler", "~> 2.0"
|
|
36
|
+
gem.add_development_dependency "pry-nav"
|
|
37
|
+
gem.add_development_dependency "pry"
|
|
38
|
+
gem.add_development_dependency "rake"
|
|
39
|
+
gem.add_development_dependency "standardrb"
|
|
40
|
+
end
|
data/tags
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
|
|
2
|
+
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
|
|
3
|
+
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
|
|
4
|
+
!_TAG_PROGRAM_NAME Exuberant Ctags //
|
|
5
|
+
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
|
|
6
|
+
!_TAG_PROGRAM_VERSION 5.8 //
|
|
7
|
+
ApplicationReflex test/tmp/app/reflexes/application_reflex.rb /^class ApplicationReflex < StimulusReflex::Reflex$/;" c
|
|
8
|
+
Broadcaster lib/stimulus_reflex/broadcasters/broadcaster.rb /^ class Broadcaster$/;" c class:StimulusReflex
|
|
9
|
+
CompareXML lib/stimulus_reflex/compare_xml.rb /^module CompareXML$/;" m
|
|
10
|
+
Engine lib/stimulus_reflex.rb /^ class Engine < Rails::Engine$/;" c class:StimulusReflex
|
|
11
|
+
NothingBroadcaster lib/stimulus_reflex/broadcasters/nothing_broadcaster.rb /^ class NothingBroadcaster < Broadcaster$/;" c class:StimulusReflex
|
|
12
|
+
PageBroadcaster lib/stimulus_reflex/broadcasters/page_broadcaster.rb /^ class PageBroadcaster < Broadcaster$/;" c class:StimulusReflex
|
|
13
|
+
SelectorBroadcaster lib/stimulus_reflex/broadcasters/selector_broadcaster.rb /^ class SelectorBroadcaster < Broadcaster$/;" c class:StimulusReflex
|
|
14
|
+
StimulusReflex lib/stimulus_reflex.rb /^module StimulusReflex$/;" m
|
|
15
|
+
StimulusReflex lib/stimulus_reflex/broadcasters/broadcaster.rb /^module StimulusReflex$/;" m
|
|
16
|
+
StimulusReflex lib/stimulus_reflex/broadcasters/nothing_broadcaster.rb /^module StimulusReflex$/;" m
|
|
17
|
+
StimulusReflex lib/stimulus_reflex/broadcasters/page_broadcaster.rb /^module StimulusReflex$/;" m
|
|
18
|
+
StimulusReflex lib/stimulus_reflex/broadcasters/selector_broadcaster.rb /^module StimulusReflex$/;" m
|
|
19
|
+
StimulusReflex lib/stimulus_reflex/channel.rb /^class StimulusReflex::Channel < ActionCable::Channel::Base$/;" c
|
|
20
|
+
StimulusReflex lib/stimulus_reflex/element.rb /^class StimulusReflex::Element < OpenStruct$/;" c
|
|
21
|
+
StimulusReflex lib/stimulus_reflex/reflex.rb /^class StimulusReflex::Reflex$/;" c
|
|
22
|
+
StimulusReflex lib/stimulus_reflex/version.rb /^module StimulusReflex$/;" m
|
|
23
|
+
StimulusReflexGenerator lib/generators/stimulus_reflex_generator.rb /^class StimulusReflexGenerator < Rails::Generators::NamedBase$/;" c
|
|
24
|
+
StimulusReflexGeneratorTest test/generators/stimulus_reflex_generator_test.rb /^class StimulusReflexGeneratorTest < Rails::Generators::TestCase$/;" c
|
|
25
|
+
UserReflex test/tmp/app/reflexes/user_reflex.rb /^class UserReflex < ApplicationReflex$/;" c
|
|
26
|
+
addDifference lib/stimulus_reflex/compare_xml.rb /^ def addDifference(node1, node2, diff1, diff2, opts, differences)$/;" f class:CompareXML
|
|
27
|
+
add_callback lib/stimulus_reflex/reflex.rb /^ def add_callback(kind, *args, &block)$/;" f class:StimulusReflex
|
|
28
|
+
after_reflex lib/stimulus_reflex/reflex.rb /^ def after_reflex(*args, &block)$/;" f class:StimulusReflex
|
|
29
|
+
around_reflex lib/stimulus_reflex/reflex.rb /^ def around_reflex(*args, &block)$/;" f class:StimulusReflex
|
|
30
|
+
attrContentExcluded? lib/stimulus_reflex/compare_xml.rb /^ def attrContentExcluded?(a1, a2, opts)$/;" f class:CompareXML
|
|
31
|
+
attrNameExcluded? lib/stimulus_reflex/compare_xml.rb /^ def attrNameExcluded?(a1, a2, opts)$/;" f class:CompareXML
|
|
32
|
+
attrsExcluded? lib/stimulus_reflex/compare_xml.rb /^ def attrsExcluded?(a1, a2, opts)$/;" f class:CompareXML
|
|
33
|
+
before_reflex lib/stimulus_reflex/reflex.rb /^ def before_reflex(*args, &block)$/;" f class:StimulusReflex
|
|
34
|
+
broadcast lib/stimulus_reflex/broadcasters/broadcaster.rb /^ def broadcast(*args)$/;" f class:StimulusReflex.Broadcaster
|
|
35
|
+
broadcast lib/stimulus_reflex/broadcasters/nothing_broadcaster.rb /^ def broadcast(_, data)$/;" f class:StimulusReflex.NothingBroadcaster
|
|
36
|
+
broadcast lib/stimulus_reflex/broadcasters/page_broadcaster.rb /^ def broadcast(selectors, data)$/;" f class:StimulusReflex.PageBroadcaster
|
|
37
|
+
broadcast lib/stimulus_reflex/broadcasters/selector_broadcaster.rb /^ def broadcast(_, data = {})$/;" f class:StimulusReflex.SelectorBroadcaster
|
|
38
|
+
broadcast_message lib/stimulus_reflex/broadcasters/broadcaster.rb /^ def broadcast_message(subject:, body: nil, data: {})$/;" f class:StimulusReflex.Broadcaster
|
|
39
|
+
collapse lib/stimulus_reflex/compare_xml.rb /^ def collapse(text)$/;" f class:CompareXML
|
|
40
|
+
commit_session lib/stimulus_reflex/channel.rb /^ def commit_session(reflex)$/;" f class:StimulusReflex
|
|
41
|
+
compareAttributeSets lib/stimulus_reflex/compare_xml.rb /^ def compareAttributeSets(n1, n2, a1_set, a2_set, opts, differences)$/;" f class:CompareXML
|
|
42
|
+
compareAttributes lib/stimulus_reflex/compare_xml.rb /^ def compareAttributes(n1, n2, a1, a2, opts, differences, status = EQUIVALENT)$/;" f class:CompareXML
|
|
43
|
+
compareChildren lib/stimulus_reflex/compare_xml.rb /^ def compareChildren(n1_set, n2_set, opts, differences, diffchildren = false, status = EQUIVALENT)$/;" f class:CompareXML
|
|
44
|
+
compareCommentNodes lib/stimulus_reflex/compare_xml.rb /^ def compareCommentNodes(n1, n2, opts, differences, status = EQUIVALENT)$/;" f class:CompareXML
|
|
45
|
+
compareDocumentNodes lib/stimulus_reflex/compare_xml.rb /^ def compareDocumentNodes(n1, n2, opts, differences, childopts = {}, diffchildren = false, status = EQUIVALENT)$/;" f class:CompareXML
|
|
46
|
+
compareElementNodes lib/stimulus_reflex/compare_xml.rb /^ def compareElementNodes(n1, n2, opts, differences, childopts = {}, diffchildren = false, status = EQUIVALENT)$/;" f class:CompareXML
|
|
47
|
+
compareNodes lib/stimulus_reflex/compare_xml.rb /^ def compareNodes(n1, n2, opts, differences, childopts = {}, diffchildren = false, status = EQUIVALENT)$/;" f class:CompareXML
|
|
48
|
+
compareSortedAttributeSets lib/stimulus_reflex/compare_xml.rb /^ def compareSortedAttributeSets(n1, n2, a1_set, a2_set, opts, differences, status = EQUIVALENT)$/;" f class:CompareXML
|
|
49
|
+
compareTextNodes lib/stimulus_reflex/compare_xml.rb /^ def compareTextNodes(n1, n2, opts, differences, status = EQUIVALENT)$/;" f class:CompareXML
|
|
50
|
+
compareUnsortedAttributeSets lib/stimulus_reflex/compare_xml.rb /^ def compareUnsortedAttributeSets(n1, n2, a1_set, a2_set, opts, differences, status = EQUIVALENT)$/;" f class:CompareXML
|
|
51
|
+
controller lib/stimulus_reflex/reflex.rb /^ def controller$/;" f
|
|
52
|
+
copy_application_files lib/generators/stimulus_reflex_generator.rb /^ def copy_application_files$/;" f class:StimulusReflexGenerator
|
|
53
|
+
dataset lib/stimulus_reflex/element.rb /^ def dataset$/;" f class:StimulusReflex
|
|
54
|
+
default_reflex lib/stimulus_reflex/reflex.rb /^ def default_reflex$/;" f
|
|
55
|
+
delegate_call_to_reflex lib/stimulus_reflex/channel.rb /^ def delegate_call_to_reflex(reflex, method_name, arguments = [])$/;" f class:StimulusReflex
|
|
56
|
+
do_more_stuff test/tmp/app/reflexes/user_reflex.rb /^ def do_more_stuff$/;" f class:UserReflex
|
|
57
|
+
do_stuff test/tmp/app/reflexes/user_reflex.rb /^ def do_stuff$/;" f class:UserReflex
|
|
58
|
+
enqueue_message lib/stimulus_reflex/broadcasters/broadcaster.rb /^ def enqueue_message(subject:, body: nil, data: {})$/;" f class:StimulusReflex.Broadcaster
|
|
59
|
+
equivalent? lib/stimulus_reflex/compare_xml.rb /^ def equivalent?(n1, n2, opts = {}, childopts = {}, diffchildren = false)$/;" f class:CompareXML
|
|
60
|
+
error javascript/log.js /^function error (response) {$/;" f
|
|
61
|
+
exception_message_with_backtrace lib/stimulus_reflex/channel.rb /^ def exception_message_with_backtrace(exception)$/;" f class:StimulusReflex
|
|
62
|
+
execute lib/generators/stimulus_reflex_generator.rb /^ def execute$/;" f class:StimulusReflexGenerator
|
|
63
|
+
export.reflexAttribute javascript/schema.js /^ reflexAttribute: 'data-reflex',$/;" p
|
|
64
|
+
export.reflexDatasetAttribute javascript/schema.js /^ reflexDatasetAttribute: 'data-reflex-dataset'$/;" p
|
|
65
|
+
export.reflexPermanentAttribute javascript/schema.js /^ reflexPermanentAttribute: 'data-reflex-permanent',$/;" p
|
|
66
|
+
export.reflexRootAttribute javascript/schema.js /^ reflexRootAttribute: 'data-reflex-root',$/;" p
|
|
67
|
+
findConsumer javascript/consumer.js /^function findConsumer (object, depth = 0) {$/;" f
|
|
68
|
+
function.success javascript/log.js /^function success (response, options = { halted: false }) {$/;" f
|
|
69
|
+
halted? lib/stimulus_reflex/reflex.rb /^ def halted?$/;" f
|
|
70
|
+
initialize lib/stimulus_reflex/broadcasters/broadcaster.rb /^ def initialize(reflex)$/;" f class:StimulusReflex.Broadcaster
|
|
71
|
+
initialize lib/stimulus_reflex/element.rb /^ def initialize(data = {})$/;" f class:StimulusReflex
|
|
72
|
+
initialize lib/stimulus_reflex/reflex.rb /^ def initialize(channel, url: nil, element: nil, selectors: [], method_name: nil, permanent_attribute_name: nil, params: {})$/;" f
|
|
73
|
+
is_reflex? lib/stimulus_reflex/channel.rb /^ def is_reflex?(reflex_class)$/;" f class:StimulusReflex
|
|
74
|
+
morph lib/stimulus_reflex/reflex.rb /^ def morph(selectors, html = "")$/;" f
|
|
75
|
+
morphs lib/stimulus_reflex/broadcasters/selector_broadcaster.rb /^ def morphs$/;" f class:StimulusReflex.SelectorBroadcaster
|
|
76
|
+
nodeExcluded? lib/stimulus_reflex/compare_xml.rb /^ def nodeExcluded?(n, opts)$/;" f class:CompareXML
|
|
77
|
+
normalize_callback_option! lib/stimulus_reflex/reflex.rb /^ def normalize_callback_option!(options, from, to)$/;" f class:StimulusReflex
|
|
78
|
+
normalize_callback_options! lib/stimulus_reflex/reflex.rb /^ def normalize_callback_options!(options)$/;" f class:StimulusReflex
|
|
79
|
+
nothing? lib/stimulus_reflex/broadcasters/broadcaster.rb /^ def nothing?$/;" f class:StimulusReflex.Broadcaster
|
|
80
|
+
nothing? lib/stimulus_reflex/broadcasters/nothing_broadcaster.rb /^ def nothing?$/;" f class:StimulusReflex.NothingBroadcaster
|
|
81
|
+
object_with_indifferent_access lib/stimulus_reflex/channel.rb /^ def object_with_indifferent_access(object)$/;" f class:StimulusReflex
|
|
82
|
+
page? lib/stimulus_reflex/broadcasters/broadcaster.rb /^ def page?$/;" f class:StimulusReflex.Broadcaster
|
|
83
|
+
page? lib/stimulus_reflex/broadcasters/page_broadcaster.rb /^ def page?$/;" f class:StimulusReflex.PageBroadcaster
|
|
84
|
+
page_cache lib/stimulus_reflex/channel.rb /^ def page_cache$/;" f class:StimulusReflex
|
|
85
|
+
params lib/stimulus_reflex/reflex.rb /^ def params$/;" f
|
|
86
|
+
process lib/stimulus_reflex/reflex.rb /^ def process(name, *args)$/;" f
|
|
87
|
+
receive lib/stimulus_reflex/channel.rb /^ def receive(data)$/;" f class:StimulusReflex
|
|
88
|
+
request lib/stimulus_reflex/reflex.rb /^ def request$/;" f
|
|
89
|
+
selector? lib/stimulus_reflex/broadcasters/broadcaster.rb /^ def selector?$/;" f class:StimulusReflex.Broadcaster
|
|
90
|
+
selector? lib/stimulus_reflex/broadcasters/selector_broadcaster.rb /^ def selector?$/;" f class:StimulusReflex.SelectorBroadcaster
|
|
91
|
+
stream_name lib/stimulus_reflex/channel.rb /^ def stream_name$/;" f class:StimulusReflex
|
|
92
|
+
subscribed lib/stimulus_reflex/channel.rb /^ def subscribed$/;" f class:StimulusReflex
|
|
93
|
+
to_sym lib/stimulus_reflex/broadcasters/broadcaster.rb /^ def to_sym$/;" f class:StimulusReflex.Broadcaster
|
|
94
|
+
to_sym lib/stimulus_reflex/broadcasters/nothing_broadcaster.rb /^ def to_sym$/;" f class:StimulusReflex.NothingBroadcaster
|
|
95
|
+
to_sym lib/stimulus_reflex/broadcasters/page_broadcaster.rb /^ def to_sym$/;" f class:StimulusReflex.PageBroadcaster
|
|
96
|
+
to_sym lib/stimulus_reflex/broadcasters/selector_broadcaster.rb /^ def to_sym$/;" f class:StimulusReflex.SelectorBroadcaster
|
|
97
|
+
update test/tmp/app/reflexes/user_reflex.rb /^ def update$/;" f class:UserReflex
|
|
98
|
+
url_params lib/stimulus_reflex/reflex.rb /^ def url_params$/;" f
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require_relative "../test_helper"
|
|
2
|
+
|
|
3
|
+
class StimulusReflex::BroadcasterTest < ActiveSupport::TestCase
|
|
4
|
+
setup do
|
|
5
|
+
@reflex = Minitest::Mock.new
|
|
6
|
+
@reflex.expect :stream_name, "TestStream"
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
test "raises a NotImplementedError if called directly" do
|
|
10
|
+
broadcaster = StimulusReflex::Broadcaster.new(@reflex)
|
|
11
|
+
|
|
12
|
+
assert_raises(NotImplementedError) { broadcaster.broadcast }
|
|
13
|
+
assert_raises(NotImplementedError) { broadcaster.broadcast_message(subject: "Test") }
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require_relative "../test_helper"
|
|
2
|
+
|
|
3
|
+
class StimulusReflex::NothingBroadcasterTest < ActiveSupport::TestCase
|
|
4
|
+
setup do
|
|
5
|
+
@reflex = Minitest::Mock.new
|
|
6
|
+
@reflex.expect :stream_name, "TestStream"
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
test "broadcasts a server message when called" do
|
|
10
|
+
broadcaster = StimulusReflex::NothingBroadcaster.new(@reflex)
|
|
11
|
+
|
|
12
|
+
cable_ready_channels = Minitest::Mock.new
|
|
13
|
+
cable_ready_channel = Minitest::Mock.new
|
|
14
|
+
CableReady::Channels.stub :instance, cable_ready_channels do
|
|
15
|
+
cable_ready_channel.expect(:dispatch_event, nil, [{name: "stimulus-reflex:server-message",
|
|
16
|
+
detail: {
|
|
17
|
+
reflexId: nil,
|
|
18
|
+
stimulus_reflex: {
|
|
19
|
+
some: :data,
|
|
20
|
+
morph: :nothing,
|
|
21
|
+
server_message: {
|
|
22
|
+
subject: "nothing", body: nil
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}}])
|
|
26
|
+
cable_ready_channels.expect(:[], cable_ready_channel, ["TestStream"])
|
|
27
|
+
cable_ready_channels.expect(:broadcast, nil)
|
|
28
|
+
broadcaster.broadcast(nil, {some: :data})
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
assert_mock cable_ready_channels
|
|
32
|
+
assert_mock cable_ready_channel
|
|
33
|
+
end
|
|
34
|
+
end
|