tokamak 1.0.0.beta2 → 1.0.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/LICENSE +14 -0
  2. data/README.md +159 -0
  3. data/lib/tokamak/builder/base.rb +74 -0
  4. data/lib/tokamak/{json/builder.rb → builder/json.rb} +38 -29
  5. data/lib/tokamak/builder/values.rb +33 -0
  6. data/lib/tokamak/{atom/builder.rb → builder/xml.rb} +46 -41
  7. data/lib/tokamak/builder.rb +22 -0
  8. data/lib/tokamak/errors.rb +3 -0
  9. data/lib/tokamak/hook/rails.rb +78 -0
  10. data/lib/tokamak/hook/sinatra.rb +18 -0
  11. data/lib/tokamak/hook/tilt.rb +42 -0
  12. data/lib/tokamak/hook.rb +6 -0
  13. data/lib/tokamak/recipes.rb +26 -0
  14. data/lib/tokamak/version.rb +13 -0
  15. data/lib/tokamak.rb +14 -18
  16. data/script/console +7 -0
  17. data/test/rails2_skel/Rakefile +16 -0
  18. data/test/rails2_skel/app/controllers/application_controller.rb +1 -0
  19. data/test/rails2_skel/app/controllers/test_controller.rb +18 -0
  20. data/test/rails2_skel/app/views/test/_feed_member.tokamak +9 -0
  21. data/test/rails2_skel/app/views/test/feed.tokamak +24 -0
  22. data/test/rails2_skel/app/views/test/show.tokamak +31 -0
  23. data/test/rails2_skel/config/boot.rb +110 -0
  24. data/test/rails2_skel/config/environment.rb +20 -0
  25. data/test/rails2_skel/config/environments/development.rb +17 -0
  26. data/test/rails2_skel/config/environments/production.rb +28 -0
  27. data/test/rails2_skel/config/environments/test.rb +28 -0
  28. data/test/rails2_skel/config/initializers/cookie_verification_secret.rb +2 -0
  29. data/test/rails2_skel/config/initializers/mime_types.rb +3 -0
  30. data/test/rails2_skel/config/initializers/new_rails_defaults.rb +10 -0
  31. data/test/rails2_skel/config/initializers/session_store.rb +5 -0
  32. data/test/rails2_skel/config/routes.rb +43 -0
  33. data/test/rails2_skel/script/console +3 -0
  34. data/test/test_helper.rb +7 -0
  35. data/test/tokamak/builder/base_test.rb +28 -0
  36. data/test/tokamak/builder/json_test.rb +227 -0
  37. data/test/tokamak/builder/xml_test.rb +254 -0
  38. data/test/tokamak/helper_test.rb +106 -0
  39. data/test/tokamak/hook/rails_test.rb +74 -0
  40. data/test/tokamak/hook/sinatra_test.rb +85 -0
  41. data/test/tokamak/hook/tilt_test.rb +35 -0
  42. data/test/tokamak/recipes_test.rb +90 -0
  43. metadata +106 -113
  44. data/.document +0 -5
  45. data/.rspec +0 -1
  46. data/Gemfile +0 -27
  47. data/Gemfile.lock +0 -77
  48. data/LICENSE.txt +0 -20
  49. data/README.rdoc +0 -69
  50. data/Rakefile +0 -50
  51. data/VERSION +0 -1
  52. data/lib/tokamak/atom/base.rb +0 -87
  53. data/lib/tokamak/atom/helpers.rb +0 -13
  54. data/lib/tokamak/atom.rb +0 -8
  55. data/lib/tokamak/error.rb +0 -6
  56. data/lib/tokamak/json/base.rb +0 -83
  57. data/lib/tokamak/json/helpers.rb +0 -13
  58. data/lib/tokamak/json.rb +0 -10
  59. data/lib/tokamak/representation/atom/atom.rng +0 -597
  60. data/lib/tokamak/representation/atom/base.rb +0 -140
  61. data/lib/tokamak/representation/atom/category.rb +0 -39
  62. data/lib/tokamak/representation/atom/entry.rb +0 -56
  63. data/lib/tokamak/representation/atom/factory.rb +0 -48
  64. data/lib/tokamak/representation/atom/feed.rb +0 -108
  65. data/lib/tokamak/representation/atom/link.rb +0 -66
  66. data/lib/tokamak/representation/atom/person.rb +0 -46
  67. data/lib/tokamak/representation/atom/source.rb +0 -57
  68. data/lib/tokamak/representation/atom/tag_collection.rb +0 -36
  69. data/lib/tokamak/representation/atom/xml.rb +0 -94
  70. data/lib/tokamak/representation/atom.rb +0 -18
  71. data/lib/tokamak/representation/generic.rb +0 -20
  72. data/lib/tokamak/representation/json/base.rb +0 -25
  73. data/lib/tokamak/representation/json/keys_as_methods.rb +0 -72
  74. data/lib/tokamak/representation/json/link.rb +0 -27
  75. data/lib/tokamak/representation/json/link_collection.rb +0 -21
  76. data/lib/tokamak/representation/json.rb +0 -11
  77. data/lib/tokamak/representation/links.rb +0 -9
  78. data/lib/tokamak/representation.rb +0 -3
  79. data/lib/tokamak/values.rb +0 -29
  80. data/lib/tokamak/xml/base.rb +0 -60
  81. data/lib/tokamak/xml/builder.rb +0 -115
  82. data/lib/tokamak/xml/helpers.rb +0 -13
  83. data/lib/tokamak/xml/link.rb +0 -31
  84. data/lib/tokamak/xml/links.rb +0 -35
  85. data/lib/tokamak/xml.rb +0 -12
  86. data/spec/integration/atom/atom_spec.rb +0 -191
  87. data/spec/integration/full_atom.xml +0 -92
  88. data/spec/integration/full_json.js +0 -46
  89. data/spec/integration/json/json_spec.rb +0 -172
  90. data/spec/integration/xml/xml_spec.rb +0 -203
  91. data/spec/spec_helper.rb +0 -12
@@ -0,0 +1,42 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../tokamak.rb') unless defined? ::Tokamak
2
+
3
+ module Tokamak
4
+ module Hook
5
+ module Tilt
6
+
7
+ class TokamakTemplate < ::Tilt::Template
8
+ def initialize_engine
9
+ return if defined?(::Tokamak)
10
+ require_template_library 'tokamak'
11
+ end
12
+
13
+ def prepare
14
+ @media_type = options[:media_type]
15
+ raise Tokamak::BuilderError.new("Content type required to build representation.") unless @media_type
16
+ end
17
+
18
+ def precompiled_preamble(locals)
19
+ local_assigns = super
20
+ <<-RUBY
21
+ begin
22
+ extend ::Tokamak.builder_lookup(#{@media_type.inspect}).helper
23
+ #{local_assigns}
24
+ RUBY
25
+ end
26
+
27
+ def precompiled_postamble(locals)
28
+ <<-RUBY
29
+ end
30
+ RUBY
31
+ end
32
+
33
+ def precompiled_template(locals)
34
+ data.to_str
35
+ end
36
+ end
37
+
38
+ ::Tilt.register 'tokamak', TokamakTemplate
39
+
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,6 @@
1
+ module Tokamak
2
+ module Hook
3
+ autoload :Rails , "tokamak/hook/rails"
4
+ autoload :Tilt , "tokamak/hook/tilt"
5
+ end
6
+ end
@@ -0,0 +1,26 @@
1
+ module Tokamak
2
+ class Recipes
3
+ @@recipes = {}
4
+
5
+ class << self
6
+
7
+ def add(recipe_name, &block)
8
+ @@recipes[recipe_name] = block
9
+ end
10
+
11
+ def remove(recipe_name)
12
+ @@recipes.delete(recipe_name)
13
+ end
14
+
15
+ def [](recipe_name)
16
+ @@recipes[recipe_name]
17
+ end
18
+
19
+ def list
20
+ @@recipes.keys
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,13 @@
1
+ module Tokamak
2
+ module VERSION #:nodoc:
3
+ MAJOR = 1
4
+ MINOR = 0
5
+ TINY = 0
6
+
7
+ STRING = [MAJOR, MINOR, TINY].join('.') + ".beta4"
8
+
9
+ def self.to_s
10
+ STRING
11
+ end
12
+ end
13
+ end
data/lib/tokamak.rb CHANGED
@@ -1,21 +1,17 @@
1
- require 'tokamak/xml'
2
- require 'tokamak/json'
3
- require 'tokamak/atom'
4
- require 'tokamak/values'
5
- require 'tokamak/representation'
6
- require 'tokamak/error'
1
+ $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__))
7
2
 
3
+ # Dependencies
4
+ require "rubygems"
5
+ require "bundler/setup"
6
+
7
+ # Lib
8
8
  module Tokamak
9
-
10
- # Returns the default root element name for an item or collection
11
- def self.root_element_for(obj)
12
- if obj.kind_of?(Hash) && obj.size==1
13
- obj.keys.first.to_s
14
- elsif obj.kind_of?(Array) && !obj.empty?
15
- root_element_for(obj.first).to_s.underscore.pluralize
16
- else
17
- obj.class.to_s.underscore
18
- end
9
+ def self.builder_lookup(media_type)
10
+ Tokamak::Builder::Base.global_media_types[media_type[/^([^\s\;]+)/, 1]]
19
11
  end
20
-
21
- end
12
+ end
13
+
14
+ require "tokamak/errors"
15
+ require "tokamak/recipes"
16
+ require "tokamak/builder"
17
+ require "tokamak/hook"
data/script/console ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+ ENV["MIGRATOR_CALLER"] = "console"
5
+ libs = " -r #{File.dirname(__FILE__) + '/../lib/tokamak.rb'} -r ruby-debug"
6
+ puts "Loading tokamak development environment..."
7
+ exec "#{irb} #{libs} --simple-prompt #{ARGV.join("")}"
@@ -0,0 +1,16 @@
1
+ require(File.join(File.dirname(__FILE__), 'config', 'boot'))
2
+ require 'rake'
3
+ # require 'rake/testtask'
4
+ # require 'rake/rdoctask'
5
+ # require 'tasks/rails'
6
+
7
+ # extracted from 'tasks/rails' since its the only tasks we're interested in
8
+ $VERBOSE = nil
9
+
10
+ task :default => :middleware
11
+ task :environment do
12
+ $rails_rake_task = true
13
+ require(File.join(RAILS_ROOT, 'config', 'environment'))
14
+ end
15
+
16
+
@@ -0,0 +1 @@
1
+ class ApplicationController < ActionController::Base; end
@@ -0,0 +1,18 @@
1
+ class TestController < ApplicationController
2
+ def show
3
+ @some_articles = [
4
+ {:id => 1, :title => "a great article", :updated => Time.now},
5
+ {:id => 2, :title => "another great article", :updated => Time.now}
6
+ ]
7
+ response.content_type = request.negotiated_type
8
+ end
9
+
10
+ def feed
11
+ @some_articles = [
12
+ {:id => 1, :title => "a great article", :updated => Time.now},
13
+ {:id => 2, :title => "another great article", :updated => Time.now}
14
+ ]
15
+ response.content_type = request.negotiated_type
16
+ end
17
+
18
+ end
@@ -0,0 +1,9 @@
1
+ member.values do |values|
2
+ values.id "uri:#{article[:id]}"
3
+ values.title article[:title]
4
+ values.updated article[:updated]
5
+ end
6
+
7
+ member.link("image", "http://example.com/image/1")
8
+ member.link("image", "http://example.com/image/2", :type => "application/json")
9
+
@@ -0,0 +1,24 @@
1
+ collection(@some_articles) do |collection|
2
+ collection.values do |values|
3
+ values.id "http://example.com/json"
4
+ values.title "Feed"
5
+ values.updated Time.now
6
+
7
+ values.author {
8
+ values.name "John Doe"
9
+ values.email "joedoe@example.com"
10
+ }
11
+
12
+ values.author {
13
+ values.name "Foo Bar"
14
+ values.email "foobar@example.com"
15
+ }
16
+ end
17
+
18
+ collection.link("next" , "http://a.link.com/next")
19
+ collection.link("previous", "http://a.link.com/previous")
20
+
21
+ collection.members(:root => "articles") do |member, article|
22
+ partial("feed_member", :locals => {:member => member, :article => article})
23
+ end
24
+ end
@@ -0,0 +1,31 @@
1
+ collection(@some_articles) do |collection|
2
+ collection.values do |values|
3
+ values.id "http://example.com/json"
4
+ values.title "Feed"
5
+ values.updated Time.now
6
+
7
+ values.author {
8
+ values.name "John Doe"
9
+ values.email "joedoe@example.com"
10
+ }
11
+
12
+ values.author {
13
+ values.name "Foo Bar"
14
+ values.email "foobar@example.com"
15
+ }
16
+ end
17
+
18
+ collection.link("next" , "http://a.link.com/next")
19
+ collection.link("previous", "http://a.link.com/previous")
20
+
21
+ collection.members(:root => "articles") do |member, article|
22
+ member.values do |values|
23
+ values.id "uri:#{article[:id]}"
24
+ values.title article[:title]
25
+ values.updated article[:updated]
26
+ end
27
+
28
+ member.link("image", "http://example.com/image/1")
29
+ member.link("image", "http://example.com/image/2", :type => "application/json")
30
+ end
31
+ end
@@ -0,0 +1,110 @@
1
+ # Don't change this file!
2
+ # Configure your app in config/environment.rb and config/environments/*.rb
3
+
4
+ RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
+
6
+ module Rails
7
+ class << self
8
+ def boot!
9
+ unless booted?
10
+ preinitialize
11
+ pick_boot.run
12
+ end
13
+ end
14
+
15
+ def booted?
16
+ defined? Rails::Initializer
17
+ end
18
+
19
+ def pick_boot
20
+ (vendor_rails? ? VendorBoot : GemBoot).new
21
+ end
22
+
23
+ def vendor_rails?
24
+ File.exist?("#{RAILS_ROOT}/vendor/rails")
25
+ end
26
+
27
+ def preinitialize
28
+ load(preinitializer_path) if File.exist?(preinitializer_path)
29
+ end
30
+
31
+ def preinitializer_path
32
+ "#{RAILS_ROOT}/config/preinitializer.rb"
33
+ end
34
+ end
35
+
36
+ class Boot
37
+ def run
38
+ load_initializer
39
+ Rails::Initializer.run(:set_load_path)
40
+ end
41
+ end
42
+
43
+ class VendorBoot < Boot
44
+ def load_initializer
45
+ require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
+ Rails::Initializer.run(:install_gem_spec_stubs)
47
+ Rails::GemDependency.add_frozen_gem_path
48
+ end
49
+ end
50
+
51
+ class GemBoot < Boot
52
+ def load_initializer
53
+ self.class.load_rubygems
54
+ load_rails_gem
55
+ require 'initializer'
56
+ end
57
+
58
+ def load_rails_gem
59
+ if version = self.class.gem_version
60
+ gem 'rails', version
61
+ else
62
+ gem 'rails'
63
+ end
64
+ rescue Gem::LoadError => load_error
65
+ $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
66
+ exit 1
67
+ end
68
+
69
+ class << self
70
+ def rubygems_version
71
+ Gem::RubyGemsVersion rescue nil
72
+ end
73
+
74
+ def gem_version
75
+ if defined? RAILS_GEM_VERSION
76
+ RAILS_GEM_VERSION
77
+ elsif ENV.include?('RAILS_GEM_VERSION')
78
+ ENV['RAILS_GEM_VERSION']
79
+ else
80
+ parse_gem_version(read_environment_rb)
81
+ end
82
+ end
83
+
84
+ def load_rubygems
85
+ min_version = '1.3.2'
86
+ require 'rubygems'
87
+ unless rubygems_version >= min_version
88
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
89
+ exit 1
90
+ end
91
+
92
+ rescue LoadError
93
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
94
+ exit 1
95
+ end
96
+
97
+ def parse_gem_version(text)
98
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
99
+ end
100
+
101
+ private
102
+ def read_environment_rb
103
+ File.read("#{RAILS_ROOT}/config/environment.rb")
104
+ end
105
+ end
106
+ end
107
+ end
108
+
109
+ # All that for this:
110
+ Rails.boot!
@@ -0,0 +1,20 @@
1
+ # Specifies gem version of Rails to use when vendor/rails is not present
2
+ RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION
3
+
4
+ # Bootstrap the Rails environment, frameworks, and default configuration
5
+ require File.join(File.dirname(__FILE__), 'boot')
6
+
7
+ Rails::Initializer.run do |config|
8
+ # Add additional load paths for your own custom dirs
9
+ # config.load_paths += %W( #{RAILS_ROOT}/extras )
10
+
11
+ # Skip frameworks we're not going to use.
12
+ config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
13
+
14
+ config.middleware.use(Rack::Conneg) do |conneg|
15
+ conneg.set :accept_all_extensions, false
16
+ conneg.set :fallback, :html
17
+ conneg.ignore('/public/')
18
+ conneg.provide([:json,:xml])
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # In the development environment your application's code is reloaded on
4
+ # every request. This slows down response time but is perfect for development
5
+ # since you don't have to restart the webserver when you make code changes.
6
+ config.cache_classes = false
7
+
8
+ # Log error messages when you accidentally call methods on nil.
9
+ config.whiny_nils = true
10
+
11
+ # Show full error reports and disable caching
12
+ config.action_controller.consider_all_requests_local = true
13
+ config.action_view.debug_rjs = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send
17
+ config.action_mailer.raise_delivery_errors = false
@@ -0,0 +1,28 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # The production environment is meant for finished, "live" apps.
4
+ # Code is not reloaded between requests
5
+ config.cache_classes = true
6
+
7
+ # Full error reports are disabled and caching is turned on
8
+ config.action_controller.consider_all_requests_local = false
9
+ config.action_controller.perform_caching = true
10
+ config.action_view.cache_template_loading = true
11
+
12
+ # See everything in the log (default is :info)
13
+ # config.log_level = :debug
14
+
15
+ # Use a different logger for distributed setups
16
+ # config.logger = SyslogLogger.new
17
+
18
+ # Use a different cache store in production
19
+ # config.cache_store = :mem_cache_store
20
+
21
+ # Enable serving of images, stylesheets, and javascripts from an asset server
22
+ # config.action_controller.asset_host = "http://assets.example.com"
23
+
24
+ # Disable delivery errors, bad email addresses will be ignored
25
+ # config.action_mailer.raise_delivery_errors = false
26
+
27
+ # Enable threaded mode
28
+ # config.threadsafe!
@@ -0,0 +1,28 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # The test environment is used exclusively to run your application's
4
+ # test suite. You never need to work with it otherwise. Remember that
5
+ # your test database is "scratch space" for the test suite and is wiped
6
+ # and recreated between test runs. Don't rely on the data there!
7
+ config.cache_classes = true
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.action_controller.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+ config.action_view.cache_template_loading = true
16
+
17
+ # Disable request forgery protection in test environment
18
+ config.action_controller.allow_forgery_protection = false
19
+
20
+ # Tell Action Mailer not to deliver emails to the real world.
21
+ # The :test delivery method accumulates sent emails in the
22
+ # ActionMailer::Base.deliveries array.
23
+ config.action_mailer.delivery_method = :test
24
+
25
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
26
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
27
+ # like if you have constraints or database-specific column types
28
+ # config.active_record.schema_format = :sql
@@ -0,0 +1,2 @@
1
+ # Your secret key for verifying the integrity of signed cookies.
2
+ ActionController::Base.cookie_verifier_secret = 'ac1cfe08c947b01f09a6141d3e36c0ce4c567b4d7ea7af417db424e099668f4506ee7ac4d31d1cb253c6e64ce248f917483d6edf54370e18c47f7f830d604b57';
@@ -0,0 +1,3 @@
1
+ # Add new mime types for use in respond_to blocks:
2
+ # Mime::Type.register "text/richtext", :rtf
3
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,10 @@
1
+ # These settings change the behavior of Rails 2 apps and will be defaults
2
+ # for Rails 3. You can remove this initializer when Rails 3 is released.
3
+ ActionController::Routing.generate_best_match = false
4
+
5
+ # Use ISO 8601 format for JSON serialized times and dates.
6
+ ActiveSupport.use_standard_json_time_format = true
7
+
8
+ # Don't escape HTML entities in JSON, leave that for the #json_escape helper.
9
+ # if you're including raw json in an HTML page.
10
+ ActiveSupport.escape_html_entities_in_json = false
@@ -0,0 +1,5 @@
1
+ # Your secret key for verifying cookie session data integrity.
2
+ ActionController::Base.session = {
3
+ :key => '_rails_app_session',
4
+ :secret => 'd91cb53f58c44cdb081eed837fbe266e4f0b95466deb07f366991b00d1fda2446c4d9c5e911f2287cb373386cd88db97ef29decbf37f95458cc99ba5d782aaae'
5
+ }
@@ -0,0 +1,43 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+ # The priority is based upon order of creation: first created -> highest priority.
3
+
4
+ # Sample of regular route:
5
+ # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
6
+ # Keep in mind you can assign values other than :controller and :action
7
+
8
+ # Sample of named route:
9
+ # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
10
+ # This route can be invoked with purchase_url(:id => product.id)
11
+
12
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
13
+ # map.resources :products
14
+
15
+ # Sample resource route with options:
16
+ # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
17
+
18
+ # Sample resource route with sub-resources:
19
+ # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
20
+
21
+ # Sample resource route with more complex sub-resources
22
+ # map.resources :products do |products|
23
+ # products.resources :comments
24
+ # products.resources :sales, :collection => { :recent => :get }
25
+ # end
26
+
27
+ # Sample resource route within a namespace:
28
+ # map.namespace :admin do |admin|
29
+ # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
30
+ # admin.resources :products
31
+ # end
32
+
33
+ # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
34
+ # map.root :controller => "welcome"
35
+
36
+ # See how all your routes lay out with "rake routes"
37
+
38
+ # Install the default routes as the lowest priority.
39
+ # Note: These default routes make all actions in every controller accessible via GET requests. You should
40
+ # consider removing or commenting them out if you're using named routes and resources.
41
+ map.connect ':controller/:action/:id'
42
+ map.connect ':controller/:action/:id.:format'
43
+ end
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path('../../config/boot', __FILE__)
3
+ require 'commands/console'
@@ -0,0 +1,7 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'ruby-debug'
4
+ require "methodize"
5
+
6
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/tokamak.rb')
7
+
@@ -0,0 +1,28 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
2
+
3
+ class Tokamak::Builder::BaseTest < Test::Unit::TestCase
4
+
5
+ class SomeBuilder < Tokamak::Builder::Base
6
+ builder_for "valid/media_type"
7
+ end
8
+
9
+ class AnotherBuilder < Tokamak::Builder::Base
10
+ builder_for "valid/media_type", "another_valid/media_type"
11
+ end
12
+
13
+ class YetAnotherBuilder < Tokamak::Builder::Base
14
+ builder_for "yet_another_valid/media_type"
15
+ end
16
+
17
+ def test_should_support_media_type_registering
18
+ assert_equal ["valid/media_type"] , SomeBuilder.media_types
19
+ assert_equal ["valid/media_type","another_valid/media_type"], AnotherBuilder.media_types
20
+ end
21
+
22
+ def test_builder_lookup
23
+ assert_equal AnotherBuilder , Tokamak.builder_lookup("valid/media_type")
24
+ assert_equal AnotherBuilder , Tokamak.builder_lookup("another_valid/media_type")
25
+ assert_equal YetAnotherBuilder, Tokamak.builder_lookup("yet_another_valid/media_type")
26
+ end
27
+
28
+ end