liquid-rails 0.1.4 → 0.2.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -8
  3. data/CHANGELOG.md +8 -0
  4. data/Gemfile +2 -1
  5. data/Rakefile +4 -3
  6. data/gemfiles/{rails_32.gemfile → rails_50.gemfile} +2 -2
  7. data/gemfiles/{rails_40.gemfile → rails_51.gemfile} +2 -1
  8. data/gemfiles/{rails_41.gemfile → rails_52.gemfile} +2 -1
  9. data/lib/liquid-rails.rb +1 -1
  10. data/lib/liquid-rails/file_system.rb +29 -4
  11. data/lib/liquid-rails/railtie.rb +1 -6
  12. data/lib/liquid-rails/rspec/drop_example_group.rb +2 -2
  13. data/lib/liquid-rails/rspec/filter_example_group.rb +2 -2
  14. data/lib/liquid-rails/rspec/tag_example_group.rb +2 -2
  15. data/lib/liquid-rails/rspec/view_controller_context.rb +4 -4
  16. data/lib/liquid-rails/tags/paginate_tag.rb +1 -1
  17. data/lib/liquid-rails/template_handler.rb +15 -5
  18. data/lib/liquid-rails/version.rb +1 -1
  19. data/liquid-rails.gemspec +3 -3
  20. data/spec/dummy/Rakefile +2 -2
  21. data/spec/dummy/app/assets/config/manifest.js +3 -0
  22. data/spec/dummy/app/controllers/home_controller.rb +8 -4
  23. data/spec/dummy/app/controllers/pages_controller.rb +2 -2
  24. data/spec/dummy/app/views/foospace/bar/{_partial.liquid → _partial.html.liquid} +0 -0
  25. data/spec/dummy/app/views/foospace/bar/{index_partial.liquid → index_partial.html.liquid} +0 -0
  26. data/spec/dummy/app/views/home/{_html_liquid_partial.liquid → _html_liquid_partial.html.liquid} +0 -0
  27. data/spec/dummy/app/views/home/{_partial.liquid → _partial.html.liquid} +0 -0
  28. data/spec/dummy/app/views/home/{erb_with_html_liquid_partial.erb → erb_with_html_liquid_partial.html.erb} +0 -0
  29. data/spec/dummy/app/views/home/{index.liquid → index.html.liquid} +0 -0
  30. data/spec/dummy/app/views/home/{index_partial.liquid → index_partial.html.liquid} +0 -0
  31. data/spec/dummy/app/views/home/{index_partial_with_full_path.liquid → index_partial_with_full_path.html.liquid} +0 -0
  32. data/spec/dummy/app/views/home/{index_with_filter.liquid → index_with_filter.html.liquid} +0 -0
  33. data/spec/dummy/app/views/home/{index_with_layout.liquid → index_with_layout.html.liquid} +0 -0
  34. data/spec/dummy/app/views/home/index_with_rss.rss.liquid +17 -0
  35. data/spec/dummy/app/views/layouts/{application.liquid → application.html.liquid} +0 -0
  36. data/spec/dummy/app/views/pages/{index_without_filter.liquid → index_without_filter.html.liquid} +0 -0
  37. data/spec/dummy/app/views/shared/{_partial.liquid → _partial.html.liquid} +0 -0
  38. data/spec/dummy/config.ru +2 -1
  39. data/spec/dummy/config/application.rb +11 -11
  40. data/spec/dummy/config/database.yml +25 -0
  41. data/spec/dummy/config/environment.rb +1 -1
  42. data/spec/dummy/config/environments/development.rb +34 -5
  43. data/spec/dummy/config/environments/production.rb +37 -26
  44. data/spec/dummy/config/environments/test.rb +6 -3
  45. data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
  46. data/spec/dummy/config/initializers/assets.rb +14 -0
  47. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  48. data/spec/dummy/config/initializers/mime_types.rb +0 -1
  49. data/spec/dummy/config/initializers/new_framework_defaults.rb +30 -0
  50. data/spec/dummy/config/initializers/session_store.rb +1 -1
  51. data/spec/dummy/config/initializers/wrap_parameters.rb +2 -2
  52. data/spec/dummy/config/puma.rb +56 -0
  53. data/spec/dummy/config/routes.rb +4 -2
  54. data/spec/dummy/config/secrets.yml +31 -0
  55. data/spec/dummy/config/spring.rb +6 -0
  56. data/spec/dummy/db/test.sqlite3 +0 -0
  57. data/spec/dummy/package.json +5 -0
  58. data/spec/dummy/public/404.html +20 -11
  59. data/spec/dummy/public/422.html +20 -11
  60. data/spec/dummy/public/500.html +19 -10
  61. data/spec/dummy/public/robots.txt +1 -0
  62. data/spec/dummy/vendor/theme/foospace/bar/_partial.html.liquid +1 -0
  63. data/spec/dummy/vendor/theme/home/_partial.html.liquid +1 -0
  64. data/spec/dummy/vendor/theme/shared/_partial.html.liquid +1 -0
  65. data/spec/lib/liquid-rails/filters/misc_filter_spec.rb +4 -4
  66. data/spec/lib/liquid-rails/filters/translate_filter_spec.rb +5 -5
  67. data/spec/lib/liquid-rails/tags/paginate_tag_spec.rb +5 -7
  68. data/spec/lib/liquid-rails/template_handler_spec.rb +81 -33
  69. metadata +68 -45
  70. data/gemfiles/rails_42.gemfile +0 -12
  71. data/spec/dummy/config/initializers/secret_token.rb +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d360aa7c06d1c93bf06023b0f4db6b53d572f80
4
- data.tar.gz: a9d624b08596805faaa776c47a5ad93aa037dc5a
3
+ metadata.gz: 474c1915c9a9570eddb80c6707bcd65ae5c19431
4
+ data.tar.gz: ca005f24e1e6f752122e307cf490c748b5805789
5
5
  SHA512:
6
- metadata.gz: 9f1630c3e34e20b06e99356aac8ff0f97098457a77e8498f85b0ed726ab6923cefe55d9343ca38131795d47e9933349089ae846aea7a8f54aae33d29b426ddfe
7
- data.tar.gz: c5b67fba26918a81ff95741978801fa3c451fd94b0cbd704f43dae0d2920a86d457fa13c909fe8c3de2530d9f41c1c31b13c7a1f6f21caa5c3778561c8bb5d2a
6
+ metadata.gz: 542d296d6222fb5a2220b04b136f6e5b5a3727cb9d46df4b476bb65b016ab4c698124c2ac19a558eb7929eab766fc99e2c0ad8ec4a6fd57eb554be89d86b7e71
7
+ data.tar.gz: 05913fa277a644982c94557caa6717a316bd78451a7601ccfefcc3e21e2ee22f14904ab6608ec7d7b577c5f54401551512a6b554147e14d3d6e4e926f2dd26ef
@@ -5,16 +5,11 @@ rvm:
5
5
  env:
6
6
  - CODECLIMATE_REPO_TOKEN=891d362268d07d6ff0f5534f92252b6195f6be8795054d3627643eb6314a8c9e
7
7
  gemfile:
8
- - gemfiles/rails_32.gemfile
9
- - gemfiles/rails_40.gemfile
10
- - gemfiles/rails_41.gemfile
11
- - gemfiles/rails_42.gemfile
8
+ - gemfiles/rails_50.gemfile
9
+ - gemfiles/rails_51.gemfile
10
+ - gemfiles/rails_52.gemfile
12
11
  notifications:
13
12
  email: false
14
- matrix:
15
- exclude:
16
- - rvm: 2.2.0
17
- gemfile: gemfiles/rails_32.gemfile
18
13
  addons:
19
14
  code_climate:
20
15
  repo_token: 891d362268d07d6ff0f5534f92252b6195f6be8795054d3627643eb6314a8c9e
@@ -1,5 +1,13 @@
1
1
  # Overview
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Resolved Issues
6
+
7
+ * Fix `Content-Type` issue
8
+ * Support from Liquid v4, Rails v5, and Kaminari v1 and up
9
+ * Use `ActionView::Resolver` as Liquid filesystem (lowang, streppa-ent)
10
+
3
11
  ## 0.1.4
4
12
 
5
13
  ### Resolved Issues
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in liquid-rails.gemspec
4
4
  gemspec
5
5
 
6
- gem 'rails', '~> 4.2.10'
6
+ gem 'rails', '~> 5.0.6'
7
7
  gem 'rake', '~> 12.3.0'
8
8
  gem 'rspec-rails', '~> 3.5.2'
9
9
  gem 'guard-rspec', '~> 4.7.3'
@@ -11,3 +11,4 @@ gem 'capybara', '~> 2.16.1'
11
11
  gem 'pry-rails', '~> 0.3.6'
12
12
  gem 'coveralls', '~> 0.8.21'
13
13
  gem 'simplecov', '~> 0.14.1'
14
+ gem 'sqlite3', '~> 1.3.13'
data/Rakefile CHANGED
@@ -9,7 +9,8 @@ end
9
9
  task default: 'spec:all'
10
10
 
11
11
  namespace :spec do
12
- %w(rails_42 rails_41 rails_40 rails_32).each do |gemfile|
12
+ rails_versions = %w(rails_50 rails_51 rails_52)
13
+ rails_versions.each do |gemfile|
13
14
  desc "Run Tests against #{gemfile}"
14
15
  task gemfile do
15
16
  sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle --quiet"
@@ -19,9 +20,9 @@ namespace :spec do
19
20
 
20
21
  desc "Run Tests against rails versions"
21
22
  task :all do
22
- %w(rails_42 rails_41 rails_40 rails_32).each do |gemfile|
23
+ rails_versions.each do |gemfile|
23
24
  sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle --quiet"
24
25
  sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle exec rake spec"
25
26
  end
26
27
  end
27
- end
28
+ end
@@ -1,13 +1,13 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'rails', '~> 3.2.21'
3
+ gem 'rails', '~> 5.0.6'
4
4
  gem 'rake', '~> 12.3.0'
5
5
  gem 'rspec-rails', '~> 3.5.2'
6
6
  gem 'guard-rspec', '~> 4.7.3'
7
7
  gem 'capybara', '~> 2.16.1'
8
- gem 'test-unit', '~> 3.0'
9
8
  gem 'pry-rails', '~> 0.3.6'
10
9
  gem 'coveralls', '~> 0.8.21'
11
10
  gem 'simplecov', '~> 0.14.1'
11
+ gem 'sqlite3', '~> 1.3.13'
12
12
 
13
13
  gemspec path: '../'
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'rails', '~> 4.0.13'
3
+ gem 'rails', '~> 5.1.4'
4
4
  gem 'rake', '~> 12.3.0'
5
5
  gem 'rspec-rails', '~> 3.5.2'
6
6
  gem 'guard-rspec', '~> 4.7.3'
@@ -8,5 +8,6 @@ gem 'capybara', '~> 2.16.1'
8
8
  gem 'pry-rails', '~> 0.3.6'
9
9
  gem 'coveralls', '~> 0.8.21'
10
10
  gem 'simplecov', '~> 0.14.1'
11
+ gem 'sqlite3', '~> 1.3.13'
11
12
 
12
13
  gemspec path: '../'
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'rails', '~> 4.1.9'
3
+ gem 'rails', '~> 5.2.0.beta2'
4
4
  gem 'rake', '~> 12.3.0'
5
5
  gem 'rspec-rails', '~> 3.5.2'
6
6
  gem 'guard-rspec', '~> 4.7.3'
@@ -8,5 +8,6 @@ gem 'capybara', '~> 2.16.1'
8
8
  gem 'pry-rails', '~> 0.3.6'
9
9
  gem 'coveralls', '~> 0.8.21'
10
10
  gem 'simplecov', '~> 0.14.1'
11
+ gem 'sqlite3', '~> 1.3.13'
11
12
 
12
13
  gemspec path: '../'
@@ -20,4 +20,4 @@ module Liquid
20
20
  end
21
21
 
22
22
  require 'liquid-rails/railtie' if defined?(Rails)
23
- Dir[File.dirname(__FILE__) + '/liquid-rails/{filters,tags,drops}/*.rb'].each { |f| require f }
23
+ Dir[File.dirname(__FILE__) + '/liquid-rails/{filters,tags,drops}/*.rb'].each { |f| require f }
@@ -2,11 +2,36 @@ require 'liquid/file_system'
2
2
 
3
3
  module Liquid
4
4
  module Rails
5
- class FileSystem < ::Liquid::LocalFileSystem
6
- def read_template_file(template_path, context)
7
- controller_path = context.registers[:controller].controller_path
5
+ class FileSystem
6
+ def initialize(view)
7
+ @view = view
8
+ end
9
+
10
+ def read_template_file(template_path)
11
+ controller_path = view.controller_path
8
12
  template_path = "#{controller_path}/#{template_path}" unless template_path.include?('/')
9
- super
13
+
14
+ name = template_path.split('/').last
15
+ prefix = template_path.split('/')[0...-1].join('/')
16
+
17
+ result = view.view_paths.find_all(name, prefix, true, lookup_details)
18
+ raise FileSystemError, "No such template '#{template_path}'" unless result.present?
19
+
20
+ result.first.source
21
+ end
22
+
23
+ private
24
+
25
+ attr_reader :view
26
+
27
+ def lookup_details
28
+ {
29
+ locale: [view.locale, :en],
30
+ formats: view.formats,
31
+ variants: [],
32
+ handlers: [:liquid],
33
+ versions: []
34
+ }
10
35
  end
11
36
  end
12
37
  end
@@ -9,11 +9,6 @@ module Liquid
9
9
  end
10
10
  end
11
11
 
12
- initializer 'liquid-rails.include_partial' do |app|
13
- template_path = ::Rails.root.join('app/views')
14
- Liquid::Template.file_system = Liquid::Rails::FileSystem.new(template_path)
15
- end
16
-
17
12
  initializer 'liquid-rails.setup_drop' do |app|
18
13
  [:active_record, :mongoid].each do |orm|
19
14
  ActiveSupport.on_load orm do
@@ -23,4 +18,4 @@ module Liquid
23
18
  end
24
19
  end
25
20
  end
26
- end
21
+ end
@@ -21,7 +21,7 @@ module Liquid
21
21
  end
22
22
  }
23
23
 
24
- before(:all) { setup_view_and_controller }
24
+ before(:each) { setup_view_and_controller }
25
25
  before(:each) { subject.context = context }
26
26
  end
27
27
  end
@@ -35,4 +35,4 @@ RSpec.configure do |config|
35
35
  else
36
36
  config.include Liquid::Rails::Rspec::DropExampleGroup, type: :drop, example_group: { file_path: %r{spec/drops} }
37
37
  end
38
- end
38
+ end
@@ -8,7 +8,7 @@ module Liquid
8
8
  included do
9
9
  metadata[:type] = :filter
10
10
 
11
- before(:all) { setup_view_and_controller }
11
+ before(:each) { setup_view_and_controller }
12
12
  end
13
13
  end
14
14
  end
@@ -21,4 +21,4 @@ RSpec.configure do |config|
21
21
  else
22
22
  config.include Liquid::Rails::Rspec::FilterExampleGroup, type: :filter, example_group: { file_path: %r{spec/filters} }
23
23
  end
24
- end
24
+ end
@@ -8,7 +8,7 @@ module Liquid
8
8
  included do
9
9
  metadata[:type] = :tag
10
10
 
11
- before(:all) { setup_view_and_controller }
11
+ before(:each) { setup_view_and_controller }
12
12
  end
13
13
  end
14
14
  end
@@ -21,4 +21,4 @@ RSpec.configure do |config|
21
21
  else
22
22
  config.include Liquid::Rails::Rspec::TagExampleGroup, type: :tag, example_group: { file_path: %r{spec/tags} }
23
23
  end
24
- end
24
+ end
@@ -6,9 +6,9 @@ module Liquid
6
6
 
7
7
  def setup_view_and_controller
8
8
  @view = ActionView::Base.new
9
- @controller = ApplicationController.new
10
- @request = ActionController::TestRequest.new('PATH_INFO' => '/')
11
- @response = ActionController::TestResponse.new
9
+ @controller = ActionController::Base.new
10
+ @request = ActionDispatch::TestRequest.new({'PATH_INFO' => '/'})
11
+ @response = ActionDispatch::TestResponse.new
12
12
  @response.request = @request
13
13
  @controller.request = @request
14
14
  @controller.response = @response
@@ -42,4 +42,4 @@ module Liquid
42
42
  end
43
43
  end
44
44
  end
45
- end
45
+ end
@@ -115,4 +115,4 @@ module Liquid
115
115
  end
116
116
  end
117
117
 
118
- Liquid::Template.register_tag('paginate', Liquid::Rails::PaginateTag)
118
+ Liquid::Template.register_tag('paginate', Liquid::Rails::PaginateTag)
@@ -13,8 +13,6 @@ module Liquid
13
13
  end
14
14
 
15
15
  def render(template, local_assigns={})
16
- @view.controller.headers['Content-Type'] ||= 'text/html; charset=utf-8'
17
-
18
16
  assigns = if @controller.respond_to?(:liquid_assigns, true)
19
17
  @controller.send(:liquid_assigns)
20
18
  else
@@ -23,9 +21,8 @@ module Liquid
23
21
  assigns['content_for_layout'] = @view.content_for(:layout) if @view.content_for?(:layout)
24
22
  assigns.merge!(local_assigns.stringify_keys)
25
23
 
26
- liquid = Liquid::Template.parse(template)
27
- render_method = (::Rails.env.development? || ::Rails.env.test?) ? :render! : :render
28
- liquid.send(render_method, assigns, filters: filters, registers: { view: @view, controller: @controller, helper: @helper }).html_safe
24
+ liquid = Liquid::Template.parse(template)
25
+ liquid.send(render_method, assigns, filters: filters, registers: registers).html_safe
29
26
  end
30
27
 
31
28
  def filters
@@ -36,9 +33,22 @@ module Liquid
36
33
  end
37
34
  end
38
35
 
36
+ def registers
37
+ {
38
+ view: @view,
39
+ controller: @controller,
40
+ helper: @helper,
41
+ file_system: Liquid::Rails::FileSystem.new(@view)
42
+ }
43
+ end
44
+
39
45
  def compilable?
40
46
  false
41
47
  end
48
+
49
+ def render_method
50
+ (::Rails.env.development? || ::Rails.env.test?) ? :render! : :render
51
+ end
42
52
  end
43
53
  end
44
54
  end
@@ -1,5 +1,5 @@
1
1
  module Liquid
2
2
  module Rails
3
- VERSION = '0.1.4'
3
+ VERSION = '0.2.0.beta1'
4
4
  end
5
5
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
21
  spec.require_paths = ['lib']
22
22
 
23
- spec.add_dependency 'rails', ">= 3.2", "< 5"
24
- spec.add_dependency 'liquid', '~> 3.0.6'
25
- spec.add_dependency 'kaminari', '~> 0.17.0'
23
+ spec.add_dependency 'rails', ">= 5.0.6"
24
+ spec.add_dependency 'liquid', '~> 4.0.0'
25
+ spec.add_dependency 'kaminari', '~> 1.1.1'
26
26
  end
@@ -1,6 +1,6 @@
1
1
  # Add your own tasks in files placed in lib/tasks ending in .rake,
2
2
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
3
 
4
- require File.expand_path('../config/application', __FILE__)
4
+ require_relative 'config/application'
5
5
 
6
- Dummy::Application.load_tasks
6
+ Rails.application.load_tasks
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
@@ -1,5 +1,5 @@
1
1
  class HomeController < ApplicationController
2
- before_filter :set_book
2
+ before_action :set_book
3
3
 
4
4
  def index
5
5
  render layout: false
@@ -20,9 +20,13 @@ class HomeController < ApplicationController
20
20
  def erb_with_html_liquid_partial
21
21
  end
22
22
 
23
+ def index_with_rss
24
+ render layout: false
25
+ end
26
+
23
27
  private
24
28
 
25
- def set_book
26
- @book = { 'name' => 'Liquid on Rails' }
27
- end
29
+ def set_book
30
+ @book = { 'name' => 'Liquid on Rails' }
31
+ end
28
32
  end
@@ -1,5 +1,5 @@
1
1
  class PagesController < ApplicationController
2
- before_filter :set_book
2
+ before_action :set_book
3
3
 
4
4
  def index_witout_filter
5
5
  end
@@ -13,4 +13,4 @@ class PagesController < ApplicationController
13
13
  def set_book
14
14
  @book = { 'name' => 'Liquid on Rails' }
15
15
  end
16
- end
16
+ end
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
3
+ <channel>
4
+ <title>The World's Best Blog | Another Epic Site</title>
5
+ <description>A great description.</description>
6
+ <language>en</language>
7
+
8
+ <item>
9
+ <title>{{ book.name }}</title>
10
+ <description>
11
+ <![CDATA[
12
+ A book.
13
+ ]]>
14
+ </description>
15
+ </item>
16
+ </channel>
17
+ </rss>
@@ -1,4 +1,5 @@
1
1
  # This file is used by Rack-based servers to start the application.
2
2
 
3
- require ::File.expand_path('../config/environment', __FILE__)
3
+ require_relative 'config/environment'
4
+
4
5
  run Rails.application
@@ -1,7 +1,7 @@
1
- require File.expand_path('../boot', __FILE__)
1
+ require_relative 'boot'
2
2
 
3
3
  # Pick the frameworks you want:
4
- require "action_controller/railtie"
4
+ require "rails/all"
5
5
  # require "rails/test_unit/railtie"
6
6
 
7
7
  Bundler.require(*Rails.groups)
@@ -9,17 +9,17 @@ require "liquid-rails"
9
9
 
10
10
  module Dummy
11
11
  class Application < Rails::Application
12
+ if Rails.version.start_with?('5.1')
13
+ # Initialize configuration defaults for originally generated Rails version.
14
+ config.load_defaults 5.1
15
+ elsif Rails.version.start_with?('5.2')
16
+ # Initialize configuration defaults for originally generated Rails version.
17
+ config.load_defaults 5.2
18
+ config.active_record.sqlite3.represent_boolean_as_integer = true
19
+ end
20
+
12
21
  # Settings in config/environments/* take precedence over those specified here.
13
22
  # Application configuration should go into files in config/initializers
14
23
  # -- all .rb files in that directory are automatically loaded.
15
-
16
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
17
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
18
- # config.time_zone = 'Central Time (US & Canada)'
19
-
20
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
21
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
22
- # config.i18n.default_locale = :de
23
24
  end
24
25
  end
25
-