Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

completing merge with whiltlerbrk rails_test3

  • Loading branch information...
commit 65441a61e37d44cbb07363e301f9d86de0615d2b 2 parents 38262ff + 3719a12
@mmorga authored
View
16 Gemfile
@@ -1,16 +1,4 @@
source :rubygems
-# Main dependencies
-gem "json_pure", :require => "json/pure"
-gem "nokogiri"
-
-group :development, :test do
- gem "ruby-debug" , :platforms => [:mri_18]
- gem "ruby-debug19", :platforms => [:mri_19]
- gem "rack" , "~>1.1"
- gem "rack-test" , :require => "rack/test"
- gem "rack-conneg", :require => "rack/conneg"
- gem "tilt" , "~>1.2"
- gem "sinatra" , "~>1.1"
- gem "rails" , ">=2.3.2"
-end
+# Specify your gem's dependencies in urtak.gemspec
+gemspec
View
18 hypertemplate.gemspec
@@ -1,3 +1,7 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+require "hypertemplate/version"
+
require File.join(File.dirname(__FILE__), "lib", "hypertemplate", "version.rb")
Gem::Specification.new do |s|
@@ -6,22 +10,24 @@ Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.summary = "A template engine that generates hypermedia enbabled media types representations"
- s.require_paths = ['lib']
- s.files = Dir["{lib/**/*.rb,README.md,LICENSE,test/**/*,script/*}"]
-
s.author = "Guilherme Silveira & Hypertemplate & Tokamak & Restfulie team"
s.email = "restfulie@googlegroups.com"
s.homepage = "http://github.com/caelum/hypertemplate"
- s.add_dependency('json_pure')
+ s.require_paths = ['lib']
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ['lib']
+
+ s.add_dependency('json')
s.add_dependency('nokogiri')
- s.add_development_dependency('ruby-debug')
s.add_development_dependency('methodize')
s.add_development_dependency('rack',"~>1.2")
s.add_development_dependency('rack-test')
s.add_development_dependency('rack-conneg')
s.add_development_dependency('tilt',"~>1.2")
s.add_development_dependency('sinatra',"~>1.1")
- s.add_development_dependency('rails',">=2.3.2")
+ s.add_development_dependency('rails',">=3.1.1")
end
View
6 lib/hypertemplate.rb
@@ -1,8 +1,4 @@
-$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__))
-
-# Dependencies
-require "rubygems"
-require "bundler/setup"
+require "hypertemplate/version"
module Hypertemplate
end
View
37 lib/hypertemplate/hook/rails.rb
@@ -2,11 +2,11 @@
module Hypertemplate
module RegistryContainer
-
+
def hypertemplate_registry
@hypertemplate || use_hypertemplate
end
-
+
def use_hypertemplate(&block)
@hypertemplate = ::Hypertemplate::Registry.new
if block_given?
@@ -17,7 +17,7 @@ def use_hypertemplate(&block)
end
@hypertemplate
end
-
+
end
end
@@ -34,13 +34,24 @@ module Rails
class Hypertemplate < (::Rails::VERSION::MAJOR < 3 ? ::ActionView::TemplateHandler : ::Object)
include ::ActionView::TemplateHandlers::Compilable if ::Rails::VERSION::MAJOR < 3
- def compile(template)
- "@content_type_helpers = controller.hypertemplate_registry[self.response.content_type].helper; " +
- "extend @content_type_helpers; " +
- "extend Hypertemplate::Hook::Rails::Helpers; " +
- "code_block = lambda { #{template.source} };" +
- "builder = code_block.call; " +
- "builder"
+ if ::Rails::VERSION::MAJOR < 3
+ def compile(template)
+ "@content_type_helpers = controller.hypertemplate_registry[self.response.content_type].helper; " +
+ "extend @content_type_helpers; " +
+ "extend Hypertemplate::Hook::Rails::Helpers; " +
+ "code_block = lambda { #{template.source} };" +
+ "builder = code_block.call; " +
+ "builder"
+ end
+ else
+ def self.call(template)
+ "@content_type_helpers = controller.hypertemplate_registry[self.response.content_type].helper; " +
+ "extend @content_type_helpers; " +
+ "extend Hypertemplate::Hook::Rails::Helpers; " +
+ "code_block = lambda { #{template.source} };" +
+ "builder = code_block.call; " +
+ "builder"
+ end
end
end
@@ -56,14 +67,14 @@ def path; virtual_path end
end
end
end
-
+
module Helpers
def self.extend_object(base)
super
base.extend(Rails3Adapter) unless base.respond_to?(:_pick_partial_template)
end
-
+
# Load a partial template to execute in describe
#
# For example:
@@ -108,7 +119,7 @@ def partial(partial_path, caller_binding = nil)
end
private
-
+
def self.registry
if defined? ::ActionView::Template and ::ActionView::Template.respond_to?(:register_template_handler)
::ActionView::Template
View
11 test/hypertemplate/hook/rails_test.rb
@@ -1,18 +1,17 @@
require 'test/unit'
require 'rubygems'
-require "methodize"
-require "rack/conneg"
+require 'methodize'
+require 'action_controller'
+require 'rack/conneg'
begin
require 'ruby-debug'
rescue Exception => e; end
-require File.expand_path(File.dirname(__FILE__) + '/../../rails2_skel/config/environment.rb')
-
# put the require below to use hypertemplate in your rails project
-require "hypertemplate/hook/rails"
+require 'hypertemplate/hook/rails'
-class Hypertemplate::Hook::RailsTest < ActionController::IntegrationTest
+class Hypertemplate::Hook::RailsTest < ActionDispatch::IntegrationTest
def test_view_generation_with_json
get '/test/show', {}, :accept => 'application/json'
View
12 test/test_helper.rb
@@ -1,9 +1,15 @@
+def is_ruby_19?
+ RUBY_VERSION == '1.9.1' or RUBY_VERSION == '1.9.2'
+end
+
require 'test/unit'
require 'rubygems'
-require "methodize"
+require 'methodize'
begin
require 'ruby-debug'
-rescue Exception => e; end
+rescue LoadError
+ # NOP, ignore
+end
-require File.expand_path(File.dirname(__FILE__) + '/../lib/hypertemplate.rb')
+require File.dirname(__FILE__) + '/../lib/hypertemplate'
Please sign in to comment.
Something went wrong with that request. Please try again.