cells-erb 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: aecccac2e02b519577101d4cc7d1a47ec5e3adbd
4
+ data.tar.gz: 0b07c8d7cdf54580331dc50b0c355fecb4e721f2
5
+ SHA512:
6
+ metadata.gz: 77f655994403ebfb181fd4ea7aa5d99612d04ebf36973d45954ed82ae2e0f41d212a565828974a93970671b283655663db37f828330481a096d998361c9031f0
7
+ data.tar.gz: 16590351dea6d55b5a994f27cf8af1ec91e6bcc06a9b5e1ee76329b2a8957e5e142495d12f59509993a691bd08b8bef00a7bace841cfa56849818a5801a4d566
@@ -0,0 +1,3 @@
1
+ /pkg/
2
+ *.bundle
3
+ *.lock
@@ -0,0 +1,23 @@
1
+ appraise 'rails-3.2' do
2
+ gem 'railties', github: 'rails/rails', branch: '3-2-stable'
3
+ gem 'tzinfo'
4
+ gem 'minitest', '4.7.5'
5
+ end
6
+
7
+ appraise "rails-4.0" do
8
+ gem 'railties', github: 'rails/rails', branch: '4-0-stable'
9
+ gem 'activemodel', github: 'rails/rails', branch: '4-0-stable'
10
+ gem 'minitest', '4.7.5'
11
+ end
12
+
13
+ appraise "rails-4.1" do
14
+ gem 'railties', github: 'rails/rails', branch: '4-1-stable'
15
+ gem 'activemodel', github: 'rails/rails', branch: '4-1-stable'
16
+ gem 'minitest', '~> 5.2'
17
+ end
18
+
19
+ appraise "rails-4.2" do
20
+ gem 'railties', github: 'rails/rails', branch: '4-2-stable'
21
+ gem 'activemodel', github: 'rails/rails', branch: '4-2-stable'
22
+ gem 'minitest', '~> 5.2'
23
+ end
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cells-erb.gemspec
4
+ gemspec
5
+ platforms :mri_20, :mri_21 do
6
+ gem 'pry-byebug'
7
+ end
8
+ gem 'cells', github: 'apotonick/cells'
9
+ gem 'appraisal'
10
+ gem 'minitest-reporters'
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014-2015 Abdelkader Boudih & Nick Sutterer
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # Cells::Erb
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'cells-erb'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install cells-erb
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/trailblazer/cells-erb/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
@@ -0,0 +1,10 @@
1
+ require 'rake/testtask'
2
+ require 'bundler/gem_tasks'
3
+
4
+ task default: :test
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << 'test'
8
+ t.pattern = 'test/*_test.rb'
9
+ t.verbose = true
10
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'cells-erb'
7
+ spec.version = '0.0.1'
8
+ spec.authors = ['Abdelkader Boudih','Nick Sutterer']
9
+ spec.email = %w(terminale@gmail.com apotonick@gmail.com)
10
+ spec.summary = 'Add block support to Erubis for cells 4'
11
+ spec.description = 'Add block support to Erubis for cells 4
12
+ '
13
+ spec.homepage = 'https://github.com/trailblazer/cells-erb'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.test_files = spec.files.grep(%r{^(test)/})
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_runtime_dependency 'cells', '~> 4.0.0.beta'
21
+ spec.add_runtime_dependency 'erubis', '~> 2.7.0'
22
+ spec.add_development_dependency 'bundler', '>= 1.7'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ end
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "cells", :github => "apotonick/cells"
6
+ gem "appraisal"
7
+ gem "minitest-reporters"
8
+ gem "railties", :github => "rails/rails", :branch => "3-2-stable"
9
+ gem "tzinfo"
10
+ gem "minitest", "4.7.5"
11
+
12
+ platforms :mri_20, :mri_21 do
13
+ gem "pry-byebug"
14
+ end
15
+
16
+ gemspec :path => "../"
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "cells", :github => "apotonick/cells"
6
+ gem "appraisal"
7
+ gem "minitest-reporters"
8
+ gem "railties", :github => "rails/rails", :branch => "4-0-stable"
9
+ gem "activemodel", :github => "rails/rails", :branch => "4-0-stable"
10
+ gem "minitest", "4.7.5"
11
+
12
+ platforms :mri_20, :mri_21 do
13
+ gem "pry-byebug"
14
+ end
15
+
16
+ gemspec :path => "../"
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "cells", :github => "apotonick/cells"
6
+ gem "appraisal"
7
+ gem "minitest-reporters"
8
+ gem "railties", :github => "rails/rails", :branch => "4-1-stable"
9
+ gem "activemodel", :github => "rails/rails", :branch => "4-1-stable"
10
+ gem "minitest", "~> 5.2"
11
+
12
+ platforms :mri_20, :mri_21 do
13
+ gem "pry-byebug"
14
+ end
15
+
16
+ gemspec :path => "../"
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "cells", :github => "apotonick/cells"
6
+ gem "appraisal"
7
+ gem "minitest-reporters"
8
+ gem "railties", :github => "rails/rails", :branch => "4-2-stable"
9
+ gem "activemodel", :github => "rails/rails", :branch => "4-2-stable"
10
+ gem "minitest", "~> 5.2"
11
+
12
+ platforms :mri_20, :mri_21 do
13
+ gem "pry-byebug"
14
+ end
15
+
16
+ gemspec :path => "../"
@@ -0,0 +1,72 @@
1
+ require 'cells'
2
+ require 'erubis/engine/eruby'
3
+ require 'tilt/erb'
4
+
5
+ # The original ERB implementation in Ruby doesn't support blocks like
6
+ # <%= form_for do %>
7
+ # which is fixed with this monkey-patch.
8
+ #
9
+ # TODO: don't monkey-patch, use this in cells/tilt, only!
10
+ module Erubis
11
+ module RubyGenerator
12
+ def init_generator(properties={})
13
+ super
14
+ @in_block = 0
15
+ @block_ignore = 0
16
+ end
17
+
18
+ def escaped_expr(code)
19
+ return "#{@escapefunc} #{code}"
20
+ end
21
+
22
+ def add_stmt(src, code)
23
+ if block_start? code
24
+ block_ignore
25
+ elsif block_end? code
26
+ src << @bufvar << ?;
27
+ block_end
28
+ end
29
+
30
+ src << "#{code};"
31
+ end
32
+
33
+ def add_expr_literal(src, code)
34
+ if block_start? code
35
+ src << "#@bufvar << #{code};"
36
+ block_start
37
+ src << "#@bufvar = '';"
38
+ else
39
+ src << "#{@bufvar} << (#{code}).to_s;"
40
+ end
41
+ end
42
+
43
+ private
44
+
45
+ def block_start? code
46
+ res = code =~ /\b(do|\{)(\s*\|[^|]*\|)?\s*\Z/
47
+ end
48
+
49
+ def block_start
50
+ @in_block += 1
51
+ @bufvar << '_tmp'
52
+ end
53
+
54
+ def block_ignore
55
+ @block_ignore += 1
56
+ end
57
+
58
+ def block_end? code
59
+ res = @in_block != 0 && code =~ /\bend\b|}/
60
+ if res && @block_ignore != 0
61
+ @block_ignore -= 1
62
+ return false
63
+ end
64
+ res
65
+ end
66
+
67
+ def block_end
68
+ @in_block -= 1
69
+ @bufvar.sub! /_tmp\Z/, ''
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,2 @@
1
+ # Autorequired by bundler
2
+ require 'cells/erb'
@@ -0,0 +1,7 @@
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
@@ -0,0 +1,6 @@
1
+ <%= content_tag :span do %>
2
+ Title:
3
+ <%= content_tag :div do %>
4
+ Still Knee Deep
5
+ <% end %>
6
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <%= form_for(OpenStruct.new, url: "/songs", as: :song) do |f| %>
2
+ <%= f.text_field :id %>
3
+ <% end %>
@@ -0,0 +1,34 @@
1
+ class SongCell < Cell::ViewModel
2
+ def edit
3
+ render
4
+ end
5
+
6
+ def with_content_tag
7
+ render
8
+ end
9
+
10
+ def with_block
11
+ render
12
+ end
13
+
14
+ def with_capture
15
+ render
16
+ end
17
+
18
+ def with_form_tag
19
+ form_tag("/songs") + content_tag(:span) + "</form>"
20
+ end
21
+
22
+ def with_link_to
23
+ render
24
+ end
25
+
26
+ def with_form_for_block
27
+ render
28
+ end
29
+
30
+ private
31
+ def cap
32
+ "yay, #{with_output_buffer { yield } }"
33
+ end
34
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ layout 'application'
4
+ end
@@ -0,0 +1,4 @@
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
@@ -0,0 +1,34 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require "active_model/railtie"
4
+ require "action_controller/railtie"
5
+ require "action_view/railtie"
6
+
7
+ module Dummy
8
+ class Application < Rails::Application
9
+ config.i18n.enforce_available_locales = false
10
+
11
+ config.cache_store = :memory_store
12
+ config.secret_token = SecureRandom.uuid
13
+ config.secret_key_base = SecureRandom.uuid
14
+
15
+ # enable asset pipeline as in development.
16
+ config.assets.enabled = true
17
+ config.assets.compile = true
18
+ config.cache_classes = true
19
+
20
+ # Show full error reports and disable caching
21
+ config.consider_all_requests_local = true
22
+ config.action_controller.perform_caching = false
23
+
24
+ # Raise exceptions instead of rendering exception templates
25
+ config.action_dispatch.show_exceptions = false
26
+
27
+ # Disable request forgery protection in test environment
28
+ config.action_controller.allow_forgery_protection = false
29
+ config.active_support.deprecation = :stderr
30
+
31
+ config.eager_load = false
32
+ config.active_support.test_order = :random
33
+ end
34
+ end
@@ -0,0 +1,5 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup
4
+
5
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,3 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: :memory:
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,3 @@
1
+ Dummy::Application.routes.draw do
2
+ resources :songs
3
+ end
@@ -0,0 +1,37 @@
1
+ require 'test_helper'
2
+
3
+
4
+ class ErbTest < MiniTest::Spec
5
+ let (:controller) { ApplicationController.new.tap { |ctl| ctl.send("request=", ActionDispatch::Request.new({})) } }
6
+ let (:cellule) { SongCell.new(controller) }
7
+
8
+
9
+ # URL helpers work in cell instance.
10
+ it { cellule.songs_path.must_equal "/songs" }
11
+
12
+ # content_tag with ERB.
13
+ it { cellule.with_content_tag.must_equal "<span>Title:\n<div>Still Knee Deep\n</div>\n</span>\n" }
14
+ #
15
+ # # form_tag with block in block work.
16
+ # it { cellule.edit.must_equal "<form><div><input/></div><label/><input/><ul><li/></ul></form>" }
17
+ #
18
+ # # form_tag, no block
19
+ # it { cellule.with_form_tag.must_equal "<form><div><input/></div><span/></form>" }
20
+ #
21
+ # # form_for with block in ERB.
22
+ # it { cellule.with_form_for_block.must_equal "<form><div><input/></div><input/></form>" }
23
+ #
24
+ # # when using yield, haml breaks it (but doesn't escape HTML)
25
+ # it { cellule.with_block.must_equal "Nice!\nyay, <b>yeah</b>\n" }
26
+ #
27
+ # # capture
28
+ # it { cellule.with_capture.must_equal "Nice!\n<b>Great!</b>\n" }
29
+ #
30
+ # # there's again escaping happening where it shouldn't be in link_to and rails <= 3.2.
31
+ # if Cell.rails_version >= Gem::Version.new('4.0')
32
+ # # link_to with block and img_tag
33
+ # it { cellule.with_link_to.must_equal "<a href=\"/songs\"><img alt=\"All\" src=\"/images/all.png\" />\n</a>\n" }
34
+ # end
35
+ end
36
+
37
+ # start with content_tag and block (or capture) and find out how sinatra handles that. goal is NOT to use those hacks in haml's action_view_extensions.
@@ -0,0 +1,12 @@
1
+ begin
2
+ require 'byebug'
3
+ rescue LoadError
4
+ end
5
+ require 'minitest/reporters'
6
+ Minitest::Reporters.use! [Minitest::Reporters::ProgressReporter.new]
7
+ require 'minitest/autorun'
8
+
9
+ ENV['RAILS_ENV'] = 'test'
10
+
11
+ require 'cell/erb'
12
+ require_relative 'dummy/config/environment'
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cells-erb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Abdelkader Boudih
8
+ - Nick Sutterer
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-02-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: cells
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 4.0.0.beta
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 4.0.0.beta
28
+ - !ruby/object:Gem::Dependency
29
+ name: erubis
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 2.7.0
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 2.7.0
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '1.7'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '1.7'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rake
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '10.0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '10.0'
70
+ description: |
71
+ Add block support to Erubis for cells 4
72
+ email:
73
+ - terminale@gmail.com
74
+ - apotonick@gmail.com
75
+ executables: []
76
+ extensions: []
77
+ extra_rdoc_files: []
78
+ files:
79
+ - ".gitignore"
80
+ - Appraisals
81
+ - Gemfile
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - cells-erb.gemspec
86
+ - gemfiles/rails_3.2.gemfile
87
+ - gemfiles/rails_4.0.gemfile
88
+ - gemfiles/rails_4.1.gemfile
89
+ - gemfiles/rails_4.2.gemfile
90
+ - lib/cell/erb.rb
91
+ - lib/cells/erb.rb
92
+ - test/dummy/Rakefile
93
+ - test/dummy/app/cells/song/with_content_tag.erb
94
+ - test/dummy/app/cells/song/with_form_for_block.erb
95
+ - test/dummy/app/cells/song_cell.rb
96
+ - test/dummy/app/controllers/application_controller.rb
97
+ - test/dummy/config.ru
98
+ - test/dummy/config/application.rb
99
+ - test/dummy/config/boot.rb
100
+ - test/dummy/config/database.yml
101
+ - test/dummy/config/environment.rb
102
+ - test/dummy/config/locales/en.yml
103
+ - test/dummy/config/routes.rb
104
+ - test/erb_test.rb
105
+ - test/test_helper.rb
106
+ homepage: https://github.com/trailblazer/cells-erb
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.4.5
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Add block support to Erubis for cells 4
130
+ test_files:
131
+ - test/dummy/Rakefile
132
+ - test/dummy/app/cells/song/with_content_tag.erb
133
+ - test/dummy/app/cells/song/with_form_for_block.erb
134
+ - test/dummy/app/cells/song_cell.rb
135
+ - test/dummy/app/controllers/application_controller.rb
136
+ - test/dummy/config.ru
137
+ - test/dummy/config/application.rb
138
+ - test/dummy/config/boot.rb
139
+ - test/dummy/config/database.yml
140
+ - test/dummy/config/environment.rb
141
+ - test/dummy/config/locales/en.yml
142
+ - test/dummy/config/routes.rb
143
+ - test/erb_test.rb
144
+ - test/test_helper.rb
145
+ has_rdoc: