fizx-parsley-ruby 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -126,6 +126,7 @@ VALUE _parse(VALUE self, VALUE options){
126
126
  if(OPT_BOOL("collate")) flags |= PARSLEY_OPTIONS_COLLATE;
127
127
  if(OPT_BOOL("allow_net")) flags |= PARSLEY_OPTIONS_ALLOW_NET;
128
128
  if(OPT_BOOL("allow_local")) flags |= PARSLEY_OPTIONS_ALLOW_LOCAL;
129
+ if(OPT_BOOL("sgwrap")) flags |= PARSLEY_OPTIONS_SGWRAP;
129
130
  if(OPT_BOOL("has_base")) base = STR2CSTR(OPT("base"));
130
131
 
131
132
  // printf("prune: %d\nallow_net: %d\nallow_local: %d\nhas_base: %d\nflags: %d\n", OPT_BOOL("prune"), OPT_BOOL("allow_net"), OPT_BOOL("allow_local"), OPT_BOOL("has_base"), flags);
@@ -34,6 +34,7 @@ class Parsley
34
34
  # :input => [:html, :xml]
35
35
  # :output => [:ruby, :json, :xml]
36
36
  # :prune => [true, false]
37
+ # :sgwrap => [false, true]
37
38
  # :collate => [true, false]
38
39
  # :base => "http://some/base/href"
39
40
  # :allow_net => [true, false]
@@ -41,6 +42,7 @@ class Parsley
41
42
  def parse(options = {})
42
43
  options[:file] || options[:string] || (raise ParsleyError.new("must specify what to parse"))
43
44
 
45
+ options[:sgwrap] = !!options[:sgwrap]
44
46
  options[:is_file] = !!options[:file]
45
47
  options[:has_base] = !!options[:base]
46
48
 
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "parsley-ruby"
3
- s.version = "0.3.2"
4
- s.date = "2009-03-23"
3
+ s.version = "0.4.0"
4
+ s.date = "2009-06-01"
5
5
  s.summary = "Ruby binding for parsley"
6
6
  s.email = "kyle@kylemaxwell.com"
7
7
  s.homepage = "http://github.com/fizx/parsley-ruby"
@@ -55,6 +55,21 @@ class TestParsley < Test::Unit::TestCase
55
55
  xml = "<?xml version=\"1.0\"?>\n<parsley:root xmlns:parsley=\"http://parselets.com/json\"><hi position=\"105\">Nick's Crispy Tacos</hi></parsley:root>\n"
56
56
  assert_equal(xml, @parsley.parse(:file => @page, :output => :xml))
57
57
  end
58
+
59
+ def test_sgwrap
60
+ @parsley = Parsley.new("hi" => "p sg_wrap")
61
+ html = "<p><b>hi</b>world</p>"
62
+ assert_equal({"hi" => "world"}, @parsley.parse(:string => html, :sgwrap => true))
63
+ end
64
+
65
+ def test_sgwrap_off
66
+ @parsley = Parsley.new("hi" => "p sg_wrap")
67
+ html = "<p><b>hi</b>world</p>"
68
+ assert_raises(ParsleyError) do
69
+ @parsley.parse(:string => html, :sgwrap => false)
70
+ end
71
+ end
72
+
58
73
 
59
74
  def test_json
60
75
  @parsley = Parsley.new("hi" => "h1")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fizx-parsley-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Maxwell
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-23 00:00:00 -07:00
12
+ date: 2009-06-01 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency