styxie 0.0.9 → 0.0.10

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
- SHA1:
3
- metadata.gz: 4626d9c6f6040d05ecbbbcf5d8d3e80121af6f36
4
- data.tar.gz: cae3f9d0f9021c893c98e6a34d1ef015edaf2af4
2
+ SHA256:
3
+ metadata.gz: 4b616eaeefe26c945f00184013497b9509b8d5a44fa005c96a864082e539f4e8
4
+ data.tar.gz: 5411d96339732638382fc3a85069095639e79a49cfcf96a3b7530cb9475ffb22
5
5
  SHA512:
6
- metadata.gz: 74599580e1b30690cacc6540c8b6fd23417068c8d56e311c696a23c0968d625fe896fb2f4b18fe7088ce54731e1e24faffc1165926d4ad821e2175fd25b1f235
7
- data.tar.gz: efa637de588df0ddc1ec2b4555650642e0cd5c993e231531633916113ed7ed957845ad3370e77ed14519035e3f12e1f75d99a33ef02d364b507d74f54519ab9f
6
+ metadata.gz: 7dbf5f07878174f40a531bc5a01452e14bcda6d80c264a29f273b5b54c6eec5ff92e59e260dd816c2fe76bd743a99552af1ab65adadd8b74569401f9b7b7c48a
7
+ data.tar.gz: d91b0ac3c2df2f6824dcd144d2b12240cbcfd7a43e0ebeab34dc0096e02dfc4a8605135870b3aa7f15de6cddd97ef6442557675e08a38ad129452c73e37c3650
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ source 'http://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  group :development, :test do
7
- gem 'combustion', '~> 0.3.1'
7
+ gem 'combustion'
8
8
  gem 'capybara'
9
9
  gem 'rspec-rails'
10
10
  gem 'rubocop'
@@ -1,8 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
  module Styxie
3
3
  module Initializer
4
- def styxie_initialize_with(data, cfg: styxie_configuration)
5
- cfg.merge! data
4
+ def styxie_initialize_with(data)
5
+ raise 'must be a hash' unless data.is_a?(Hash)
6
+
7
+ data = data.with_indifferent_access
8
+
9
+ # This code looks a bit weird but it is for backward compatibility with old approach when we
10
+ # pass cfg: as a keyword argument. I removed the keyword argument because of it does not work
11
+ # good with ruby 3.
12
+ if data[:cfg].is_a?(Hash)
13
+ cfg = data.delete(:cfg)
14
+ styxie_configuration.merge!(cfg)
15
+ end
16
+
17
+ styxie_configuration.merge! data
6
18
  end
7
19
 
8
20
  def styxie_initialize(klass: styxie_class, method: action_name, data: styxie_configuration, camel_case: false)
@@ -14,13 +26,18 @@ module Styxie
14
26
  if (typeof Styxie === 'undefined' || Styxie === null) {
15
27
  Styxie = {}
16
28
  }
29
+
30
+ const klass = '#{klass}'
31
+ const method = '#{method}'
32
+ const json = #{json}
33
+
17
34
  if (Styxie.applyInitializer) {
18
- Styxie.applyInitializer('#{klass}', '#{method}', #{json});
35
+ Styxie.applyInitializer(klass, method, json);
19
36
  } else {
20
37
  if (Styxie.initQueue == null) {
21
38
  Styxie.initQueue = []
22
39
  }
23
- Styxie.initQueue.push(['#{klass}', '#{method}', #{json}]);
40
+ Styxie.initQueue.push([klass, method, json]);
24
41
  }
25
42
  }
26
43
  //]]>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Styxie
4
- VERSION = '0.0.9'.freeze
4
+ VERSION = '0.0.10'.freeze
5
5
  end
@@ -6,6 +6,10 @@ describe TestsController, type: :controller do
6
6
 
7
7
  it 'index' do
8
8
  get :index
9
- response.body.should have_content("Styxie.applyInitializer('Tests', 'index', {\"data\":\"test\"})")
9
+
10
+ expect(response.body).to have_content("const klass = 'Tests'")
11
+ expect(response.body).to have_content("const method = 'index'")
12
+ expect(response.body).to have_content('const json = {"data":"test"}')
13
+ expect(response.body).to have_content('Styxie.applyInitializer(klass, method, json)')
10
14
  end
11
15
  end
@@ -12,8 +12,8 @@ describe Styxie::Helpers do
12
12
  end
13
13
 
14
14
  it '#this_page?' do
15
- controller.stub(controller_name: 'tests')
16
- controller.stub(action_name: 'index')
15
+ allow(controller).to receive(:controller_name).and_return('tests')
16
+ allow(controller).to receive(:action_name).and_return('index')
17
17
 
18
18
  cases = [
19
19
  [
@@ -39,7 +39,7 @@ describe Styxie::Helpers do
39
39
  end
40
40
 
41
41
  it '#this_namespace?' do
42
- controller.stub(controller_path: 'module/tests')
42
+ allow(controller).to receive(:controller_path).and_return('module/tests')
43
43
 
44
44
  cases = [
45
45
  [
@@ -14,14 +14,16 @@ describe Styxie::Initializer do
14
14
  it '#styxie_initialize_with' do
15
15
  expect(controller.styxie_configuration).to eq({})
16
16
  controller.styxie_initialize_with(test: 'data')
17
- expect(controller.styxie_configuration).to eq({ test: 'data' })
17
+ expect(controller.styxie_configuration).to eq({ 'test' => 'data' })
18
18
  end
19
19
 
20
20
  it '#styxie_initialize' do
21
- controller.stub(controller_path: 'module/tests')
22
- controller.stub(action_name: 'index')
21
+ allow(controller).to receive(:controller_path).and_return('module/tests')
22
+ allow(controller).to receive(:action_name).and_return('index')
23
23
  result = controller.styxie_initialize
24
- expect(result).to include "Styxie.applyInitializer('ModuleTests', 'index', {});"
24
+ expect(result).to include "const klass = 'ModuleTests'"
25
+ expect(result).to include "const method = 'index'"
26
+ expect(result).to include "const json = {}"
25
27
  expect(result.html_safe?).to be_truthy
26
28
  end
27
29
 
data/spec/spec_helper.rb CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
3
3
  require 'bundler'
4
4
  Bundler.require :development
5
5
  require 'capybara/rspec'
6
- Combustion.initialize! :action_controller, :action_view, :sprockets
6
+ Combustion.initialize! :action_controller, :action_view
7
7
  Bundler.require :default
8
8
  require 'rspec/rails'
9
9
  require 'capybara/rails'
data/styxie.gemspec CHANGED
@@ -14,7 +14,6 @@ Gem::Specification.new do |s|
14
14
  s.description = s.summary
15
15
  s.authors = ['Yury Kotov', 'Httplab']
16
16
 
17
- s.has_rdoc = false # disable rdoc generation until we've got more
18
17
  s.files = `git ls-files`.split("\n")
19
18
  s.require_paths = ['lib']
20
19
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: styxie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yury Kotov
8
8
  - Httplab
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-06-24 00:00:00.000000000 Z
12
+ date: 2024-03-11 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
@@ -47,7 +47,7 @@ files:
47
47
  homepage: http://github.com/httplab/styxie
48
48
  licenses: []
49
49
  metadata: {}
50
- post_install_message:
50
+ post_install_message:
51
51
  rdoc_options: []
52
52
  require_paths:
53
53
  - lib
@@ -62,9 +62,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
62
  - !ruby/object:Gem::Version
63
63
  version: '0'
64
64
  requirements: []
65
- rubyforge_project:
66
- rubygems_version: 2.6.10
67
- signing_key:
65
+ rubygems_version: 3.4.10
66
+ signing_key:
68
67
  specification_version: 4
69
68
  summary: Set of helpers to maintain bridge between Server side and Client (JS) side
70
69
  test_files: []