orange 0.2.5 → 0.2.6

This diff has not been reviewed by any users.
Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,7 @@ module Orange
6
6
  class Radius < Resource
7
7
  call_me :radius
8
8
  def afterLoad
9
- @context = ::Radius::Context.new
9
+ @context = ::Radius::PacketContext.new
10
10
  orange.fire(:radius_loaded, self)
11
11
  end
12
12
 
@@ -18,10 +18,18 @@ module Orange
18
18
  @context.define_tag(*args, &block)
19
19
  end
20
20
 
21
+ def parse_text(packet, text = false)
22
+ content = text
23
+ unless content.blank?
24
+ parser = ::Radius::PacketParser.new(context, :tag_prefix => 'o')
25
+ parser.parse(content, packet)
26
+ end
27
+ end
28
+
21
29
  def parse(packet)
22
30
  content = packet[:content, false]
23
31
  unless content.blank?
24
- parser = ::Radius::Parser.new(context, :tag_prefix => 'o')
32
+ parser = ::Radius::PacketParser.new(context, :tag_prefix => 'o')
25
33
  packet[:content] = parser.parse(content, packet)
26
34
  end
27
35
  end
@@ -34,7 +42,7 @@ module Radius
34
42
  # defines how tags should be expanded. See the QUICKSTART[link:files/QUICKSTART.html]
35
43
  # for a detailed explaination of its usage.
36
44
  #
37
- class Parser
45
+ class PacketParser < Parser
38
46
  def parse(string, packet = false)
39
47
  @stack = [ParseContainerTag.new { |t| t.contents.to_s }]
40
48
  tokenize(string)
@@ -69,7 +77,7 @@ module Radius
69
77
  raise MissingEndTagError.new(@stack.last.name, @stack) if @stack.length != 1
70
78
  end
71
79
  end
72
- class Context
80
+ class PacketContext < Context
73
81
 
74
82
  # Returns the value of a rendered tag. Used internally by Parser#parse.
75
83
  def render_tag(name, attributes = {}, packet = false, &block)
@@ -2,14 +2,14 @@ module Orange
2
2
  class Slices < Orange::Resource
3
3
  call_me :slices
4
4
  def stack_init
5
- orange[:radius].context.define_tag "slice" do |tag|
5
+ orange[:radius].define_tag "slice" do |tag|
6
6
  content = ''
7
7
  resource = (tag.attr['resource'] || :slices).to_sym
8
8
  id = tag.attr['id'] || nil
9
9
  mode = (tag.attr['mode'] || tag.attr['chunk'] || (id ? :show : :index )).to_sym
10
10
  if orange.loaded?(resource)
11
11
  if orange[resource].respond_to?(mode) || resource == :slices
12
- content << (id ? orange[resource].__send__(mode, tag.locals.packet, :id => id) : orange[resource].__send__(mode, tag.locals.packet))
12
+ content << (id ? orange[resource].__send__(mode, tag.locals.packet, :id => id) : orange[resource].__send__(mode, tag.locals.packet, {:attrs => tag.attr}))
13
13
  else
14
14
  content << "resource #{resource} doesn't respond to #{mode}"
15
15
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 5
9
- version: 0.2.5
8
+ - 6
9
+ version: 0.2.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - David Haslem
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-07 00:00:00 -04:00
17
+ date: 2010-05-09 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency