Permalink
Browse files

remove support for Rails (only 1.x and 2.x were supported)

  • Loading branch information...
1 parent fa87bc1 commit 36848fb6d259732768f645de5ddfbedf6563c0b1 @smtlaissezfaire smtlaissezfaire committed Dec 18, 2013
Showing with 0 additions and 952 deletions.
  1. +0 −1 Gemfile
  2. +0 −2 Gemfile.lock
  3. +0 −29 garlic.rb
  4. +0 −6 init.rb
  5. +0 −2 lib/markaby.rb
  6. +0 −75 lib/markaby/rails.rb
  7. +0 −85 lib/markaby/rails/current.rb
  8. +0 −124 lib/markaby/rails/deprecated.rb
  9. +0 −91 lib/markaby/rails/rails_builder.rb
  10. +0 −29 spec/markaby/rails/spec_helper.rb
  11. +0 −11 spec/markaby/rails/views/layouts/layout.mab
  12. +0 −3 spec/markaby/rails/views/markaby/_a_partial.mab
  13. +0 −1 spec/markaby/rails/views/markaby/_form_for_with_body_in_erb.erb
  14. +0 −1 spec/markaby/rails/views/markaby/_partial_child_with_locals.mab
  15. +0 −1 spec/markaby/rails/views/markaby/access_to_helpers.mab
  16. +0 −7 spec/markaby/rails/views/markaby/broken.mab
  17. +0 −1 spec/markaby/rails/views/markaby/commented_out_template.mab
  18. +0 −5 spec/markaby/rails/views/markaby/correct_template_values.mab
  19. +0 −8 spec/markaby/rails/views/markaby/double_output.mab
  20. +0 −2 spec/markaby/rails/views/markaby/form_for.mab
  21. +0 −3 spec/markaby/rails/views/markaby/form_for_with_fields.mab
  22. +0 −4 spec/markaby/rails/views/markaby/form_for_with_multiple_fields.mab
  23. +0 −3 spec/markaby/rails/views/markaby/no_values_passed.mab
  24. +0 −1 spec/markaby/rails/views/markaby/partial_parent.mab
  25. +0 −7 spec/markaby/rails/views/markaby/partial_parent_with_locals.mab
  26. +0 −1 spec/markaby/rails/views/markaby/render_erb_without_explicit_render_call.erb
  27. 0 spec/markaby/rails/views/markaby/render_explicit_but_empty_markaby_layout.mab
  28. +0 −3 spec/markaby/rails/views/markaby/render_mab_without_explicit_render_call.mab
  29. +0 −3 spec/markaby/rails/views/markaby/render_with_ivar.mab
  30. +0 −1 spec/markaby/rails/views/markaby/renders_erb.rhtml
  31. +0 −3 spec/markaby/rails/views/markaby/renders_form_for_with_erb_body.mab
  32. +0 −1 spec/markaby/rails/views/markaby/routes.mab
  33. +0 −3 spec/markaby/rails/views/markaby/yielding.mab
  34. +0 −5 spec/markaby/rails/views/markaby/yielding_content_for_with_block_helper.mab
  35. +0 −7 spec/markaby/rails/views/markaby/yielding_two.mab
  36. +0 −3 spec/markaby/rails/views/markaby/yielding_with_content_for.mab
  37. +0 −380 spec/markaby/rails_spec.rb
  38. +0 −37 spec/markaby/rails_version_spec.rb
  39. +0 −3 spec/spec_helper.rb
View
@@ -4,6 +4,5 @@ gem 'builder'
group :test do
gem 'rake'
- gem 'garlic'
gem 'rspec'
end
View
@@ -3,7 +3,6 @@ GEM
specs:
builder (3.2.2)
diff-lcs (1.2.5)
- garlic (0.1.10)
rake (10.1.0)
rspec (2.14.1)
rspec-core (~> 2.14.0)
@@ -19,6 +18,5 @@ PLATFORMS
DEPENDENCIES
builder
- garlic
rake
rspec
View
@@ -1,29 +0,0 @@
-require File.expand_path(File.dirname(__FILE__) + "/lib/markaby/rails")
-
-garlic do
- # this plugin
- repo "markaby", :path => '.'
-
- # other repos
- repo "rails", :url => "git://github.com/rails/rails"
-
- # target railses
- RAILS_TAREGETS = Markaby::Rails::SUPPORTED_RAILS_VERSIONS.map do |version|
- "v#{version}"
- end
-
- RAILS_TAREGETS.each do |rails|
- # declare how to prepare, and run each CI target
- target "Rails: #{rails}", :tree_ish => rails do
- prepare do
- plugin "markaby", :clone => true # so we can work in targets
- end
-
- run do
- cd "vendor/plugins/markaby" do
- sh "rake"
- end
- end
- end
- end
-end
View
@@ -1,6 +0,0 @@
-$:.unshift File.expand_path(File.join(File.dirname(__FILE__), 'lib'))
-
-require 'markaby'
-require 'markaby/rails'
-
-Markaby::Rails.load
View
@@ -16,8 +16,6 @@
# * Markaby::MetAid: metaprogramming helper methods.
# * Markaby::Tags: lists the roles of various XHTML tags to help Builder
# use these tags as they are intended.
-# * Markaby::Template: a class for hooking Markaby into Rails as a
-# proper templating language.
module Markaby
class InvalidXhtmlError < StandardError; end
end
View
@@ -1,75 +0,0 @@
-module Markaby
- module Rails
- UNSUPPORTED_RAILS_VERSIONS = [
- "2.0.0",
- "2.0.1",
- "2.0.2",
- "2.0.3",
- "2.0.4",
- "2.0.5",
- "2.1.0",
- "2.1.1",
- "2.1.2",
- "2.3.0"
- ]
-
- DEPRECATED_RAILS_VERSIONS = [
- "1.2.2",
- "1.2.3",
- "1.2.4",
- "1.2.5",
- "1.2.6"
- ]
-
- FULLY_SUPPORTED_RAILS_VERSIONS = [
- "2.2.0",
- "2.2.1",
- "2.2.2",
- "2.2.3",
- "2.3.1",
- "2.3.2",
- "2.3.2.1",
- "2.3.3",
- "2.3.3.1",
- "2.3.4",
- "2.3.5",
- "2.3.6",
- "2.3.7",
- "2.3.8"
- ]
-
- SUPPORTED_RAILS_VERSIONS = DEPRECATED_RAILS_VERSIONS + FULLY_SUPPORTED_RAILS_VERSIONS
-
- class << self
- def load
- check_rails_version
-
- if deprecated_rails_version?
- require File.dirname(__FILE__) + "/rails/deprecated"
- else
- require File.dirname(__FILE__) + "/rails/current"
- end
- end
-
- def deprecated_rails_version?
- DEPRECATED_RAILS_VERSIONS.include?(detected_rails_version)
- end
-
- def check_rails_version
- if UNSUPPORTED_RAILS_VERSIONS.include?(detected_rails_version)
- error_message = "Cannot load markaby under rails version #{detected_rails_version}. "
- error_message << "See Markaby::Rails::SUPPORTED_RAILS_VERSIONS for exactly that, or redefine this constant."
- raise LoadError, error_message
- end
- end
-
- private
-
- def detected_rails_version
- if defined?(::Rails)
- ::Rails::VERSION::STRING
- end
- end
- end
- end
-end
@@ -1,85 +0,0 @@
-require 'markaby/rails/rails_builder'
-
-module Markaby
- module Rails
- class TemplateHandler < ::ActionView::TemplateHandler
- include ActionView::TemplateHandlers::Compilable
-
- def compile(template, local_assigns={})
- <<-CODE
- __template_handler = Markaby::Rails::TemplateHandler.new
- __template_handler.view = self
- __template_handler.render(lambda {
- #{template.source}
- }, local_assigns)
- CODE
- end
-
- def render(template, local_assigns = (template.respond_to?(:locals) ? template.locals : {}))
- builder = RailsBuilder.new(instance_variables.merge(local_assigns), @view)
- @view.output_buffer = builder
-
- template.is_a?(Proc) ?
- builder.instance_eval(&template) :
- builder.instance_eval(template.source)
-
- builder.to_s
- end
-
- attr_accessor :view
-
- private
-
- def instance_variables
- instance_variable_hash(@view)
- end
-
- def instance_variable_hash(object)
- returning Hash.new do |hash|
- object.instance_variables.each do |var_name|
- hash[var_name.gsub("@", "")] = object.instance_variable_get(var_name)
- end
- end
- end
- end
-
- module Helpers
- # allow fragments to act as strings. url_for has a
- # case statment in it:
- #
- # case options
- # when String
- # ...
- #
- # which essential is doing the following:
- #
- # String === options
- #
- # That assertion fails with Markaby::Fragments, which are essential
- # builder/string fragments.
- #
- def url_for(options={})
- case options
- when Markaby::Fragment
- super(options.to_s)
- else
- super
- end
- end
-
- def capture(*args, &block)
- if output_buffer.kind_of?(Markaby::Builder)
- output_buffer.capture(&block)
- else
- super
- end
- end
- end
- end
-end
-
-ActionView::Base.class_eval do
- include Markaby::Rails::Helpers
-end
-
-ActionView::Template.register_template_handler(:mab, Markaby::Rails::TemplateHandler)
@@ -1,124 +0,0 @@
-require 'markaby/rails/rails_builder'
-
-module ActionView # :nodoc:
- class Base # :nodoc:
- def render_template(template_extension, template, file_path = nil, local_assigns = {})
- if handler = @@template_handlers[template_extension]
- template ||= read_template_file(file_path, template_extension)
- handler.new(self).render(template, local_assigns, file_path)
- else
- compile_and_render_template(template_extension, template, file_path, local_assigns)
- end
- end
- end
-end
-
-module Markaby
- module Rails
- class Template
-
- def self.builder_class=(builder)
- @@builder_class = builder
- end
-
- def self.builder_class
- @@builder_class ||= Builder
- end
-
- attr_accessor :source, :path
-
- def initialize(source)
- @source = source.to_s
- end
-
- def render(*args)
- output = self.class.builder_class.new(*args)
-
- if path
- output.instance_eval source, path
- else
- output.instance_eval source
- end
-
- output.to_s
- end
- end
-
- # Markaby helpers for Rails.
- module ActionControllerHelpers
- # Returns a string of HTML built from the attached +block+. Any +options+ are
- # passed into the render method.
- #
- # Use this method in your controllers to output Markaby directly from inside.
- def render_markaby(options = {}, &block)
- render options.merge({ :text => Builder.new(options[:locals], self, &block).to_s })
- end
- end
-
- class ActionViewTemplateHandler # :nodoc:
- def initialize(action_view)
- @action_view = action_view
- end
- def render(template, local_assigns, file_path)
- template = Template.new(template)
- template.path = file_path
- template.render(@action_view.assigns.merge(local_assigns), @action_view)
- end
- end
-
- class Builder < RailsBuilder # :nodoc:
- def initialize(*args, &block)
- super *args, &block
-
- @assigns.each { |k, v| @helpers.instance_variable_set("@#{k}", v) }
- end
-
- def flash(*args)
- @helpers.controller.send(:flash, *args)
- end
-
- # Emulate ERB to satisfy helpers like <tt>form_for</tt>.
- def _erbout
- @_erbout ||= FauxErbout.new(self)
- end
-
- # Content_for will store the given block in an instance variable for later use
- # in another template or in the layout.
- #
- # The name of the instance variable is content_for_<name> to stay consistent
- # with @content_for_layout which is used by ActionView's layouts.
- #
- # Example:
- #
- # content_for("header") do
- # h1 "Half Shark and Half Lion"
- # end
- #
- # If used several times, the variable will contain all the parts concatenated.
- def content_for(name, &block)
- @helpers.assigns["content_for_#{name}"] =
- eval("@content_for_#{name} = (@content_for_#{name} || '') + capture(&block)")
- end
- end
-
- Template.builder_class = Builder
-
- class FauxErbout < ::Builder::BlankSlate # :nodoc:
- def initialize(builder)
- @builder = builder
- end
- def nil? # see ActionView::Helpers::CaptureHelper#capture
- true
- end
- def method_missing(*args, &block)
- @builder.send *args, &block
- end
- end
- end
-
- if defined? ActionView::Template and ActionView::Template.respond_to? :register_template_handler
- ActionView::Template
- else
- ActionView::Base
- end.register_template_handler(:mab, Markaby::Rails::ActionViewTemplateHandler)
-end
Oops, something went wrong.

0 comments on commit 36848fb

Please sign in to comment.