skates 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -50,16 +50,19 @@ module Skates
50
50
  return if @view and !options[:force] # Avoid double rendering, if we have already attached a view
51
51
 
52
52
  if options == {} # default rendering
53
- result = render(:file => default_template_name)
53
+ render(:file => default_template_name)
54
+
55
+ elsif action_name = options[:action]
56
+ result = render(:file => default_template_name(action_name.to_s))
57
+
54
58
  elsif options[:file]
55
59
  file = options[:file]
56
60
  if file =~ /^\// # Render from view root
57
- result = render_for_file(File.join("app", "views", "#{file}.xml.builder"))
61
+ @view = render_for_file(File.join("app", "views", "#{file}.xml.builder"))
58
62
  else
59
- result = render_for_file(view_path(file))
63
+ @view = render_for_file(view_path(file))
60
64
  end
61
- elsif action_name = options[:action]
62
- result = render(:file => default_template_name(action_name.to_s))
65
+
63
66
  elsif options[:nothing]
64
67
  @view = Skates::Base::View.new()
65
68
  end
@@ -105,10 +108,7 @@ module Skates
105
108
  Skates.logger.info {
106
109
  "RENDERING : #{file}"
107
110
  }
108
- @view = Skates::Base::View.new(file, assigns)
109
- Skates.logger.info {
110
- " "
111
- }
111
+ Skates::Base::View.new(file, assigns)
112
112
  end
113
113
 
114
114
  end
@@ -1,5 +1,8 @@
1
1
  module Skates
2
2
  module Router
3
+ ##
4
+ # We use this class to assert the ordering of the router DSL
5
+ class OutOfOrder < StandardError; end
3
6
 
4
7
  # Creates a simple DSL for stanza routing.
5
8
  class DSL
@@ -17,7 +20,9 @@ module Skates
17
20
 
18
21
  # Set the priority of the last created route.
19
22
  def priority(n)
20
- set(:priority, n)
23
+ route = @routes.last
24
+ raise OutOfOrder unless route.is_a?(Route) # check that this is in the right order
25
+ route.priority = n
21
26
  self
22
27
  end
23
28
 
@@ -33,23 +38,15 @@ module Skates
33
38
 
34
39
  # Map a route to a specific controller and action.
35
40
  def to(params)
36
- set(:controller, params[:controller])
37
- set(:action, params[:action])
41
+ last = @routes.pop
42
+ last["controller"] = params[:controller]
43
+ last["action"] = params[:action]
38
44
  # We now have all the properties we really need to create a route.
39
- route = Route.new(@routes.pop)
40
- @routes << route
45
+ @routes << Route.new(last)
41
46
  self
42
47
  end
43
48
 
44
49
  protected
45
- # We do this magic, or crap depending on your perspective, because we don't know whether we're setting values on a
46
- # Hash or a Route. We can't create the Route until we have a controller and action.
47
- def set(property, value)
48
- last = @routes.last
49
- last[property.to_s] = value if last.is_a?(Hash)
50
- last.send("#{property.to_s}=", value) if last.is_a?(Route)
51
- end
52
-
53
50
  def disco_for(type, node = nil)
54
51
  str = "//iq[@type='get']/*[namespace(., 'query', 'http://jabber.org/protocol/disco##{type.to_s}')"
55
52
  str += " and @node = '#{node}'" if node
@@ -25,10 +25,10 @@ describe Skates::Router::DSL do
25
25
  end }.should raise_error(/destination/)
26
26
  end
27
27
 
28
- it "creates a route with the specified xpath, controller and action" do
28
+ it "creates a route with the specified xpath, controller, action and priority" do
29
29
  Skates.router.draw do
30
30
  xpath("//test"
31
- ).to(:controller => "controller", :action => "action")
31
+ ).to(:controller => "controller", :action => "action").priority(5)
32
32
  end
33
33
  routes = Skates.router.instance_variable_get("@routes")
34
34
  routes.length.should == 1
@@ -10,7 +10,7 @@ require File.dirname(__FILE__) + "/dependencies"
10
10
 
11
11
 
12
12
  # Start the App
13
- Skates::Runner::run(ARGV[0] || "development") do
13
+ Skates::Runner::run(SKATES_ENV || "development") do
14
14
  # Run the initializers, too. This is done here since some initializers might need EventMachine to be started.
15
15
  Dir.glob('config/initializers/*.rb').each { |f| require f }
16
16
  end
@@ -13,7 +13,7 @@ ARGV.options do |o|
13
13
 
14
14
  o.set_summary_indent(' ')
15
15
  o.banner = "Usage: script/#{script_name} [OPTIONS]"
16
- o.define_head "Runs the Babylon Application."
16
+ o.define_head "Runs the Skates Application."
17
17
  o.separator ""
18
18
  o.separator "Arguments :"
19
19
 
@@ -31,6 +31,6 @@ ARGV.options do |o|
31
31
  o.parse!
32
32
  end
33
33
 
34
- $appname = OPTIONS[:name]
35
- BABYLON_ENV = OPTIONS[:environment]
34
+ $appname = OPTIONS[:name]
35
+ SKATES_ENV = OPTIONS[:environment]
36
36
  require File.dirname(__FILE__) + '/../config/boot.rb'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skates
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - julien Genestoux
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-03 00:00:00 -08:00
12
+ date: 2009-11-04 00:00:00 -08:00
13
13
  default_executable: skates
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -141,20 +141,20 @@ signing_key:
141
141
  specification_version: 3
142
142
  summary: Skates is a framework to create EventMachine based XMPP External Components in Ruby.
143
143
  test_files:
144
- - spec/bin/babylon_spec.rb
144
+ - spec/bin/skates_spec.rb
145
145
  - spec/em_mock.rb
146
- - spec/lib/babylon/base/controller_spec.rb
147
- - spec/lib/babylon/base/stanza_spec.rb
148
- - spec/lib/babylon/base/view_spec.rb
149
- - spec/lib/babylon/client_connection_spec.rb
150
- - spec/lib/babylon/component_connection_spec.rb
151
- - spec/lib/babylon/generator_spec.rb
152
- - spec/lib/babylon/router/dsl_spec.rb
153
- - spec/lib/babylon/router_spec.rb
154
- - spec/lib/babylon/runner_spec.rb
155
- - spec/lib/babylon/xmpp_connection_spec.rb
156
- - spec/lib/babylon/xmpp_parser_spec.rb
157
- - spec/lib/babylon/xpath_helper_spec.rb
146
+ - spec/lib/skates/base/controller_spec.rb
147
+ - spec/lib/skates/base/stanza_spec.rb
148
+ - spec/lib/skates/base/view_spec.rb
149
+ - spec/lib/skates/client_connection_spec.rb
150
+ - spec/lib/skates/component_connection_spec.rb
151
+ - spec/lib/skates/generator_spec.rb
152
+ - spec/lib/skates/router/dsl_spec.rb
153
+ - spec/lib/skates/router_spec.rb
154
+ - spec/lib/skates/runner_spec.rb
155
+ - spec/lib/skates/xmpp_connection_spec.rb
156
+ - spec/lib/skates/xmpp_parser_spec.rb
157
+ - spec/lib/skates/xpath_helper_spec.rb
158
158
  - spec/spec_helper.rb
159
159
  - test/skates_test.rb
160
160
  - test/test_helper.rb
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes