cells-slim 0.0.6 → 0.1.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
  SHA256:
3
- metadata.gz: f0b5b27149489ac1f463ca7aafd322561c88edaca5dcf89c1449cc560c1d9c3e
4
- data.tar.gz: 9ef5b16f43aade60de28631ec83b085fa8c834266d52c29ed51261aca4c8acb0
3
+ metadata.gz: 52e735835b5f077cbf10973bc7fc0fe799dce188dc0cb8cfd8c9d11c8a4c2745
4
+ data.tar.gz: 775acbf19e08c7a559bcdb18be0550ff59d6f63f12e6e7de5d5e5902d5964242
5
5
  SHA512:
6
- metadata.gz: 6faa7c49ae0948e26b1cbbe4add6d53ebb12a6d35c75e8dd8c39af967d0d33780510730659c9b0dba096fd6e460bb6f685c32345026820b6408a6ee9bb5ed044
7
- data.tar.gz: 40112c9d040e15a4144f676af28f204f5c831979381c1690730b90a87b0b6037be763216b758570ac2f0df2d4d308bbfa83ef236820f9a55fc47e4d73d8d0d4e
6
+ metadata.gz: 628e6589d7854a1dbb7f2d0d612cff8a47dc1579c7b77a0d0a9f7688bfc1ae34573147df58b32245d197857075a28fa81b756e731bd0b65b994e915c0523573d
7
+ data.tar.gz: 5177e37e484a3e9758a23b4986f621d3a349f8fed4dd1dec285de21aecadd8ac4c586b59cf02504b58b8849f2917056c864c4e871f7c51751c614504f2d17bfd
data/.gitignore CHANGED
@@ -13,3 +13,4 @@
13
13
  *.o
14
14
  *.a
15
15
  mkmf.log
16
+ *.gem
@@ -1,13 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.4.1
4
- - 2.3.3
3
+ - 2.5.1
4
+ - 2.4.4
5
+ - 2.3.7
5
6
  - 2.2
6
- - 2.1
7
7
 
8
8
  sudo: false
9
9
 
10
- bundler_args: '--without local_development --jobs 3 --retry 3'
11
-
12
10
  script: bundle exec rake
13
11
 
data/CHANGES.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 0.1.1
2
+
3
+ * Support `slim` 4.0 and up, too.
4
+
5
+ # 0.1.0
6
+ * Drop all rails hacks , add 'cells-rails' for all the rails witchcraft.
7
+ * Introduce ViewModelSlim
8
+
1
9
  # 0.0.6
2
10
 
3
11
  * Rails 5.1 compatibility
data/Gemfile CHANGED
@@ -1,11 +1,9 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in cells-slim.gemspec
1
+ source "https://rubygems.org"
4
2
  gemspec
5
3
 
6
-
7
- gem "railties", "~> 4.2.0"
8
- gem "activemodel"
9
- gem "minitest", "~> 5.2"
10
-
11
- # gem 'cells', path: "../cells"
4
+ case ENV["GEMS_SOURCE"]
5
+ when "local"
6
+ gem "cells", path: "../cells"
7
+ when "github"
8
+ gem "cells", github: "trailblazer/cells"
9
+ end
data/README.md CHANGED
@@ -12,11 +12,8 @@ gem 'cells-slim'
12
12
 
13
13
  ## Usage
14
14
 
15
- Outside of Rails, you need to include `Cell::Slim` in your cell.
16
-
17
15
  ```ruby
18
- class CommentCell < Cell::ViewModel
19
- include Cell::Slim
16
+ class CommentCell < Cell::ViewModelSlim
20
17
  ```
21
18
 
22
19
  ## Important
@@ -18,7 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_runtime_dependency "cells", ">= 4.0.1", "< 6.0.0"
21
- spec.add_runtime_dependency "slim", "~> 3.0"
21
+ spec.add_runtime_dependency "slim", ">= 3.0"
22
22
  spec.add_development_dependency "bundler"
23
23
  spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "minitest"
24
25
  end
@@ -10,7 +10,7 @@ module Cell
10
10
  @output_buffer = old_output_buffer
11
11
  end
12
12
 
13
- def template_options_for(options)
13
+ def template_options_for(_options)
14
14
  {
15
15
  template_class: ::Slim::Template,
16
16
  suffix: "slim",
@@ -20,10 +20,9 @@ module Cell
20
20
  buffer: "@output_buffer"
21
21
  }
22
22
  end
23
+ end
23
24
 
24
- if Object.const_defined?(:ActionView)
25
- require "cell/slim/rails"
26
- include Cell::Slim::Rails
27
- end
25
+ class ViewModelSlim < ViewModel
26
+ include Cell::Slim
28
27
  end
29
28
  end
@@ -1,5 +1,5 @@
1
1
  module Cell
2
2
  module Slim
3
- VERSION = "0.0.6"
3
+ VERSION = "0.1.1".freeze
4
4
  end
5
5
  end
@@ -1,2 +1 @@
1
- require "cells"
2
1
  require "cell/slim"
@@ -0,0 +1 @@
1
+ strong Yes!
@@ -0,0 +1,7 @@
1
+ class SongCell < Cell::ViewModelSlim
2
+ self.view_paths = ["test/cells"]
3
+
4
+ def render_in_render
5
+ render
6
+ end
7
+ end
@@ -1,67 +1,9 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  class SlimTest < MiniTest::Spec
4
- let (:controller) { ApplicationController.new.tap { |ctl| ctl.send("request=", ActionDispatch::Request.new({})) } }
5
- let (:song_cell) { SongCell.new(controller) }
4
+ let(:song_cell) { SongCell.new }
6
5
 
7
- # render in render
8
- it("bla") { song_cell.(:render_in_render).must_equal "<b>Questions: Yes!</b>" }
9
-
10
- # content_tag { }
11
- it { song_cell.(:with_content_tag).must_equal "<div>Beachparty</div>" }
12
-
13
- # content_tag { content_tag { } }
14
- it do song_cell.(:with_content_tag_and_content_tag).must_equal %{<span>Title:<div>Still Knee Deep</div></span>}
6
+ it("render nested cells") do
7
+ assert_equal "<b>Questions: <strong>Yes!</strong></b>", song_cell.(:render_in_render)
15
8
  end
16
-
17
- # form_tag { content_tag { } }
18
- it( "xxx") do
19
- form_tag = "<form action=\"/erubis/is/horribly/outdated\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" />"
20
- form_tag = "<form accept-charset=\"UTF-8\" action=\"/erubis/is/horribly/outdated\" method=\"post\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /></div>" if ActionPack::VERSION::MAJOR == 3
21
-
22
- input_tag = %{<input type="text" name="id" id="id" />}
23
- input_tag = "<input id=\"id\" name=\"id\" type=\"text\" />" if ActionPack::VERSION::MAJOR == 3
24
-
25
- form_with_body_tag = "<form url=\"/rails/escapes/too/much\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"button\"/></form>"
26
- form_with_body_tag = "<form method=\"post\" url=\"/rails/escapes/too/much\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /></div><input type=\"button\"/></form>" if ActionPack::VERSION::MAJOR == 3
27
-
28
- form_for_tag = "<form class=\"new_open\" id=\"new_open\" action=\"/\" accept-charset=\"UTF-8\" method=\"post\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input type=\"text\" name=\"open[id]\" id=\"open_id\" />"
29
- form_for_tag = "<form accept-charset=\"UTF-8\" action=\"/\" class=\"new_open\" id=\"new_open\" method=\"post\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /></div><input id=\"open_id\" name=\"open[id]\" size=\"30\" type=\"text\" />" if ActionPack::VERSION::MAJOR == 3
30
-
31
- song_cell.(:with_form_tag_and_content_tag).must_equal %{Word.
32
- #{form_tag}
33
- #{input_tag}
34
- <a href=\"/rails/sucks\">
35
- hallo
36
- <div class="row">Cool</div>
37
- </a>
38
- <ul data-x="{&quot;a&quot;:&quot;1&quot;}">Hallo
39
- </ul>
40
- </form>
41
- Weiter!
42
- Bonjour!
43
- <a href=\"/coffee\">Coffee?</a>
44
- <b>Yes please!</b>
45
- <script>oui!</script>
46
- <a href=\"/1\">1</a>+<a href=\"/2\">2</a>
47
- <b>No current page!<b>
48
- #{form_with_body_tag}
49
- #{form_for_tag}
50
- </form>
51
- <div><p>Concat!</p>Whoo</div>
52
- }.gsub("\n", "").gsub(" ", "")
53
- end
54
-
55
- it 'allows concatenation chains' do
56
- song_cell.capture do
57
- song_cell.concat('Lorem').concat('ipsum')
58
- end
59
- end
60
-
61
- describe "block capture" do
62
- it do
63
- song_cell.(:with_capture).must_equal %{Hallo<p>More</p>Hidden!}
64
- end
65
- end
66
-
67
9
  end
@@ -1,10 +1,3 @@
1
- require 'minitest/autorun'
2
-
3
- ENV['RAILS_ENV'] = 'test'
4
-
5
- require_relative 'dummy/config/environment'
6
- require "rails/test_help" # adds stuff like @routes, etc.
7
-
8
- require 'cell/slim'
9
-
10
- # Cell::ViewModel.send :include, Cell::Slim
1
+ require "minitest/autorun"
2
+ require "cells-slim"
3
+ require_relative "cells/song_cell"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cells-slim
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Abdelkader Boudih
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-04-11 00:00:00.000000000 Z
12
+ date: 2020-02-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cells
@@ -35,14 +35,14 @@ dependencies:
35
35
  name: slim
36
36
  requirement: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.0'
41
41
  type: :runtime
42
42
  prerelease: false
43
43
  version_requirements: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '3.0'
48
48
  - !ruby/object:Gem::Dependency
@@ -73,6 +73,20 @@ dependencies:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
+ - !ruby/object:Gem::Dependency
77
+ name: minitest
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
76
90
  description: Slim integration for Cells.
77
91
  email:
78
92
  - terminale@gmail.com
@@ -89,26 +103,12 @@ files:
89
103
  - README.md
90
104
  - Rakefile
91
105
  - cells-slim.gemspec
92
- - gemfiles/rails4.2.gemfile
93
106
  - lib/cell/slim.rb
94
- - lib/cell/slim/rails.rb
95
107
  - lib/cell/slim/version.rb
96
108
  - lib/cells-slim.rb
97
- - test/dummy/Rakefile
98
- - test/dummy/app/cells/song/render_in_render.slim
99
- - test/dummy/app/cells/song/render_in_render_2.slim
100
- - test/dummy/app/cells/song/with_capture.slim
101
- - test/dummy/app/cells/song/with_content_tag.slim
102
- - test/dummy/app/cells/song/with_content_tag_and_content_tag.slim
103
- - test/dummy/app/cells/song/with_form_tag_and_content_tag.slim
104
- - test/dummy/app/cells/song_cell.rb
105
- - test/dummy/app/controllers/application_controller.rb
106
- - test/dummy/config.ru
107
- - test/dummy/config/application.rb
108
- - test/dummy/config/boot.rb
109
- - test/dummy/config/environment.rb
110
- - test/dummy/config/routes.rb
111
- - test/dummy/script/rails
109
+ - test/cells/song/render_in_render.slim
110
+ - test/cells/song/render_in_render_2.slim
111
+ - test/cells/song_cell.rb
112
112
  - test/slim_test.rb
113
113
  - test/test_helper.rb
114
114
  homepage: https://github.com/trailblazer/cells-slim
@@ -136,20 +136,8 @@ signing_key:
136
136
  specification_version: 4
137
137
  summary: Slim integration for Cells.
138
138
  test_files:
139
- - test/dummy/Rakefile
140
- - test/dummy/app/cells/song/render_in_render.slim
141
- - test/dummy/app/cells/song/render_in_render_2.slim
142
- - test/dummy/app/cells/song/with_capture.slim
143
- - test/dummy/app/cells/song/with_content_tag.slim
144
- - test/dummy/app/cells/song/with_content_tag_and_content_tag.slim
145
- - test/dummy/app/cells/song/with_form_tag_and_content_tag.slim
146
- - test/dummy/app/cells/song_cell.rb
147
- - test/dummy/app/controllers/application_controller.rb
148
- - test/dummy/config.ru
149
- - test/dummy/config/application.rb
150
- - test/dummy/config/boot.rb
151
- - test/dummy/config/environment.rb
152
- - test/dummy/config/routes.rb
153
- - test/dummy/script/rails
139
+ - test/cells/song/render_in_render.slim
140
+ - test/cells/song/render_in_render_2.slim
141
+ - test/cells/song_cell.rb
154
142
  - test/slim_test.rb
155
143
  - test/test_helper.rb
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "railties", "~> 4.2.0"
4
- gem "minitest", "~> 5.2"
5
-
6
- gemspec path: "../"
@@ -1,54 +0,0 @@
1
- module Cell
2
- module Slim::Rails
3
- def self.included(includer)
4
- includer.send :include, ActionView::Helpers::FormHelper
5
- includer.send :include, ::Cell::Slim::Rails::Helpers
6
- end
7
-
8
- module Helpers # include after AV helpers to override.
9
- def with_output_buffer(block_buffer=ViewModel::OutputBuffer.new)
10
- @output_buffer, old_buffer = block_buffer, @output_buffer
11
- yield
12
- @output_buffer = old_buffer
13
-
14
- block_buffer
15
- end
16
-
17
- def capture(*args)
18
- value = nil
19
- buffer = with_output_buffer { value = yield(*args) }
20
-
21
- return buffer.to_s if buffer.size > 0
22
- value # this applies for "Beachparty" string-only statements.
23
- end
24
-
25
- # From FormTagHelper. why do they escape every possible string? why?
26
- def form_tag_in_block(html_options, &block)
27
- content = capture(&block)
28
- form_tag_with_body(html_options, content)
29
- end
30
-
31
- def form_tag_with_body(html_options, content)
32
- "#{form_tag_html(html_options)}" << content.to_s << "</form>"
33
- end
34
-
35
- def form_tag_html(html_options)
36
- extra_tags = extra_tags_for_form(html_options)
37
- "#{tag(:form, html_options, true) + extra_tags}"
38
- end
39
-
40
- def tag(name = nil, options = nil, open = false, escape = true)
41
- super(name, options, open, true)
42
- end
43
-
44
- def content_tag(name, content_or_options_with_block = nil, options = nil, escape = true, &block)
45
- super(name, content_or_options_with_block, options, false, &block)
46
- end
47
-
48
- def concat(string)
49
- @output_buffer << string
50
- self
51
- end
52
- end
53
- end
54
- end
@@ -1,7 +0,0 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require File.expand_path('../config/application', __FILE__)
5
- require 'rake'
6
-
7
- Dummy::Application.load_tasks
@@ -1,11 +0,0 @@
1
- | Hallo
2
-
3
- - bla = 1
4
-
5
- - hidden = capture do
6
- | Hidden!
7
-
8
- p
9
- | More
10
-
11
- = hidden
@@ -1 +0,0 @@
1
- = content_tag(:div) { "Beachparty" }
@@ -1,4 +0,0 @@
1
- = content_tag :span
2
- | Title:
3
- = content_tag :div
4
- | Still Knee Deep
@@ -1,39 +0,0 @@
1
- | Word.
2
-
3
- = form_tag "/erubis/is/horribly/outdated"
4
- = text_field_tag :id
5
- = link_to "/rails/sucks" do
6
- | hallo
7
- .row
8
- | Cool
9
-
10
-
11
- = content_tag(:ul, "data-x" => '{"a":"1"}')
12
- | Hallo
13
-
14
- - answer = "<script>oui!</script>"
15
-
16
- / test content rendering in capture.
17
- - content = capture do
18
- | Bonjour!
19
- = link_to "Coffee?", "/coffee"
20
- b Yes please!
21
- == answer
22
-
23
- | Weiter!
24
-
25
- == content
26
-
27
- - breadcrumbs = capture do
28
- - [link_to("1", "/1"), link_to("2", "/2")].join("+")
29
-
30
- = breadcrumbs
31
-
32
- = current_page
33
- = form_tag_with_body( {url: "/rails/escapes/too/much"}, %{<input type="button"/>})
34
-
35
-
36
- = form_for OpenStruct.new, url: "/", as: "open" do |f|
37
- = f.text_field :id
38
-
39
- = concatting
@@ -1,69 +0,0 @@
1
- class SongCell < Cell::ViewModel
2
- self.view_paths = ["test/dummy/app/cells"]
3
-
4
-
5
- include Cell::Slim
6
-
7
- def protect_against_forgery?
8
- false
9
- end
10
-
11
- def with_form_tag_and_content_tag
12
- render
13
- end
14
-
15
- def with_content_tag_and_content_tag
16
- render
17
- end
18
-
19
- def with_content_tag
20
- render
21
- end
22
-
23
- def with_block
24
- render
25
- end
26
-
27
- def with_capture
28
- render
29
- end
30
-
31
- def with_form_tag
32
- form_tag("/songs") + content_tag(:span) + "</form>"
33
- end
34
-
35
- def with_link_to
36
- render
37
- end
38
-
39
- def with_form_for_block
40
- render
41
- end
42
-
43
- def render_in_render
44
- render
45
- end
46
-
47
- def with_capture
48
- render
49
- end
50
-
51
- private
52
- def cap
53
- "yay, #{with_output_buffer { yield } }"
54
- end
55
-
56
- def current_page
57
- capture do # FIXME: this escapes!
58
- #[link_to("1", "/1"), link_to("2", "/2")].join("+") # this breaks, too!
59
- "<b>No current page!<b>".html_safe
60
- end
61
- end
62
-
63
- def concatting
64
- content_tag :div do
65
- concat content_tag :p, "Concat!"
66
- concat "Whoo"
67
- end
68
- end
69
- end
@@ -1,2 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- end
@@ -1,4 +0,0 @@
1
- # This file is used by Rack-based servers to start the application.
2
-
3
- require ::File.expand_path('../config/environment', __FILE__)
4
- run Dummy::Application
@@ -1,37 +0,0 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- require "action_controller/railtie"
4
- require "action_view/railtie"
5
-
6
- module Dummy
7
- class Application < Rails::Application
8
- config.encoding = "utf-8"
9
- config.i18n.enforce_available_locales = false
10
-
11
- # Configure sensitive parameters which will be filtered from the log file.
12
- config.filter_parameters += [:password]
13
-
14
- config.cache_store = :memory_store
15
- config.secret_token = SecureRandom.uuid
16
- config.secret_key_base = SecureRandom.uuid
17
-
18
- # enable asset pipeline as in development.
19
- config.assets.enabled = true
20
- config.assets.compile = true
21
- config.cache_classes = true
22
-
23
- # Show full error reports and disable caching
24
- config.consider_all_requests_local = true
25
- config.action_controller.perform_caching = false
26
-
27
- # Raise exceptions instead of rendering exception templates
28
- config.action_dispatch.show_exceptions = false
29
-
30
- # Disable request forgery protection in test environment
31
- config.action_controller.allow_forgery_protection = false
32
- config.active_support.deprecation = :stderr
33
-
34
- config.eager_load = false
35
- config.active_support.test_order = :random
36
- end
37
- end
@@ -1,5 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- Bundler.setup
4
-
5
- $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -1,5 +0,0 @@
1
- # Load the rails application
2
- require File.expand_path('../application', __FILE__)
3
-
4
- # Initialize the rails application
5
- Dummy::Application.initialize!
@@ -1,3 +0,0 @@
1
- Dummy::Application.routes.draw do
2
- resources :songs
3
- end
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
-
4
- APP_PATH = File.expand_path('../../config/application', __FILE__)
5
- require File.expand_path('../../config/boot', __FILE__)
6
- require 'rails/commands'